-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Disabling Advancements + Narrator
- Loading branch information
1 parent
adc6735
commit d3923c6
Showing
8 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/nomiceu/nomilabs/mixin/AdvancementListMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.nomiceu.nomilabs.mixin; | ||
|
||
import com.nomiceu.nomilabs.config.LabsConfig; | ||
import net.minecraft.advancements.Advancement; | ||
import net.minecraft.advancements.AdvancementList; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(value = AdvancementList.class) | ||
public class AdvancementListMixin { | ||
@Inject(method = "loadAdvancements(Ljava/util/Map;)V", at = @At("HEAD"), cancellable = true) | ||
public void cancelAdvancements(Map<ResourceLocation, Advancement.Builder> advancementsIn, CallbackInfo ci) { | ||
if (LabsConfig.advanced.disableAdvancements) ci.cancel(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/nomiceu/nomilabs/mixin/AdvancementManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.nomiceu.nomilabs.mixin; | ||
|
||
import com.nomiceu.nomilabs.config.LabsConfig; | ||
import net.minecraft.advancements.AdvancementList; | ||
import net.minecraft.advancements.AdvancementManager; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = AdvancementManager.class) | ||
public class AdvancementManagerMixin { | ||
@Shadow | ||
@Final | ||
private static AdvancementList ADVANCEMENT_LIST; | ||
|
||
@Inject(method = "reload()V", at = @At("HEAD"), cancellable = true) | ||
public void reloadWithoutAdvancements(CallbackInfo ci) { | ||
if (!LabsConfig.advanced.disableAdvancements) return; | ||
ADVANCEMENT_LIST.clear(); | ||
ci.cancel(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/nomiceu/nomilabs/mixin/ClientAdvancementManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.nomiceu.nomilabs.mixin; | ||
|
||
import com.nomiceu.nomilabs.config.LabsConfig; | ||
import net.minecraft.advancements.AdvancementList; | ||
import net.minecraft.client.multiplayer.ClientAdvancementManager; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = ClientAdvancementManager.class) | ||
public class ClientAdvancementManagerMixin { | ||
@Shadow | ||
@Final | ||
private AdvancementList advancementList; | ||
|
||
@Inject(method = "read(Lnet/minecraft/network/play/server/SPacketAdvancementInfo;)V", at = @At("HEAD"), cancellable = true) | ||
public void reloadWithoutAdvancements(CallbackInfo ci) { | ||
if (!LabsConfig.advanced.disableAdvancements) return; | ||
advancementList.clear(); | ||
ci.cancel(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/nomiceu/nomilabs/mixin/NarratorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.nomiceu.nomilabs.mixin; | ||
|
||
import com.mojang.text2speech.Narrator; | ||
import com.mojang.text2speech.NarratorDummy; | ||
import com.nomiceu.nomilabs.config.LabsConfig; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@SuppressWarnings("PublicStaticMixinMember") | ||
@Mixin(value = Narrator.class, remap = false) | ||
public interface NarratorMixin { | ||
@Inject(method = "getNarrator", at = @At("HEAD"), cancellable = true, remap = false) | ||
static void getDummyNarrator(CallbackInfoReturnable<Narrator> cir) { | ||
if (LabsConfig.advanced.disableNarrator) cir.setReturnValue(new NarratorDummy()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters