├── gradle └── wrapper │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── src └── main │ ├── resources │ ├── assets │ │ └── masaadditions │ │ │ └── lang │ │ │ ├── zh_cn.json │ │ │ └── en_us.json │ ├── masaadditions.minihud_additions.mixin.json │ ├── masaadditions.litematica_additions.mixin.json │ ├── masaadditions.minihud_additions.minihud_mixin.json │ ├── masaadditions.litematica_additions.litematica_mixin.json │ ├── masaadditions.tweakeroo_additions.tweakeroo_mixin.json │ ├── fabric.mod.json │ └── masaadditions.tweakeroo_additions.mixin.json │ └── java │ └── com │ └── red │ └── masaadditions │ ├── MasaAdditions.java │ ├── tweakeroo_additions │ ├── mixin │ │ ├── MixinAbstractBlockAccessor.java │ │ ├── MixinKeyBindingAccessor.java │ │ ├── MixinClientWorld.java │ │ ├── MixinSkyProperties.java │ │ ├── MixinLlamaEntity.java │ │ ├── MixinBossBarHud.java │ │ ├── MixinModelPredicateProviderRegistry.java │ │ ├── MixinTallPlantBlock.java │ │ ├── MixinFlowerBlock.java │ │ ├── MixinBeaconBlockEntityRenderer.java │ │ ├── MixinTitleScreen.java │ │ ├── MixinHorseBaseEntity.java │ │ ├── MixinChickenEntity.java │ │ ├── MixinPlayerEntity.java │ │ ├── MixinStuckArrowsFeatureRenderer.java │ │ ├── MixinWorldAccess.java │ │ ├── MixinPlayerEntityRenderer.java │ │ ├── MixinRecipeBookWidget.java │ │ ├── MixinGameInfoChatListener.java │ │ ├── MixinInGameHud.java │ │ ├── MixinPlugin.java │ │ ├── MixinClientPlayNetworkHandler.java │ │ ├── MixinBlockDustParticle.java │ │ ├── MixinItemFrameEntityRenderer.java │ │ ├── MixinAnvilScreen.java │ │ ├── MixinBlockColors.java │ │ ├── MixinMinecraftClient.java │ │ ├── MixinSlimeBlock.java │ │ ├── MixinClientPlayerEntity.java │ │ ├── MixinArmorItem.java │ │ ├── MixinParticleManager.java │ │ └── MixinClientPlayerInteractionManager.java │ ├── util │ │ ├── BlockDustParticleExt.java │ │ ├── MiscUtils.java │ │ └── Callbacks.java │ ├── tweakeroo_mixin │ │ ├── MixinInternalConfigs.java │ │ ├── MixinFixesConfigs.java │ │ ├── MixinListsConfigs.java │ │ ├── MixinDisableConfigs.java │ │ ├── MixinGenericConfigs.java │ │ ├── MixinHotkeys.java │ │ ├── MixinInventoryUtils.java │ │ ├── MixinInitializationHandler.java │ │ ├── MixinExplosionCarpet.java │ │ ├── MixinPlugin.java │ │ ├── MixinMiscTweaks.java │ │ ├── MixinGuiConfigs.java │ │ ├── MixinConfigs.java │ │ ├── MixinCallbacks.java │ │ ├── MixinInputHandler.java │ │ └── MixinPlacementTweaks.java │ ├── config │ │ ├── HotkeysExtended.java │ │ ├── FeatureToggleExtended.java │ │ └── ConfigsExtended.java │ └── tweaks │ │ ├── InventoryTweaks.java │ │ └── PlacementTweaks.java │ ├── litematica_additions │ ├── config │ │ ├── HotkeysExtended.java │ │ └── ConfigsExtended.java │ ├── mixin │ │ ├── MixinFlowerPotBlockAccessor.java │ │ ├── MixinPlayerEntity.java │ │ └── MixinPlugin.java │ ├── util │ │ ├── FileImportUtil.java │ │ ├── MiscUtils.java │ │ ├── GuiFileImport.java │ │ └── GuiFileImportBase.java │ └── litematica_mixin │ │ ├── MixinGenericConfigs.java │ │ ├── MixinHotkeys.java │ │ ├── MixinLitematicaGui.java │ │ ├── MixinKeyCallbacks.java │ │ ├── MixinTaskCountBlocksPlacement.java │ │ ├── MixinGuiMainMenu.java │ │ ├── MixinPlugin.java │ │ ├── MixinBlockModelRendererSchematic.java │ │ └── MixinChunkRendererSchematicVbo.java │ └── minihud_additions │ ├── minihud_mixin │ ├── MixinColorConfigs.java │ ├── MixinDataStorage.java │ ├── MixinRenderContainer.java │ ├── MixinGuiConfigs.java │ ├── MixinOverlayRenderer.java │ ├── MixinPlugin.java │ ├── MixinKeyCallbacks.java │ ├── MixinConfigs.java │ └── MixinInputHandler.java │ ├── mixin │ ├── MixinTileEntityBeacon.java │ └── MixinPlugin.java │ ├── config │ ├── ConfigsExtended.java │ └── RendererToggleExtended.java │ └── renderer │ └── OverlayRendererBeaconRange.java ├── gradle.properties ├── LICENSE_MIT └── README.md /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | build/ 3 | out/ 4 | classes/ 5 | libs/ 6 | .idea/ 7 | *.iml 8 | *.ipr 9 | *.iws 10 | .classpath 11 | .project 12 | run/ 13 | /remappedSrc/ 14 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | jcenter() 4 | maven { 5 | name = 'Fabric' 6 | url = 'https://maven.fabricmc.net/' 7 | } 8 | gradlePluginPortal() 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/assets/masaadditions/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "masaadditions.gui.title.save_dragged_schematic": "储存拖入的原理图文件", 3 | "masaadditions.gui.button.open_schematics_folder": "打开原理图文件夹", 4 | "masaadditions.message.fast_right_click_disabled": "停用disableFarmlandMaking 以使用tweakFastRightClick !" 5 | } -------------------------------------------------------------------------------- /src/main/resources/assets/masaadditions/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "masaadditions.gui.button.open_schematics_folder": "Open Schematics Folder", 3 | "masaadditions.gui.title.save_dragged_schematic": "Save Dragged Schematic File", 4 | "masaadditions.message.fast_right_click_disabled": "Disable disableFarmlandMaking to use tweakFastRightClick!" 5 | } -------------------------------------------------------------------------------- /src/main/resources/masaadditions.minihud_additions.mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "com.red.masaadditions.minihud_additions.mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "plugin": "com.red.masaadditions.minihud_additions.mixin.MixinPlugin", 7 | "mixins": [ 8 | "MixinTileEntityBeacon" 9 | ], 10 | "injectors": { 11 | "defaultRequire": 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/masaadditions.litematica_additions.mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "com.red.masaadditions.litematica_additions.mixin", 5 | "compatibilityLevel": "JAVA_16", 6 | "plugin": "com.red.masaadditions.litematica_additions.mixin.MixinPlugin", 7 | "mixins": [ 8 | "MixinFlowerPotBlockAccessor", 9 | "MixinPlayerEntity" 10 | ], 11 | "injectors": { 12 | "defaultRequire": 1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/MasaAdditions.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions; 2 | 3 | import net.fabricmc.api.ModInitializer; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | public class MasaAdditions implements ModInitializer { 8 | public static final Logger logger = LogManager.getLogger("masaadditions"); 9 | 10 | @Override 11 | public void onInitialize() { 12 | logger.info("MasaAdditions Loaded."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | 4 | # Fabric Properties 5 | minecraft_version=1.16.5 6 | yarn_mappings=1.16.5+build.9 7 | loader_version=0.11.2 8 | 9 | # Mod Properties 10 | mod_version=1.2.0 11 | maven_group=com.red.masaadditions 12 | archives_base_name=masaadditions 13 | 14 | # Dependencies 15 | tweakeroo_fileid=3224921 16 | minihud_fileid=3101187 17 | litematica_fileid=3349118 18 | malilib_fileid=3252979 19 | masa_minecraft_version=1.16.4 20 | fabric_version=0.25.1+build.416-1.16 21 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinAbstractBlockAccessor.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import net.minecraft.block.AbstractBlock; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(AbstractBlock.class) 8 | public interface MixinAbstractBlockAccessor { 9 | @Accessor("velocityMultiplier") 10 | void setVelocityMultiplier(float velocityMultiplier); 11 | 12 | @Accessor("jumpVelocityMultiplier") 13 | void setJumpVelocityMultiplier(float jumpVelocityMultiplier); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinKeyBindingAccessor.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import net.minecraft.client.options.KeyBinding; 4 | import net.minecraft.client.util.InputUtil; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | import java.util.Map; 9 | 10 | @Mixin(KeyBinding.class) 11 | public interface MixinKeyBindingAccessor { 12 | @Accessor("keyToBindings") 13 | static Map getKeyToBindings() { 14 | throw new AssertionError(); 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/masaadditions.minihud_additions.minihud_mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "com.red.masaadditions.minihud_additions.minihud_mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "plugin": "com.red.masaadditions.minihud_additions.minihud_mixin.MixinPlugin", 7 | "mixins": [ 8 | "MixinColorConfigs", 9 | "MixinConfigs", 10 | "MixinDataStorage", 11 | "MixinGuiConfigs", 12 | "MixinInputHandler", 13 | "MixinKeyCallbacks", 14 | "MixinOverlayRenderer", 15 | "MixinRenderContainer" 16 | ], 17 | "injectors": { 18 | "defaultRequire": 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/config/HotkeysExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.config; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import fi.dy.masa.malilib.config.options.ConfigHotkey; 5 | 6 | import java.util.List; 7 | 8 | public class HotkeysExtended { 9 | public static final ConfigHotkey RENDER_HELD_ITEM_ONLY_TOGGLE = new ConfigHotkey("renderHeldItemOnlyToggle", "", "Toggles renderHeldItemOnly on/off"); 10 | 11 | public static final List EXTENDED_HOTKEY_LIST = ImmutableList.of( 12 | RENDER_HELD_ITEM_ONLY_TOGGLE 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/mixin/MixinFlowerPotBlockAccessor.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.mixin; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.block.FlowerPotBlock; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | import java.util.Map; 9 | 10 | @Mixin(FlowerPotBlock.class) 11 | public interface MixinFlowerPotBlockAccessor { 12 | @Accessor("CONTENT_TO_POTTED") 13 | static Map getContentToPotted() { 14 | throw new AssertionError(); 15 | } 16 | 17 | @Accessor("content") 18 | Block getContent(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/masaadditions.litematica_additions.litematica_mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "com.red.masaadditions.litematica_additions.litematica_mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "plugin": "com.red.masaadditions.litematica_additions.litematica_mixin.MixinPlugin", 7 | "mixins": [ 8 | "MixinBlockModelRendererSchematic", 9 | "MixinChunkRendererSchematicVbo", 10 | "MixinGenericConfigs", 11 | "MixinGuiMainMenu", 12 | "MixinHotkeys", 13 | "MixinKeyCallbacks", 14 | "MixinLitematicaGui", 15 | "MixinTaskCountBlocksPlacement" 16 | ], 17 | "injectors": { 18 | "defaultRequire": 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/util/BlockDustParticleExt.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.util; 2 | 3 | import net.minecraft.block.BlockState; 4 | import net.minecraft.client.particle.BlockDustParticle; 5 | import net.minecraft.client.world.ClientWorld; 6 | 7 | public class BlockDustParticleExt extends BlockDustParticle { 8 | // From 1.12 Tweakeroo by Masa 9 | public BlockDustParticleExt(ClientWorld worldIn, double xCoordIn, double yCoordIn, double zCoordIn, 10 | double xSpeedIn, double ySpeedIn, double zSpeedIn, BlockState state) { 11 | super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state); 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/util/FileImportUtil.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.util; 2 | 3 | import fi.dy.masa.litematica.schematic.LitematicaSchematic; 4 | import fi.dy.masa.malilib.gui.GuiBase; 5 | import fi.dy.masa.malilib.util.GuiUtils; 6 | 7 | import java.nio.file.Path; 8 | 9 | public class FileImportUtil { 10 | public static void saveDraggedLitematic(Path path) { 11 | LitematicaSchematic schematic = LitematicaSchematic.createFromFile(path.getParent().toFile(), path.getFileName().toString()); 12 | 13 | if (schematic == null) { 14 | return; 15 | } 16 | 17 | GuiFileImport gui = new GuiFileImport(schematic); 18 | gui.setParent(GuiUtils.getCurrentScreen()); 19 | GuiBase.openGui(gui); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinClientWorld.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import net.minecraft.client.world.ClientWorld; 6 | import net.minecraft.world.LunarWorldView; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.*; 9 | 10 | @Mixin(ClientWorld.class) 11 | public class MixinClientWorld { 12 | @ModifyVariable(method = "doRandomBlockDisplayTicks", at = @At(value = "STORE")) 13 | private boolean doRandomBlockDisplayTicks(boolean bl) { 14 | return FeatureToggleExtended.TWEAK_ALWAYS_RENDER_BARRIER_PARTICLES.getBooleanValue() || bl; 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinSkyProperties.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.render.SkyProperties; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.ModifyArg; 8 | 9 | @Mixin(SkyProperties.Overworld.class) 10 | public class MixinSkyProperties { 11 | @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/SkyProperties;(FZLnet/minecraft/client/render/SkyProperties$SkyType;ZZ)V"), index = 0) 12 | private static float Overworld(float cloudsHeight) { 13 | return (float) ConfigsExtended.Generic.CLOUD_HEIGHT.getDoubleValue(); 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/resources/masaadditions.tweakeroo_additions.tweakeroo_mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "plugin": "com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin.MixinPlugin", 7 | "mixins": [ 8 | "MixinCallbacks", 9 | "MixinConfigs", 10 | "MixinDisableConfigs", 11 | "MixinExplosionCarpet", 12 | "MixinFixesConfigs", 13 | "MixinGenericConfigs", 14 | "MixinGuiConfigs", 15 | "MixinHotkeys", 16 | "MixinInitializationHandler", 17 | "MixinInputHandler", 18 | "MixinInternalConfigs", 19 | "MixinListsConfigs", 20 | "MixinMiscTweaks", 21 | "MixinPlacementTweaks", 22 | "MixinInventoryUtils" 23 | ], 24 | "injectors": { 25 | "defaultRequire": 1 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinLlamaEntity.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import net.minecraft.entity.passive.LlamaEntity; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 9 | 10 | @Mixin(LlamaEntity.class) 11 | public class MixinLlamaEntity { 12 | @Inject(method = "canBeControlledByRider", at = @At("HEAD"), cancellable = true) 13 | private void allowLamaSteering(CallbackInfoReturnable cir) { 14 | if (FeatureToggleExtended.TWEAK_LLAMA_STEERING.getBooleanValue()) { 15 | cir.setReturnValue(true); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinColorConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.minihud_additions.config.ConfigsExtended; 5 | import fi.dy.masa.malilib.config.IConfigBase; 6 | import fi.dy.masa.minihud.config.Configs; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Colors.class, remap = false) 14 | public class MixinColorConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Colors.OPTIONS).addAll(ConfigsExtended.Colors.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinBossBarHud.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.gui.hud.BossBarHud; 5 | import net.minecraft.client.util.math.MatrixStack; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Mixin(BossBarHud.class) 12 | public abstract class MixinBossBarHud { 13 | @Inject(method = "render", at = @At("HEAD"), cancellable = true) 14 | private void render(MatrixStack matrices, CallbackInfo ci) { 15 | if (ConfigsExtended.Disable.DISABLE_BOSS_BAR_RENDERING.getBooleanValue()) 16 | ci.cancel(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinGenericConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.litematica_additions.config.ConfigsExtended; 5 | import fi.dy.masa.litematica.config.Configs; 6 | import fi.dy.masa.malilib.config.IConfigBase; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Generic.class, remap = false) 14 | public class MixinGenericConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Generic.OPTIONS).addAll(ConfigsExtended.Generic.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinInternalConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import fi.dy.masa.malilib.config.IConfigBase; 6 | import fi.dy.masa.tweakeroo.config.Configs; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Internal.class, remap = false) 14 | public class MixinInternalConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Internal.OPTIONS).addAll(ConfigsExtended.Internal.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinHotkeys.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.litematica_additions.config.HotkeysExtended; 5 | import fi.dy.masa.malilib.config.options.ConfigHotkey; 6 | import fi.dy.masa.litematica.config.Hotkeys; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | import java.util.List; 13 | 14 | @Pseudo 15 | @Mixin(value = Hotkeys.class, remap = false) 16 | public class MixinHotkeys { 17 | @Final 18 | @Shadow 19 | public static List HOTKEY_LIST = new ImmutableList.Builder().addAll(Hotkeys.HOTKEY_LIST).addAll(HotkeysExtended.EXTENDED_HOTKEY_LIST).build(); 20 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinFixesConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import fi.dy.masa.malilib.config.IConfigBase; 6 | import fi.dy.masa.tweakeroo.config.Configs; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Fixes.class, remap = false) 14 | public class MixinFixesConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Fixes.OPTIONS).addAll(ConfigsExtended.Fixes.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinListsConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import fi.dy.masa.malilib.config.IConfigBase; 6 | import fi.dy.masa.tweakeroo.config.Configs; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Lists.class, remap = false) 14 | public class MixinListsConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Lists.OPTIONS).addAll(ConfigsExtended.Lists.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinDisableConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import fi.dy.masa.malilib.config.IConfigBase; 6 | import fi.dy.masa.tweakeroo.config.Configs; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Disable.class, remap = false) 14 | public class MixinDisableConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Disable.OPTIONS).addAll(ConfigsExtended.Disable.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinGenericConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import fi.dy.masa.malilib.config.IConfigBase; 6 | import fi.dy.masa.tweakeroo.config.Configs; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | @Pseudo 13 | @Mixin(value = Configs.Generic.class, remap = false) 14 | public class MixinGenericConfigs { 15 | @Final 16 | @Shadow 17 | public static ImmutableList OPTIONS = new ImmutableList.Builder().addAll(Configs.Generic.OPTIONS).addAll(ConfigsExtended.Generic.ADDITIONAL_OPTIONS).build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinHotkeys.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.HotkeysExtended; 5 | import fi.dy.masa.malilib.config.options.ConfigHotkey; 6 | import fi.dy.masa.tweakeroo.config.Hotkeys; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | 12 | import java.util.List; 13 | 14 | @Pseudo 15 | @Mixin(value = Hotkeys.class, remap = false) 16 | public class MixinHotkeys { 17 | @Final 18 | @Shadow 19 | public static List HOTKEY_LIST = new ImmutableList.Builder().addAll(Hotkeys.HOTKEY_LIST).addAll(HotkeysExtended.EXTENDED_HOTKEY_LIST).build(); 20 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinModelPredicateProviderRegistry.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import net.minecraft.client.world.ClientWorld; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.At; 6 | import org.spongepowered.asm.mixin.injection.Redirect; 7 | 8 | @Mixin(targets = "net.minecraft.client.item.ModelPredicateProviderRegistry$1") 9 | public class MixinModelPredicateProviderRegistry { 10 | @Redirect(method = "call(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/entity/LivingEntity;)F", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getSkyAngle(F)F")) 11 | private float getSkyAngle(ClientWorld clientWorld, float tickDelta) { 12 | return clientWorld.getDimension().getSkyAngle(clientWorld.getLevelProperties().getTimeOfDay()); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/config/HotkeysExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.config; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import fi.dy.masa.malilib.config.options.ConfigHotkey; 5 | 6 | import java.util.List; 7 | 8 | public class HotkeysExtended { 9 | public static final ConfigHotkey BLINK_DRIVE = new ConfigHotkey("blinkDrive", "", "Teleports the player (using a tp command) to the location the player is looking at.\nPorted from 1.12 Tweakeroo."); 10 | public static final ConfigHotkey BLINK_DRIVE_Y_LEVEL = new ConfigHotkey("blinkDriveYLevel", "", "Teleports the player (using a tp command)\nto the location the player is looking at,\nbut it maintains the current y-position.\nPorted from 1.12 Tweakeroo."); 11 | 12 | public static final List EXTENDED_HOTKEY_LIST = ImmutableList.of( 13 | BLINK_DRIVE, 14 | BLINK_DRIVE_Y_LEVEL 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/config/ConfigsExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.config; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import fi.dy.masa.malilib.config.IConfigBase; 5 | import fi.dy.masa.malilib.config.options.ConfigBoolean; 6 | 7 | public class ConfigsExtended { 8 | public static class Generic { 9 | public static final ConfigBoolean MATERIAL_LIST_IGNORE_BLOCK_STATE = new ConfigBoolean("materialListIgnoreBlockState", false, "Ignores block state for material list counts", "Material List Ignore Block State"); 10 | public static final ConfigBoolean RENDER_HELD_ITEM_ONLY = new ConfigBoolean("renderHeldItemOnly", false, "Only renders currently held block item", "Render Held Item Only"); 11 | 12 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 13 | MATERIAL_LIST_IGNORE_BLOCK_STATE, 14 | RENDER_HELD_ITEM_ONLY 15 | ); 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinTallPlantBlock.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.block.AbstractBlock; 5 | import net.minecraft.block.TallPlantBlock; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(TallPlantBlock.class) 12 | public class MixinTallPlantBlock { 13 | // From UsefulMod by nessie 14 | @Inject(method = "getOffsetType", at = @At("HEAD"), cancellable = true) 15 | private void getOffsetType(CallbackInfoReturnable cir) { 16 | if (ConfigsExtended.Disable.DISABLE_PLANT_BLOCK_MODEL_OFFSET.getBooleanValue()) { 17 | cir.setReturnValue(AbstractBlock.OffsetType.NONE); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinFlowerBlock.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.block.AbstractBlock; 5 | import net.minecraft.block.FlowerBlock; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(FlowerBlock.class) 12 | public class MixinFlowerBlock { 13 | // From UsefulMod by nessie 14 | @Inject(method = "getOffsetType", at = @At("HEAD"), cancellable = true) 15 | private void getOffsetType(CallbackInfoReturnable cir) { 16 | if (ConfigsExtended.Disable.DISABLE_PLANT_BLOCK_MODEL_OFFSET.getBooleanValue()) { 17 | cir.setReturnValue(AbstractBlock.OffsetType.NONE); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinDataStorage.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.red.masaadditions.minihud_additions.renderer.OverlayRendererBeaconRange; 4 | import fi.dy.masa.minihud.util.DataStorage; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Pseudo; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Pseudo 12 | @Mixin(value = DataStorage.class, remap = false) 13 | public class MixinDataStorage { 14 | @Inject(method = "reset", at = @At("RETURN")) 15 | private void reset(boolean isLogout, CallbackInfo ci) { 16 | OverlayRendererBeaconRange.clear(); 17 | } 18 | 19 | @Inject(method = "onWorldJoin", at = @At("RETURN")) 20 | private void onWorldJoin(CallbackInfo ci) { 21 | OverlayRendererBeaconRange.setNeedsUpdate(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinBeaconBlockEntityRenderer.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | 10 | @Mixin(BeaconBlockEntityRenderer.class) 11 | public abstract class MixinBeaconBlockEntityRenderer { 12 | @Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true) 13 | private void render(CallbackInfo ci) { 14 | if (ConfigsExtended.Disable.DISABLE_BEACON_BEAM_RENDERING.getBooleanValue()) 15 | ci.cancel(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinTitleScreen.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.gui.screen.Screen; 5 | import net.minecraft.client.gui.screen.TitleScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(TitleScreen.class) 13 | public class MixinTitleScreen extends Screen { 14 | protected MixinTitleScreen(Text title) { 15 | super(title); 16 | } 17 | 18 | @Inject(method = "initWidgetsNormal", at = @At(value = "RETURN")) 19 | private void disableRealmsButton(int y, int spacingY, CallbackInfo ci) { 20 | if (ConfigsExtended.Disable.DISABLE_REALMS_BUTTON.getBooleanValue()) { 21 | this.buttons.get(2).active = false; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinRenderContainer.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.red.masaadditions.minihud_additions.renderer.OverlayRendererBeaconRange; 4 | import fi.dy.masa.minihud.renderer.OverlayRendererBase; 5 | import fi.dy.masa.minihud.renderer.RenderContainer; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Pseudo; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Pseudo 14 | @Mixin(value = RenderContainer.class, remap = false) 15 | public abstract class MixinRenderContainer { 16 | @Shadow 17 | protected abstract void addRenderer(OverlayRendererBase renderer); 18 | 19 | @Inject(method = "", at = @At("RETURN")) 20 | private void RenderContainer(CallbackInfo ci) { 21 | this.addRenderer(new OverlayRendererBeaconRange()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE_MIT: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "masaadditions", 4 | "version": "${version}", 5 | "name": "MasaAdditions", 6 | "description": "Add-on for Masa's Mods (Tweakeroo, MiniHUD, Litematica)", 7 | "authors": [ 8 | "Red.#9015" 9 | ], 10 | "contact": { 11 | "homepage": "https://github.com/hp3721/masaadditions", 12 | "sources": "https://github.com/hp3721/masaadditions" 13 | }, 14 | "license": "GPL-3.0", 15 | "environment": "*", 16 | "entrypoints": { 17 | "main": [ 18 | "com.red.masaadditions.MasaAdditions" 19 | ] 20 | }, 21 | "mixins": [ 22 | "masaadditions.tweakeroo_additions.tweakeroo_mixin.json", 23 | "masaadditions.tweakeroo_additions.mixin.json", 24 | "masaadditions.minihud_additions.minihud_mixin.json", 25 | "masaadditions.minihud_additions.mixin.json", 26 | "masaadditions.litematica_additions.litematica_mixin.json", 27 | "masaadditions.litematica_additions.mixin.json" 28 | ], 29 | "depends": { 30 | }, 31 | "suggests": { 32 | "tweakeroo": "*", 33 | "minihud": "*", 34 | "malilib": "*" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinHorseBaseEntity.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import net.minecraft.entity.passive.HorseBaseEntity; 5 | import net.minecraft.entity.passive.LlamaEntity; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Redirect; 9 | 10 | @Mixin(HorseBaseEntity.class) 11 | public class MixinHorseBaseEntity { 12 | @Redirect(method = "travel", require = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/HorseBaseEntity;isSaddled()Z")) 13 | public boolean spoofIsSaddled(HorseBaseEntity entity) { 14 | if (FeatureToggleExtended.TWEAK_LLAMA_STEERING.getBooleanValue() && (Object) this instanceof LlamaEntity && ((LlamaEntity) (Object) this).getCarpetColor() != null) // The only way to know on the client that the Llama has a Carpet 15 | { 16 | return true; 17 | } 18 | 19 | return entity.isSaddled(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinInventoryUtils.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.tweaks.InventoryTweaks; 4 | import fi.dy.masa.tweakeroo.util.InventoryUtils; 5 | import net.minecraft.item.ItemStack; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(value = InventoryUtils.class, remap = false) 12 | public class MixinInventoryUtils { 13 | @Inject(method = "getMinDurability", at = @At(value = "FIELD", target = "Lfi/dy/masa/tweakeroo/config/Configs$Generic;ITEM_SWAP_DURABILITY_THRESHOLD:Lfi/dy/masa/malilib/config/options/ConfigInteger;"), cancellable = true) 14 | private static void applyCanSwapAlmostBrokenTool(ItemStack stack, CallbackInfoReturnable cir) { 15 | if (!InventoryTweaks.canSwapAlmostBrokenTool(stack.getItem())) { 16 | cir.setReturnValue(0); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinLitematicaGui.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.util.FileImportUtil; 4 | import fi.dy.masa.litematica.gui.GuiMainMenu; 5 | import fi.dy.masa.litematica.gui.GuiSchematicLoad; 6 | import fi.dy.masa.litematica.gui.GuiSchematicManager; 7 | import net.minecraft.client.gui.screen.Screen; 8 | import net.minecraft.text.Text; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | 11 | import java.nio.file.Path; 12 | import java.util.List; 13 | 14 | import static fi.dy.masa.litematica.schematic.LitematicaSchematic.FILE_EXTENSION; 15 | 16 | @Mixin(value = {GuiMainMenu.class, GuiSchematicManager.class, GuiSchematicLoad.class}, remap = false) 17 | public class MixinLitematicaGui extends Screen { 18 | protected MixinLitematicaGui(Text title) { 19 | super(title); 20 | } 21 | 22 | @Override 23 | public void filesDragged(List paths) { 24 | paths.stream().filter(_path -> _path.toString().endsWith(FILE_EXTENSION)).findFirst().ifPresent(FileImportUtil::saveDraggedLitematic); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/mixin/MixinPlayerEntity.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.config.ConfigsExtended; 4 | import fi.dy.masa.litematica.config.Configs; 5 | import fi.dy.masa.litematica.util.SchematicWorldRefresher; 6 | import net.minecraft.entity.player.PlayerEntity; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(value = PlayerEntity.class) 13 | public class MixinPlayerEntity { 14 | @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;")) 15 | private void renderBlocksAndOverlay(CallbackInfo ci) { 16 | if (ConfigsExtended.Generic.RENDER_HELD_ITEM_ONLY.getBooleanValue() && Configs.Visuals.ENABLE_RENDERING.getBooleanValue() && Configs.Visuals.ENABLE_SCHEMATIC_RENDERING.getBooleanValue()) { 17 | SchematicWorldRefresher.INSTANCE.updateAll(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinChickenEntity.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.entity.EntityType; 5 | import net.minecraft.entity.passive.AnimalEntity; 6 | import net.minecraft.entity.passive.ChickenEntity; 7 | import net.minecraft.world.World; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(ChickenEntity.class) 14 | public abstract class MixinChickenEntity extends AnimalEntity { 15 | public MixinChickenEntity(EntityType entityType, World world) { 16 | super(entityType, world); 17 | } 18 | 19 | // From CutelessMod by nessie 20 | @Inject(method = "tickMovement", at = @At("RETURN")) 21 | private void derpyChicken(CallbackInfo ci) { 22 | if (ConfigsExtended.Generic.DERPY_CHICKEN.getBooleanValue()) 23 | this.pitch = -90F; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinPlayerEntity.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.entity.EntityType; 5 | import net.minecraft.entity.LivingEntity; 6 | import net.minecraft.entity.player.PlayerEntity; 7 | import net.minecraft.world.World; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(PlayerEntity.class) 14 | public abstract class MixinPlayerEntity extends LivingEntity { 15 | protected MixinPlayerEntity(EntityType entityType, World world) { 16 | super(entityType, world); 17 | } 18 | 19 | @Inject(method = "updateSwimming", at = @At("HEAD"), cancellable = true) 20 | private void updateSwimming(CallbackInfo ci) { 21 | if (ConfigsExtended.Disable.DISABLE_SWIMMING.getBooleanValue()) { 22 | this.setSwimming(false); 23 | ci.cancel(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinStuckArrowsFeatureRenderer.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.render.VertexConsumerProvider; 5 | import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer; 6 | import net.minecraft.client.util.math.MatrixStack; 7 | import net.minecraft.entity.Entity; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(StuckArrowsFeatureRenderer.class) 14 | public abstract class MixinStuckArrowsFeatureRenderer { 15 | @Inject(method = "renderObject", at = @At("HEAD"), cancellable = true) 16 | private void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, Entity entity, float directionX, float directionY, float directionZ, float tickDelta, CallbackInfo ci) { 17 | if (ConfigsExtended.Disable.DISABLE_STUCK_ARROWS_RENDERING.getBooleanValue()) 18 | ci.cancel(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/mixin/MixinTileEntityBeacon.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.mixin; 2 | 3 | import com.red.masaadditions.minihud_additions.renderer.OverlayRendererBeaconRange; 4 | import net.minecraft.block.entity.BeaconBlockEntity; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Shadow; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | // From 1.12 MiniHUD by Masa 12 | @Mixin(BeaconBlockEntity.class) 13 | public abstract class MixinTileEntityBeacon { 14 | @Shadow 15 | private int level; 16 | 17 | private int levelsPre; 18 | 19 | @Inject(method = "updateLevel", at = @At("HEAD")) 20 | private void onUpdateSegmentsPre(int x, int y, int z, CallbackInfo ci) { 21 | this.levelsPre = this.level; 22 | } 23 | 24 | @Inject(method = "updateLevel", at = @At("RETURN")) 25 | private void onUpdateSegmentsPost(int x, int y, int z, CallbackInfo ci) { 26 | if (this.level != this.levelsPre) { 27 | OverlayRendererBeaconRange.setNeedsUpdate(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinWorldAccess.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import net.minecraft.world.LunarWorldView; 6 | import net.minecraft.world.RegistryWorldView; 7 | import net.minecraft.world.WorldAccess; 8 | import net.minecraft.world.WorldProperties; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Overwrite; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | 13 | @Mixin(WorldAccess.class) 14 | public interface MixinWorldAccess extends RegistryWorldView, LunarWorldView { 15 | @Shadow 16 | WorldProperties getLevelProperties(); 17 | 18 | /** 19 | * @author Red.#9015 20 | * @reason Isn't possible to inject into interfaces. Overwrite shouldn't affect most other mods though. 21 | */ 22 | @Overwrite() 23 | default long getLunarTime() { 24 | if (FeatureToggleExtended.TWEAK_OVERRIDE_SKY_TIME.getBooleanValue()) 25 | return ConfigsExtended.Generic.SKY_TIME_OVERRIDE.getIntegerValue(); 26 | return this.getLevelProperties().getTimeOfDay(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinPlayerEntityRenderer.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.network.AbstractClientPlayerEntity; 6 | import net.minecraft.client.render.VertexConsumerProvider; 7 | import net.minecraft.client.render.entity.PlayerEntityRenderer; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(PlayerEntityRenderer.class) 15 | public class MixinPlayerEntityRenderer { 16 | @Inject(method = "render", at = @At("HEAD"), cancellable = true) 17 | private void render(AbstractClientPlayerEntity abstractClientPlayerEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { 18 | if (ConfigsExtended.Disable.DISABLE_OTHER_PLAYER_RENDERING.getBooleanValue() && !abstractClientPlayerEntity.isMainPlayer()) 19 | ci.cancel(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinKeyCallbacks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.litematica_additions.config.HotkeysExtended; 5 | import fi.dy.masa.litematica.event.KeyCallbacks; 6 | import fi.dy.masa.litematica.util.SchematicWorldRefresher; 7 | import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Pseudo 15 | @Mixin(value = KeyCallbacks.class, remap = false) 16 | public class MixinKeyCallbacks { 17 | @Inject(method = "init", at = @At("RETURN")) 18 | private static void init(CallbackInfo ci) { 19 | HotkeysExtended.RENDER_HELD_ITEM_ONLY_TOGGLE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(ConfigsExtended.Generic.RENDER_HELD_ITEM_ONLY)); 20 | ConfigsExtended.Generic.RENDER_HELD_ITEM_ONLY.setValueChangeCallback((config) -> SchematicWorldRefresher.INSTANCE.updateAll()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinInitializationHandler.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import fi.dy.masa.malilib.event.InitializationHandler; 5 | import fi.dy.masa.tweakeroo.config.Configs; 6 | import fi.dy.masa.tweakeroo.config.FeatureToggle; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Pseudo; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Pseudo 14 | @Mixin(value = InitializationHandler.class, remap = false) 15 | public class MixinInitializationHandler { 16 | @Inject(method = "onGameInitDone", at = @At("RETURN")) 17 | private void onGameInitDone(CallbackInfo ci) { 18 | // Hack fix to get around 'Mod Configs only loaded after mod initialisation' https://github.com/maruohon/malilib/issues/25 19 | FeatureToggle.TWEAK_GAMMA_OVERRIDE.onValueChanged(); 20 | Configs.Disable.DISABLE_SLIME_BLOCK_SLOWDOWN.onValueChanged(); 21 | ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_SLOWDOWN.onValueChanged(); 22 | ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_JUMPING.onValueChanged(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/config/ConfigsExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.config; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import fi.dy.masa.malilib.config.IConfigBase; 5 | import fi.dy.masa.malilib.config.options.ConfigColor; 6 | 7 | public class ConfigsExtended { 8 | public static class Colors { 9 | public static final ConfigColor BEACON_RANGE_LVL1_OVERLAY_COLOR = new ConfigColor("beaconRangeLvl1", "#20E060FF", "Color for level 1 beacon overlay."); 10 | public static final ConfigColor BEACON_RANGE_LVL2_OVERLAY_COLOR = new ConfigColor("beaconRangeLvl2", "#20FFB040", "Color for level 2 beacon overlay."); 11 | public static final ConfigColor BEACON_RANGE_LVL3_OVERLAY_COLOR = new ConfigColor("beaconRangeLvl3", "#20FFF040", "Color for level 3 beacon overlay."); 12 | public static final ConfigColor BEACON_RANGE_LVL4_OVERLAY_COLOR = new ConfigColor("beaconRangeLvl4", "#2060FF40", "Color for level 4 beacon overlay."); 13 | 14 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 15 | BEACON_RANGE_LVL1_OVERLAY_COLOR, 16 | BEACON_RANGE_LVL2_OVERLAY_COLOR, 17 | BEACON_RANGE_LVL3_OVERLAY_COLOR, 18 | BEACON_RANGE_LVL4_OVERLAY_COLOR 19 | ); 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinTaskCountBlocksPlacement.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.config.ConfigsExtended; 4 | import fi.dy.masa.litematica.scheduler.tasks.TaskCountBlocksPlacement; 5 | import net.minecraft.block.BlockState; 6 | import net.minecraft.util.math.BlockPos; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 12 | 13 | @Mixin(value = TaskCountBlocksPlacement.class, remap = false) 14 | public class MixinTaskCountBlocksPlacement { 15 | @Inject(method = "countAtPosition", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/Object2IntOpenHashMap;addTo(Ljava/lang/Object;I)I", ordinal = 2), cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT) 16 | private void countAtPosition(BlockPos pos, CallbackInfo ci, BlockState stateSchematic, BlockState stateClient) { 17 | if (ConfigsExtended.Generic.MATERIAL_LIST_IGNORE_BLOCK_STATE.getBooleanValue() && stateSchematic.getBlock() == stateClient.getBlock()) { 18 | ci.cancel(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinRecipeBookWidget.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.gui.screen.Screen; 6 | import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; 7 | import net.minecraft.screen.slot.SlotActionType; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(RecipeBookWidget.class) 15 | public abstract class MixinRecipeBookWidget { 16 | @Shadow 17 | protected MinecraftClient client; 18 | 19 | // From UsefulMod by nessie 20 | @Inject(method = "refreshInputs", at = @At("RETURN")) 21 | private void refreshInputs(CallbackInfo ci) { 22 | if (ConfigsExtended.Generic.CLICK_RECIPE_CRAFT.getBooleanValue() && Screen.hasControlDown() && Screen.hasShiftDown()) { 23 | client.interactionManager.clickSlot(client.player.currentScreenHandler.syncId, 0, 1, Screen.hasAltDown() ? SlotActionType.THROW : SlotActionType.QUICK_MOVE, client.player); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinGameInfoChatListener.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.gui.GameInfoChatListener; 5 | import net.minecraft.network.MessageType; 6 | import net.minecraft.text.Text; 7 | import net.minecraft.text.TranslatableText; 8 | import net.minecraft.util.Util; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | import java.util.UUID; 15 | 16 | @Mixin(GameInfoChatListener.class) 17 | public class MixinGameInfoChatListener { 18 | @Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true) 19 | public void onChatMessage(MessageType type, Text message, UUID sender, CallbackInfo ci) { 20 | if (!(ConfigsExtended.Disable.DISABLE_SLEEPING_NOTIFICATION.getBooleanValue() && type == MessageType.GAME_INFO && sender == Util.NIL_UUID && message instanceof TranslatableText)) 21 | return; 22 | 23 | TranslatableText text = (TranslatableText) message; 24 | if (text.getKey().equals("sleep.skipping_night") || text.getKey().equals("sleep.players_sleeping")) 25 | ci.cancel(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.mixin; 2 | 3 | import net.fabricmc.loader.api.FabricLoader; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | public class MixinPlugin implements IMixinConfigPlugin { 12 | @Override 13 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 14 | return FabricLoader.getInstance().isModLoaded("litematica"); 15 | } 16 | 17 | @Override 18 | public void acceptTargets(Set myTargets, Set otherTargets) { 19 | } 20 | 21 | @Override 22 | public void onLoad(String mixinPackage) { 23 | } 24 | 25 | @Override 26 | public String getRefMapperConfig() { 27 | return null; 28 | } 29 | 30 | @Override 31 | public List getMixins() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 37 | } 38 | 39 | @Override 40 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/resources/masaadditions.tweakeroo_additions.mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "com.red.masaadditions.tweakeroo_additions.mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "plugin": "com.red.masaadditions.tweakeroo_additions.mixin.MixinPlugin", 7 | "mixins": [ 8 | "MixinAbstractBlockAccessor", 9 | "MixinAnvilScreen", 10 | "MixinArmorItem", 11 | "MixinBeaconBlockEntityRenderer", 12 | "MixinBlockColors", 13 | "MixinBlockDustParticle", 14 | "MixinBossBarHud", 15 | "MixinChickenEntity", 16 | "MixinClientPlayerEntity", 17 | "MixinClientPlayerInteractionManager", 18 | "MixinClientPlayNetworkHandler", 19 | "MixinClientWorld", 20 | "MixinFlowerBlock", 21 | "MixinGameInfoChatListener", 22 | "MixinHorseBaseEntity", 23 | "MixinInGameHud", 24 | "MixinItemFrameEntityRenderer", 25 | "MixinKeyBindingAccessor", 26 | "MixinLlamaEntity", 27 | "MixinMinecraftClient", 28 | "MixinModelPredicateProviderRegistry", 29 | "MixinParticleManager", 30 | "MixinPlayerEntity", 31 | "MixinPlayerEntityRenderer", 32 | "MixinRecipeBookWidget", 33 | "MixinSkyProperties", 34 | "MixinSlimeBlock", 35 | "MixinStuckArrowsFeatureRenderer", 36 | "MixinTallPlantBlock", 37 | "MixinTitleScreen", 38 | "MixinWorldAccess" 39 | ], 40 | "injectors": { 41 | "defaultRequire": 1 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinInGameHud.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.gui.hud.InGameHud; 5 | import net.minecraft.client.util.math.MatrixStack; 6 | import net.minecraft.scoreboard.ScoreboardObjective; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Constant; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(InGameHud.class) 15 | public class MixinInGameHud { 16 | @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) 17 | private void getOffsetType(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { 18 | if (ConfigsExtended.Disable.DISABLE_SCOREBOARD_SIDEBAR_RENDERING.getBooleanValue()) { 19 | ci.cancel(); 20 | } 21 | } 22 | 23 | @ModifyConstant(method = "renderScoreboardSidebar", constant = @Constant(intValue = 15)) 24 | private int scoreboardSidebarMaxLength(int val) { 25 | return ConfigsExtended.Generic.SCOREBOARD_SIDEBAR_MAX_LENGTH.getIntegerValue(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.mixin; 2 | 3 | import net.fabricmc.loader.api.FabricLoader; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | public class MixinPlugin implements IMixinConfigPlugin { 12 | @Override 13 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 14 | return FabricLoader.getInstance().isModLoaded("minihud"); 15 | } 16 | 17 | @Override 18 | public void acceptTargets(Set myTargets, Set otherTargets) { 19 | } 20 | 21 | @Override 22 | public void onLoad(String mixinPackage) { 23 | } 24 | 25 | @Override 26 | public String getRefMapperConfig() { 27 | return null; 28 | } 29 | 30 | @Override 31 | public List getMixins() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 37 | } 38 | 39 | @Override 40 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import net.fabricmc.loader.api.FabricLoader; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | public class MixinPlugin implements IMixinConfigPlugin { 12 | @Override 13 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 14 | return FabricLoader.getInstance().isModLoaded("tweakeroo"); 15 | } 16 | 17 | @Override 18 | public void acceptTargets(Set myTargets, Set otherTargets) { 19 | } 20 | 21 | @Override 22 | public void onLoad(String mixinPackage) { 23 | } 24 | 25 | @Override 26 | public String getRefMapperConfig() { 27 | return null; 28 | } 29 | 30 | @Override 31 | public List getMixins() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 37 | } 38 | 39 | @Override 40 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinClientPlayNetworkHandler.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.network.ClientPlayNetworkHandler; 6 | import net.minecraft.client.network.ClientPlayerEntity; 7 | import net.minecraft.network.packet.s2c.play.CombatEventS2CPacket; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(ClientPlayNetworkHandler.class) 14 | public class MixinClientPlayNetworkHandler { 15 | // From UsefulMod by nessie 16 | @Inject(method = "onCombatEvent", at = @At(value = "INVOKE", 17 | target = "Lnet/minecraft/client/MinecraftClient;openScreen(Lnet/minecraft/client/gui/screen/Screen;)V")) 18 | private void onPlayerDeath(CombatEventS2CPacket packetIn, CallbackInfo ci) { 19 | // ClientPlayerEntity::showDeathScreen will prevent tweakPrintDeathCoordinates from working 20 | ClientPlayerEntity player = MinecraftClient.getInstance().player; 21 | if (FeatureToggleExtended.TWEAK_RESPAWN_ON_DEATH.getBooleanValue() && player != null) { 22 | player.requestRespawn(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinBlockDustParticle.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import net.minecraft.client.particle.BlockDustParticle; 5 | import net.minecraft.client.particle.Particle; 6 | import net.minecraft.client.world.ClientWorld; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(BlockDustParticle.class) 13 | public abstract class MixinBlockDustParticle extends Particle { 14 | protected MixinBlockDustParticle(ClientWorld worldIn, double posXIn, double posYIn, double posZIn) { 15 | super(worldIn, posXIn, posYIn, posZIn); 16 | } 17 | 18 | // From UsefulMod by nessie 19 | @Inject(method = "", at = @At("RETURN")) 20 | private void removeRandomParticleMotion(CallbackInfo ci) { 21 | if (FeatureToggleExtended.TWEAK_INSANE_BLOCK_BREAKING_PARTICLES.getBooleanValue()) { 22 | final double multiplier = this.random.nextFloat() * 5; 23 | this.velocityX *= multiplier; 24 | this.velocityY *= multiplier; 25 | this.velocityZ *= multiplier; 26 | this.maxAge *= multiplier; 27 | this.gravityStrength = 0F; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinExplosionCarpet.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import fi.dy.masa.tweakeroo.config.FeatureToggle; 4 | import net.minecraft.particle.DefaultParticleType; 5 | import net.minecraft.particle.ParticleTypes; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Pseudo; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | import org.spongepowered.asm.mixin.injection.Slice; 11 | 12 | @Pseudo 13 | @Mixin(targets = {"carpet.helpers.OptimizedExplosion"}, remap = false) 14 | public class MixinExplosionCarpet { 15 | @SuppressWarnings("UnresolvedMixinReference") 16 | @Redirect(method = "doExplosionB", 17 | slice = @Slice(to = @At(value = "INVOKE", 18 | target = "Lnet/minecraft/world/explosion/Explosion;getAffectedBlocks()Ljava/util/List;", ordinal = 1, remap = true)), 19 | at = @At(value = "FIELD", 20 | target = "Lnet/minecraft/particle/ParticleTypes;EXPLOSION_EMITTER:Lnet/minecraft/particle/DefaultParticleType;", remap = true)) 21 | private static DefaultParticleType redirectSpawnParticles() { 22 | if (FeatureToggle.TWEAK_EXPLOSION_REDUCED_PARTICLES.getBooleanValue()) { 23 | return ParticleTypes.EXPLOSION; 24 | } 25 | 26 | return ParticleTypes.EXPLOSION_EMITTER; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinGuiConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.minihud_additions.config.RendererToggleExtended; 5 | import fi.dy.masa.malilib.config.ConfigType; 6 | import fi.dy.masa.malilib.config.ConfigUtils; 7 | import fi.dy.masa.malilib.config.IConfigBase; 8 | import fi.dy.masa.malilib.config.IConfigValue; 9 | import fi.dy.masa.minihud.config.RendererToggle; 10 | import fi.dy.masa.minihud.gui.GuiConfigs; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Pseudo; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 15 | 16 | import java.util.Arrays; 17 | import java.util.List; 18 | 19 | @Pseudo 20 | @Mixin(value = GuiConfigs.class, remap = false) 21 | public class MixinGuiConfigs { 22 | private static final ImmutableList RENDERER_TOGGLE = new ImmutableList.Builder().addAll(Arrays.asList(RendererToggle.values())).addAll(Arrays.asList(RendererToggleExtended.values())).build(); 23 | 24 | @ModifyVariable(method = "getConfigs", at = @At(value = "STORE", target = "Lfi/dy/masa/minihud/gui/GuiConfigs;getConfigs()Ljava/util/List;", ordinal = 5)) 25 | private List ExtendRendererHotkeys(List configs) { 26 | return ConfigUtils.createConfigWrapperForType(ConfigType.HOTKEY, RENDERER_TOGGLE); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinGuiMainMenu.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.util.MiscUtils; 4 | import fi.dy.masa.litematica.gui.GuiMainMenu; 5 | import fi.dy.masa.malilib.gui.GuiBase; 6 | import fi.dy.masa.malilib.gui.button.ButtonGeneric; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.ModifyArg; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(value = GuiMainMenu.class, remap = false) 15 | public abstract class MixinGuiMainMenu extends GuiBase { 16 | @Shadow 17 | protected abstract int getButtonWidth(); 18 | 19 | @ModifyArg(method = "initGui", at = @At(value = "INVOKE", target = "Lfi/dy/masa/litematica/gui/GuiMainMenu;createChangeMenuButton(IIILfi/dy/masa/litematica/gui/GuiMainMenu$ButtonListenerChangeMenu$ButtonType;)V", ordinal = 6), index = 1) 20 | private int createSchematicManagerButton(int y) { 21 | return y - 22; 22 | } 23 | 24 | @Inject(method = "initGui", at = @At("RETURN")) 25 | private void initGui(CallbackInfo ci) { 26 | int width = this.getButtonWidth(); 27 | ButtonGeneric button = new ButtonGeneric(width + 32, 74, width, 20, "Open Schematics Folder"); 28 | this.addButton(button, new MiscUtils.ButtonListenerOpenFolder()); 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinItemFrameEntityRenderer.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.client.render.VertexConsumerProvider; 5 | import net.minecraft.client.render.entity.ItemFrameEntityRenderer; 6 | import net.minecraft.client.util.math.MatrixStack; 7 | import net.minecraft.entity.decoration.ItemFrameEntity; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(value = ItemFrameEntityRenderer.class) 15 | public class MixinItemFrameEntityRenderer { 16 | private ItemFrameEntity itemFrameEntity; 17 | 18 | @Inject(method = "render", at = @At(value = "HEAD")) 19 | private void disableItemFrameFrameRendering(ItemFrameEntity itemFrameEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { 20 | this.itemFrameEntity = itemFrameEntity; 21 | } 22 | 23 | @ModifyVariable(method = "render", at = @At("STORE")) 24 | private boolean disableItemFrameFrameRendering(boolean bl) { 25 | return ConfigsExtended.Disable.DISABLE_ITEM_FRAME_FRAME_RENDERING.getBooleanValue() && !itemFrameEntity.getHeldItemStack().isEmpty() || itemFrameEntity.isInvisible(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinOverlayRenderer.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.red.masaadditions.minihud_additions.config.RendererToggleExtended; 4 | import com.red.masaadditions.minihud_additions.renderer.OverlayRendererBeaconRange; 5 | import fi.dy.masa.minihud.renderer.OverlayRenderer; 6 | import net.minecraft.client.MinecraftClient; 7 | import net.minecraft.client.util.math.MatrixStack; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Pseudo 15 | @Mixin(value = OverlayRenderer.class, remap = false) 16 | public class MixinOverlayRenderer { 17 | @Inject(method = "renderOverlays", at = @At("RETURN")) 18 | private static void renderOverlays(MatrixStack matrixStack, MinecraftClient mc, float partialTicks, CallbackInfo ci) { 19 | if (RendererToggleExtended.OVERLAY_BEACON_RANGE.getBooleanValue()) { 20 | double dx = mc.player.prevX + (mc.player.getPos().x - mc.player.prevX) * partialTicks; 21 | double dy = mc.player.prevY + (mc.player.getPos().y - mc.player.prevY) * partialTicks; 22 | double dz = mc.player.prevZ + (mc.player.getPos().z - mc.player.prevZ) * partialTicks; 23 | OverlayRendererBeaconRange.renderBeaconBoxForPlayerIfHoldingItem(mc.player, dx, dy, dz, partialTicks); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.red.masaadditions.MasaAdditions; 4 | import net.fabricmc.loader.api.FabricLoader; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 7 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 8 | 9 | import java.util.List; 10 | import java.util.Set; 11 | 12 | public class MixinPlugin implements IMixinConfigPlugin { 13 | @Override 14 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 15 | return FabricLoader.getInstance().isModLoaded("minihud"); 16 | } 17 | 18 | @Override 19 | public void acceptTargets(Set myTargets, Set otherTargets) { 20 | if (FabricLoader.getInstance().isModLoaded("minihud")) 21 | MasaAdditions.logger.info("MiniHUDAdditions Loaded."); 22 | } 23 | 24 | @Override 25 | public void onLoad(String mixinPackage) { 26 | } 27 | 28 | @Override 29 | public String getRefMapperConfig() { 30 | return null; 31 | } 32 | 33 | @Override 34 | public List getMixins() { 35 | return null; 36 | } 37 | 38 | @Override 39 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 40 | } 41 | 42 | @Override 43 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.MasaAdditions; 4 | import net.fabricmc.loader.api.FabricLoader; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 7 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 8 | 9 | import java.util.List; 10 | import java.util.Set; 11 | 12 | public class MixinPlugin implements IMixinConfigPlugin { 13 | @Override 14 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 15 | return FabricLoader.getInstance().isModLoaded("litematica"); 16 | } 17 | 18 | @Override 19 | public void acceptTargets(Set myTargets, Set otherTargets) { 20 | if (FabricLoader.getInstance().isModLoaded("litematica")) 21 | MasaAdditions.logger.info("LitematicaAdditions Loaded."); 22 | } 23 | 24 | @Override 25 | public void onLoad(String mixinPackage) { 26 | } 27 | 28 | @Override 29 | public String getRefMapperConfig() { 30 | return null; 31 | } 32 | 33 | @Override 34 | public List getMixins() { 35 | return null; 36 | } 37 | 38 | @Override 39 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 40 | } 41 | 42 | @Override 43 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinAnvilScreen.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.gui.screen.ingame.AnvilScreen; 6 | import net.minecraft.client.gui.screen.ingame.ForgingScreen; 7 | import net.minecraft.client.gui.widget.TextFieldWidget; 8 | import net.minecraft.entity.player.PlayerInventory; 9 | import net.minecraft.screen.AnvilScreenHandler; 10 | import net.minecraft.screen.slot.Slot; 11 | import net.minecraft.text.Text; 12 | import net.minecraft.util.Identifier; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Redirect; 16 | 17 | @Mixin(AnvilScreen.class) 18 | public abstract class MixinAnvilScreen extends ForgingScreen { 19 | public MixinAnvilScreen(AnvilScreenHandler handler, PlayerInventory playerInventory, Text title, Identifier texture) { 20 | super(handler, playerInventory, title, texture); 21 | } 22 | 23 | @Redirect(method = "onSlotUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;setText(Ljava/lang/String;)V")) 24 | private void setText(TextFieldWidget nameField, String text) { 25 | Slot slot = this.handler.getSlot(0); 26 | if (FeatureToggleExtended.TWEAK_ITEM_NAME_COPY.getBooleanValue() && slot != null && slot.hasStack()) 27 | nameField.setText(MinecraftClient.getInstance().keyboard.getClipboard()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinKeyCallbacks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.red.masaadditions.minihud_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.minihud_additions.config.RendererToggleExtended; 5 | import com.red.masaadditions.minihud_additions.renderer.OverlayRendererBeaconRange; 6 | import fi.dy.masa.minihud.hotkeys.KeyCallbacks; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Pseudo; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Pseudo 14 | @Mixin(value = KeyCallbacks.class, remap = false) 15 | public class MixinKeyCallbacks { 16 | @Inject(method = "init", at = @At("RETURN")) 17 | private static void init(CallbackInfo ci) { 18 | ConfigsExtended.Colors.BEACON_RANGE_LVL1_OVERLAY_COLOR.setValueChangeCallback((config) -> OverlayRendererBeaconRange.setNeedsUpdate()); 19 | ConfigsExtended.Colors.BEACON_RANGE_LVL2_OVERLAY_COLOR.setValueChangeCallback((config) -> OverlayRendererBeaconRange.setNeedsUpdate()); 20 | ConfigsExtended.Colors.BEACON_RANGE_LVL3_OVERLAY_COLOR.setValueChangeCallback((config) -> OverlayRendererBeaconRange.setNeedsUpdate()); 21 | ConfigsExtended.Colors.BEACON_RANGE_LVL4_OVERLAY_COLOR.setValueChangeCallback((config) -> OverlayRendererBeaconRange.setNeedsUpdate()); 22 | 23 | RendererToggleExtended.OVERLAY_BEACON_RANGE.setValueChangeCallback((config) -> OverlayRendererBeaconRange.setNeedsUpdate()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweaks/InventoryTweaks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweaks; 2 | 3 | import com.google.common.collect.Sets; 4 | import net.minecraft.item.Item; 5 | import net.minecraft.util.Identifier; 6 | import net.minecraft.util.registry.Registry; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | public class InventoryTweaks { 12 | private static final Set SWAP_ALMOST_BROKEN_TOOLS_WHITELIST = Sets.newIdentityHashSet(); 13 | private static final Set SWAP_ALMOST_BROKEN_TOOLS_BLACKLIST = Sets.newIdentityHashSet(); 14 | 15 | public static void setSwapAlmostBrokenToolsWhitelist(List whitelist) { 16 | parseList(whitelist, SWAP_ALMOST_BROKEN_TOOLS_WHITELIST); 17 | } 18 | 19 | public static void setSwapAlmostBrokenToolsBlacklist(List blacklist) { 20 | parseList(blacklist, SWAP_ALMOST_BROKEN_TOOLS_BLACKLIST); 21 | } 22 | 23 | private static void parseList(List list, Set set) { 24 | set.clear(); 25 | for (String blockStr : list) { 26 | Identifier id = Identifier.tryParse(blockStr); 27 | if (id == null) { 28 | continue; 29 | } 30 | Registry.ITEM.getOrEmpty(id).ifPresent(set::add); 31 | } 32 | } 33 | 34 | public static boolean canSwapAlmostBrokenTool(Item item) { 35 | if (SWAP_ALMOST_BROKEN_TOOLS_BLACKLIST.contains(item)) { 36 | return false; 37 | } 38 | if (!SWAP_ALMOST_BROKEN_TOOLS_WHITELIST.isEmpty()) { 39 | return SWAP_ALMOST_BROKEN_TOOLS_WHITELIST.contains(item); 40 | } 41 | return true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinBlockColors.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import net.minecraft.block.BlockState; 5 | import net.minecraft.block.LeavesBlock; 6 | import net.minecraft.client.color.block.BlockColors; 7 | import net.minecraft.util.math.BlockPos; 8 | import net.minecraft.world.BlockRenderView; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Unique; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 14 | 15 | import java.awt.*; 16 | 17 | @Mixin(BlockColors.class) 18 | public class MixinBlockColors { 19 | // From UsefulMod by nessie 20 | @Inject(method = "getColor(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/util/math/BlockPos;I)I", at = @At("HEAD"), cancellable = true) 21 | private void getColor(BlockState state, BlockRenderView world, BlockPos pos, int tint, CallbackInfoReturnable cir) { 22 | if (!FeatureToggleExtended.TWEAK_RAINBOW_LEAVES.getBooleanValue() || pos == null || !(state.getBlock() instanceof LeavesBlock)) { 23 | return; 24 | } 25 | 26 | final int sc = 1024; 27 | final float hue = this.dist(pos.getX(), 32 * pos.getY(), pos.getX() + pos.getZ()) % sc / sc; 28 | cir.setReturnValue(Color.HSBtoRGB(hue, 0.7F, 1F)); 29 | } 30 | 31 | @Unique 32 | private float dist(int x, int y, int z) { 33 | return (float) Math.sqrt(x * x + y * y + z * z); 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinMinecraftClient.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import com.red.masaadditions.tweakeroo_additions.util.MiscUtils; 6 | import net.minecraft.client.MinecraftClient; 7 | import net.minecraft.client.options.KeyBinding; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 | 14 | @Mixin(MinecraftClient.class) 15 | public class MixinMinecraftClient { 16 | @Inject(method = "handleInputEvents", at = @At("HEAD")) 17 | private void onProcessKeybindsPre(CallbackInfo ci) 18 | { 19 | if (((MinecraftClient) (Object) this).currentScreen == null) 20 | { 21 | if (FeatureToggleExtended.TWEAK_MOVEMENT_HOLD.getBooleanValue()) 22 | { 23 | for (KeyBinding movementKey : MiscUtils.MOVEMENT_HOLD_KEYS) { 24 | movementKey.setPressed(true); 25 | } 26 | } 27 | } 28 | } 29 | 30 | @Inject(method = "getWindowTitle", at = @At("HEAD"), cancellable = true) 31 | private void getWindowTitle(CallbackInfoReturnable cir) { 32 | if (FeatureToggleExtended.TWEAK_OVERRIDE_WINDOW_TITLE.getBooleanValue()) { 33 | cir.setReturnValue(ConfigsExtended.Generic.WINDOW_TITLE_OVERRIDE.getStringValue()); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.red.masaadditions.MasaAdditions; 4 | import net.fabricmc.loader.api.FabricLoader; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 7 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 8 | 9 | import java.util.List; 10 | import java.util.Set; 11 | 12 | public class MixinPlugin implements IMixinConfigPlugin { 13 | @Override 14 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 15 | if (mixinClassName.endsWith(".MixinExplosionCarpet")) { 16 | return FabricLoader.getInstance().isModLoaded("carpet"); 17 | } 18 | 19 | return FabricLoader.getInstance().isModLoaded("tweakeroo"); 20 | } 21 | 22 | @Override 23 | public void acceptTargets(Set myTargets, Set otherTargets) { 24 | if (FabricLoader.getInstance().isModLoaded("tweakeroo")) 25 | MasaAdditions.logger.info("TweakerooAdditions Loaded."); 26 | } 27 | 28 | @Override 29 | public void onLoad(String mixinPackage) { 30 | } 31 | 32 | @Override 33 | public String getRefMapperConfig() { 34 | return null; 35 | } 36 | 37 | @Override 38 | public List getMixins() { 39 | return null; 40 | } 41 | 42 | @Override 43 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 44 | } 45 | 46 | @Override 47 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinBlockModelRendererSchematic.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.litematica_additions.util.MiscUtils; 5 | import fi.dy.masa.litematica.render.schematic.BlockModelRendererSchematic; 6 | import net.minecraft.block.BlockState; 7 | import net.minecraft.client.MinecraftClient; 8 | import net.minecraft.client.network.ClientPlayerEntity; 9 | import net.minecraft.item.ItemStack; 10 | import net.minecraft.util.math.BlockPos; 11 | import net.minecraft.util.math.Direction; 12 | import net.minecraft.world.BlockRenderView; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 17 | 18 | @Mixin(value = BlockModelRendererSchematic.class, remap = false) 19 | public class MixinBlockModelRendererSchematic { 20 | @Inject(method = "shouldRenderModelSide", at = @At("RETURN"), cancellable = true) 21 | private void shouldRenderModelSide(BlockRenderView worldIn, BlockState stateIn, BlockPos posIn, Direction side, CallbackInfoReturnable cir) { 22 | if (cir.getReturnValue()) { 23 | return; 24 | } 25 | 26 | ClientPlayerEntity player = MinecraftClient.getInstance().player; 27 | ItemStack item = player != null ? player.getMainHandStack() : ItemStack.EMPTY; 28 | BlockState neighborBlockState = worldIn.getBlockState(posIn.offset(side)); 29 | cir.setReturnValue(ConfigsExtended.Generic.RENDER_HELD_ITEM_ONLY.getBooleanValue() && MiscUtils.checkHeldItem(item, neighborBlockState)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinSlimeBlock.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.block.SlimeBlock; 5 | import net.minecraft.block.TransparentBlock; 6 | import net.minecraft.entity.Entity; 7 | import net.minecraft.entity.player.PlayerEntity; 8 | import net.minecraft.util.math.BlockPos; 9 | import net.minecraft.world.BlockView; 10 | import net.minecraft.world.World; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(SlimeBlock.class) 17 | public class MixinSlimeBlock extends TransparentBlock { 18 | protected MixinSlimeBlock(Settings settings) { 19 | super(settings); 20 | } 21 | 22 | @Inject(method = "onEntityLand", at = @At("HEAD"), cancellable = true) 23 | private void onEntityLand(BlockView world, Entity entity, CallbackInfo ci) { 24 | if (ConfigsExtended.Disable.DISABLE_SLIME_BLOCK_BOUNCING.getBooleanValue() && entity instanceof PlayerEntity) { 25 | super.onEntityLand(world, entity); 26 | ci.cancel(); 27 | } 28 | } 29 | 30 | @Inject(method = "onLandedUpon", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;handleFallDamage(FF)Z"), cancellable = true) 31 | private void handleFallDamage(World world, BlockPos pos, Entity entity, float distance, CallbackInfo ci) { 32 | if (ConfigsExtended.Disable.DISABLE_SLIME_BLOCK_BOUNCING.getBooleanValue() && entity instanceof PlayerEntity) { 33 | super.onLandedUpon(world, pos, entity, distance); 34 | ci.cancel(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.minihud_additions.config.RendererToggleExtended; 5 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 6 | import fi.dy.masa.minihud.config.Configs; 7 | import fi.dy.masa.minihud.config.RendererToggle; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Pseudo; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.ModifyArg; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | @Pseudo 17 | @Mixin(value = Configs.class, remap = false) 18 | public class MixinConfigs { 19 | private static final ImmutableList RENDERER_OPTIONS = new ImmutableList.Builder().addAll(Arrays.asList(RendererToggle.values())).addAll(Arrays.asList(RendererToggleExtended.values())).build(); 20 | 21 | @ModifyArg(method = "loadFromFile", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/config/ConfigUtils;readHotkeyToggleOptions(Lcom/google/gson/JsonObject;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 1), index = 3) 22 | private static List readRendererOptions(List options) { 23 | return RENDERER_OPTIONS; 24 | } 25 | 26 | @ModifyArg(method = "saveToFile", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/config/ConfigUtils;writeHotkeyToggleOptions(Lcom/google/gson/JsonObject;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 1), index = 3) 27 | private static List writeRendererOptions(List options) { 28 | return RENDERER_OPTIONS; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinMiscTweaks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import fi.dy.masa.tweakeroo.tweaks.MiscTweaks; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.network.ClientPlayerEntity; 6 | import net.minecraft.entity.EquipmentSlot; 7 | import net.minecraft.entity.effect.StatusEffectInstance; 8 | import net.minecraft.entity.effect.StatusEffects; 9 | import net.minecraft.entity.player.PlayerEntity; 10 | import net.minecraft.item.Items; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Pseudo; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 18 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 19 | 20 | import java.util.Collection; 21 | import java.util.TreeSet; 22 | import java.util.stream.Collectors; 23 | 24 | @Pseudo 25 | @Mixin(value = MiscTweaks.class, remap = false) 26 | public class MixinMiscTweaks { 27 | @ModifyVariable(method = "doPotionWarnings", at = @At(value = "STORE", target = "Lfi/dy/masa/tweakeroo/tweaks/MiscTweaks;doPotionWarnings(Lnet/minecraft/entity/player/PlayerEntity;)V")) 28 | private static Collection doPotionWarnings(Collection effects) { 29 | ClientPlayerEntity player = MinecraftClient.getInstance().player; 30 | return player != null && player.getEquippedStack(EquipmentSlot.HEAD).getItem() != Items.TURTLE_HELMET ? effects : effects.stream().filter(e -> e.getEffectType() != StatusEffects.WATER_BREATHING).collect(Collectors.toCollection(TreeSet::new)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/minihud_mixin/MixinInputHandler.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.minihud_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.minihud_additions.config.RendererToggleExtended; 5 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 6 | import fi.dy.masa.malilib.hotkeys.IKeybindManager; 7 | import fi.dy.masa.minihud.config.RendererToggle; 8 | import fi.dy.masa.minihud.event.InputHandler; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Pseudo; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.ModifyArg; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | import java.util.Arrays; 17 | import java.util.List; 18 | 19 | @Pseudo 20 | @Mixin(value = InputHandler.class, remap = false) 21 | public class MixinInputHandler { 22 | private static final ImmutableList RENDERER_TOGGLE = new ImmutableList.Builder().addAll(Arrays.asList(RendererToggle.values())).addAll(Arrays.asList(RendererToggleExtended.values())).build(); 23 | 24 | @Inject(method = "addKeysToMap", at = @At("RETURN")) 25 | private void addKeysToMap(IKeybindManager manager, CallbackInfo ci) { 26 | for (RendererToggleExtended toggle : RendererToggleExtended.values()) { 27 | manager.addKeybindToMap(toggle.getKeybind()); 28 | } 29 | } 30 | 31 | @ModifyArg(method = "addHotkeys", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/hotkeys/IKeybindManager;addHotkeysForCategory(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 2), index = 2) 32 | private List addHotkeysForCategory(List hotkeys) { 33 | return RENDERER_TOGGLE; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinClientPlayerEntity.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import net.minecraft.client.network.AbstractClientPlayerEntity; 6 | import net.minecraft.client.network.ClientPlayerEntity; 7 | import net.minecraft.client.world.ClientWorld; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 14 | 15 | @Mixin(ClientPlayerEntity.class) 16 | public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity { 17 | @Shadow 18 | public int ticksSinceSprintingChanged; 19 | 20 | @Shadow 21 | public abstract boolean isSubmergedInWater(); 22 | 23 | public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { 24 | super(world, profile); 25 | } 26 | 27 | @Inject(method = "setSprinting", at = @At("HEAD"), cancellable = true) 28 | private void setSprinting(boolean sprinting, CallbackInfo ci) { 29 | if (ConfigsExtended.Disable.DISABLE_SPRINTING_UNDERWATER.getBooleanValue() && ((this.isTouchingWater() && !this.isSubmergedInWater()) || (ConfigsExtended.Disable.DISABLE_SWIMMING.getBooleanValue()))) { 30 | super.setSprinting(false); 31 | this.ticksSinceSprintingChanged = 0; 32 | ci.cancel(); 33 | } 34 | } 35 | 36 | @Inject(method = "shouldSpawnSprintingParticles", at = @At("HEAD"), cancellable = true) 37 | private void shouldSpawnSprintingParticles(CallbackInfoReturnable cir) { 38 | if (ConfigsExtended.Disable.DISABLE_FOOTSTEP_PARTICLES.getBooleanValue()) 39 | cir.setReturnValue(false); 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinArmorItem.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 4 | import com.red.masaadditions.tweakeroo_additions.util.MiscUtils; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.entity.mob.MobEntity; 7 | import net.minecraft.entity.player.PlayerEntity; 8 | import net.minecraft.item.ArmorItem; 9 | import net.minecraft.item.ElytraItem; 10 | import net.minecraft.item.ItemStack; 11 | import net.minecraft.screen.slot.SlotActionType; 12 | import net.minecraft.util.Hand; 13 | import net.minecraft.util.TypedActionResult; 14 | import net.minecraft.world.World; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 19 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 20 | 21 | @Mixin(value = {ArmorItem.class, ElytraItem.class}) 22 | public class MixinArmorItem { 23 | @Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/TypedActionResult;fail(Ljava/lang/Object;)Lnet/minecraft/util/TypedActionResult;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT) 24 | private void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir, ItemStack itemStack) { 25 | MinecraftClient mc = MinecraftClient.getInstance(); 26 | 27 | if (!FeatureToggleExtended.TWEAK_FORCE_SWAP_GEAR.getBooleanValue() || !user.isSneaking() || hand != Hand.MAIN_HAND || mc.interactionManager == null || user.currentScreenHandler != user.playerScreenHandler) { 28 | return; 29 | } 30 | 31 | mc.interactionManager.clickSlot(user.playerScreenHandler.syncId, MiscUtils.getSlotNumberForEquipmentSlot(MobEntity.getPreferredEquipmentSlot(itemStack)), user.inventory.selectedSlot, SlotActionType.SWAP, user); 32 | cir.setReturnValue(TypedActionResult.success(itemStack, world.isClient())); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinParticleManager.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import com.red.masaadditions.tweakeroo_additions.util.MiscUtils; 6 | import fi.dy.masa.tweakeroo.config.Configs; 7 | import net.minecraft.block.BlockState; 8 | import net.minecraft.client.particle.ParticleManager; 9 | import net.minecraft.client.world.ClientWorld; 10 | import net.minecraft.util.math.BlockPos; 11 | import net.minecraft.util.math.Direction; 12 | import org.spongepowered.asm.mixin.Final; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.Shadow; 15 | import org.spongepowered.asm.mixin.injection.At; 16 | import org.spongepowered.asm.mixin.injection.Inject; 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 18 | 19 | import java.util.Random; 20 | 21 | 22 | @Mixin(ParticleManager.class) 23 | public class MixinParticleManager { 24 | @Shadow 25 | protected ClientWorld world; 26 | @Shadow 27 | @Final 28 | private Random random; 29 | 30 | // From 1.12 Tweakeroo by Masa 31 | @Inject(method = "addBlockBreakParticles", at = @At("HEAD"), cancellable = true) 32 | private void onAddBlockDestroyEffects1(BlockPos pos, BlockState state, CallbackInfo ci) { 33 | if (!Configs.Disable.DISABLE_BLOCK_BREAK_PARTICLES.getBooleanValue() && FeatureToggleExtended.TWEAK_BLOCK_BREAKING_PARTICLES.getBooleanValue()) { 34 | MiscUtils.addCustomBlockBreakingParticles((net.minecraft.client.particle.ParticleManager) (Object) this, this.world, this.random, pos, state); 35 | ci.cancel(); 36 | } 37 | } 38 | 39 | @Inject(method = "addBlockBreakingParticles", at = @At("HEAD"), cancellable = true) 40 | private void onAddBlockDestroyEffects2(BlockPos pos, Direction direction, CallbackInfo ci) { 41 | if (ConfigsExtended.Disable.DISABLE_BLOCK_ATTACKED_PARTICLES.getBooleanValue()) { 42 | ci.cancel(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/litematica_mixin/MixinChunkRendererSchematicVbo.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.litematica_mixin; 2 | 3 | import com.red.masaadditions.litematica_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.litematica_additions.util.MiscUtils; 5 | import fi.dy.masa.litematica.render.schematic.BufferBuilderCache; 6 | import fi.dy.masa.litematica.render.schematic.ChunkCacheSchematic; 7 | import fi.dy.masa.litematica.render.schematic.ChunkRenderDataSchematic; 8 | import fi.dy.masa.litematica.render.schematic.ChunkRendererSchematicVbo; 9 | import net.minecraft.block.BlockState; 10 | import net.minecraft.block.entity.BlockEntity; 11 | import net.minecraft.client.MinecraftClient; 12 | import net.minecraft.client.network.ClientPlayerEntity; 13 | import net.minecraft.client.render.RenderLayer; 14 | import net.minecraft.client.util.math.MatrixStack; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.util.math.BlockPos; 17 | import org.spongepowered.asm.mixin.Mixin; 18 | import org.spongepowered.asm.mixin.Shadow; 19 | import org.spongepowered.asm.mixin.injection.At; 20 | import org.spongepowered.asm.mixin.injection.Inject; 21 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 22 | 23 | import java.util.Set; 24 | 25 | @Mixin(value = ChunkRendererSchematicVbo.class, remap = false) 26 | public class MixinChunkRendererSchematicVbo { 27 | @Shadow 28 | protected ChunkCacheSchematic schematicWorldView; 29 | 30 | @Inject(method = "renderBlocksAndOverlay", at = @At("HEAD"), cancellable = true) 31 | private void renderBlocksAndOverlay(BlockPos pos, ChunkRenderDataSchematic data, Set tileEntities, Set usedLayers, MatrixStack matrices, BufferBuilderCache buffers, CallbackInfo ci) { 32 | ClientPlayerEntity player = MinecraftClient.getInstance().player; 33 | ItemStack item = player != null ? player.getMainHandStack() : ItemStack.EMPTY; 34 | BlockState stateSchematic = this.schematicWorldView.getBlockState(pos); 35 | if (ConfigsExtended.Generic.RENDER_HELD_ITEM_ONLY.getBooleanValue() && MiscUtils.checkHeldItem(item, stateSchematic)) { 36 | ci.cancel(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MasaAdditions 2 | An add-on mod for Masa's mods, Tweakeroo, MiniHUD, and Litematica. 3 | 4 | ## Features 5 | - [TweakerooAdditions](https://github.com/hp3721/masaadditions/wiki/TweakerooAdditions) 6 | - [MiniHUDAdditions](https://github.com/hp3721/masaadditions/wiki/MiniHUDAdditions) 7 | - [LitematicaAdditions](https://github.com/hp3721/masaadditions/wiki/LitematicaAdditions) 8 | 9 | ## Installation 10 | 1. Download and run the [Fabric installer](https://fabricmc.net/use). 11 | - Note: this step may vary if you aren't using the vanilla launcher. 12 | 1. Download the [Fabric API](https://minecraft.curseforge.com/projects/fabric) and move it to the mods folder (`.minecraft/mods`). 13 | 1. Download MasaAdditions from the [releases page](https://github.com/hp3721/masaadditions/releases) and move it to the mods folder (`.minecraft/mods`). 14 | 15 | ## Contributing 16 | 1. Clone the repository 17 | ``` 18 | git clone https://github.com/hp3721/masaadditions.git 19 | cd masaadditions 20 | ``` 21 | 1. Generate the Minecraft source code 22 | ``` 23 | ./gradlew genSources 24 | ``` 25 | - Note: on Windows, use `gradlew` rather than `./gradlew`. 26 | 1. Import the project into your preferred IDE. 27 | 1. If you use IntelliJ (the preferred option), you can simply import the project as a Gradle project. 28 | 1. If you use Eclipse, you need to `./gradlew eclipse` before importing the project as an Eclipse project. 29 | 1. Edit the code 30 | 1. After testing in the IDE, build a JAR to test whether it works outside the IDE too 31 | ``` 32 | ./gradlew build 33 | ``` 34 | The mod JAR may be found in the `build/libs` directory 35 | 1. [Create a pull request](https://help.github.com/en/articles/creating-a-pull-request) so that your changes can be integrated into MasaAdditions 36 | - Note: for large contributions, create an issue before doing all that work, to ask whether your pull request is likely to be accepted 37 | 38 | ## License 39 | This project is licensed under [GPL-3.0](https://github.com/hp3721/masaadditions/LICENSE). Some portions of code are liberally adapted from [UsefulMod](https://github.com/Nessiesson/UsefulMod) and [CutelessMod](https://github.com/Nessiesson/CutelessMod) by [nessie](https://github.com/Nessiesson) which is licensed under the [MIT License](https://github.com/hp3721/masaadditions/blob/master/LICENSE_MIT). -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweaks/PlacementTweaks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweaks; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import net.minecraft.block.Block; 6 | import net.minecraft.block.DragonEggBlock; 7 | import net.minecraft.client.MinecraftClient; 8 | import net.minecraft.client.world.ClientWorld; 9 | import net.minecraft.entity.player.PlayerEntity; 10 | import net.minecraft.util.Identifier; 11 | import net.minecraft.util.math.BlockPos; 12 | import net.minecraft.util.registry.Registry; 13 | import net.minecraft.world.Heightmap; 14 | 15 | import javax.annotation.Nullable; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class PlacementTweaks { 20 | public static final ArrayList PERIMETER_OUTLINE_BLOCKS = new ArrayList<>(); 21 | 22 | public static boolean onProcessLeftClickBlock(BlockPos pos) { 23 | PlayerEntity player = MinecraftClient.getInstance().player; 24 | return ConfigsExtended.Disable.DISABLE_DRAGON_EGG_TELEPORTING.getBooleanValue() && player != null && !player.isCreative() && player.getEntityWorld().getBlockState(pos).getBlock() instanceof DragonEggBlock; 25 | } 26 | 27 | public static boolean isPositionDisallowedByPerimeterOutlineList(BlockPos pos) { 28 | boolean restrictionEnabled = FeatureToggleExtended.TWEAK_PERIMETER_WALL_DIG_HELPER.getBooleanValue(); 29 | 30 | if (!restrictionEnabled) 31 | return false; 32 | 33 | ClientWorld world = MinecraftClient.getInstance().world; 34 | return world != null && PERIMETER_OUTLINE_BLOCKS.contains(world.getBlockState(world.getTopPosition(Heightmap.Type.WORLD_SURFACE, pos).down()).getBlock()); 35 | } 36 | 37 | public static void setPerimeterOutlineBlocks(List blocks) { 38 | PERIMETER_OUTLINE_BLOCKS.clear(); 39 | 40 | for (String str : blocks) { 41 | Block block = getBlockFromName(str); 42 | 43 | if (block != null) 44 | PERIMETER_OUTLINE_BLOCKS.add(block); 45 | } 46 | } 47 | 48 | @Nullable 49 | private static Block getBlockFromName(String name) { 50 | try { 51 | Identifier identifier = new Identifier(name); 52 | return Registry.BLOCK.getOrEmpty(identifier).orElse(null); 53 | } catch (Exception e) { 54 | return null; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinGuiConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import fi.dy.masa.malilib.config.ConfigType; 6 | import fi.dy.masa.malilib.config.ConfigUtils; 7 | import fi.dy.masa.malilib.config.IConfigBase; 8 | import fi.dy.masa.malilib.config.IConfigValue; 9 | import fi.dy.masa.tweakeroo.config.FeatureToggle; 10 | import fi.dy.masa.tweakeroo.gui.GuiConfigs; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Pseudo; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | 22 | @Pseudo 23 | @Mixin(value = GuiConfigs.class, remap = false) 24 | public class MixinGuiConfigs { 25 | private static final ImmutableList FEATURE_TOGGLES = new ImmutableList.Builder().addAll(Arrays.asList(FeatureToggle.values())).addAll(Arrays.asList(FeatureToggleExtended.values())).build(); 26 | 27 | @ModifyVariable(method = "getConfigs", at = @At(value = "STORE", target = "Lfi/dy/masa/tweakeroo/gui/GuiConfigs;getConfigs()Ljava/util/List;", ordinal = 5)) 28 | private List ExtendFeatureToggles(List configs) { 29 | return ConfigUtils.createConfigWrapperForType(ConfigType.BOOLEAN, FEATURE_TOGGLES); 30 | } 31 | 32 | @ModifyVariable(method = "getConfigs", at = @At(value = "STORE", target = "Lfi/dy/masa/tweakeroo/gui/GuiConfigs;getConfigs()Ljava/util/List;", ordinal = 6)) 33 | private List ExtendFeatureHotkeys(List configs) { 34 | return ConfigUtils.createConfigWrapperForType(ConfigType.HOTKEY, FEATURE_TOGGLES); 35 | } 36 | 37 | @Inject(method = "initGui", at = @At(value = "INVOKE", target = "Lfi/dy/masa/tweakeroo/gui/GuiConfigs;createButton(IIILfi/dy/masa/tweakeroo/gui/GuiConfigs$ConfigGuiTab;)I"), cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT) 38 | private void initGui(CallbackInfo ci, int x, int y, GuiConfigs.ConfigGuiTab[] var3, int var4, int var5, GuiConfigs.ConfigGuiTab tab) { 39 | if (tab == GuiConfigs.ConfigGuiTab.PLACEMENT) { 40 | ci.cancel(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinConfigs.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended.Lists; 5 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 6 | import com.red.masaadditions.tweakeroo_additions.tweaks.InventoryTweaks; 7 | import com.red.masaadditions.tweakeroo_additions.tweaks.PlacementTweaks; 8 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 9 | import fi.dy.masa.tweakeroo.config.Configs; 10 | import fi.dy.masa.tweakeroo.config.FeatureToggle; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Pseudo; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.ModifyArg; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | @Pseudo 22 | @Mixin(value = Configs.class, remap = false) 23 | public class MixinConfigs { 24 | private static final ImmutableList FEATURE_OPTIONS = new ImmutableList.Builder().addAll(Arrays.asList(FeatureToggle.values())).addAll(Arrays.asList(FeatureToggleExtended.values())).build(); 25 | 26 | @ModifyArg(method = "loadFromFile", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/config/ConfigUtils;readHotkeyToggleOptions(Lcom/google/gson/JsonObject;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 1), index = 3) 27 | private static List readFeatureOptions(List options) { 28 | return FEATURE_OPTIONS; 29 | } 30 | 31 | @ModifyArg(method = "saveToFile", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/config/ConfigUtils;writeHotkeyToggleOptions(Lcom/google/gson/JsonObject;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 1), index = 3) 32 | private static List writeFeatureOptions(List options) { 33 | return FEATURE_OPTIONS; 34 | } 35 | 36 | @Inject(method = "loadFromFile", at = @At("RETURN")) 37 | private static void setTweakLists(CallbackInfo ci) { 38 | PlacementTweaks.setPerimeterOutlineBlocks(Lists.PERIMETER_OUTLINE_BLOCKS_LIST.getStrings()); 39 | InventoryTweaks.setSwapAlmostBrokenToolsWhitelist(Lists.SWAP_ALMOST_BROKEN_TOOLS_WHITELIST.getStrings()); 40 | InventoryTweaks.setSwapAlmostBrokenToolsBlacklist(Lists.SWAP_ALMOST_BROKEN_TOOLS_BLACKLIST.getStrings()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinCallbacks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import com.red.masaadditions.tweakeroo_additions.config.HotkeysExtended; 6 | import com.red.masaadditions.tweakeroo_additions.tweaks.PlacementTweaks; 7 | import com.red.masaadditions.tweakeroo_additions.util.Callbacks; 8 | import com.red.masaadditions.tweakeroo_additions.util.MiscUtils; 9 | import fi.dy.masa.malilib.hotkeys.IHotkeyCallback; 10 | import fi.dy.masa.tweakeroo.config.FeatureToggle; 11 | import net.minecraft.client.MinecraftClient; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Pseudo; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | @Pseudo 19 | @Mixin(value = fi.dy.masa.tweakeroo.config.Callbacks.class, remap = false) 20 | public abstract class MixinCallbacks { 21 | @Inject(method = "init", at = @At("RETURN")) 22 | private static void init(MinecraftClient mc, CallbackInfo ci) { 23 | final IHotkeyCallback callbackGeneric = new Callbacks.KeyCallbackHotkeysGeneric(); 24 | HotkeysExtended.BLINK_DRIVE.getKeybind().setCallback(callbackGeneric); 25 | HotkeysExtended.BLINK_DRIVE_Y_LEVEL.getKeybind().setCallback(callbackGeneric); 26 | ConfigsExtended.Lists.PERIMETER_OUTLINE_BLOCKS_LIST.setValueChangeCallback((cfg) -> PlacementTweaks.setPerimeterOutlineBlocks(cfg.getStrings())); 27 | ConfigsExtended.Disable.DISABLE_PLANT_BLOCK_MODEL_OFFSET.setValueChangeCallback((cfg) -> mc.worldRenderer.reload()); 28 | FeatureToggleExtended.TWEAK_OVERRIDE_WINDOW_TITLE.setValueChangeCallback((cfg) -> mc.updateWindowTitle()); 29 | ConfigsExtended.Generic.WINDOW_TITLE_OVERRIDE.setValueChangeCallback((cfg) -> mc.updateWindowTitle()); 30 | ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_SLOWDOWN.setValueChangeCallback(new Callbacks.FeatureCallbackHoney(ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_SLOWDOWN)); 31 | ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_JUMPING.setValueChangeCallback(new Callbacks.FeatureCallbackHoney(ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_JUMPING)); 32 | ConfigsExtended.Disable.DISABLE_FARMLAND_MAKING.setValueChangeCallback((cfg) -> FeatureToggle.TWEAK_FAST_RIGHT_CLICK.setBooleanValue(false)); 33 | FeatureToggle.TWEAK_FAST_RIGHT_CLICK.setValueChangeCallback((cfg) -> { 34 | if (ConfigsExtended.Disable.DISABLE_FARMLAND_MAKING.getBooleanValue()) { 35 | FeatureToggle.TWEAK_FAST_RIGHT_CLICK.setBooleanValue(false); 36 | } 37 | }); 38 | FeatureToggle.TWEAK_FAST_RIGHT_CLICK.getKeybind().setCallback(new Callbacks.KeyCallbackToggleFastRightClick(FeatureToggle.TWEAK_FAST_RIGHT_CLICK)); 39 | FeatureToggleExtended.TWEAK_MOVEMENT_HOLD.setValueChangeCallback((cfg) -> MiscUtils.setMovementHoldKeys(cfg.getBooleanValue())); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinInputHandler.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 5 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 6 | import com.red.masaadditions.tweakeroo_additions.config.HotkeysExtended; 7 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 8 | import fi.dy.masa.malilib.config.options.ConfigHotkey; 9 | import fi.dy.masa.malilib.hotkeys.IHotkey; 10 | import fi.dy.masa.malilib.hotkeys.IKeybindManager; 11 | import fi.dy.masa.tweakeroo.config.FeatureToggle; 12 | import fi.dy.masa.tweakeroo.event.InputHandler; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.Pseudo; 15 | import org.spongepowered.asm.mixin.injection.At; 16 | import org.spongepowered.asm.mixin.injection.Inject; 17 | import org.spongepowered.asm.mixin.injection.ModifyArg; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | @Pseudo 24 | @Mixin(value = InputHandler.class, remap = false) 25 | public class MixinInputHandler { 26 | private static final ImmutableList FEATURE_TOGGLE = new ImmutableList.Builder().addAll(Arrays.asList(FeatureToggle.values())).addAll(Arrays.asList(FeatureToggleExtended.values())).build(); 27 | 28 | @Inject(method = "addKeysToMap", at = @At("RETURN")) 29 | private void addKeysToMap(IKeybindManager manager, CallbackInfo ci) { 30 | for (FeatureToggleExtended toggle : FeatureToggleExtended.values()) { 31 | manager.addKeybindToMap(toggle.getKeybind()); 32 | } 33 | 34 | for (IHotkey hotkey : HotkeysExtended.EXTENDED_HOTKEY_LIST) { 35 | manager.addKeybindToMap(hotkey.getKeybind()); 36 | } 37 | 38 | for (IHotkey hotkey : ConfigsExtended.Disable.ADDITIONAL_OPTIONS) { 39 | manager.addKeybindToMap(hotkey.getKeybind()); 40 | } 41 | } 42 | 43 | @ModifyArg(method = "addHotkeys", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/hotkeys/IKeybindManager;addHotkeysForCategory(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 0), index = 2) 44 | private List addDisableHotkeys(List hotkeys) { 45 | return ConfigsExtended.Disable.ADDITIONAL_OPTIONS; 46 | } 47 | 48 | @ModifyArg(method = "addHotkeys", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/hotkeys/IKeybindManager;addHotkeysForCategory(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 1), index = 2) 49 | private List addGenericHotkeys(List hotkeys) { 50 | return HotkeysExtended.EXTENDED_HOTKEY_LIST; 51 | } 52 | 53 | @ModifyArg(method = "addHotkeys", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/hotkeys/IKeybindManager;addHotkeysForCategory(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", ordinal = 2), index = 2) 54 | private List addFeatureHotkeys(List hotkeys) { 55 | return FEATURE_TOGGLE; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/util/MiscUtils.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.util; 2 | 3 | import com.red.masaadditions.litematica_additions.mixin.MixinFlowerPotBlockAccessor; 4 | import fi.dy.masa.litematica.data.DataManager; 5 | import fi.dy.masa.malilib.gui.button.ButtonBase; 6 | import fi.dy.masa.malilib.gui.button.IButtonActionListener; 7 | import net.minecraft.block.*; 8 | import net.minecraft.block.enums.PistonType; 9 | import net.minecraft.fluid.Fluids; 10 | import net.minecraft.item.Item; 11 | import net.minecraft.item.ItemStack; 12 | import net.minecraft.item.Items; 13 | import net.minecraft.potion.PotionUtil; 14 | import net.minecraft.potion.Potions; 15 | import net.minecraft.state.property.Properties; 16 | import net.minecraft.util.Util; 17 | 18 | import java.util.*; 19 | 20 | public class MiscUtils { 21 | static final Item[] IGNORED_ITEMS_VALUES = new Item[] { Items.PISTON, Items.STICKY_PISTON, Items.WATER_BUCKET, Items.POTION, Items.LAVA_BUCKET, Items.FLINT_AND_STEEL, Items.FIRE_CHARGE }; 22 | public static final Set IGNORED_ITEMS = new HashSet<>(Arrays.asList(IGNORED_ITEMS_VALUES)); 23 | 24 | public static class ButtonListenerOpenFolder implements IButtonActionListener { 25 | @Override 26 | public void actionPerformedWithButton(ButtonBase button, int mouseButton) { 27 | Util.getOperatingSystem().open(DataManager.getSchematicsBaseDirectory()); 28 | } 29 | } 30 | 31 | // TODO: Refactor 32 | public static boolean checkHeldItem(ItemStack heldItemStack, BlockState stateSchematic) { 33 | Item heldItem = heldItemStack.getItem(); 34 | boolean match = false; 35 | if (heldItemStack.isEmpty()) { 36 | return false; 37 | } else if (stateSchematic.getBlock() == Blocks.PISTON_HEAD || stateSchematic.getBlock() == Blocks.MOVING_PISTON) { 38 | match = heldItem == (stateSchematic.get(Properties.PISTON_TYPE) == PistonType.DEFAULT ? Blocks.PISTON : Blocks.STICKY_PISTON).asItem(); 39 | } else if (stateSchematic.getFluidState().getFluid() == Fluids.WATER || stateSchematic.getFluidState().getFluid() == Fluids.FLOWING_WATER) { 40 | match = heldItem == Items.WATER_BUCKET; 41 | } else if (stateSchematic.getBlock() == Blocks.CAULDRON) { 42 | match = heldItem == Items.POTION && PotionUtil.getPotion(heldItemStack) == Potions.WATER || (stateSchematic.get(CauldronBlock.LEVEL) == 3 && heldItem == Items.WATER_BUCKET); 43 | } else if (stateSchematic.getFluidState().getFluid() == Fluids.LAVA || stateSchematic.getFluidState().getFluid() == Fluids.FLOWING_LAVA) { 44 | match = heldItem == Items.LAVA_BUCKET; 45 | } else if (stateSchematic.getBlock() == Blocks.NETHER_PORTAL) { 46 | match = heldItem == Items.FLINT_AND_STEEL || heldItem == Items.FIRE_CHARGE; 47 | } else if (stateSchematic.getBlock() instanceof FlowerPotBlock) { 48 | match = heldItem == ((MixinFlowerPotBlockAccessor)stateSchematic.getBlock()).getContent().asItem() || heldItem == Items.FLOWER_POT; 49 | } else if (stateSchematic.getBlock() instanceof Waterloggable && stateSchematic.get(Properties.WATERLOGGED)) { 50 | match = heldItem == Items.WATER_BUCKET; 51 | } 52 | return !match && (Item.BLOCK_ITEMS.containsValue(heldItem) || IGNORED_ITEMS.contains(heldItem)) && heldItem != stateSchematic.getBlock().asItem(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/util/GuiFileImport.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.util; 2 | 3 | import fi.dy.masa.litematica.data.DataManager; 4 | import fi.dy.masa.litematica.gui.GuiSchematicSaveBase; 5 | import fi.dy.masa.litematica.schematic.LitematicaSchematic; 6 | import fi.dy.masa.malilib.gui.GuiBase; 7 | import fi.dy.masa.malilib.gui.Message; 8 | import fi.dy.masa.malilib.gui.button.ButtonBase; 9 | import fi.dy.masa.malilib.gui.button.IButtonActionListener; 10 | import fi.dy.masa.malilib.interfaces.ICompletionListener; 11 | import fi.dy.masa.malilib.util.GuiUtils; 12 | import fi.dy.masa.malilib.util.StringUtils; 13 | 14 | import java.io.File; 15 | 16 | public class GuiFileImport extends GuiFileImportBase implements ICompletionListener { 17 | public GuiFileImport(LitematicaSchematic schematic) { 18 | super(schematic); 19 | 20 | this.title = StringUtils.translate("masaadditions.gui.title.save_dragged_schematic"); 21 | } 22 | 23 | @Override 24 | public String getBrowserContext() { 25 | return "schematic_save"; 26 | } 27 | 28 | @Override 29 | public File getDefaultDirectory() { 30 | return DataManager.getSchematicsBaseDirectory(); 31 | } 32 | 33 | @Override 34 | protected IButtonActionListener createButtonListener(GuiSchematicSaveBase.ButtonType type) { 35 | return new GuiFileImport.ButtonListener(type, this); 36 | } 37 | 38 | @Override 39 | public void onTaskCompleted() { 40 | if (this.mc.isOnThread()) { 41 | this.refreshList(); 42 | } else { 43 | this.mc.execute(GuiFileImport.this::refreshList); 44 | } 45 | } 46 | 47 | private void refreshList() { 48 | if (GuiUtils.getCurrentScreen() == this) { 49 | this.getListWidget().refreshEntries(); 50 | this.getListWidget().clearSchematicMetadataCache(); 51 | } 52 | } 53 | 54 | private static class ButtonListener implements IButtonActionListener { 55 | private final GuiFileImport gui; 56 | private final GuiSchematicSaveBase.ButtonType type; 57 | 58 | public ButtonListener(GuiSchematicSaveBase.ButtonType type, GuiFileImport gui) { 59 | this.type = type; 60 | this.gui = gui; 61 | } 62 | 63 | @Override 64 | public void actionPerformedWithButton(ButtonBase button, int mouseButton) { 65 | if (this.type == GuiSchematicSaveBase.ButtonType.SAVE) { 66 | File dir = this.gui.getListWidget().getCurrentDirectory(); 67 | String fileName = this.gui.getTextFieldText(); 68 | 69 | if (!dir.isDirectory()) { 70 | this.gui.addMessage(Message.MessageType.ERROR, "litematica.error.schematic_save.invalid_directory", dir.getAbsolutePath()); 71 | return; 72 | } 73 | 74 | if (fileName.isEmpty()) { 75 | this.gui.addMessage(Message.MessageType.ERROR, "litematica.error.schematic_save.invalid_schematic_name", fileName); 76 | return; 77 | } 78 | 79 | LitematicaSchematic schematic = this.gui.schematic; 80 | schematic.getMetadata().setTimeModified(System.currentTimeMillis()); 81 | 82 | if (schematic.writeToFile(dir, fileName, GuiBase.isShiftDown())) { 83 | this.gui.addMessage(Message.MessageType.SUCCESS, "litematica.message.schematic_saved_as", fileName); 84 | this.gui.getListWidget().refreshEntries(); 85 | } 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/util/MiscUtils.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.util; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import net.minecraft.block.*; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.network.ClientPlayerEntity; 7 | import net.minecraft.client.options.GameOptions; 8 | import net.minecraft.client.options.KeyBinding; 9 | import net.minecraft.client.particle.ParticleManager; 10 | import net.minecraft.client.world.ClientWorld; 11 | import net.minecraft.entity.EquipmentSlot; 12 | import net.minecraft.item.HoeItem; 13 | import net.minecraft.item.Item; 14 | import net.minecraft.item.ShovelItem; 15 | import net.minecraft.util.math.BlockPos; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Random; 19 | 20 | public class MiscUtils { 21 | public static final ArrayList MOVEMENT_HOLD_KEYS = new ArrayList<>(); 22 | 23 | public static void setMovementHoldKeys(boolean enabled) { 24 | if (!enabled) { 25 | KeyBinding.updatePressedStates(); 26 | return; 27 | } 28 | 29 | MOVEMENT_HOLD_KEYS.clear(); 30 | GameOptions options = MinecraftClient.getInstance().options; 31 | KeyBinding[] movementKeys = { options.keyJump, options.keyLeft, options.keyRight, options.keyBack, options.keyForward }; 32 | for (KeyBinding movementKey : movementKeys) { 33 | if (movementKey.isPressed()) { 34 | MOVEMENT_HOLD_KEYS.add(movementKey); 35 | } 36 | } 37 | } 38 | 39 | // From 1.12 Tweakeroo by Masa 40 | public static void addCustomBlockBreakingParticles(ParticleManager manager, ClientWorld world, Random rand, BlockPos pos, BlockState state) { 41 | if (state.getMaterial() != Material.AIR) { 42 | int limit = ConfigsExtended.Generic.BLOCK_BREAKING_PARTICLE_LIMIT.getIntegerValue(); 43 | 44 | for (int i = 0; i < limit; ++i) { 45 | double x = ((double) pos.getX() + rand.nextDouble()); 46 | double y = ((double) pos.getY() + rand.nextDouble()); 47 | double z = ((double) pos.getZ() + rand.nextDouble()); 48 | double speedX = (0.5 - rand.nextDouble()); 49 | double speedY = (0.5 - rand.nextDouble()); 50 | double speedZ = (0.5 - rand.nextDouble()); 51 | 52 | manager.addParticle((new BlockDustParticleExt(world, x, y, z, speedX, speedY, speedZ, state)) 53 | .setBlockPos(pos) 54 | .move((float) ConfigsExtended.Generic.BLOCK_BREAKING_PARTICLE_SPEED.getDoubleValue()) 55 | .scale((float) ConfigsExtended.Generic.BLOCK_BREAKING_PARTICLE_SCALE.getDoubleValue())); 56 | } 57 | } 58 | } 59 | 60 | public static boolean handleUseSnowLayer(Block block, ClientPlayerEntity player) { 61 | return ConfigsExtended.Disable.DISABLE_SNOW_LAYER_STACKING.getBooleanValue() && block instanceof SnowBlock; 62 | } 63 | 64 | public static boolean handleUseDragonEgg(Block block, ClientPlayerEntity player) { 65 | return ConfigsExtended.Disable.DISABLE_DRAGON_EGG_TELEPORTING.getBooleanValue() && block instanceof DragonEggBlock && !player.isSneaking(); 66 | } 67 | 68 | public static boolean handleUseBed(Block block, ClientWorld world) { 69 | return ConfigsExtended.Disable.DISABLE_BED_EXPLOSIONS.getBooleanValue() && block instanceof BedBlock && !world.getDimension().isBedWorking(); 70 | } 71 | 72 | public static boolean handleUseTools(Block block, Item heldItem) { 73 | return (ConfigsExtended.Disable.DISABLE_FARMLAND_MAKING.getBooleanValue() && heldItem instanceof HoeItem && MiscUtils.isTillableBlock(block) || (ConfigsExtended.Disable.DISABLE_PATH_MAKING.getBooleanValue() && heldItem instanceof ShovelItem && block instanceof GrassBlock)); 74 | } 75 | 76 | public static boolean isTillableBlock(Block block) { 77 | return block instanceof GrassBlock || block instanceof GrassPathBlock || block.equals(Blocks.DIRT); 78 | } 79 | 80 | public static int getSlotNumberForEquipmentSlot(EquipmentSlot type) { 81 | switch (type) { 82 | case HEAD: 83 | return 5; 84 | case CHEST: 85 | return 6; 86 | case LEGS: 87 | return 7; 88 | case FEET: 89 | return 8; 90 | default: 91 | return -1; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/config/RendererToggleExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.config; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import fi.dy.masa.malilib.config.ConfigType; 6 | import fi.dy.masa.malilib.config.IConfigBoolean; 7 | import fi.dy.masa.malilib.config.IConfigNotifiable; 8 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 9 | import fi.dy.masa.malilib.hotkeys.IKeybind; 10 | import fi.dy.masa.malilib.hotkeys.KeybindMulti; 11 | import fi.dy.masa.malilib.hotkeys.KeybindSettings; 12 | import fi.dy.masa.malilib.interfaces.IValueChangeCallback; 13 | import fi.dy.masa.minihud.MiniHUD; 14 | import fi.dy.masa.minihud.hotkeys.KeyCallbackToggleRenderer; 15 | 16 | import javax.annotation.Nullable; 17 | 18 | public enum RendererToggleExtended implements IHotkeyTogglable, IConfigNotifiable { 19 | OVERLAY_BEACON_RANGE("overlayBeaconRange", "", "Toggles the Beacon Range overlay renderer.\nPorted from 1.12 MiniHUD", "Beacon Range overlay"); 20 | 21 | private final String name; 22 | private final String prettyName; 23 | private final String comment; 24 | private final IKeybind keybind; 25 | private final boolean defaultValueBoolean; 26 | private boolean valueBoolean; 27 | @Nullable 28 | private IValueChangeCallback callback; 29 | 30 | RendererToggleExtended(String name, String defaultHotkey, String comment, String prettyName) { 31 | this(name, defaultHotkey, KeybindSettings.DEFAULT, comment, prettyName); 32 | } 33 | 34 | RendererToggleExtended(String name, String defaultHotkey, KeybindSettings settings, String comment, String prettyName) { 35 | this.name = name; 36 | this.prettyName = prettyName; 37 | this.comment = comment; 38 | this.defaultValueBoolean = true; 39 | this.keybind = KeybindMulti.fromStorageString(defaultHotkey, settings); 40 | this.keybind.setCallback(new KeyCallbackToggleRenderer(this)); 41 | } 42 | 43 | @Override 44 | public ConfigType getType() { 45 | return ConfigType.HOTKEY; 46 | } 47 | 48 | @Override 49 | public String getName() { 50 | return this.name; 51 | } 52 | 53 | @Override 54 | public String getPrettyName() { 55 | return this.prettyName; 56 | } 57 | 58 | @Override 59 | public String getStringValue() { 60 | return String.valueOf(this.valueBoolean); 61 | } 62 | 63 | @Override 64 | public String getDefaultStringValue() { 65 | return String.valueOf(this.defaultValueBoolean); 66 | } 67 | 68 | @Override 69 | public String getComment() { 70 | return comment != null ? this.comment : ""; 71 | } 72 | 73 | @Override 74 | public boolean getBooleanValue() { 75 | return this.valueBoolean; 76 | } 77 | 78 | @Override 79 | public boolean getDefaultBooleanValue() { 80 | return this.defaultValueBoolean; 81 | } 82 | 83 | @Override 84 | public void setBooleanValue(boolean value) { 85 | boolean oldValue = this.valueBoolean; 86 | this.valueBoolean = value; 87 | 88 | if (oldValue != this.valueBoolean) { 89 | this.onValueChanged(); 90 | } 91 | } 92 | 93 | @Override 94 | public void setValueChangeCallback(IValueChangeCallback callback) { 95 | this.callback = callback; 96 | } 97 | 98 | @Override 99 | public void onValueChanged() { 100 | if (this.callback != null) { 101 | this.callback.onValueChanged(this); 102 | } 103 | } 104 | 105 | @Override 106 | public IKeybind getKeybind() { 107 | return this.keybind; 108 | } 109 | 110 | @Override 111 | public boolean isModified() { 112 | return this.valueBoolean != this.defaultValueBoolean; 113 | } 114 | 115 | @Override 116 | public boolean isModified(String newValue) { 117 | return !String.valueOf(this.defaultValueBoolean).equals(newValue); 118 | } 119 | 120 | @Override 121 | public void resetToDefault() { 122 | this.valueBoolean = this.defaultValueBoolean; 123 | } 124 | 125 | @Override 126 | public void setValueFromString(String value) { 127 | try { 128 | this.valueBoolean = Boolean.parseBoolean(value); 129 | } catch (Exception e) { 130 | MiniHUD.logger.warn("Failed to read config value for {} from the JSON config", this.getName(), e); 131 | } 132 | } 133 | 134 | @Override 135 | public void setValueFromJsonElement(JsonElement element) { 136 | try { 137 | if (element.isJsonPrimitive()) { 138 | this.valueBoolean = element.getAsBoolean(); 139 | } else { 140 | MiniHUD.logger.warn("Failed to read config value for {} from the JSON config", this.getName()); 141 | } 142 | } catch (Exception e) { 143 | MiniHUD.logger.warn("Failed to read config value for {} from the JSON config", this.getName(), e); 144 | } 145 | } 146 | 147 | @Override 148 | public JsonElement getAsJsonElement() { 149 | return new JsonPrimitive(this.valueBoolean); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/litematica_additions/util/GuiFileImportBase.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.litematica_additions.util; 2 | 3 | import fi.dy.masa.litematica.gui.GuiSchematicBrowserBase; 4 | import fi.dy.masa.litematica.gui.GuiSchematicSave; 5 | import fi.dy.masa.litematica.gui.GuiSchematicSaveBase; 6 | import fi.dy.masa.litematica.schematic.LitematicaSchematic; 7 | import fi.dy.masa.malilib.gui.GuiTextFieldGeneric; 8 | import fi.dy.masa.malilib.gui.Message; 9 | import fi.dy.masa.malilib.gui.button.ButtonGeneric; 10 | import fi.dy.masa.malilib.gui.button.IButtonActionListener; 11 | import fi.dy.masa.malilib.gui.interfaces.ISelectionListener; 12 | import fi.dy.masa.malilib.gui.widgets.WidgetFileBrowserBase; 13 | import fi.dy.masa.malilib.util.FileUtils; 14 | import fi.dy.masa.malilib.util.KeyCodes; 15 | import fi.dy.masa.malilib.util.StringUtils; 16 | import net.minecraft.client.util.math.MatrixStack; 17 | 18 | import javax.annotation.Nullable; 19 | 20 | public abstract class GuiFileImportBase extends GuiSchematicBrowserBase implements ISelectionListener { 21 | protected GuiTextFieldGeneric textField; 22 | protected String lastText = ""; 23 | protected String defaultText = ""; 24 | protected final LitematicaSchematic schematic; 25 | 26 | public GuiFileImportBase(LitematicaSchematic schematic) { 27 | super(10, 70); 28 | 29 | this.schematic = schematic; 30 | 31 | this.textField = new GuiTextFieldGeneric(10, 32, 160, 20, this.textRenderer); 32 | this.textField.setMaxLength(256); 33 | this.textField.setFocused(true); 34 | } 35 | 36 | @Override 37 | public int getBrowserHeight() { 38 | return this.height - 80; 39 | } 40 | 41 | @Override 42 | public void initGui() { 43 | super.initGui(); 44 | 45 | boolean focused = this.textField.isFocused(); 46 | String text = this.textField.getText(); 47 | int pos = this.textField.getCursorPosition(); 48 | this.textField = new GuiTextFieldGeneric(10, 32, this.width - 196, 20, this.textRenderer); 49 | this.textField.setText(text); 50 | this.textField.setCursorPosition(pos); 51 | this.textField.setFocused(focused); 52 | 53 | WidgetFileBrowserBase.DirectoryEntry entry = this.getListWidget().getLastSelectedEntry(); 54 | 55 | // Only set the text field contents if it hasn't been set already. 56 | // This prevents overwriting any user input text when switching to a newly created directory. 57 | if (this.lastText.isEmpty()) { 58 | if (entry != null && entry.getType() != WidgetFileBrowserBase.DirectoryEntryType.DIRECTORY && entry.getType() != WidgetFileBrowserBase.DirectoryEntryType.INVALID) { 59 | this.setTextFieldText(FileUtils.getNameWithoutExtension(entry.getName())); 60 | } else if (this.schematic != null) { 61 | this.setTextFieldText(this.schematic.getMetadata().getName()); 62 | } else { 63 | this.setTextFieldText(this.defaultText); 64 | } 65 | } 66 | 67 | this.createButton(this.textField.getX() + this.textField.getWidth() + 12, 32); 68 | } 69 | 70 | protected void setTextFieldText(String text) { 71 | this.lastText = text; 72 | this.textField.setText(text); 73 | this.textField.setCursorPositionEnd(); 74 | } 75 | 76 | protected String getTextFieldText() { 77 | return this.textField.getText(); 78 | } 79 | 80 | protected abstract IButtonActionListener createButtonListener(GuiSchematicSaveBase.ButtonType type); 81 | 82 | private int createButton(int x, int y) { 83 | String label = StringUtils.translate(GuiSchematicSave.ButtonType.SAVE.getLabelKey()); 84 | int width = this.getStringWidth(label) + 10; 85 | ButtonGeneric button = new ButtonGeneric(x, y, width, 20, label, "litematica.gui.label.schematic_save.hoverinfo.hold_shift_to_overwrite"); 86 | this.addButton(button, this.createButtonListener(GuiSchematicSave.ButtonType.SAVE)); 87 | return x + width + 4; 88 | } 89 | 90 | @Override 91 | public void setString(String string) { 92 | this.setNextMessageType(Message.MessageType.ERROR); 93 | super.setString(string); 94 | } 95 | 96 | @Override 97 | public void drawContents(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { 98 | super.drawContents(matrixStack, mouseX, mouseY, partialTicks); 99 | 100 | this.textField.render(matrixStack, mouseX, mouseY, partialTicks); 101 | } 102 | 103 | @Override 104 | public void onSelectionChange(@Nullable WidgetFileBrowserBase.DirectoryEntry entry) { 105 | if (entry != null && entry.getType() != WidgetFileBrowserBase.DirectoryEntryType.DIRECTORY && entry.getType() != WidgetFileBrowserBase.DirectoryEntryType.INVALID) { 106 | this.setTextFieldText(FileUtils.getNameWithoutExtension(entry.getName())); 107 | } 108 | } 109 | 110 | @Override 111 | protected ISelectionListener getSelectionListener() { 112 | return this; 113 | } 114 | 115 | @Override 116 | public boolean onMouseClicked(int mouseX, int mouseY, int mouseButton) { 117 | if (this.textField.mouseClicked(mouseX, mouseY, mouseButton)) { 118 | return true; 119 | } 120 | 121 | return super.onMouseClicked(mouseX, mouseY, mouseButton); 122 | } 123 | 124 | @Override 125 | public boolean onKeyTyped(int keyCode, int scanCode, int modifiers) { 126 | if (this.textField.keyPressed(keyCode, scanCode, modifiers)) { 127 | this.getListWidget().clearSelection(); 128 | return true; 129 | } else if (keyCode == KeyCodes.KEY_TAB) { 130 | this.textField.setFocused(!this.textField.isFocused()); 131 | return true; 132 | } 133 | 134 | return super.onKeyTyped(keyCode, scanCode, modifiers); 135 | } 136 | 137 | @Override 138 | public boolean onCharTyped(char charIn, int modifiers) { 139 | if (this.textField.charTyped(charIn, modifiers)) { 140 | this.getListWidget().clearSelection(); 141 | return true; 142 | } 143 | 144 | return super.onCharTyped(charIn, modifiers); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/mixin/MixinClientPlayerInteractionManager.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import com.red.masaadditions.tweakeroo_additions.tweaks.PlacementTweaks; 6 | import net.minecraft.client.MinecraftClient; 7 | import net.minecraft.client.network.ClientPlayNetworkHandler; 8 | import net.minecraft.client.network.ClientPlayerEntity; 9 | import net.minecraft.client.network.ClientPlayerInteractionManager; 10 | import net.minecraft.client.world.ClientWorld; 11 | import net.minecraft.entity.Entity; 12 | import net.minecraft.entity.EntityType; 13 | import net.minecraft.entity.LivingEntity; 14 | import net.minecraft.entity.mob.PiglinEntity; 15 | import net.minecraft.entity.player.PlayerEntity; 16 | import net.minecraft.item.NameTagItem; 17 | import net.minecraft.item.SwordItem; 18 | import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; 19 | import net.minecraft.util.ActionResult; 20 | import net.minecraft.util.Hand; 21 | import net.minecraft.util.hit.BlockHitResult; 22 | import net.minecraft.util.math.BlockPos; 23 | import net.minecraft.util.math.Direction; 24 | import net.minecraft.util.math.Vec3d; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.Unique; 27 | import org.spongepowered.asm.mixin.injection.At; 28 | import org.spongepowered.asm.mixin.injection.Inject; 29 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 30 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 31 | 32 | import java.util.stream.StreamSupport; 33 | 34 | @Mixin(ClientPlayerInteractionManager.class) 35 | public class MixinClientPlayerInteractionManager { 36 | @Unique 37 | float attackedBlockHardness; 38 | 39 | @Inject(method = "attackBlock", at = @At("HEAD"), cancellable = true) 40 | private void handleBreakingRestriction1(BlockPos pos, Direction side, CallbackInfoReturnable cir) { 41 | if (PlacementTweaks.onProcessLeftClickBlock(pos) || PlacementTweaks.isPositionDisallowedByPerimeterOutlineList(pos)) { 42 | cir.setReturnValue(false); 43 | } 44 | } 45 | 46 | @Inject(method = "updateBlockBreakingProgress", at = @At("HEAD"), cancellable = true) 47 | private void handleBreakingRestriction2(BlockPos pos, Direction side, CallbackInfoReturnable cir) { 48 | if (PlacementTweaks.onProcessLeftClickBlock(pos) || PlacementTweaks.isPositionDisallowedByPerimeterOutlineList(pos)) { 49 | cir.setReturnValue(true); 50 | } 51 | } 52 | 53 | // From UselessMod by nessie 54 | @Inject(method = "attackBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;breakBlock(Lnet/minecraft/util/math/BlockPos;)Z", shift = At.Shift.BEFORE, ordinal = 1)) 55 | private void preInstantMine(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { 56 | if (!ConfigsExtended.Fixes.MINING_GHOST_BLOCK_FIX.getBooleanValue()) 57 | return; 58 | final ClientWorld world = MinecraftClient.getInstance().world; 59 | attackedBlockHardness = world.getBlockState(pos).getHardness(world, pos); 60 | } 61 | 62 | // From UselessMod by nessie 63 | @Inject(method = "attackBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;breakBlock(Lnet/minecraft/util/math/BlockPos;)Z", shift = At.Shift.AFTER, ordinal = 1)) 64 | private void postInstantMine(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { 65 | if (ConfigsExtended.Fixes.MINING_GHOST_BLOCK_FIX.getBooleanValue() && attackedBlockHardness > 0F) { 66 | final ClientPlayNetworkHandler connection = MinecraftClient.getInstance().getNetworkHandler(); 67 | if (connection != null) { 68 | final BlockHitResult blockHitResult = new BlockHitResult(new Vec3d(0, 0, 0), direction, pos, false); 69 | connection.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, blockHitResult)); 70 | } 71 | } 72 | } 73 | 74 | @Inject(method = "attackEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;attack(Lnet/minecraft/entity/Entity;)V"), cancellable = true) 75 | private void onAttackEntity1(PlayerEntity player, Entity target, CallbackInfo ci) { 76 | if (FeatureToggleExtended.TWEAK_ONE_HIT_KILL.getBooleanValue() && player.abilities.creativeMode && target instanceof LivingEntity && ((LivingEntity) target).getHealth() > 0f) { 77 | ((ClientPlayerEntity) player).sendChatMessage(String.format("/kill %s", target.getUuidAsString())); 78 | } 79 | } 80 | 81 | @Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true) 82 | private void onAttackEntity2(PlayerEntity player, Entity target, CallbackInfo ci) { 83 | if (FeatureToggleExtended.TWEAK_PREVENT_ATTACK_ENTITIES.getBooleanValue() && ConfigsExtended.Lists.PREVENT_ATTACK_ENTITIES_LIST.getStrings().contains(EntityType.getId(target.getType()).toString())) { 84 | ci.cancel(); 85 | } 86 | } 87 | 88 | @Inject(method = "interactEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;syncSelectedSlot()V", shift = At.Shift.AFTER), cancellable = true) 89 | private void onInteractEntity(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable cir) { 90 | if (FeatureToggleExtended.TWEAK_NAME_TAG_PIGLINS.getBooleanValue() && player.getStackInHand(hand).getItem() instanceof NameTagItem) { 91 | if (!(entity instanceof PiglinEntity)) { 92 | cir.setReturnValue(ActionResult.PASS); 93 | return; 94 | } 95 | 96 | PiglinEntity piglinEntity = (PiglinEntity)entity; 97 | if (piglinEntity.isBaby() || piglinEntity.getCustomName() != null || StreamSupport.stream(piglinEntity.getItemsHand().spliterator(), false).noneMatch(itemStack -> itemStack.getItem() instanceof SwordItem)) { 98 | cir.setReturnValue(ActionResult.PASS); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/util/Callbacks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.util; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.HotkeysExtended; 5 | import com.red.masaadditions.tweakeroo_additions.mixin.MixinAbstractBlockAccessor; 6 | import fi.dy.masa.malilib.config.IConfigBoolean; 7 | import fi.dy.masa.malilib.config.options.ConfigBoolean; 8 | import fi.dy.masa.malilib.hotkeys.IHotkeyCallback; 9 | import fi.dy.masa.malilib.hotkeys.IKeybind; 10 | import fi.dy.masa.malilib.hotkeys.KeyAction; 11 | import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; 12 | import fi.dy.masa.malilib.interfaces.IValueChangeCallback; 13 | import fi.dy.masa.malilib.util.InfoUtils; 14 | import fi.dy.masa.malilib.util.StringUtils; 15 | import fi.dy.masa.tweakeroo.util.RayTraceUtils; 16 | import net.minecraft.block.Blocks; 17 | import net.minecraft.client.MinecraftClient; 18 | import net.minecraft.entity.Entity; 19 | import net.minecraft.util.hit.BlockHitResult; 20 | import net.minecraft.util.hit.HitResult; 21 | import net.minecraft.util.math.Direction; 22 | import net.minecraft.util.math.Vec3d; 23 | 24 | public class Callbacks { 25 | public static class KeyCallbackHotkeysGeneric implements IHotkeyCallback { 26 | private final MinecraftClient mc = MinecraftClient.getInstance(); 27 | 28 | // From 1.12 Tweakeroo by Masa 29 | @Override 30 | public boolean onKeyAction(KeyAction action, IKeybind key) { 31 | if (key == HotkeysExtended.BLINK_DRIVE.getKeybind()) { 32 | this.blinkDriveTeleport(false); 33 | return true; 34 | } else if (key == HotkeysExtended.BLINK_DRIVE_Y_LEVEL.getKeybind()) { 35 | this.blinkDriveTeleport(true); 36 | return true; 37 | } 38 | 39 | return false; 40 | } 41 | 42 | private void blinkDriveTeleport(boolean maintainY) { 43 | if (this.mc.player.abilities.creativeMode) { 44 | Entity entity = fi.dy.masa.malilib.util.EntityUtils.getCameraEntity(); 45 | HitResult trace = RayTraceUtils.getRayTraceFromEntity(this.mc.world, entity, true, this.mc.options.viewDistance * 16 + 200); 46 | 47 | if (trace.getType() != HitResult.Type.MISS) { 48 | Vec3d pos = trace.getPos(); 49 | if (trace.getType() == HitResult.Type.BLOCK) { 50 | pos = adjustPositionToSideOfEntity(pos, this.mc.player, ((BlockHitResult) trace).getSide()); 51 | } 52 | 53 | this.mc.player.sendChatMessage(String.format("/tp @p %.6f %.6f %.6f", pos.x, maintainY ? this.mc.player.getY() : pos.y, pos.z)); 54 | } 55 | } 56 | } 57 | 58 | public static Vec3d adjustPositionToSideOfEntity(Vec3d pos, Entity entity, Direction side) { 59 | double x = pos.x; 60 | double y = pos.y; 61 | double z = pos.z; 62 | 63 | if (side == Direction.DOWN) { 64 | y -= entity.getHeight(); 65 | } else if (side.getAxis().isHorizontal()) { 66 | x += side.getOffsetX() * (entity.getWidth() / 2 + 1.0E-4D); 67 | z += side.getOffsetZ() * (entity.getWidth() / 2 + 1.0E-4D); 68 | } 69 | 70 | return new Vec3d(x, y, z); 71 | } 72 | } 73 | 74 | public static class KeyCallbackToggleFastRightClick extends KeyCallbackToggleBooleanConfigWithMessage { 75 | public KeyCallbackToggleFastRightClick(IConfigBoolean config) { 76 | super(config); 77 | } 78 | 79 | public boolean onKeyAction(KeyAction action, IKeybind key) { 80 | if (ConfigsExtended.Disable.DISABLE_FARMLAND_MAKING.getBooleanValue()) { 81 | this.config.setBooleanValue(false); 82 | String message = StringUtils.translate("masaadditions.message.fast_right_click_disabled"); 83 | InfoUtils.printActionbarMessage(message); 84 | } else { 85 | super.onKeyAction(action, key); 86 | } 87 | return true; 88 | } 89 | } 90 | 91 | public static class FeatureCallbackHoney implements IValueChangeCallback 92 | { 93 | public FeatureCallbackHoney(ConfigBoolean feature) 94 | { 95 | if (feature.equals(ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_SLOWDOWN)) { 96 | ConfigsExtended.Internal.HONEY_BLOCK_VELOCITY_MULTIPLIER_ORIGINAL.setDoubleValue(Blocks.HONEY_BLOCK.getVelocityMultiplier()); 97 | 98 | if (feature.getBooleanValue()) 99 | { 100 | ((MixinAbstractBlockAccessor) Blocks.HONEY_BLOCK).setVelocityMultiplier(Blocks.STONE.getVelocityMultiplier()); 101 | } 102 | } else { 103 | ConfigsExtended.Internal.HONEY_BLOCK_JUMP_VELOCITY_MULTIPLIER_ORIGINAL.setDoubleValue(Blocks.HONEY_BLOCK.getJumpVelocityMultiplier()); 104 | 105 | if (!feature.getBooleanValue()) 106 | { 107 | ((MixinAbstractBlockAccessor) Blocks.HONEY_BLOCK).setJumpVelocityMultiplier(Blocks.STONE.getJumpVelocityMultiplier()); 108 | } 109 | } 110 | } 111 | 112 | @Override 113 | public void onValueChanged(ConfigBoolean config) 114 | { 115 | if (config.equals(ConfigsExtended.Disable.DISABLE_HONEY_BLOCK_SLOWDOWN)) { 116 | if (config.getBooleanValue()) { 117 | ((MixinAbstractBlockAccessor) Blocks.HONEY_BLOCK).setVelocityMultiplier(Blocks.STONE.getVelocityMultiplier()); 118 | } else { 119 | ((MixinAbstractBlockAccessor) Blocks.HONEY_BLOCK).setVelocityMultiplier((float) ConfigsExtended.Internal.HONEY_BLOCK_VELOCITY_MULTIPLIER_ORIGINAL.getDoubleValue()); 120 | } 121 | } else { 122 | if (config.getBooleanValue()) { 123 | ((MixinAbstractBlockAccessor) Blocks.HONEY_BLOCK).setJumpVelocityMultiplier((float) ConfigsExtended.Internal.HONEY_BLOCK_JUMP_VELOCITY_MULTIPLIER_ORIGINAL.getDoubleValue()); 124 | } else { 125 | ((MixinAbstractBlockAccessor) Blocks.HONEY_BLOCK).setJumpVelocityMultiplier(Blocks.STONE.getJumpVelocityMultiplier()); 126 | } 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/tweakeroo_mixin/MixinPlacementTweaks.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.tweakeroo_mixin; 2 | 3 | import com.red.masaadditions.tweakeroo_additions.config.ConfigsExtended; 4 | import com.red.masaadditions.tweakeroo_additions.config.FeatureToggleExtended; 5 | import com.red.masaadditions.tweakeroo_additions.util.MiscUtils; 6 | import fi.dy.masa.malilib.hotkeys.IKeybind; 7 | import fi.dy.masa.malilib.util.GuiUtils; 8 | import fi.dy.masa.tweakeroo.tweaks.PlacementTweaks; 9 | import fi.dy.masa.tweakeroo.util.InventoryUtils; 10 | import fi.dy.masa.tweakeroo.util.PlacementRestrictionMode; 11 | import net.minecraft.block.Block; 12 | import net.minecraft.block.Blocks; 13 | import net.minecraft.client.MinecraftClient; 14 | import net.minecraft.client.network.ClientPlayerEntity; 15 | import net.minecraft.client.network.ClientPlayerInteractionManager; 16 | import net.minecraft.client.world.ClientWorld; 17 | import net.minecraft.item.Item; 18 | import net.minecraft.item.ItemPlacementContext; 19 | import net.minecraft.util.ActionResult; 20 | import net.minecraft.util.Hand; 21 | import net.minecraft.util.hit.BlockHitResult; 22 | import net.minecraft.util.math.BlockPos; 23 | import net.minecraft.util.math.Direction; 24 | import net.minecraft.world.World; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.Pseudo; 27 | import org.spongepowered.asm.mixin.Shadow; 28 | import org.spongepowered.asm.mixin.injection.At; 29 | import org.spongepowered.asm.mixin.injection.Inject; 30 | import org.spongepowered.asm.mixin.injection.Redirect; 31 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 32 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 33 | 34 | @Pseudo 35 | @Mixin(value = PlacementTweaks.class, remap = false) 36 | public class MixinPlacementTweaks { 37 | @Shadow 38 | private static boolean isPositionAllowedByRestrictions(BlockPos pos, Direction side, BlockPos posFirst, Direction sideFirst, boolean restrictionEnabled, PlacementRestrictionMode mode, boolean gridEnabled, int gridSize) { 39 | return false; 40 | } 41 | 42 | @Inject(method = "canPlaceBlockIntoPosition", at = @At("HEAD"), cancellable = true) 43 | private static void canPlaceBlockIntoPosition(World world, BlockPos pos, ItemPlacementContext useContext, CallbackInfoReturnable cir) { 44 | if (ConfigsExtended.Disable.DISABLE_SNOW_LAYER_STACKING.getBooleanValue() && world.getBlockState(pos).getBlock().equals(Blocks.SNOW)) 45 | { 46 | cir.setReturnValue(false); 47 | } 48 | } 49 | 50 | @Inject(method = "onProcessRightClickBlock", at = @At("HEAD"), cancellable = true) 51 | private static void onProcessRightClickBlock(ClientPlayerInteractionManager controller, ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) { 52 | Block block = world.getBlockState(hitResult.getBlockPos()).getBlock(); 53 | Item heldItem = player.getStackInHand(hand).getItem(); 54 | 55 | if (MiscUtils.handleUseSnowLayer(block, player) || MiscUtils.handleUseDragonEgg(block, player) || MiscUtils.handleUseBed(block, world) || MiscUtils.handleUseTools(block, heldItem)) { 56 | cir.setReturnValue(ActionResult.PASS); 57 | } 58 | } 59 | 60 | @Inject(method = "onTick", at = @At("RETURN")) 61 | private static void onTick(CallbackInfo ci) { 62 | MinecraftClient mc = MinecraftClient.getInstance(); 63 | 64 | if (mc.player != null && ConfigsExtended.Generic.HAND_RESTOCK_CONTINUOUS.getBooleanValue() && GuiUtils.getCurrentScreen() == null) 65 | { 66 | InventoryUtils.preRestockHand(mc.player, Hand.MAIN_HAND, true); 67 | InventoryUtils.preRestockHand(mc.player, Hand.OFF_HAND, true); 68 | } 69 | } 70 | 71 | @Redirect(method = "tryPlaceBlock", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/hotkeys/IKeybind;isKeybindHeld()Z", ordinal = 1)) 72 | private static boolean isKeybindHeld1(IKeybind iKeybind) { 73 | return iKeybind.isKeybindHeld() || FeatureToggleExtended.TWEAK_FLEXIBLE_BLOCK_PLACEMENT_OFFSET_TOGGLE.getBooleanValue(); 74 | } 75 | 76 | @Redirect(method = "tryPlaceBlock", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/hotkeys/IKeybind;isKeybindHeld()Z", ordinal = 2)) 77 | private static boolean isKeybindHeld2(IKeybind iKeybind) { 78 | return iKeybind.isKeybindHeld() || FeatureToggleExtended.TWEAK_FLEXIBLE_BLOCK_PLACEMENT_ADJACENT_TOGGLE.getBooleanValue(); 79 | } 80 | 81 | @Redirect(method = "isPositionAllowedByPlacementRestriction", at = @At(value = "INVOKE", target = "Lfi/dy/masa/tweakeroo/tweaks/PlacementTweaks;isPositionAllowedByRestrictions(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;ZLfi/dy/masa/tweakeroo/util/PlacementRestrictionMode;ZI)Z"), require = 0) 82 | private static boolean isPositionAllowedByPlacementRestriction1(BlockPos pos, Direction side, BlockPos posFirst, Direction sideFirst, boolean restrictionEnabled, PlacementRestrictionMode mode, boolean gridEnabled, int gridSize) 83 | { 84 | return handleGridRestriction(pos, side, posFirst, sideFirst, restrictionEnabled, mode, gridEnabled, gridSize); 85 | } 86 | 87 | @Redirect(method = "isPositionAllowedByPlacementRestriction", at = @At(value = "INVOKE", target = "Lfi/dy/masa/tweakeroo/tweaks/PlacementTweaks;isPositionAllowedByRestrictions(Lnet/minecraft/class_2338;Lnet/minecraft/class_2350;Lnet/minecraft/class_2338;Lnet/minecraft/class_2350;ZLfi/dy/masa/tweakeroo/util/PlacementRestrictionMode;ZI)Z"), require = 0) 88 | private static boolean isPositionAllowedByPlacementRestriction2(BlockPos pos, Direction side, BlockPos posFirst, Direction sideFirst, boolean restrictionEnabled, PlacementRestrictionMode mode, boolean gridEnabled, int gridSize) 89 | { 90 | return handleGridRestriction(pos, side, posFirst, sideFirst, restrictionEnabled, mode, gridEnabled, gridSize); 91 | } 92 | 93 | @Redirect(method = "isPositionAllowedByBreakingRestriction", at = @At(value = "INVOKE", target = "Lfi/dy/masa/tweakeroo/tweaks/PlacementTweaks;isPositionAllowedByRestrictions(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;ZLfi/dy/masa/tweakeroo/util/PlacementRestrictionMode;ZI)Z"), require = 0) 94 | private static boolean isPositionAllowedByBreakingRestriction1(BlockPos pos, Direction side, BlockPos posFirst, Direction sideFirst, boolean restrictionEnabled, PlacementRestrictionMode mode, boolean gridEnabled, int gridSize) 95 | { 96 | return handleGridRestriction(pos, side, posFirst, sideFirst, restrictionEnabled, mode, gridEnabled, gridSize); 97 | } 98 | 99 | @Redirect(method = "isPositionAllowedByBreakingRestriction", at = @At(value = "INVOKE", target = "Lfi/dy/masa/tweakeroo/tweaks/PlacementTweaks;isPositionAllowedByRestrictions(Lnet/minecraft/class_2338;Lnet/minecraft/class_2350;Lnet/minecraft/class_2338;Lnet/minecraft/class_2350;ZLfi/dy/masa/tweakeroo/util/PlacementRestrictionMode;ZI)Z"), require = 0) 100 | private static boolean isPositionAllowedByBreakingRestriction2(BlockPos pos, Direction side, BlockPos posFirst, Direction sideFirst, boolean restrictionEnabled, PlacementRestrictionMode mode, boolean gridEnabled, int gridSize) 101 | { 102 | return handleGridRestriction(pos, side, posFirst, sideFirst, restrictionEnabled, mode, gridEnabled, gridSize); 103 | } 104 | 105 | private static boolean handleGridRestriction(BlockPos pos, Direction side, BlockPos posFirst, Direction sideFirst, boolean restrictionEnabled, PlacementRestrictionMode mode, boolean gridEnabled, int gridSize) 106 | { 107 | if (gridEnabled) 108 | { 109 | if ((ConfigsExtended.Generic.GRID_RESTRICT_X.getBooleanValue() && (Math.abs(pos.getX() - posFirst.getX()) % gridSize) != 0) || 110 | (ConfigsExtended.Generic.GRID_RESTRICT_Y.getBooleanValue() && (Math.abs(pos.getY() - posFirst.getY()) % gridSize) != 0) || 111 | (ConfigsExtended.Generic.GRID_RESTRICT_Z.getBooleanValue() && (Math.abs(pos.getZ() - posFirst.getZ()) % gridSize) != 0)) 112 | { 113 | return false; 114 | } 115 | } 116 | 117 | return isPositionAllowedByRestrictions(pos, side, posFirst, sideFirst, restrictionEnabled, mode, false, gridSize); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/config/FeatureToggleExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.config; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import fi.dy.masa.malilib.config.ConfigType; 6 | import fi.dy.masa.malilib.config.IConfigBoolean; 7 | import fi.dy.masa.malilib.config.IConfigNotifiable; 8 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 9 | import fi.dy.masa.malilib.gui.GuiBase; 10 | import fi.dy.masa.malilib.hotkeys.IKeybind; 11 | import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; 12 | import fi.dy.masa.malilib.hotkeys.KeybindMulti; 13 | import fi.dy.masa.malilib.hotkeys.KeybindSettings; 14 | import fi.dy.masa.malilib.interfaces.IValueChangeCallback; 15 | import fi.dy.masa.malilib.util.StringUtils; 16 | import fi.dy.masa.tweakeroo.Tweakeroo; 17 | 18 | public enum FeatureToggleExtended implements IHotkeyTogglable, IConfigNotifiable { 19 | TWEAK_ALWAYS_RENDER_BARRIER_PARTICLES("tweakAlwaysRenderBarrierParticles", false, "", "Barrier block particles will always be rendered regardless of\nthe player's current gamemode and held item if enabled."), 20 | TWEAK_BLOCK_BREAKING_PARTICLES("tweakBlockBreakingParticleTweaks", false, "", "Allows tweaking the block breaking particles, such as reducing the number\nof particles produced per block broken.\nSet the limit in Generic -> 'Block Breaking Particle Limit'.\nPorted from 1.12 Tweakeroo."), 21 | TWEAK_FLEXIBLE_BLOCK_PLACEMENT_ADJACENT_TOGGLE("tweakFlexibleBlockPlacementAdjacentToggle", false, "", "Emulates holding the flexible block placement adjacent keybind."), 22 | TWEAK_FLEXIBLE_BLOCK_PLACEMENT_OFFSET_TOGGLE("tweakFlexibleBlockPlacementOffsetToggle", false, "", "Emulates holding the flexible block placement offset keybind."), 23 | TWEAK_FORCE_SWAP_GEAR("tweakForceSwapGear", false, "", "Allows the player to equip an armor piece in their main hand by\nright clicking while sneaking even if the player already has\narmor in the respective armor slot. This also works with elytras."), 24 | TWEAK_INSANE_BLOCK_BREAKING_PARTICLES("tweakInsaneBlockBreakingParticles", false, "", "Changes block breaking particles to have no gravity and increased velocity.\nThis feature is originally from UsefulMod by nessie."), 25 | TWEAK_ITEM_NAME_COPY("tweakItemNameCopy", false, "", "Sets item name in anvil to string stored in clipboard."), 26 | TWEAK_LLAMA_STEERING("tweakLlamaSteering", false, "", "Allows the player to control Llamas while riding them.\nPorted from 1.12 Tweakeroo."), 27 | TWEAK_MOVEMENT_HOLD("tweakMovementHold", false, "", KeybindSettings.PRESS_ALLOWEXTRA, "Emulates holding down the movement keys that were\ncurrently pressed when the tweak is enabled."), 28 | TWEAK_NAME_TAG_PIGLINS("tweakNameTagPiglins", false, "", "Only allows player to use name tags on piglins holding swords"), 29 | TWEAK_ONE_HIT_KILL("tweakOneHitKill", false, "", "Enables one hit killing attacked living entities if player is in creative.\nRequires operator permission to use /kill."), 30 | TWEAK_OVERRIDE_SKY_TIME("tweakOverrideSkyTime", false, "", "Overrides the day time used for rendering the sky.\nInspired by tweakDayCycleOverride in Tweakfork by Andrews54757.\nAllows you to see the actual time through mods such as MiniHUD\nor using the Clock item unlike tweakDayCycleOverride."), 31 | TWEAK_OVERRIDE_WINDOW_TITLE("tweakOverrideWindowTitle", false, "", "Replaces the current window title with the string\nspecified in the Window Title Override generic config."), 32 | TWEAK_PERIMETER_WALL_DIG_HELPER("tweakPerimeterWallDigHelper", false, "", "Prevents player from mining underneath the block types\nspecified in the Perimeter Outline Blocks list."), 33 | TWEAK_PREVENT_ATTACK_ENTITIES("tweakPreventAttackEntities", false, "", "Prevents player from attacking entities with the entity types\nspecified in the Prevent Attack Entities list."), 34 | TWEAK_RAINBOW_LEAVES("tweakRainbowLeaves", false, "", "Makes leaves more colorful.\nThis feature is originally from UsefulMod by nessie."), 35 | TWEAK_RESPAWN_ON_DEATH("tweakRespawnOnDeath", false, "", "Enables automatic respawning on death.\nThis feature is originally from UsefulMod by nessie."); 36 | 37 | private final String name; 38 | private final String comment; 39 | private final String prettyName; 40 | private final IKeybind keybind; 41 | private final boolean defaultValueBoolean; 42 | private final boolean singlePlayer; 43 | private boolean valueBoolean; 44 | private IValueChangeCallback callback; 45 | 46 | FeatureToggleExtended(String name, boolean defaultValue, String defaultHotkey, String comment) { 47 | this(name, defaultValue, false, defaultHotkey, KeybindSettings.DEFAULT, comment); 48 | } 49 | 50 | FeatureToggleExtended(String name, boolean defaultValue, boolean singlePlayer, String defaultHotkey, String comment) { 51 | this(name, defaultValue, singlePlayer, defaultHotkey, KeybindSettings.DEFAULT, comment); 52 | } 53 | 54 | FeatureToggleExtended(String name, boolean defaultValue, String defaultHotkey, KeybindSettings settings, String comment) { 55 | this(name, defaultValue, false, defaultHotkey, settings, comment); 56 | } 57 | 58 | FeatureToggleExtended(String name, boolean defaultValue, boolean singlePlayer, String defaultHotkey, KeybindSettings settings, String comment) { 59 | this(name, defaultValue, singlePlayer, defaultHotkey, settings, comment, StringUtils.splitCamelCase(name.substring(5))); 60 | } 61 | 62 | FeatureToggleExtended(String name, boolean defaultValue, String defaultHotkey, String comment, String prettyName) { 63 | this(name, defaultValue, false, defaultHotkey, comment, prettyName); 64 | } 65 | 66 | FeatureToggleExtended(String name, boolean defaultValue, boolean singlePlayer, String defaultHotkey, String comment, String prettyName) { 67 | this(name, defaultValue, singlePlayer, defaultHotkey, KeybindSettings.DEFAULT, comment, prettyName); 68 | } 69 | 70 | FeatureToggleExtended(String name, boolean defaultValue, boolean singlePlayer, String defaultHotkey, KeybindSettings settings, String comment, String prettyName) { 71 | this.name = name; 72 | this.valueBoolean = defaultValue; 73 | this.defaultValueBoolean = defaultValue; 74 | this.singlePlayer = singlePlayer; 75 | this.comment = comment; 76 | this.prettyName = prettyName; 77 | this.keybind = KeybindMulti.fromStorageString(defaultHotkey, settings); 78 | this.keybind.setCallback(new KeyCallbackToggleBooleanConfigWithMessage(this)); 79 | } 80 | 81 | @Override 82 | public ConfigType getType() { 83 | return ConfigType.HOTKEY; 84 | } 85 | 86 | @Override 87 | public String getName() { 88 | return this.name; 89 | } 90 | 91 | @Override 92 | public String getConfigGuiDisplayName() { 93 | if (this.singlePlayer) { 94 | return GuiBase.TXT_GOLD + this.getName() + GuiBase.TXT_RST; 95 | } 96 | 97 | return this.getName(); 98 | } 99 | 100 | @Override 101 | public String getPrettyName() { 102 | return this.prettyName; 103 | } 104 | 105 | @Override 106 | public String getStringValue() { 107 | return String.valueOf(this.valueBoolean); 108 | } 109 | 110 | @Override 111 | public String getDefaultStringValue() { 112 | return String.valueOf(this.defaultValueBoolean); 113 | } 114 | 115 | @Override 116 | public void setValueFromString(String value) { 117 | } 118 | 119 | @Override 120 | public void onValueChanged() { 121 | if (this.callback != null) { 122 | this.callback.onValueChanged(this); 123 | } 124 | } 125 | 126 | @Override 127 | public void setValueChangeCallback(IValueChangeCallback callback) { 128 | this.callback = callback; 129 | } 130 | 131 | @Override 132 | public String getComment() { 133 | if (this.comment == null) { 134 | return ""; 135 | } 136 | 137 | if (this.singlePlayer) { 138 | return this.comment + "\n" + StringUtils.translate("tweakeroo.label.config_comment.single_player_only"); 139 | } else { 140 | return this.comment; 141 | } 142 | } 143 | 144 | @Override 145 | public IKeybind getKeybind() { 146 | return this.keybind; 147 | } 148 | 149 | @Override 150 | public boolean getBooleanValue() { 151 | return this.valueBoolean; 152 | } 153 | 154 | @Override 155 | public boolean getDefaultBooleanValue() { 156 | return this.defaultValueBoolean; 157 | } 158 | 159 | @Override 160 | public void setBooleanValue(boolean value) { 161 | boolean oldValue = this.valueBoolean; 162 | this.valueBoolean = value; 163 | 164 | if (oldValue != this.valueBoolean) { 165 | this.onValueChanged(); 166 | } 167 | } 168 | 169 | @Override 170 | public boolean isModified() { 171 | return this.valueBoolean != this.defaultValueBoolean; 172 | } 173 | 174 | @Override 175 | public boolean isModified(String newValue) { 176 | return Boolean.parseBoolean(newValue) != this.defaultValueBoolean; 177 | } 178 | 179 | @Override 180 | public void resetToDefault() { 181 | this.valueBoolean = this.defaultValueBoolean; 182 | } 183 | 184 | @Override 185 | public JsonElement getAsJsonElement() { 186 | return new JsonPrimitive(this.valueBoolean); 187 | } 188 | 189 | @Override 190 | public void setValueFromJsonElement(JsonElement element) { 191 | try { 192 | if (element.isJsonPrimitive()) { 193 | this.valueBoolean = element.getAsBoolean(); 194 | } else { 195 | Tweakeroo.logger.warn("Failed to set config value for '{}' from the JSON element '{}'", this.getName(), element); 196 | } 197 | } catch (Exception e) { 198 | Tweakeroo.logger.warn("Failed to set config value for '{}' from the JSON element '{}'", this.getName(), element, e); 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/minihud_additions/renderer/OverlayRendererBeaconRange.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.minihud_additions.renderer; 2 | 3 | import com.mojang.blaze3d.platform.GlStateManager; 4 | import com.red.masaadditions.minihud_additions.config.ConfigsExtended; 5 | import com.red.masaadditions.minihud_additions.config.RendererToggleExtended; 6 | import fi.dy.masa.malilib.util.Color4f; 7 | import fi.dy.masa.minihud.renderer.OverlayRendererBase; 8 | import fi.dy.masa.minihud.renderer.RenderObjectBase; 9 | import net.minecraft.block.BeaconBlock; 10 | import net.minecraft.block.BlockState; 11 | import net.minecraft.block.entity.BeaconBlockEntity; 12 | import net.minecraft.block.entity.BlockEntity; 13 | import net.minecraft.client.MinecraftClient; 14 | import net.minecraft.client.render.BufferBuilder; 15 | import net.minecraft.client.render.Tessellator; 16 | import net.minecraft.client.render.VertexFormats; 17 | import net.minecraft.entity.Entity; 18 | import net.minecraft.entity.player.PlayerEntity; 19 | import net.minecraft.item.BlockItem; 20 | import net.minecraft.item.Item; 21 | import net.minecraft.util.math.BlockPos; 22 | import net.minecraft.util.math.ChunkPos; 23 | import net.minecraft.util.math.Vec3d; 24 | import net.minecraft.world.World; 25 | import net.minecraft.world.chunk.Chunk; 26 | import org.lwjgl.opengl.GL11; 27 | 28 | import java.util.HashSet; 29 | import java.util.Set; 30 | 31 | import static net.minecraft.world.Heightmap.Type.WORLD_SURFACE; 32 | 33 | // From 1.12 MiniHUD by Masa 34 | public class OverlayRendererBeaconRange extends OverlayRendererBase { 35 | private static final Set BEACON_POSITIONS = new HashSet<>(); 36 | private static final Set BEACON_CHUNKS = new HashSet<>(); 37 | 38 | private static boolean needsUpdate; 39 | 40 | public static void clear() { 41 | synchronized (BEACON_POSITIONS) { 42 | BEACON_CHUNKS.clear(); 43 | BEACON_POSITIONS.clear(); 44 | } 45 | } 46 | 47 | public static void setNeedsUpdate() { 48 | if (!RendererToggleExtended.OVERLAY_BEACON_RANGE.getBooleanValue()) { 49 | clear(); 50 | } 51 | 52 | needsUpdate = true; 53 | } 54 | 55 | public static void checkNeedsUpdate(BlockPos pos, BlockState state) { 56 | synchronized (BEACON_POSITIONS) { 57 | if (RendererToggleExtended.OVERLAY_BEACON_RANGE.getBooleanValue() && 58 | (state.getBlock() instanceof BeaconBlock || BEACON_POSITIONS.contains(pos))) { 59 | setNeedsUpdate(); 60 | } 61 | } 62 | } 63 | 64 | public static void checkNeedsUpdate(ChunkPos chunkPos) { 65 | synchronized (BEACON_POSITIONS) { 66 | if (RendererToggleExtended.OVERLAY_BEACON_RANGE.getBooleanValue() && 67 | BEACON_CHUNKS.contains(chunkPos)) { 68 | setNeedsUpdate(); 69 | } 70 | } 71 | } 72 | 73 | @Override 74 | public boolean shouldRender(MinecraftClient mc) { 75 | return RendererToggleExtended.OVERLAY_BEACON_RANGE.getBooleanValue(); 76 | } 77 | 78 | @Override 79 | public boolean needsUpdate(Entity entity, MinecraftClient mc) { 80 | return needsUpdate || this.lastUpdatePos == null; 81 | } 82 | 83 | @Override 84 | public void update(Vec3d cameraPos, Entity entity, MinecraftClient mc) { 85 | clear(); 86 | 87 | RenderObjectBase renderQuads = this.renderObjects.get(0); 88 | RenderObjectBase renderLines = this.renderObjects.get(1); 89 | BUFFER_1.begin(renderQuads.getGlMode(), VertexFormats.POSITION_COLOR); 90 | BUFFER_2.begin(renderLines.getGlMode(), VertexFormats.POSITION_COLOR); 91 | 92 | synchronized (BEACON_POSITIONS) { 93 | this.renderBeaconRanges(entity.getEntityWorld(), cameraPos, BUFFER_1, BUFFER_2); 94 | } 95 | 96 | BUFFER_1.end(); 97 | BUFFER_2.end(); 98 | renderQuads.uploadData(BUFFER_1); 99 | renderLines.uploadData(BUFFER_2); 100 | 101 | needsUpdate = false; 102 | } 103 | 104 | @Override 105 | public void allocateGlResources() { 106 | this.allocateBuffer(GL11.GL_QUADS); 107 | this.allocateBuffer(GL11.GL_LINES); 108 | } 109 | 110 | protected static Color4f getColorForLevel(int level) { 111 | switch (level) { 112 | case 1: 113 | return ConfigsExtended.Colors.BEACON_RANGE_LVL1_OVERLAY_COLOR.getColor(); 114 | case 2: 115 | return ConfigsExtended.Colors.BEACON_RANGE_LVL2_OVERLAY_COLOR.getColor(); 116 | case 3: 117 | return ConfigsExtended.Colors.BEACON_RANGE_LVL3_OVERLAY_COLOR.getColor(); 118 | default: 119 | return ConfigsExtended.Colors.BEACON_RANGE_LVL4_OVERLAY_COLOR.getColor(); 120 | } 121 | } 122 | 123 | protected void renderBeaconRanges(World world, Vec3d cameraPos, BufferBuilder bufferQuads, BufferBuilder bufferLines) { 124 | for (BlockEntity be : world.blockEntities) { 125 | if (be instanceof BeaconBlockEntity) { 126 | BlockPos pos = be.getPos(); 127 | int level = ((BeaconBlockEntity) be).getLevel(); 128 | 129 | if (level >= 1 && level <= 4) { 130 | this.renderBeaconBox(world, pos, cameraPos, level, getColorForLevel(level), bufferQuads, bufferLines); 131 | } 132 | } 133 | } 134 | } 135 | 136 | protected void renderBeaconBox(World world, BlockPos pos, Vec3d cameraPos, int level, Color4f color, BufferBuilder bufferQuads, BufferBuilder bufferLines) { 137 | double x = pos.getX(); 138 | double y = pos.getY(); 139 | double z = pos.getZ(); 140 | 141 | int range = level * 10 + 10; 142 | double minX = x - range - cameraPos.x; 143 | double minY = y - range - cameraPos.y; 144 | double minZ = z - range - cameraPos.z; 145 | double maxX = x + range + 1 - cameraPos.x; 146 | double maxY = this.getMaxHeight(world, pos, range) - cameraPos.y; 147 | double maxZ = z + range + 1 - cameraPos.z; 148 | 149 | fi.dy.masa.malilib.render.RenderUtils.drawBoxAllSidesBatchedQuads(minX, minY, minZ, maxX, maxY, maxZ, color, bufferQuads); 150 | fi.dy.masa.malilib.render.RenderUtils.drawBoxAllEdgesBatchedLines(minX, minY, minZ, maxX, maxY, maxZ, Color4f.fromColor(color, 1f), bufferLines); 151 | 152 | BEACON_POSITIONS.add(pos); 153 | BEACON_CHUNKS.add(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4)); 154 | } 155 | 156 | protected int getMaxHeight(World world, BlockPos pos, int range) { 157 | final int minX = pos.getX() - range; 158 | final int minZ = pos.getZ() - range; 159 | final int maxX = pos.getX() + range; 160 | final int maxZ = pos.getZ() + range; 161 | 162 | final int minCX = minX >> 4; 163 | final int minCZ = minZ >> 4; 164 | final int maxCX = maxX >> 4; 165 | final int maxCZ = maxZ >> 4; 166 | int maxY = 0; 167 | 168 | for (int cz = minCZ; cz <= maxCZ; ++cz) { 169 | for (int cx = minCX; cx <= maxCX; ++cx) { 170 | final int xMin = Math.max(minX, cx << 4); 171 | final int zMin = Math.max(minZ, cz << 4); 172 | final int xMax = Math.min(maxX, (cx << 4) + 15); 173 | final int zMax = Math.min(maxZ, (cz << 4) + 15); 174 | Chunk chunk = world.getChunk(cx, cz); 175 | 176 | for (int z = zMin; z <= zMax; ++z) { 177 | for (int x = xMin; x <= xMax; ++x) { 178 | int height = chunk.sampleHeightmap(WORLD_SURFACE, x, z); 179 | 180 | if (height > maxY) { 181 | maxY = height; 182 | } 183 | } 184 | } 185 | } 186 | } 187 | 188 | return maxY + 4; 189 | } 190 | 191 | public static void renderBeaconBoxForPlayerIfHoldingItem(PlayerEntity player, double dx, double dy, double dz, float partialTicks) { 192 | Item item = player.getMainHandStack().getItem(); 193 | 194 | if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BeaconBlock) { 195 | renderBeaconBoxForPlayer(player, dx, dy, dz, partialTicks); 196 | return; 197 | } 198 | 199 | item = player.getOffHandStack().getItem(); 200 | 201 | if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BeaconBlock) { 202 | renderBeaconBoxForPlayer(player, dx, dy, dz, partialTicks); 203 | } 204 | } 205 | 206 | private static void renderBeaconBoxForPlayer(PlayerEntity player, double dx, double dy, double dz, float partialTicks) { 207 | double x = Math.floor(player.getX()) - dx; 208 | double y = Math.floor(player.getY()) - dy; 209 | double z = Math.floor(player.getZ()) - dz; 210 | // Use the slot number as the level if sneaking 211 | int level = player.isSneaking() ? Math.min(4, player.inventory.selectedSlot + 1) : 4; 212 | double range = level * 10 + 10; 213 | double minX = x - range; 214 | double minY = y - range; 215 | double minZ = z - range; 216 | double maxX = x + range + 1; 217 | double maxY = y + 4; 218 | double maxZ = z + range + 1; 219 | Color4f color = getColorForLevel(level); 220 | 221 | GlStateManager.disableTexture(); 222 | GlStateManager.enableAlphaTest(); 223 | GlStateManager.alphaFunc(GL11.GL_GREATER, 0.01F); 224 | GlStateManager.disableCull(); 225 | GlStateManager.disableLighting(); 226 | GlStateManager.enableDepthTest(); 227 | GlStateManager.depthMask(false); 228 | GlStateManager.polygonOffset(-3f, -3f); 229 | GlStateManager.enablePolygonOffset(); 230 | GlStateManager.lineWidth(1f); 231 | fi.dy.masa.malilib.render.RenderUtils.setupBlend(); 232 | fi.dy.masa.malilib.render.RenderUtils.color(1f, 1f, 1f, 1f); 233 | 234 | Tessellator tessellator = Tessellator.getInstance(); 235 | BufferBuilder buffer = tessellator.getBuffer(); 236 | buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR); 237 | 238 | fi.dy.masa.malilib.render.RenderUtils.drawBoxAllSidesBatchedQuads(minX, minY, minZ, maxX, maxY, maxZ, Color4f.fromColor(color, 0.3f), buffer); 239 | 240 | tessellator.draw(); 241 | buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); 242 | 243 | fi.dy.masa.malilib.render.RenderUtils.drawBoxAllEdgesBatchedLines(minX, minY, minZ, maxX, maxY, maxZ, Color4f.fromColor(color, 1f), buffer); 244 | 245 | tessellator.draw(); 246 | 247 | GlStateManager.polygonOffset(0f, 0f); 248 | GlStateManager.disablePolygonOffset(); 249 | GlStateManager.enableCull(); 250 | GlStateManager.enableTexture(); 251 | GlStateManager.disableBlend(); 252 | } 253 | } -------------------------------------------------------------------------------- /src/main/java/com/red/masaadditions/tweakeroo_additions/config/ConfigsExtended.java: -------------------------------------------------------------------------------- 1 | package com.red.masaadditions.tweakeroo_additions.config; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import fi.dy.masa.malilib.config.IConfigBase; 5 | import fi.dy.masa.malilib.config.IHotkeyTogglable; 6 | import fi.dy.masa.malilib.config.options.*; 7 | 8 | public class ConfigsExtended { 9 | public static class Generic { 10 | public static final ConfigInteger BLOCK_BREAKING_PARTICLE_LIMIT = new ConfigInteger("blockBreakingParticleLimit", 8, 1, 1024, "This controls the maximum number of block breaking\nparticles produced per block broken if the\n'Block Breaking Particle Tweaks' tweak is enabled.\nThe default in vanilla is 64 particles per block.\nPorted from 1.12 Tweakeroo."); 11 | public static final ConfigDouble BLOCK_BREAKING_PARTICLE_SCALE = new ConfigDouble("blockBreakingParticleScale", 1, 0, 20, "This is just an extra option for some fun looking\nblock breaking particles. Works if you have the\n'Block Breaking Particle Tweaks' tweak enabled.\nPorted from 1.12 Tweakeroo."); 12 | public static final ConfigDouble BLOCK_BREAKING_PARTICLE_SPEED = new ConfigDouble("blockBreakingParticleSpeedMultiplier", 1, 0, 20, "This is just an extra option for some fun looking\nblock breaking particles. Works if you have the\n'Block Breaking Particle Tweaks' tweak enabled.\nPorted from 1.12 Tweakeroo."); 13 | public static final ConfigBoolean CLICK_RECIPE_CRAFT = new ConfigBoolean("clickRecipeCraft", false, "Craft a recipe by clicking on it in the recipe book\nwhile holding CTRL and SHIFT modifier keys.\nHold ALT modifier key to throw crafted items.\nThis feature is originally from UsefulMod by nessie."); 14 | public static final ConfigDouble CLOUD_HEIGHT = new ConfigDouble("cloudHeight", 128, 0, 256, "This controls the height of clouds in the Overworld dimension."); 15 | public static final ConfigBoolean DERPY_CHICKEN = new ConfigBoolean("derpyChicken", false, "Makes chickens always face upwards.\nThis feature is originally from CutelessMod by nessie."); 16 | public static final ConfigBoolean HAND_RESTOCK_CONTINUOUS = new ConfigBoolean("handRestockContinuous", false, "If enabled, then hand restocking is attempted every tick,\nwhereas normally it only happens before and after\nleft/right clicks or in the fast block placement mode.\nPorted from 1.12 Tweakeroo.\n§6It is recommended to have this disabled, §6unless you\nknow you will need it for some specific use case."); 17 | public static final ConfigBoolean GRID_RESTRICT_X = new ConfigBoolean("gridRestrictX", true, "If enabled, then grid restriction will work along the X axis."); 18 | public static final ConfigBoolean GRID_RESTRICT_Y = new ConfigBoolean("gridRestrictY", true, "If enabled, then grid restriction will work along the Y axis."); 19 | public static final ConfigBoolean GRID_RESTRICT_Z = new ConfigBoolean("gridRestrictZ", true, "If enabled, then grid restriction will work along the Z axis."); 20 | public static final ConfigInteger SCOREBOARD_SIDEBAR_MAX_LENGTH = new ConfigInteger("scoreboardSidebarMaxLength", 15, 1, 30, "This controls the maximum length of the scoreboard sidebar."); 21 | public static final ConfigInteger SKY_TIME_OVERRIDE = new ConfigInteger("skyTimeOverride", 0, 0, 24000, "The day time to use when overriding the time used for rendering the sky if the Override Sky Time tweak is enabled."); 22 | public static final ConfigString WINDOW_TITLE_OVERRIDE = new ConfigString("windowTitleOverride", "", "The title used to override the default instance window title if the Override Window Title tweak is enabled."); 23 | 24 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 25 | BLOCK_BREAKING_PARTICLE_LIMIT, 26 | BLOCK_BREAKING_PARTICLE_SCALE, 27 | BLOCK_BREAKING_PARTICLE_SPEED, 28 | CLICK_RECIPE_CRAFT, 29 | CLOUD_HEIGHT, 30 | DERPY_CHICKEN, 31 | HAND_RESTOCK_CONTINUOUS, 32 | GRID_RESTRICT_X, 33 | GRID_RESTRICT_Y, 34 | GRID_RESTRICT_Z, 35 | SCOREBOARD_SIDEBAR_MAX_LENGTH, 36 | SKY_TIME_OVERRIDE, 37 | WINDOW_TITLE_OVERRIDE 38 | ); 39 | } 40 | 41 | public static class Fixes { 42 | public static final ConfigBoolean MINING_GHOST_BLOCK_FIX = new ConfigBoolean("miningGhostBlockFix", false, "Reduces ghost blocks while mining by sending\nuse item packets on the mined block.\nThis feature is originally from UsefulMod by nessie."); 43 | 44 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 45 | MINING_GHOST_BLOCK_FIX 46 | ); 47 | } 48 | 49 | public static class Lists { 50 | public static final ConfigStringList PERIMETER_OUTLINE_BLOCKS_LIST = new ConfigStringList("perimeterOutlineBlocksList", ImmutableList.of(), "The block types checked by the Perimeter Wall Dig Helper tweak."); 51 | public static final ConfigStringList PREVENT_ATTACK_ENTITIES_LIST = new ConfigStringList("preventAttackEntitiesList", ImmutableList.of(), "The entity types checked by the Prevent Attack Entities tweak."); 52 | public static final ConfigStringList SWAP_ALMOST_BROKEN_TOOLS_WHITELIST = new ConfigStringList("swapAlmostBrokenToolsWhitelist", ImmutableList.of(), "A whitelist of tools checked by the Swap Almost Broken Tools tweak."); 53 | public static final ConfigStringList SWAP_ALMOST_BROKEN_TOOLS_BLACKLIST = new ConfigStringList("swapAlmostBrokenToolsBlacklist", ImmutableList.of(), "A blacklist of tools checked by the Swap Almost Broken Tools tweak."); 54 | 55 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 56 | PERIMETER_OUTLINE_BLOCKS_LIST, 57 | PREVENT_ATTACK_ENTITIES_LIST, 58 | SWAP_ALMOST_BROKEN_TOOLS_WHITELIST, 59 | SWAP_ALMOST_BROKEN_TOOLS_BLACKLIST 60 | ); 61 | } 62 | 63 | public static class Disable { 64 | public static final ConfigBooleanHotkeyed DISABLE_BEACON_BEAM_RENDERING = new ConfigBooleanHotkeyed("disableBeaconBeamRendering", false, "", "Disables rendering of beacon beams."); 65 | public static final ConfigBooleanHotkeyed DISABLE_BED_EXPLOSIONS = new ConfigBooleanHotkeyed("disableBedExplosions", false, "", "Prevents player from using beds while in the Nether or End\nwhich would cause the bed to explode."); 66 | public static final ConfigBooleanHotkeyed DISABLE_BLOCK_ATTACKED_PARTICLES = new ConfigBooleanHotkeyed("disableBlockAttackedParticles", false, "", "Removes block particles that are rendered on sides of blocks when attacked."); 67 | public static final ConfigBooleanHotkeyed DISABLE_BOSS_BAR_RENDERING = new ConfigBooleanHotkeyed("disableBossBarRendering", false, "", "Disables rendering of boss bars."); 68 | public static final ConfigBooleanHotkeyed DISABLE_DRAGON_EGG_TELEPORTING = new ConfigBooleanHotkeyed("disableDragonEggTeleporting", false, "", "Prevents player from attacking (outside of creative mode)\nor using dragon eggs while not shifting."); 69 | public static final ConfigBooleanHotkeyed DISABLE_FARMLAND_MAKING = new ConfigBooleanHotkeyed("disableFarmlandMaking", false, "", "Disables making farmland with a hoe.\nFast right click is disabled while this is enabled."); 70 | public static final ConfigBooleanHotkeyed DISABLE_FOOTSTEP_PARTICLES = new ConfigBooleanHotkeyed("disableFootstepParticles", false, "", "Removes players' footstep particles."); 71 | public static final ConfigBooleanHotkeyed DISABLE_HONEY_BLOCK_SLOWDOWN = new ConfigBooleanHotkeyed("disableHoneyBlockSlowdown", false, "", "Removes the slowdown from walking on honey blocks."); 72 | public static final ConfigBooleanHotkeyed DISABLE_HONEY_BLOCK_JUMPING = new ConfigBooleanHotkeyed("disableHoneyBlockJumping", true, "", "Prevents player from jumping while on honey blocks."); 73 | public static final ConfigBooleanHotkeyed DISABLE_ITEM_FRAME_FRAME_RENDERING = new ConfigBooleanHotkeyed("disableItemFrameFrameRendering", false, "", "Disables rendering of item frame frames.\nThis feature is originally from UsefulMod by nessie."); 74 | public static final ConfigBooleanHotkeyed DISABLE_OTHER_PLAYER_RENDERING = new ConfigBooleanHotkeyed("disableOtherPlayerRendering", false, "", "Disables rendering of other players."); 75 | public static final ConfigBooleanHotkeyed DISABLE_PATH_MAKING = new ConfigBooleanHotkeyed("disablePathMaking", false, "", "Disables making path blocks with a shovel."); 76 | public static final ConfigBooleanHotkeyed DISABLE_PLANT_BLOCK_MODEL_OFFSET = new ConfigBooleanHotkeyed("disablePlantBlockModelOffset", false, "", "Disables the random XZ offsetting of plant block models.\nThis feature is originally from UsefulMod by nessie."); 77 | public static final ConfigBooleanHotkeyed DISABLE_REALMS_BUTTON = new ConfigBooleanHotkeyed("disableRealmsButton", false, "", "Disables the 'Minecraft Realms' button on the title screen.\nThis feature is originally from UsefulMod by nessie."); 78 | public static final ConfigBooleanHotkeyed DISABLE_SCOREBOARD_SIDEBAR_RENDERING = new ConfigBooleanHotkeyed("disableScoreboardSidebarRendering", false, "", "Disables rendering of scoreboard sidebar."); 79 | public static final ConfigBooleanHotkeyed DISABLE_SLEEPING_NOTIFICATION = new ConfigBooleanHotkeyed("disableSleepingNotification", false, "", "Prevents the sleeping status from being displayed in the action bar."); 80 | public static final ConfigBooleanHotkeyed DISABLE_SLIME_BLOCK_BOUNCING = new ConfigBooleanHotkeyed("disableSlimeBlockBouncing", false, "", "Prevents player from bouncing on slime blocks."); 81 | public static final ConfigBooleanHotkeyed DISABLE_SNOW_LAYER_STACKING = new ConfigBooleanHotkeyed("disableSnowLayerStacking", false, "", "Prevents player from placing multiple snow layers in a block."); 82 | public static final ConfigBooleanHotkeyed DISABLE_SPRINTING_UNDERWATER = new ConfigBooleanHotkeyed("disableSprintingUnderwater", true, "", "Prevents player from sprinting underwater with the Disable Swimming tweak.\nAlso, prevents player from sprinting in one block tall water with the\nPermanent Sprint tweak, which is not possible in Vanilla, if enabled."); 83 | public static final ConfigBooleanHotkeyed DISABLE_STUCK_ARROWS_RENDERING = new ConfigBooleanHotkeyed("disableStuckArrowsRendering", false, "", "Disables rendering of stuck arrows."); 84 | public static final ConfigBooleanHotkeyed DISABLE_SWIMMING = new ConfigBooleanHotkeyed("disableSwimming", false, "", "Disables swimming while sprinting underwater."); 85 | 86 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 87 | DISABLE_BEACON_BEAM_RENDERING, 88 | DISABLE_BED_EXPLOSIONS, 89 | DISABLE_BLOCK_ATTACKED_PARTICLES, 90 | DISABLE_BOSS_BAR_RENDERING, 91 | DISABLE_DRAGON_EGG_TELEPORTING, 92 | DISABLE_FARMLAND_MAKING, 93 | DISABLE_FOOTSTEP_PARTICLES, 94 | DISABLE_HONEY_BLOCK_SLOWDOWN, 95 | DISABLE_HONEY_BLOCK_JUMPING, 96 | DISABLE_ITEM_FRAME_FRAME_RENDERING, 97 | DISABLE_OTHER_PLAYER_RENDERING, 98 | DISABLE_PATH_MAKING, 99 | DISABLE_PLANT_BLOCK_MODEL_OFFSET, 100 | DISABLE_REALMS_BUTTON, 101 | DISABLE_SCOREBOARD_SIDEBAR_RENDERING, 102 | DISABLE_SLEEPING_NOTIFICATION, 103 | DISABLE_SLIME_BLOCK_BOUNCING, 104 | DISABLE_SNOW_LAYER_STACKING, 105 | DISABLE_SPRINTING_UNDERWATER, 106 | DISABLE_STUCK_ARROWS_RENDERING, 107 | DISABLE_SWIMMING 108 | ); 109 | } 110 | 111 | public static class Internal { 112 | public static final ConfigDouble HONEY_BLOCK_VELOCITY_MULTIPLIER_ORIGINAL = new ConfigDouble("honeyBlockVelocityMultiplierOriginal", 0.4, 0, 1, "The original velocity value of Honey Blocks"); 113 | public static final ConfigDouble HONEY_BLOCK_JUMP_VELOCITY_MULTIPLIER_ORIGINAL = new ConfigDouble("honeyBlockJumpVelocityMultiplierOriginal", 0.5, 0, 1, "The original jump velocity value of Honey Blocks"); 114 | 115 | public static final ImmutableList ADDITIONAL_OPTIONS = ImmutableList.of( 116 | HONEY_BLOCK_VELOCITY_MULTIPLIER_ORIGINAL, 117 | HONEY_BLOCK_JUMP_VELOCITY_MULTIPLIER_ORIGINAL 118 | ); 119 | } 120 | } 121 | --------------------------------------------------------------------------------