From 03ccd4bb7b45cdfb7878bb0cffff17e8397d1e81 Mon Sep 17 00:00:00 2001 From: Haven Date: Wed, 27 May 2020 20:31:27 -0700 Subject: [PATCH 01/53] Updated to 1.16 --- gradle.properties | 14 +++++++------- .../dev/hephaestus/tweaks/block/MoistBlock.java | 5 ----- .../render/block/entity/LabelRenderer.java | 4 ++-- .../entity/ai/goal/GroundFoodMateGoal.java | 2 -- .../tweaks/mixin/block/CocoaBlockMixin.java | 2 +- .../tweaks/mixin/block/CropBlockMixin.java | 2 +- .../tweaks/mixin/block/FernBlockMixin.java | 10 +++------- .../tweaks/mixin/block/FlowerBlockMixin.java | 10 +++------- .../tweaks/mixin/block/LeavesBlockMixin.java | 4 ++-- .../tweaks/mixin/block/LilyPadBlockMixin.java | 11 +++-------- .../tweaks/mixin/block/MoistObjectsMixin.java | 5 ----- .../tweaks/mixin/block/NetherWartBlockMixin.java | 2 +- .../tweaks/mixin/block/RedstoneTorchMixin.java | 5 +++-- .../tweaks/mixin/block/SpreadableBlockMixin.java | 3 +-- .../tweaks/mixin/block/SugarCaneMixin.java | 4 +--- .../tweaks/mixin/block/TallPlantBlockMixin.java | 5 ++--- .../tweaks/mixin/entity/LivingEntityMixin.java | 16 +++++++--------- .../ai/brain/task/FarmerVillagerTaskMixin.java | 8 ++++---- .../tweaks/mixin/fluid/WaterFluidMixin.java | 4 ++-- 19 files changed, 43 insertions(+), 73 deletions(-) diff --git a/gradle.properties b/gradle.properties index f63470c..0b26498 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version = 1.15.2 -yarn_mappings = 1.15.2+build.15 -loader_version = 0.8.2+build.194 +minecraft_version=20w21a +yarn_mappings=20w21a+build.18 +loader_version=0.8.4+build.198 #Mod properties mod_version = 1.0.7 @@ -11,7 +11,7 @@ maven_group = dev.hephaestus archives_base_name = tinytweaks #Dependencies -fabric_api_version = 0.7.1+build.301-1.15 -modmenu_version = 1.10.2+build.32 -cloth_config_2_version = 2.13.2 -autoconfig1u_version = 2.0.1 \ No newline at end of file +fabric_api_version = 0.10.10+build.347-1.16 +modmenu_version = 1.11.6+build.11 +cloth_config_2_version = 4.4.0-unstable +autoconfig1u_version = 3.2.0-unstable \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java index 920e6eb..5d19f94 100644 --- a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java +++ b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java @@ -43,9 +43,4 @@ public static void randomTick(BlockState state, ServerWorld world, BlockPos pos) public boolean hasRandomTicks(BlockState state) { return true; } - - @Override - public int getTickRate(WorldView worldView) { - return 5; - } } diff --git a/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java b/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java index e717f55..fd0b14e 100644 --- a/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java +++ b/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java @@ -97,7 +97,7 @@ else if (dispatcher.crosshairTarget.getType() == HitResult.Type.BLOCK){ TextRenderer textRenderer = dispatcher.getTextRenderer(); String string = blockEntity.getName().asString(); - float s = (float) (-textRenderer.getStringWidth(string) / 2); + float s = (float) (-textRenderer.getWidth(string) / 2); textRenderer.draw(string, s, 0f, 16777215, true, matrices.peek().getModel(), vertexConsumers, false, 0, 15728880); matrices.pop(); } @@ -177,7 +177,7 @@ public static void renderLabel(LockableContainerBlockEntity blockEntity, BlockEn TextRenderer textRenderer = dispatcher.getTextRenderer(); String string = blockEntity.getName().asString(); - float s = (float) (-textRenderer.getStringWidth(string) / 2); + float s = (float) (-textRenderer.getWidth(string) / 2); textRenderer.draw(string, s, 0f, 16777215, true, matrices.peek().getModel(), vertexConsumers, false, 0, 15728880); matrices.pop(); } diff --git a/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java b/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java index 6d2d66f..8ad7dc4 100644 --- a/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java +++ b/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java @@ -1,7 +1,6 @@ package dev.hephaestus.tweaks.entity.ai.goal; import dev.hephaestus.tweaks.Tweaks; -import jdk.internal.jline.internal.Nullable; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.passive.AnimalEntity; @@ -57,7 +56,6 @@ public void tick() { } } - @Nullable private ItemEntity findFood() { List list = animal.world.getEntities(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), null); double d = Double.MAX_VALUE; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java index bfe02ab..a0e2880 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java @@ -26,7 +26,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt stack.setCount(stack.getCount() - 1); } - boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).method_14239(); + boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).isDisconnected(); if (playerAvailable) player.inventory.offerOrDrop(world, stack); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java index 473bb77..2dac629 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java @@ -35,7 +35,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt stack.setCount(stack.getCount() - 1); } - boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).method_14239(); + boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).isDisconnected(); if (playerAvailable) player.inventory.offerOrDrop(world, stack); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java index 7d7e9ef..2311d21 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java @@ -1,11 +1,7 @@ package dev.hephaestus.tweaks.mixin.block; import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.BlockState; -import net.minecraft.block.FernBlock; -import net.minecraft.block.FlowerBlock; -import net.minecraft.block.PlantBlock; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.*; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; @@ -23,8 +19,8 @@ protected FernBlockMixin(Settings settings) { super(settings); } - - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (!Tweaks.CONFIG.plantHitboxes && !context.isHolding(Items.SHEARS)) return VoxelShapes.empty(); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java index 26af82c..32970cc 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java @@ -1,11 +1,7 @@ package dev.hephaestus.tweaks.mixin.block; import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.BlockState; -import net.minecraft.block.FernBlock; -import net.minecraft.block.FlowerBlock; -import net.minecraft.block.PlantBlock; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.*; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; @@ -23,8 +19,8 @@ protected FlowerBlockMixin(Settings settings) { super(settings); } - - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (!Tweaks.CONFIG.plantHitboxes && !context.isHolding(Items.SHEARS)) return VoxelShapes.empty(); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java index 986e4e7..dd6f6b4 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java @@ -4,8 +4,8 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.LeavesBlock; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; import net.minecraft.entity.ItemEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -23,7 +23,7 @@ public LeavesBlockMixin(Settings settings) { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (state.get(LeavesBlock.PERSISTENT)) return Tweaks.CONFIG.leaves.persistentCollide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java index 45970fd..24d6e18 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java @@ -1,12 +1,8 @@ package dev.hephaestus.tweaks.mixin.block; import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.LilyPadBlock; -import net.minecraft.block.PlantBlock; +import net.minecraft.block.*; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; @@ -14,7 +10,6 @@ import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -38,13 +33,13 @@ public void overwriteEntityCollision(BlockState state, World world, BlockPos pos private static final VoxelShape COLLIDER = Block.createCuboidShape(1.0D, -0.155D, 1.0D, 15.0D, -1.5D, 15.0D); @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) - public void overwriteOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context, CallbackInfoReturnable cir) { + public void overwriteOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (Tweaks.CONFIG.betterLilyPads) cir.setReturnValue(COLLIDER); } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (Tweaks.CONFIG.betterLilyPads) return context.isAbove(COLLIDER, pos, false) ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java index 7c475b6..f0878c9 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java @@ -25,9 +25,4 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random public boolean hasRandomTicks(BlockState state) { return true; } - - @Override - public int getTickRate(WorldView worldView) { - return 5; - } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java index 115b8c6..ae94da9 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java @@ -29,7 +29,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt stack.setCount(stack.getCount() - 1); } - boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).method_14239(); + boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).isDisconnected(); if (playerAvailable) player.inventory.offerOrDrop(world, stack); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java index 0b79e5a..e7b5785 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java @@ -3,14 +3,15 @@ import dev.hephaestus.tweaks.Tweaks; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.block.*; +import net.minecraft.particle.ParticleEffect; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldView; import org.spongepowered.asm.mixin.Mixin; @Mixin(RedstoneTorchBlock.class) public class RedstoneTorchMixin extends TorchBlock { - protected RedstoneTorchMixin(Settings settings) { - super(settings); + protected RedstoneTorchMixin(Settings settings, ParticleEffect particle) { + super(settings, particle); } @Override diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java index 280179b..f005dac 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java @@ -2,7 +2,6 @@ import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.*; -import net.minecraft.client.MinecraftClient; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import org.spongepowered.asm.mixin.Mixin; @@ -15,7 +14,7 @@ @Mixin(SpreadableBlock.class) public class SpreadableBlockMixin { - @Inject(method = "scheduledTick", at = @At(value = "INVOKE", target = "net/minecraft/block/SpreadableBlock.getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) + @Inject(method = "randomTick", at = @At(value = "INVOKE", target = "net/minecraft/block/SpreadableBlock.getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) public void growGrass(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { if (Tweaks.CONFIG.rejuvenation.enabled && state.getBlock() == Blocks.GRASS_BLOCK) { Block above = world.getBlockState(pos.up()).getBlock(); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java index ce8cf96..0af28f3 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java @@ -27,8 +27,6 @@ public SugarCaneMixin(Settings settings) { super(settings); } - - private int destroySugarcane(World world, BlockPos pos) { int r = 0; if (world.getBlockState(pos).getBlock() == Blocks.SUGAR_CANE) { @@ -49,7 +47,7 @@ private boolean tryBreakSugarcane(World world, BlockPos pos, PlayerEntity player } if (n > 0) { - boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity) player).method_14239(); + boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity) player).isDisconnected(); if (playerAvailable) player.inventory.offerOrDrop(world, new ItemStack(Items.SUGAR_CANE, n)); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java index a47152e..3d87c7e 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java @@ -2,10 +2,9 @@ import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.BlockState; -import net.minecraft.block.FernBlock; import net.minecraft.block.PlantBlock; +import net.minecraft.block.ShapeContext; import net.minecraft.block.TallPlantBlock; -import net.minecraft.entity.EntityContext; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; @@ -19,7 +18,7 @@ protected TallPlantBlockMixin(Settings settings) { super(settings); } - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (!Tweaks.CONFIG.plantHitboxes && !context.isHolding(Items.SHEARS)) return VoxelShapes.empty(); else diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java index a116486..abb11bb 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java @@ -3,10 +3,10 @@ import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.BlockState; import net.minecraft.block.LeavesBlock; -import net.minecraft.block.LogBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; +import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -22,16 +22,14 @@ public LivingEntityMixin(EntityType type, World world) { } @Inject(method = "isClimbing", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) - public void onIsClimbing(CallbackInfoReturnable info, BlockState state) { - BlockPos pos = this.getBlockPos(); - - if ((state.getBlock() instanceof LeavesBlock || world.getBlockState(pos.up()).getBlock() instanceof LeavesBlock)) { + public void onIsClimbing(CallbackInfoReturnable info, BlockPos pos) { + if ((world.getBlockState(pos).getBlock() instanceof LeavesBlock || world.getBlockState(pos.up()).getBlock() instanceof LeavesBlock)) { if (Tweaks.CONFIG.leaves.climb) { boolean logsAdjacent = - world.getBlockState(pos.north()).getBlock() instanceof LogBlock || - world.getBlockState(pos.east()).getBlock() instanceof LogBlock || - world.getBlockState(pos.south()).getBlock() instanceof LogBlock || - world.getBlockState(pos.west()).getBlock() instanceof LogBlock; + world.getBlockState(pos.north()).getBlock().isIn(BlockTags.LOGS) || + world.getBlockState(pos.east()).getBlock().isIn(BlockTags.LOGS) || + world.getBlockState(pos.south()).getBlock().isIn(BlockTags.LOGS) || + world.getBlockState(pos.west()).getBlock().isIn(BlockTags.LOGS); info.setReturnValue(logsAdjacent); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java index e1a5773..3eb4390 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java @@ -57,17 +57,17 @@ public void shouldStoreThings(ServerWorld serverWorld, VillagerEntity villagerEn if (target != null) { Inventory inventory = villagerEntity.getInventory(); - for(int i = 0; i < inventory.getInvSize(); ++i) { - ItemStack stack = inventory.getInvStack(i); + for(int i = 0; i < inventory.size(); ++i) { + ItemStack stack = inventory.getStack(i); if (stack.getCount() > stack.getMaxCount()/2) { int amount = stack.getCount() - stack.getMaxCount()/2; - ItemStack itemStack2 = HopperBlockEntity.transfer(inventory, target, inventory.takeInvStack(i, amount), null); + ItemStack itemStack2 = HopperBlockEntity.transfer(inventory, target, inventory.removeStack(i, amount), null); if (itemStack2.isEmpty()) { inventory.markDirty(); break; } - inventory.getInvStack(i).decrement(amount); + inventory.getStack(i).decrement(amount); } } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java index 9475cfa..b110ced 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java @@ -2,7 +2,7 @@ import dev.hephaestus.tweaks.block.Moistener; import net.minecraft.block.BlockState; -import net.minecraft.fluid.BaseFluid; +import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.WaterFluid; import net.minecraft.util.math.BlockPos; @@ -12,7 +12,7 @@ import java.util.Random; @Mixin(WaterFluid.class) -public abstract class WaterFluidMixin extends BaseFluid { +public abstract class WaterFluidMixin extends Fluid { @Override protected void onRandomTick(World world, BlockPos pos, FluidState state, Random random) { if (this.isStill(state)) { From da2b08880fc9b5f3e8b1d4332f47f8589ed9bc43 Mon Sep 17 00:00:00 2001 From: Haven Date: Wed, 27 May 2020 21:33:54 -0700 Subject: [PATCH 02/53] New Tweak: Burned Logs Drop Charcoal Additionally, Sapling Succession got an upgrade. Saplings can now replace blocks like grass to plant themselves. --- build.gradle | 1 + .../dev/hephaestus/tweaks/TweaksConfig.java | 3 +++ .../tweaks/mixin/block/FireBlockMixin.java | 26 +++++++++++++++++++ .../tweaks/mixin/entity/ItemEntityMixin.java | 19 +++++++++++--- .../mixin/item/CharcoalDoesntBurnMixin.java | 16 ++++++++++++ .../assets/tinytweaks/lang/en_us.json | 5 +++- src/main/resources/fabric.mod.json | 1 + src/main/resources/tweaks.accesswidener | 2 ++ src/main/resources/tweaks.mixins.json | 2 ++ 9 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/item/CharcoalDoesntBurnMixin.java create mode 100644 src/main/resources/tweaks.accesswidener diff --git a/build.gradle b/build.gradle index 5e8e8bc..300a758 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,7 @@ version = project.mod_version group = project.maven_group minecraft { + accessWidener = file("src/main/resources/tweaks.accesswidener") } repositories { diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 72229c2..e255dae 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -66,6 +66,9 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.Tooltip(count = 2) public boolean mossyThings = true; + @ConfigEntry.Category("misc") + public boolean burningLogsDropCharcoal = true; + @ConfigEntry.Category("debug") public boolean grassDestroysRedstoneTorches = false; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java new file mode 100644 index 0000000..ec963aa --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java @@ -0,0 +1,26 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.FireBlock; +import net.minecraft.entity.ItemEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.tag.BlockTags; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Random; + +@Mixin(FireBlock.class) +public class FireBlockMixin { + @Inject(method = "trySpreadingFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 1)) + private void beforeSet(World world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo ci) { + if (Tweaks.CONFIG.burningLogsDropCharcoal && world.getBlockState(pos).getBlock().isIn(BlockTags.LOGS_THAT_BURN)) { + world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.CHARCOAL))); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java index b49599d..bd900af 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java @@ -4,13 +4,18 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.pattern.CachedBlockPosition; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; import net.minecraft.tag.ItemTags; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.RayTraceContext; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -38,9 +43,17 @@ public void plantSaplings(CallbackInfo ci) { ItemStack stack = this.getStack(); BlockPos pos = this.getBlockPos(); BlockState state = world.getBlockState(pos); - if (this.getBlockPos() != triedToPlantAt && stack.getItem().isIn(ItemTags.SAPLINGS) && stack.getItem() instanceof BlockItem && state.getBlock() == Blocks.AIR && isDirt(world.getBlockState(pos.down()).getBlock())) { - world.setBlockState(pos, ((BlockItem) stack.getItem()).getBlock().getDefaultState()); - stack.decrement(1); + if (this.getBlockPos() != triedToPlantAt) { + stack.useOnBlock(new ItemPlacementContext(world, null, null, stack, world.rayTrace( + new RayTraceContext( + new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), + new Vec3d(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5), + RayTraceContext.ShapeType.COLLIDER, + RayTraceContext.FluidHandling.ANY, + this + ) + ))); + triedToPlantAt = this.getBlockPos(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/item/CharcoalDoesntBurnMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/item/CharcoalDoesntBurnMixin.java new file mode 100644 index 0000000..62a3e87 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/item/CharcoalDoesntBurnMixin.java @@ -0,0 +1,16 @@ +package dev.hephaestus.tweaks.mixin.item; + +import net.minecraft.item.Item; +import net.minecraft.item.Items; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(Items.class) +public class CharcoalDoesntBurnMixin { + @SuppressWarnings("UnresolvedMixinReference") + @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/item/Item", ordinal = 3)) + private static Item charcoalShouldntBurn(Item.Settings settings) { + return new Item(settings.fireproof()); + } +} diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 108e33e..74d3d20 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -55,6 +55,7 @@ "text.autoconfig.tinytweaks.option.mossyThings": "Mossy Things", "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[0]": "Cobblestone, stone bricks, and their stairs/slabs/walls turn mossy when near water or in rain", "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[1]": "Mossy cobblestone, stone bricks, and their stairs/slabs/walls turn normal in sunlight", + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal": "Burned Logs Drop Charcoal", "text.autoconfig.tinytweaks.option.grassDestroysRedstoneTorches": "Grass Destroys Redstone Torches", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", @@ -76,6 +77,7 @@ "text.autoconfig.tinytweaks.option.leaves.persistentCollide.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.leaves.climb.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.mossyThings.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§cOff", @@ -95,5 +97,6 @@ "text.autoconfig.tinytweaks.option.leaves.slow.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.leaves.persistentCollide.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.leaves.climb.boolean.false": "§cOff", - "text.autoconfig.tinytweaks.option.mossyThings.boolean.false": "§cOff" + "text.autoconfig.tinytweaks.option.mossyThings.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§cOff" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5b2b40a..a3bdc76 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,6 +26,7 @@ "dev.hephaestus.tweaks.ModMenuIntegration" ] }, + "accessWidener" : "tweaks.accesswidener", "mixins": [ "tweaks.mixins.json" ], diff --git a/src/main/resources/tweaks.accesswidener b/src/main/resources/tweaks.accesswidener new file mode 100644 index 0000000..4caf793 --- /dev/null +++ b/src/main/resources/tweaks.accesswidener @@ -0,0 +1,2 @@ +accessWidener v1 named +accessible method net/minecraft/item/ItemPlacementContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 6305fca..2f2fd33 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -8,6 +8,7 @@ "block.CropBlockMixin", "block.DeadBushBlockMixin", "block.FernBlockMixin", + "block.FireBlockMixin", "block.FlowerBlockMixin", "block.LanternResistanceMixin", "block.LeavesBlockMixin", @@ -29,6 +30,7 @@ "entity.passive.SheepEntityMixin", "entity.passive.WolfEntityMixin", "fluid.WaterFluidMixin", + "item.CharcoalDoesntBurnMixin", "item.FlintAndSteelMixin", "item.HoeItemMixin", "item.ShovelMixin" From 98498dfdd14a8846038450075e365060cc3e02ae Mon Sep 17 00:00:00 2001 From: Haven Date: Thu, 28 May 2020 16:12:29 -0700 Subject: [PATCH 03/53] Added editable signs. Cause it was easy. --- .../tweaks/mixin/block/SignBlockMixin.java | 31 +++++++++++++++++++ .../screen/ingame/SignEditScreenMixin.java | 27 ++++++++++++++++ src/main/resources/tweaks.mixins.json | 2 ++ 3 files changed, 60 insertions(+) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java new file mode 100644 index 0000000..63e06da --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java @@ -0,0 +1,31 @@ +package dev.hephaestus.tweaks.mixin.block; + +import net.minecraft.block.AbstractSignBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.SignBlock; +import net.minecraft.block.entity.SignBlockEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.SignType; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(SignBlock.class) +public class SignBlockMixin extends AbstractSignBlock { + protected SignBlockMixin(Settings settings, SignType type) { + super(settings, type); + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + if (!world.isClient && player != null) { + player.openEditSignScreen((SignBlockEntity)world.getBlockEntity(pos)); + return ActionResult.SUCCESS; + } + + return super.onUse(state, world, pos, player, hand, hit); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java new file mode 100644 index 0000000..acaec05 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java @@ -0,0 +1,27 @@ +package dev.hephaestus.tweaks.mixin.client.gui.screen.ingame; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.block.entity.SignBlockEntity; +import net.minecraft.client.gui.screen.ingame.SignEditScreen; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(SignEditScreen.class) +@Environment(EnvType.CLIENT) +public class SignEditScreenMixin { + @Shadow @Final private String[] field_24285; + + @Shadow @Final private SignBlockEntity sign; + + @Inject(method = "init", at = @At("TAIL")) + private void setRows(CallbackInfo ci) { + for (int i = 0; i < 4; ++i) { + this.field_24285[i] = this.sign.getTextOnRow(i).asString(); + } + } +} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 2f2fd33..bd6d9bc 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -17,6 +17,7 @@ "block.MoistObjectsMixin", "block.NetherWartBlockMixin", "block.RedstoneTorchMixin", + "block.SignBlockMixin", "block.SpreadableBlockMixin", "block.SugarCaneMixin", "block.TallPlantBlockMixin", @@ -36,6 +37,7 @@ "item.ShovelMixin" ], "client": [ + "client.gui.screen.ingame.SignEditScreenMixin", "client.render.CameraMixin", "client.render.entity.BoatEntityRendererMixin", "client.render.entity.PlayerEntityRendererMixin", From 52955809c02fb7ce57edc9455ba9f76ba02efa49 Mon Sep 17 00:00:00 2001 From: Haven Date: Thu, 28 May 2020 17:25:12 -0700 Subject: [PATCH 04/53] Added a new tweak: Double Doors. Doors and trapdoors open adjacent doors and trapdoors of the same type Works when opened by hand or with redstone Also fixed a bug with Sapling Succession where I forgot to check if the ItemStack was actually a sapling... Yeah that was fun. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 4 + .../tweaks/mixin/block/DoorBlockMixin.java | 73 +++++++++++++ .../tweaks/mixin/block/TrapDoorMixin.java | 103 ++++++++++++++++++ .../tweaks/mixin/entity/ItemEntityMixin.java | 3 +- .../assets/tinytweaks/lang/en_us.json | 7 +- src/main/resources/tweaks.mixins.json | 2 + 6 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index e255dae..88984e6 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -69,6 +69,10 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Category("misc") public boolean burningLogsDropCharcoal = true; + @ConfigEntry.Category("misc") + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean doubleDoors = true; + @ConfigEntry.Category("debug") public boolean grassDestroysRedstoneTorches = false; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java new file mode 100644 index 0000000..6d2c499 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java @@ -0,0 +1,73 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.DoorBlock; +import net.minecraft.block.enums.DoorHinge; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(DoorBlock.class) +public abstract class DoorBlockMixin { + @Shadow @Final public static DirectionProperty FACING; + + @Shadow @Final public static EnumProperty HINGE; + + @Shadow @Final public static BooleanProperty OPEN; + + @Shadow protected abstract int getCloseSoundEventId(); + + @Shadow protected abstract int getOpenSoundEventId(); + + @Shadow @Final public static BooleanProperty POWERED; + + @Inject(method = "onUse", at = @At(value = "TAIL", ordinal = 1)) + private void openOther(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + openOther(world, pos, player); + } + + @Inject(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) + private void openOther(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify, CallbackInfo ci, boolean bl) { + openOther(world, pos, null); + } + + private void openOther(World world, BlockPos pos, PlayerEntity player) { + if (Tweaks.CONFIG.doubleDoors) { + BlockState state = world.getBlockState(pos); + BlockPos otherPos = null; + BlockState otherState = null; + switch (state.get(HINGE)) { + case LEFT: + otherPos = pos.offset(state.get(FACING).rotateYClockwise()); + otherState = world.getBlockState(otherPos); + break; + case RIGHT: + otherPos = pos.offset(state.get(FACING).rotateYCounterclockwise()); + otherState = world.getBlockState(otherPos); + break; + } + + if (otherState.getBlock() == state.getBlock() && otherState.get(FACING) == state.get(FACING) && otherState.get(OPEN) != state.get(OPEN)) { + otherState = otherState.cycle(OPEN); + world.setBlockState(otherPos, otherState, 10); + world.syncWorldEvent(player, state.get(OPEN) ? this.getCloseSoundEventId() : this.getOpenSoundEventId(), pos, 0); + } + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java new file mode 100644 index 0000000..d174bdd --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java @@ -0,0 +1,103 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.HorizontalFacingBlock; +import net.minecraft.block.TrapdoorBlock; +import net.minecraft.block.enums.BlockHalf; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.Fluids; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import javax.annotation.Nullable; + +@Mixin(TrapdoorBlock.class) +public abstract class TrapDoorMixin extends HorizontalFacingBlock { + @Shadow @Final public static BooleanProperty OPEN; + + @Shadow @Final public static BooleanProperty WATERLOGGED; + + @Shadow protected abstract void playToggleSound(@Nullable PlayerEntity player, World world, BlockPos pos, boolean open); + + @Shadow @Final public static EnumProperty HALF; + + protected TrapDoorMixin(Settings settings) { + super(settings); + } + + @Inject(method = "onUse", at = @At(value = "TAIL", ordinal = 1)) + private void openOthers(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + openOthers(world, pos, player); + } + + @Inject(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) + private void openOthers(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify, CallbackInfo ci) { + openOthers(world, pos, null); + } + + private void openOthers(World world, BlockPos pos, PlayerEntity player) { + if (Tweaks.CONFIG.doubleDoors) { + BlockState state = world.getBlockState(pos); + BlockPos otherPos = pos.offset(state.get(FACING)); + BlockState otherState = world.getBlockState(otherPos); + if (otherState.getBlock() == state.getBlock() && otherState.get(OPEN) != state.get(OPEN) && otherState.get(HALF) == state.get(HALF)) { + world.setBlockState(otherPos, otherState.cycle(OPEN)); + toggleAdjacent(world, otherPos, player); + } + + toggleAdjacent(world, pos, player); + } + } + + private void toggleAdjacent(World world, BlockPos pos, PlayerEntity player) { + BlockState state = world.getBlockState(pos); + Direction [] dirs = new Direction[2]; + switch (state.get(FACING)) { + case NORTH: + case SOUTH: + dirs[0] = Direction.EAST; + dirs[1] = Direction.WEST; + break; + case WEST: + case EAST: + dirs[0] = Direction.NORTH; + dirs[1] = Direction.SOUTH; + break; + default: + return; + } + + BlockPos otherPos; + BlockState otherState; + for (int d = 0; d < 2; ++d) { + for (int i = 1; i < 16; ++i) { + if ((otherState = world.getBlockState(otherPos = pos.offset(dirs[d], i))).getBlock() == state.getBlock() && otherState.get(OPEN) != state.get(OPEN) && otherState.get(HALF) == state.get(HALF)) { + world.setBlockState(otherPos, otherState.cycle(OPEN), 2); + if (otherState.get(WATERLOGGED)) { + world.getFluidTickScheduler().schedule(otherPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + this.playToggleSound(player, world, otherPos, otherState.get(OPEN)); + } else { + break; + } + } + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java index bd900af..3168115 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java @@ -42,8 +42,7 @@ public void plantSaplings(CallbackInfo ci) { if (Tweaks.CONFIG.saplingsAutoPlant && this.age > 20) { ItemStack stack = this.getStack(); BlockPos pos = this.getBlockPos(); - BlockState state = world.getBlockState(pos); - if (this.getBlockPos() != triedToPlantAt) { + if (stack.getItem().isIn(ItemTags.SAPLINGS) && this.getBlockPos() != triedToPlantAt) { stack.useOnBlock(new ItemPlacementContext(world, null, null, stack, world.rayTrace( new RayTraceContext( new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 74d3d20..8ffb87f 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -56,6 +56,9 @@ "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[0]": "Cobblestone, stone bricks, and their stairs/slabs/walls turn mossy when near water or in rain", "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[1]": "Mossy cobblestone, stone bricks, and their stairs/slabs/walls turn normal in sunlight", "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal": "Burned Logs Drop Charcoal", + "text.autoconfig.tinytweaks.option.doubleDoors": "Double Doors & Trapdoors", + "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[0]": "Doors and trapdoors open adjacent doors and trapdoors of the same type", + "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[1]": "Works when opened by hand or with redstone", "text.autoconfig.tinytweaks.option.grassDestroysRedstoneTorches": "Grass Destroys Redstone Torches", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", @@ -78,6 +81,7 @@ "text.autoconfig.tinytweaks.option.leaves.climb.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.mossyThings.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.doubleDoors.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§cOff", @@ -98,5 +102,6 @@ "text.autoconfig.tinytweaks.option.leaves.persistentCollide.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.leaves.climb.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.mossyThings.boolean.false": "§cOff", - "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§cOff" + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§cOff" } \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index bd6d9bc..b2a7ebd 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -7,6 +7,7 @@ "block.CocoaBlockMixin", "block.CropBlockMixin", "block.DeadBushBlockMixin", + "block.DoorBlockMixin", "block.FernBlockMixin", "block.FireBlockMixin", "block.FlowerBlockMixin", @@ -21,6 +22,7 @@ "block.SpreadableBlockMixin", "block.SugarCaneMixin", "block.TallPlantBlockMixin", + "block.TrapDoorMixin", "entity.ItemEntityMixin", "entity.LivingEntityMixin", "entity.ai.brain.task.FarmerVillagerTaskMixin", From 87f9002df18539a35c6e9faeb29d2b7e426c7e1a Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 30 May 2020 16:41:30 -0700 Subject: [PATCH 05/53] Added a new tweak: Bubble Columns Flow When set to On, bubble columns behave as they do in vanilla. When set to Off, bubble columns don't spread water to their surrounding blocks. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 3 ++ .../mixin/block/BubbleColumnBlockMixin.java | 20 ++++++++ .../tweaks/mixin/item/BucketItemMixin.java | 49 +++++++++++++++++++ .../assets/tinytweaks/lang/en_us.json | 5 +- src/main/resources/tweaks.accesswidener | 3 +- src/main/resources/tweaks.mixins.json | 2 + 6 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 88984e6..e9b1e13 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -73,6 +73,9 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.Tooltip(count = 2) public boolean doubleDoors = true; + @ConfigEntry.Category("misc") + public boolean bubbleColumnsFlow = false; + @ConfigEntry.Category("debug") public boolean grassDestroysRedstoneTorches = false; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java new file mode 100644 index 0000000..c4f3885 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java @@ -0,0 +1,20 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.BubbleColumnBlock; +import net.minecraft.fluid.Fluid; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.TickScheduler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BubbleColumnBlock.class) +public class BubbleColumnBlockMixin { + @Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/TickScheduler;schedule(Lnet/minecraft/util/math/BlockPos;Ljava/lang/Object;I)V")) + private void dontFluidTick(TickScheduler tickScheduler, BlockPos pos, Object object, int delay) { + if (Tweaks.CONFIG.bubbleColumnsFlow) { + tickScheduler.schedule(pos, (Fluid) object, delay); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java new file mode 100644 index 0000000..01892bf --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java @@ -0,0 +1,49 @@ +package dev.hephaestus.tweaks.mixin.item; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.BubbleColumnBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.BucketItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BucketItem.class) +public class BucketItemMixin { + boolean shouldChange = false; + @Inject(method = "use", at = @At("HEAD")) + private void captureVariables(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + shouldChange = user.isSneaking(); + } + + @Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;", ordinal = 2)) + private Block change(BlockState blockState) { + if (shouldChange) + return Blocks.BEDROCK; + else + return blockState.getBlock(); + } + + @Redirect(method = "placeFluid", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + private boolean placeBubbleColumnIfPossible(World world, BlockPos pos, BlockState state, int flags) { + if (state.getFluidState().getFluid() == Fluids.WATER) { + BlockState downState = world.getBlockState(pos.down()); + if (downState.getBlock() == Blocks.BUBBLE_COLUMN) + state = downState; + else if (downState.getBlock() == Blocks.SOUL_SAND || downState.getBlock() == Blocks.MAGMA_BLOCK) + state = Blocks.BUBBLE_COLUMN.getDefaultState().with(BubbleColumnBlock.DRAG, BubbleColumnBlock.calculateDrag(world, pos.down())); + } + + return world.setBlockState(pos, state, flags); + } +} diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 8ffb87f..98ebfa3 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -59,6 +59,7 @@ "text.autoconfig.tinytweaks.option.doubleDoors": "Double Doors & Trapdoors", "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[0]": "Doors and trapdoors open adjacent doors and trapdoors of the same type", "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[1]": "Works when opened by hand or with redstone", + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow": "Bubble Columns Flow", "text.autoconfig.tinytweaks.option.grassDestroysRedstoneTorches": "Grass Destroys Redstone Torches", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", @@ -82,6 +83,7 @@ "text.autoconfig.tinytweaks.option.mossyThings.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.doubleDoors.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§cOff", @@ -103,5 +105,6 @@ "text.autoconfig.tinytweaks.option.leaves.climb.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.mossyThings.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§cOff", - "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§cOff" + "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§cOff" } \ No newline at end of file diff --git a/src/main/resources/tweaks.accesswidener b/src/main/resources/tweaks.accesswidener index 4caf793..174ca72 100644 --- a/src/main/resources/tweaks.accesswidener +++ b/src/main/resources/tweaks.accesswidener @@ -1,2 +1,3 @@ accessWidener v1 named -accessible method net/minecraft/item/ItemPlacementContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V \ No newline at end of file +accessible method net/minecraft/item/ItemPlacementContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V +accessible method net/minecraft/block/BubbleColumnBlock calculateDrag (Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index b2a7ebd..74f60cf 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_8", "plugin": "dev.hephaestus.tweaks.mixin.VolatileMixinPlugin", "mixins": [ + "block.BubbleColumnBlockMixin", "block.CocoaBlockMixin", "block.CropBlockMixin", "block.DeadBushBlockMixin", @@ -33,6 +34,7 @@ "entity.passive.SheepEntityMixin", "entity.passive.WolfEntityMixin", "fluid.WaterFluidMixin", + "item.BucketItemMixin", "item.CharcoalDoesntBurnMixin", "item.FlintAndSteelMixin", "item.HoeItemMixin", From 4de59345ab937ebc361a1ef6911d811638a50789 Mon Sep 17 00:00:00 2001 From: Haven Date: Sun, 31 May 2020 12:55:37 -0700 Subject: [PATCH 06/53] Updated Loom and mappings versions --- build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 300a758..4463c4b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.2.7-SNAPSHOT' + id 'fabric-loom' version '0.4.13' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index 0b26498..988105a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties minecraft_version=20w21a -yarn_mappings=20w21a+build.18 +yarn_mappings=20w21a+build.20 loader_version=0.8.4+build.198 #Mod properties From 4ac90e552235ff92be770db24b611bbfa1b3e0ab Mon Sep 17 00:00:00 2001 From: Hephaestus-Dev <54509200+Hephaestus-Dev@users.noreply.github.com> Date: Tue, 9 Jun 2020 15:50:55 -0700 Subject: [PATCH 07/53] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c53f9b1..f427ec3 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,9 @@ A collection of small tweaks for Minecraft. * Wild Wolves Breed - Wild wolves are able to be bred. Allows for some neat natural systems! ## Miscellaneous Tweaks +* Bubble Columns Flow - When set to On, bubble columns behave as they do in vanilla. When set to Off, bubble columns don't spread water to their surrounding blocks +* Burned Logs Drop Charcoal - When a log that's on fire is destroyed, it drops a charcoal. Also makes charcoal fireproof +* Double Doors - Doors and trapdoors open adjacent doors and trapdoors of the same type. Works when opened by hand or with redstone +* Editable Signs - No config for this one, just don't use it if you don't want it! * Entity Ignition - Right click mobs with flint and steel to light them on fire -* Sturdy Lanterns - Gives lanterns a blast resistance of 6 (allows them to survive Ghast fireballs) \ No newline at end of file +* Sturdy Lanterns - Gives lanterns a blast resistance of 6 (allows them to survive Ghast fireballs) From 771224401132271a31b15bcbd43aea7d5988347c Mon Sep 17 00:00:00 2001 From: Haven Date: Fri, 26 Jun 2020 14:59:05 -0700 Subject: [PATCH 08/53] Minor compatibility changes. --- gradle.properties | 2 +- .../tweaks/client/render/block/entity/LabelRenderer.java | 8 -------- .../tweaks/mixin/block/BubbleColumnBlockMixin.java | 2 +- .../dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/gradle.properties b/gradle.properties index 988105a..6a60dae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings=20w21a+build.20 loader_version=0.8.4+build.198 #Mod properties -mod_version = 1.0.7 +mod_version = 1.0.8 maven_group = dev.hephaestus archives_base_name = tinytweaks diff --git a/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java b/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java index fd0b14e..dfb2acd 100644 --- a/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java +++ b/src/main/java/dev/hephaestus/tweaks/client/render/block/entity/LabelRenderer.java @@ -36,15 +36,7 @@ public class LabelRenderer { private static final Quaternion rotate180 = new Quaternion(yAxis, 180, true); private static final Quaternion rotate270 = new Quaternion(yAxis, 270, true); - static boolean test = true; public static void renderLabel(LockableContainerBlockEntity blockEntity, BlockEntityRenderDispatcher dispatcher, MatrixStack matrices, VertexConsumerProvider vertexConsumers, boolean open, Direction facing) { - if (test) { - BlockState state = Blocks.STONE.getDefaultState(); - BakedModel model = MinecraftClient.getInstance().getBlockRenderManager().getModel(state); - List quads = model.getQuads(state, null, new Random()); - - test = false; - } if (!blockEntity.hasCustomName() && MinecraftClient.getInstance().getNetworkHandler() != null) { MinecraftClient.getInstance().getNetworkHandler().getDataQueryHandler().queryBlockNbt(blockEntity.getPos(), (tag) -> { if (tag.contains("CustomName", 8)) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java index c4f3885..1fc143d 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(BubbleColumnBlock.class) +@Mixin(value = BubbleColumnBlock.class, priority = 2000) public class BubbleColumnBlockMixin { @Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/TickScheduler;schedule(Lnet/minecraft/util/math/BlockPos;Ljava/lang/Object;I)V")) private void dontFluidTick(TickScheduler tickScheduler, BlockPos pos, Object object, int delay) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java index 01892bf..0aaff23 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java @@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(BucketItem.class) +@Mixin(value = BucketItem.class, priority = 2000) public class BucketItemMixin { boolean shouldChange = false; @Inject(method = "use", at = @At("HEAD")) From 38bfcc0e9cb20eb711aabc03284cf7320383997b Mon Sep 17 00:00:00 2001 From: Haven Date: Fri, 26 Jun 2020 15:17:27 -0700 Subject: [PATCH 09/53] Added config option for grass growth rate. Addresses #6. --- src/main/java/dev/hephaestus/tweaks/TweaksConfig.java | 5 ++++- .../hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java | 4 ++-- src/main/resources/assets/tinytweaks/lang/en_us.json | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index e9b1e13..a98dfca 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -84,7 +84,10 @@ public static class Rejuvenation { public boolean enabled = true; @ConfigEntry.Gui.Tooltip(count = 2) - public float longGrass = 0.01f; + public double growthRate = 0.025D; + + @ConfigEntry.Gui.Tooltip(count = 2) + public float longGrass = 0.01F; @ConfigEntry.Gui.Tooltip public boolean saplings = true; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java index f005dac..ec7faf2 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java @@ -33,13 +33,13 @@ public void growGrass(BlockState state, ServerWorld world, BlockPos pos, Random } } - if (above == Blocks.AIR && random.nextFloat() < 0.01 + 0.2 * (friends)) { + if (above == Blocks.AIR && random.nextFloat() < Tweaks.CONFIG.rejuvenation.growthRate + 0.2 * (friends)) { world.setBlockState(pos.up(), Blocks.GRASS.getDefaultState()); ci.cancel(); } else if (Tweaks.CONFIG.rejuvenation.longGrass > 0.000001 && above == Blocks.GRASS) { Random tallGrassRandom = new Random(); tallGrassRandom.setSeed(pos.asLong()); - if (tallGrassRandom.nextFloat() < Tweaks.CONFIG.rejuvenation.longGrass && random.nextFloat() < 0.01) { + if (tallGrassRandom.nextFloat() < Tweaks.CONFIG.rejuvenation.longGrass && random.nextFloat() < Tweaks.CONFIG.rejuvenation.growthRate) { ((TallPlantBlock) Blocks.TALL_GRASS).placeAt(world, pos.up(), 2); ci.cancel(); } diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 98ebfa3..e7b3acf 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -28,6 +28,9 @@ "text.autoconfig.tinytweaks.option.rejuvenation": "Rejuvenation", "text.autoconfig.tinytweaks.option.rejuvenation.enabled": "Enabled", "text.autoconfig.tinytweaks.option.rejuvenation.enabled.@Tooltip": "Grass grows taller over time", + "text.autoconfig.tinytweaks.option.rejuvenation.growthRate": "Grass Growth Rate", + "text.autoconfig.tinytweaks.option.rejuvenation.growthRate.@Tooltip[0]": "Percent chance of grass spreading", + "text.autoconfig.tinytweaks.option.rejuvenation.growthRate.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass": "Long Grass", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.@Tooltip[0]": "Percent of grass that can grow into tall grass", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.@Tooltip[1]": "0.0 is disabled, 0.01 is default, 1.0 is all of them", From a184df353d08988e92acd08cae32ac06c174d6d2 Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 27 Jun 2020 11:21:32 -0700 Subject: [PATCH 10/53] Updated to actually be on 1.16.1. Oops. --- .../tweaks/entity/ai/goal/GroundFoodMateGoal.java | 2 +- .../client/gui/screen/ingame/SignEditScreenMixin.java | 9 ++++++++- .../hephaestus/tweaks/mixin/item/FlintAndSteelMixin.java | 7 ++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java b/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java index 8ad7dc4..2012b07 100644 --- a/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java +++ b/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java @@ -31,7 +31,7 @@ public GroundFoodMateGoal(AnimalEntity animal, Ingredient food) { } public boolean canStart() { - if (Tweaks.CONFIG.animalsEatOffGround && this.animal.getEntityWorld().getGameRules().getBoolean(GameRules.MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) { + if (Tweaks.CONFIG.animalsEatOffGround && this.animal.getEntityWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) { this.foodEntity = this.findFood(); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java index acaec05..6939327 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java @@ -4,6 +4,10 @@ import net.fabricmc.api.Environment; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.gui.screen.ingame.SignEditScreen; +import net.minecraft.text.LiteralText; +import net.minecraft.text.StringRenderable; +import net.minecraft.text.Style; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -11,6 +15,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.List; + @Mixin(SignEditScreen.class) @Environment(EnvType.CLIENT) public class SignEditScreenMixin { @@ -21,7 +27,8 @@ public class SignEditScreenMixin { @Inject(method = "init", at = @At("TAIL")) private void setRows(CallbackInfo ci) { for (int i = 0; i < 4; ++i) { - this.field_24285[i] = this.sign.getTextOnRow(i).asString(); + StringRenderable text = sign.getTextBeingEditedOnRow(i, t -> t); + this.field_24285[i] = (text == null ? LiteralText.EMPTY : text).getString(); } } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/item/FlintAndSteelMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/item/FlintAndSteelMixin.java index eddd75a..a4a3d9f 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/item/FlintAndSteelMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/item/FlintAndSteelMixin.java @@ -6,6 +6,7 @@ import net.minecraft.item.FlintAndSteelItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import org.spongepowered.asm.mixin.Mixin; @@ -16,13 +17,13 @@ public FlintAndSteelMixin(Settings settings) { } @Override - public boolean useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) { + public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) { if (Tweaks.CONFIG.flintAndSteel.enabled && !entity.isFireImmune()) { entity.setOnFireFor(Tweaks.CONFIG.flintAndSteel.burnTime); stack.damage(1, user, ((p) -> p.sendToolBreakStatus(hand))); - return true; + return ActionResult.SUCCESS; } else { - return false; + return ActionResult.PASS; } } } From 61c73ccb34c27d43ac19117694f9861465006dbf Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 27 Jun 2020 11:28:28 -0700 Subject: [PATCH 11/53] Somehow my gradle files didn't actually push? Whatever. Here we go again! --- build.gradle | 12 +++++----- gradle.properties | 22 ++++++++++--------- .../screen/ingame/SignEditScreenMixin.java | 4 ---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 4463c4b..8ae52cc 100644 --- a/build.gradle +++ b/build.gradle @@ -25,15 +25,15 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" compileOnly "com.google.code.findbugs:jsr305:3.0.2" - modImplementation "io.github.prospector:modmenu:${project.modmenu_version}" + modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}" - modApi "me.shedaniel.cloth:config-2:${project.cloth_config_2_version}" - include "me.shedaniel.cloth:config-2:${project.cloth_config_2_version}" + modApi "me.shedaniel.cloth:config-2:${project.cloth_config_version}" + include "me.shedaniel.cloth:config-2:${project.cloth_config_version}" - modCompile "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u_version}" - include "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u_version}" + modCompile "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}" + include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" } processResources { diff --git a/gradle.properties b/gradle.properties index 6a60dae..fa95f2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,19 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version=20w21a -yarn_mappings=20w21a+build.20 -loader_version=0.8.4+build.198 +minecraft_version = 1.16.1 +yarn_mappings = 1.16.1+build.9 +loader_version = 0.8.8+build.202 #Mod properties -mod_version = 1.0.8 -maven_group = dev.hephaestus -archives_base_name = tinytweaks +mod_version = 1.0.9 +maven_group = dev.hephaestus +archives_base_name = tinytweaks #Dependencies -fabric_api_version = 0.10.10+build.347-1.16 -modmenu_version = 1.11.6+build.11 -cloth_config_2_version = 4.4.0-unstable -autoconfig1u_version = 3.2.0-unstable \ No newline at end of file +fabric_version = 0.14.0+build.371-1.16 +cloth_config_version = 4.5.6 +auto_config_version = 3.2.0-unstable + +# Dev Mods +mod_menu_version = 1.12.0+build.14 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java index 6939327..d11e801 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java @@ -6,8 +6,6 @@ import net.minecraft.client.gui.screen.ingame.SignEditScreen; import net.minecraft.text.LiteralText; import net.minecraft.text.StringRenderable; -import net.minecraft.text.Style; -import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -15,8 +13,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; - @Mixin(SignEditScreen.class) @Environment(EnvType.CLIENT) public class SignEditScreenMixin { From 081e64a437ae5cb78b7fc84219b20b7ccc781044 Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 27 Jun 2020 12:37:41 -0700 Subject: [PATCH 12/53] Fixes Issue #7 --- .../mixin/entity/InteractableEntityMixin.java | 24 +++++++++++++++++++ src/main/resources/tweaks.mixins.json | 1 + 2 files changed, 25 insertions(+) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java new file mode 100644 index 0000000..c7562b9 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java @@ -0,0 +1,24 @@ +package dev.hephaestus.tweaks.mixin.entity; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Items; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(targets = { + "net/minecraft/entity/passive/VillagerEntity", + "net/minecraft/entity/passive/WanderingTraderEntity", + "net/minecraft/entity/mob/PiglinEntity" +}) +public class InteractableEntityMixin { + @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) + private void useFlintAndSteel(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { + if (player.getStackInHand(hand).getItem().equals(Items.FLINT_AND_STEEL)) { + cir.setReturnValue(ActionResult.PASS); + } + } +} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 74f60cf..c4c42aa 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -27,6 +27,7 @@ "entity.ItemEntityMixin", "entity.LivingEntityMixin", "entity.ai.brain.task.FarmerVillagerTaskMixin", + "entity.InteractableEntityMixin", "entity.passive.ChickenEntityMixin", "entity.passive.CowEntityMixin", "entity.passive.HorseAndDonkeyMixin", From a698d9b41d8f5a351dc28d4d4166e365e9bc54d9 Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 14 Jul 2020 12:29:48 -0700 Subject: [PATCH 13/53] Fixes Issue #11 --- build.gradle | 5 +++++ gradle.properties | 12 ++++++------ .../tweaks/mixin/entity/ItemEntityMixin.java | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 8ae52cc..54dc05e 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,9 @@ minecraft { repositories { jcenter() + maven { + url = "https://www.cursemaven.com" + } } dependencies { @@ -26,6 +29,8 @@ dependencies { compileOnly "com.google.code.findbugs:jsr305:3.0.2" modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}" + modImplementation "curse.maven:sodium:3003093" + modImplementation "curse.maven:lithium:3000628" modApi "me.shedaniel.cloth:config-2:${project.cloth_config_version}" include "me.shedaniel.cloth:config-2:${project.cloth_config_version}" diff --git a/gradle.properties b/gradle.properties index fa95f2d..6ef77c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,18 +2,18 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties minecraft_version = 1.16.1 -yarn_mappings = 1.16.1+build.9 -loader_version = 0.8.8+build.202 +yarn_mappings = 1.16.1+build.21 +loader_version = 0.9.0+build.204 #Mod properties -mod_version = 1.0.9 +mod_version = 1.0.10 maven_group = dev.hephaestus archives_base_name = tinytweaks #Dependencies -fabric_version = 0.14.0+build.371-1.16 -cloth_config_version = 4.5.6 +fabric_version = 0.14.1+build.372-1.16 +cloth_config_version = 4.6.0 auto_config_version = 3.2.0-unstable # Dev Mods -mod_menu_version = 1.12.0+build.14 \ No newline at end of file +mod_menu_version = 1.14.0+build.24 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java index 3168115..b09df76 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java @@ -42,7 +42,7 @@ public void plantSaplings(CallbackInfo ci) { if (Tweaks.CONFIG.saplingsAutoPlant && this.age > 20) { ItemStack stack = this.getStack(); BlockPos pos = this.getBlockPos(); - if (stack.getItem().isIn(ItemTags.SAPLINGS) && this.getBlockPos() != triedToPlantAt) { + if (stack.getItem().isIn(ItemTags.SAPLINGS) && this.getBlockPos() != triedToPlantAt && world.getFluidState(pos).isEmpty()) { stack.useOnBlock(new ItemPlacementContext(world, null, null, stack, world.rayTrace( new RayTraceContext( new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), From c1d55e865952627f082b8575aa4a72d96a6dd78b Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 14 Jul 2020 12:36:05 -0700 Subject: [PATCH 14/53] Fixes Wither Rose crash. Flowers are now unaffected by the "Plant Hitboxes" tweak. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 2 +- .../tweaks/mixin/block/FlowerBlockMixin.java | 29 ------------------- src/main/resources/tweaks.mixins.json | 1 - 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index a98dfca..259010f 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -84,7 +84,7 @@ public static class Rejuvenation { public boolean enabled = true; @ConfigEntry.Gui.Tooltip(count = 2) - public double growthRate = 0.025D; + public double growthRate = 0.0125D; @ConfigEntry.Gui.Tooltip(count = 2) public float longGrass = 0.01F; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java deleted file mode 100644 index 32970cc..0000000 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/FlowerBlockMixin.java +++ /dev/null @@ -1,29 +0,0 @@ -package dev.hephaestus.tweaks.mixin.block; - -import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.*; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(FlowerBlock.class) -public class FlowerBlockMixin extends PlantBlock { - @Shadow @Final protected static VoxelShape SHAPE; - - protected FlowerBlockMixin(Settings settings) { - super(settings); - } - - @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { - if (!Tweaks.CONFIG.plantHitboxes && !context.isHolding(Items.SHEARS)) - return VoxelShapes.empty(); - else - return SHAPE; - } -} \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index c4c42aa..a5485ad 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -11,7 +11,6 @@ "block.DoorBlockMixin", "block.FernBlockMixin", "block.FireBlockMixin", - "block.FlowerBlockMixin", "block.LanternResistanceMixin", "block.LeavesBlockMixin", "block.LilyPadBlockMixin", From 8dedb77bcebfd4cf12f270e91e0e50a1c28172b9 Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 14 Jul 2020 14:19:59 -0700 Subject: [PATCH 15/53] Added a new tweak: Nether Rejuvenation. Nylium and other nether plants now spread in the Nether! --- build.gradle | 6 ++ .../dev/hephaestus/tweaks/TweaksConfig.java | 24 ++++++- .../tweaks/mixin/block/NyliumBlockMixin.java | 71 +++++++++++++++++++ .../mixin/block/RedstoneTorchMixin.java | 21 ------ .../tweaks/mixin/item/BucketItemMixin.java | 3 +- .../assets/tinytweaks/lang/en_us.json | 19 ++++- src/main/resources/tweaks.mixins.json | 4 +- 7 files changed, 118 insertions(+), 30 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java delete mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java diff --git a/build.gradle b/build.gradle index 54dc05e..b65344f 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,10 @@ repositories { maven { url = "https://www.cursemaven.com" } + maven { + url = "http://maven.fabricmc.net/" + name = "Fabric" + } } dependencies { @@ -29,8 +33,10 @@ dependencies { compileOnly "com.google.code.findbugs:jsr305:3.0.2" modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}" + modImplementation "net.fabricmc:fabric-language-kotlin:1.3.72+build.1" modImplementation "curse.maven:sodium:3003093" modImplementation "curse.maven:lithium:3000628" + modImplementation "curse.maven:makkit:2986981" modApi "me.shedaniel.cloth:config-2:${project.cloth_config_version}" include "me.shedaniel.cloth:config-2:${project.cloth_config_version}" diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 259010f..50a4eee 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -3,6 +3,7 @@ import me.sargunvohra.mcmods.autoconfig1u.ConfigData; import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry; +import sun.nio.ch.Net; @Config(name = "tinytweaks") @Config.Gui.Background("minecraft:textures/block/hay_block_side.png") @@ -49,6 +50,11 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.Tooltip public boolean breedWildWolves = true; + // - Nether! -------------------------------------------------------------- + @ConfigEntry.Category("nether") + @ConfigEntry.Gui.CollapsibleObject + public NetherRejuvenation netherRejuvenation = new NetherRejuvenation(); + // - Miscellaneous! ------------------------------------------------------- @ConfigEntry.Category("misc") @ConfigEntry.Gui.CollapsibleObject @@ -76,9 +82,6 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Category("misc") public boolean bubbleColumnsFlow = false; - @ConfigEntry.Category("debug") - public boolean grassDestroysRedstoneTorches = false; - public static class Rejuvenation { @ConfigEntry.Gui.Tooltip public boolean enabled = true; @@ -93,6 +96,21 @@ public static class Rejuvenation { public boolean saplings = true; } + public static class NetherRejuvenation { + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean enabled = true; + + @ConfigEntry.Gui.Tooltip(count = 2) + public double growthRate = 0.0125D; + + @ConfigEntry.Gui.Tooltip(count = 2) + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int sproutRootsRatio = 75; + + @ConfigEntry.Gui.Tooltip(count = 2) + public double vinesChance = 0.01; + } + public static class LeavesConfig { public boolean collide = false; @ConfigEntry.Gui.Tooltip diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java new file mode 100644 index 0000000..f93858f --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java @@ -0,0 +1,71 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.*; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldView; +import net.minecraft.world.biome.Biomes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Random; + +@Mixin(NyliumBlock.class) +public abstract class NyliumBlockMixin { + @Shadow private static boolean stayAlive(BlockState state, WorldView world, BlockPos pos) {return true;} + + private static boolean canSpread(BlockState state, WorldView worldView, BlockPos pos) { + BlockPos blockPos = pos.up(); + BlockState blockState = worldView.getBlockState(blockPos); + return blockState.isAir() && + (state.getBlock() == Blocks.WARPED_NYLIUM && worldView.getBiome(pos) == Biomes.WARPED_FOREST || + state.getBlock() == Blocks.CRIMSON_NYLIUM && worldView.getBiome(pos) == Biomes.CRIMSON_FOREST); + } + + @Inject(method = "randomTick", at = @At("TAIL")) + private void spread(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { + if (Tweaks.CONFIG.netherRejuvenation.enabled && stayAlive(state, world, pos)) { + int friends = 0; + + for (int x = -1; x <= 1; x++) { + for (int y = 0; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + Block friend = world.getBlockState(pos.add(x, y, z)).getBlock(); + if (friend instanceof FernBlock || friend instanceof TallPlantBlock) { + friends++; + friends *= 1.25; + } + } + } + } + + if (world.getBlockState(pos.up()).isAir() && random.nextFloat() < Tweaks.CONFIG.netherRejuvenation.growthRate + 0.2 * (friends)) { + float f = random.nextFloat(); + double ratio = Tweaks.CONFIG.netherRejuvenation.sproutRootsRatio / 100D; + Block block; + + if (f < Tweaks.CONFIG.netherRejuvenation.vinesChance && state.isOf(Blocks.WARPED_NYLIUM)) { + block = Blocks.TWISTING_VINES; + } else if (f > ratio) { + block = state.isOf(Blocks.CRIMSON_NYLIUM) ? Blocks.CRIMSON_ROOTS : Blocks.WARPED_ROOTS; + } else { + block = state.isOf(Blocks.CRIMSON_NYLIUM) ? Blocks.CRIMSON_ROOTS : Blocks.NETHER_SPROUTS; + } + + world.setBlockState(pos.up(), block.getDefaultState()); + } else { + for(int i = 0; i < 4; ++i) { + BlockPos blockPos = pos.add(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); + + if (world.getBlockState(blockPos).isOf(Blocks.NETHERRACK) && canSpread(state, world, blockPos)) { + world.setBlockState(blockPos, state); + } + } + } + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java deleted file mode 100644 index e7b5785..0000000 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/RedstoneTorchMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package dev.hephaestus.tweaks.mixin.block; - -import dev.hephaestus.tweaks.Tweaks; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.block.*; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldView; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(RedstoneTorchBlock.class) -public class RedstoneTorchMixin extends TorchBlock { - protected RedstoneTorchMixin(Settings settings, ParticleEffect particle) { - super(settings, particle); - } - - @Override - public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return ((!Tweaks.CONFIG.grassDestroysRedstoneTorches) || world.getBlockState(pos.down()).getBlock() != Blocks.GRASS_BLOCK) && super.canPlaceAt(state, world, pos); - } -} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java index 0aaff23..f6040e8 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/item/BucketItemMixin.java @@ -1,5 +1,6 @@ package dev.hephaestus.tweaks.mixin.item; +import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -36,7 +37,7 @@ private Block change(BlockState blockState) { @Redirect(method = "placeFluid", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) private boolean placeBubbleColumnIfPossible(World world, BlockPos pos, BlockState state, int flags) { - if (state.getFluidState().getFluid() == Fluids.WATER) { + if (!Tweaks.CONFIG.bubbleColumnsFlow && state.getFluidState().getFluid() == Fluids.WATER) { BlockState downState = world.getBlockState(pos.down()); if (downState.getBlock() == Blocks.BUBBLE_COLUMN) state = downState; diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index e7b3acf..efbd710 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -3,8 +3,8 @@ "text.autoconfig.boolean.value.true": "On", "text.autoconfig.tinytweaks.category.plants": "Plants", "text.autoconfig.tinytweaks.category.animals": "Animals", + "text.autoconfig.tinytweaks.category.nether": "Nether", "text.autoconfig.tinytweaks.category.misc": "Miscellaneous", - "text.autoconfig.tinytweaks.category.debug": "Debug", "text.autoconfig.tinytweaks.option.easyHarvestCrops": "Easy Harvest Crops", "text.autoconfig.tinytweaks.option.easyHarvestCrops.@Tooltip": "Right clicking fully grown crops harvests and replants them", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane": "Easy Harvest Sugarcane", @@ -63,7 +63,18 @@ "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[0]": "Doors and trapdoors open adjacent doors and trapdoors of the same type", "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[1]": "Works when opened by hand or with redstone", "text.autoconfig.tinytweaks.option.bubbleColumnsFlow": "Bubble Columns Flow", - "text.autoconfig.tinytweaks.option.grassDestroysRedstoneTorches": "Grass Destroys Redstone Torches", + "text.autoconfig.tinytweaks.option.netherRejuvenation": "Nether Rejuvenation", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled": "Enabled", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[0]": "Causes nylium, roots, and nether sprouts to spread", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[1]": "Only spread within their respective biomes", + "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate.@Tooltip[0]": "Percent chance of roots/sprouts spreading", + "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", + "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio": "Ratio of Sprouts to Roots", + "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio.@Tooltip[0]": "0 is all sprouts and no roots, 100 is all roots and no sprouts", + "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio.@Tooltip[1]": "Only effects the Warped Forest biome", + "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance": "Vines Chance", + "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance.@Tooltip[0]": "Percent chance of warped vines spawning", + "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.true": "§aOn", @@ -87,6 +98,7 @@ "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.doubleDoors.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§cOff", @@ -109,5 +121,6 @@ "text.autoconfig.tinytweaks.option.mossyThings.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§cOff", - "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§cOff" + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§cOff" } \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index a5485ad..f1e4ffc 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -17,16 +17,16 @@ "block.MoistBlocksMixin", "block.MoistObjectsMixin", "block.NetherWartBlockMixin", - "block.RedstoneTorchMixin", + "block.NyliumBlockMixin", "block.SignBlockMixin", "block.SpreadableBlockMixin", "block.SugarCaneMixin", "block.TallPlantBlockMixin", "block.TrapDoorMixin", + "entity.InteractableEntityMixin", "entity.ItemEntityMixin", "entity.LivingEntityMixin", "entity.ai.brain.task.FarmerVillagerTaskMixin", - "entity.InteractableEntityMixin", "entity.passive.ChickenEntityMixin", "entity.passive.CowEntityMixin", "entity.passive.HorseAndDonkeyMixin", From 935e41a95e9d52d95de3eb979c4de076a0b3de3a Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 14 Jul 2020 15:55:10 -0700 Subject: [PATCH 16/53] Added a new tweak: Soul fire is now blue when rendered on the screen and on entities lit on fire by soul fire. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 4 ++ .../gui/hud/InGameOverlayRendererMixin.java | 33 ++++++++++ .../entity/EntityRenderDispatcherMixin.java | 39 ++++++++++++ .../client/render/model/ModelLoaderMixin.java | 23 +++++++ .../tweaks/mixin/entity/SetSoulFireType.java | 63 +++++++++++++++++++ .../dev/hephaestus/tweaks/util/SoulFire.java | 33 ++++++++++ .../assets/tinytweaks/lang/en_us.json | 3 + src/main/resources/tweaks.mixins.json | 4 ++ 8 files changed, 202 insertions(+) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/client/render/model/ModelLoaderMixin.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java create mode 100644 src/main/java/dev/hephaestus/tweaks/util/SoulFire.java diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 50a4eee..5fd4903 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -55,6 +55,10 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.CollapsibleObject public NetherRejuvenation netherRejuvenation = new NetherRejuvenation(); + @ConfigEntry.Category("nether") + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean blueSoulFireEffects = true; + // - Miscellaneous! ------------------------------------------------------- @ConfigEntry.Category("misc") @ConfigEntry.Gui.CollapsibleObject diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java new file mode 100644 index 0000000..abc7aef --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java @@ -0,0 +1,33 @@ +package dev.hephaestus.tweaks.mixin.client.gui.hud; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.SoulFire; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.hud.InGameOverlayRenderer; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.util.SpriteIdentifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Environment(EnvType.CLIENT) +@Mixin(InGameOverlayRenderer.class) +public class InGameOverlayRendererMixin { + @Redirect(method = "renderFireOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;")) + private static Sprite getSoulFireSprite(SpriteIdentifier spriteIdentifier) { + ClientPlayerEntity playerEntity = MinecraftClient.getInstance().player; + + if (playerEntity != null && Tweaks.CONFIG.blueSoulFireEffects) { + SoulFire.FireTypeModifier.of(playerEntity).updateFireType(); + + if (SoulFire.FireTypeModifier.of(playerEntity).getFireType() == SoulFire.FireType.SOUL) { + return SoulFire.getSprite(); + } + } + + return spriteIdentifier.getSprite(); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java new file mode 100644 index 0000000..b280605 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java @@ -0,0 +1,39 @@ +package dev.hephaestus.tweaks.mixin.client.render.entity; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.SoulFire; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.util.SpriteIdentifier; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Environment(EnvType.CLIENT) +@Mixin(EntityRenderDispatcher.class) +public class EntityRenderDispatcherMixin { + @Unique private Entity renderedEntity; + + @Inject(method = "renderFire", at = @At("HEAD")) + private void captureEntity(MatrixStack matrices, VertexConsumerProvider vertexConsumers, Entity entity, CallbackInfo ci) { + this.renderedEntity = entity; + } + + @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;")) + private Sprite renderSoulFire(SpriteIdentifier spriteIdentifier) { + SoulFire.FireTypeModifier.of(renderedEntity).updateFireType(); + if (this.renderedEntity != null && Tweaks.CONFIG.blueSoulFireEffects && SoulFire.FireTypeModifier.of(this.renderedEntity).getFireType() == SoulFire.FireType.SOUL) { + return SoulFire.getSprite(); + } else { + return spriteIdentifier.getSprite(); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/model/ModelLoaderMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/model/ModelLoaderMixin.java new file mode 100644 index 0000000..8e3a91a --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/model/ModelLoaderMixin.java @@ -0,0 +1,23 @@ +package dev.hephaestus.tweaks.mixin.client.render.model; + +import dev.hephaestus.tweaks.util.SoulFire; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.render.model.ModelLoader; +import net.minecraft.client.util.SpriteIdentifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.HashSet; + +@Environment(EnvType.CLIENT) +@Mixin(ModelLoader.class) +public class ModelLoaderMixin { + @Inject(method = "method_24150(Ljava/util/HashSet;)V", at = @At("TAIL")) + private static void addSoulFireToHashSet(HashSet hashSet, CallbackInfo ci) { + hashSet.add(SoulFire.SPRITE_0); + hashSet.add(SoulFire.SPRITE_1); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java new file mode 100644 index 0000000..15be0fe --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java @@ -0,0 +1,63 @@ +package dev.hephaestus.tweaks.mixin.entity; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.SoulFire; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Entity.class) +@Environment(EnvType.CLIENT) +public abstract class SetSoulFireType implements SoulFire.FireTypeModifier { + @Shadow public World world; + + @Shadow public abstract Box getBoundingBox(); + + private SoulFire.FireType fireType = SoulFire.FireType.NORMAL; + + @Override + public SoulFire.FireType getFireType() { + return this.fireType; + } + + @Override + public void updateFireType() { + if (this.world.isClient && Tweaks.CONFIG.blueSoulFireEffects) { + Box box = this.getBoundingBox(); + BlockPos blockPos = new BlockPos(box.minX + 0.001D, box.minY + 0.001D, box.minZ + 0.001D); + BlockPos blockPos2 = new BlockPos(box.maxX - 0.001D, box.maxY - 0.001D, box.maxZ - 0.001D); + BlockPos.Mutable mutable = new BlockPos.Mutable(); + if (this.world.isRegionLoaded(blockPos, blockPos2)) { + for (int i = blockPos.getX(); i <= blockPos2.getX(); ++i) { + for (int j = blockPos.getY(); j <= blockPos2.getY(); ++j) { + for (int k = blockPos.getZ(); k <= blockPos2.getZ(); ++k) { + mutable.set(i, j, k); + + Block fire = this.world.getBlockState(mutable).getBlock(); + if (fire == Blocks.SOUL_FIRE) { + this.fireType = SoulFire.FireType.SOUL; + } else if (fire == Blocks.FIRE) { + this.fireType = SoulFire.FireType.NORMAL; + } + } + } + } + } + } + } + + @Inject(method = "baseTick", at = @At("HEAD")) + private void setFireType(CallbackInfo ci) { + this.updateFireType(); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java new file mode 100644 index 0000000..2b3d67f --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java @@ -0,0 +1,33 @@ +package dev.hephaestus.tweaks.util; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.texture.SpriteAtlasTexture; +import net.minecraft.client.util.SpriteIdentifier; +import net.minecraft.util.Identifier; + +@Environment(EnvType.CLIENT) +public class SoulFire { + public static final SpriteIdentifier SPRITE_0 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_0")); + public static final SpriteIdentifier SPRITE_1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_1")); + + public static Sprite getSprite() { + return MinecraftClient.getInstance().isInSingleplayer() ? SPRITE_0.getSprite() : SPRITE_1.getSprite(); + } + + public enum FireType { + NORMAL, + SOUL + } + + public interface FireTypeModifier { + static FireTypeModifier of(Object object) { + return (FireTypeModifier) object; + } + + FireType getFireType(); + void updateFireType(); + } +} diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index efbd710..3ee441f 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -75,6 +75,9 @@ "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance": "Vines Chance", "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance.@Tooltip[0]": "Percent chance of warped vines spawning", "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects": "Improved Soul Fire", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[0]": "Makes fire rendered on the hud and entities on fire blue", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[1]": "when lit on fire by soul fire", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.true": "§aOn", diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index f1e4ffc..155e631 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -41,12 +41,16 @@ "item.ShovelMixin" ], "client": [ + "client.gui.hud.InGameOverlayRendererMixin", "client.gui.screen.ingame.SignEditScreenMixin", "client.render.CameraMixin", "client.render.entity.BoatEntityRendererMixin", + "client.render.entity.EntityRenderDispatcherMixin", "client.render.entity.PlayerEntityRendererMixin", + "client.render.model.ModelLoaderMixin", "dev.ChestBlockEntityRendererMixin", "dev.ShulkerBoxEntityRendererMixin", + "entity.SetSoulFireType", "prod.ChestBlockEntityRendererMixin", "prod.ShulkerBoxEntityRendererMixin" ], From 9a1546685cb01b5add303edeab3cfa848305c8e3 Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 14 Jul 2020 18:23:31 -0700 Subject: [PATCH 17/53] Added a new tweak: Soul fire is now blue when rendered on the screen and on entities lit on fire by soul fire. --- .../gui/hud/InGameOverlayRendererMixin.java | 2 +- .../entity/EntityRenderDispatcherMixin.java | 16 +++++++++++++--- .../dev/hephaestus/tweaks/util/SoulFire.java | 6 ------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java index abc7aef..bf391f4 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java @@ -24,7 +24,7 @@ private static Sprite getSoulFireSprite(SpriteIdentifier spriteIdentifier) { SoulFire.FireTypeModifier.of(playerEntity).updateFireType(); if (SoulFire.FireTypeModifier.of(playerEntity).getFireType() == SoulFire.FireType.SOUL) { - return SoulFire.getSprite(); + return SoulFire.SPRITE_1.getSprite(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java index b280605..041705a 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java @@ -27,11 +27,21 @@ private void captureEntity(MatrixStack matrices, VertexConsumerProvider vertexCo this.renderedEntity = entity; } - @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;")) - private Sprite renderSoulFire(SpriteIdentifier spriteIdentifier) { + @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;", ordinal = 0)) + private Sprite renderSoulFire0(SpriteIdentifier spriteIdentifier) { SoulFire.FireTypeModifier.of(renderedEntity).updateFireType(); if (this.renderedEntity != null && Tweaks.CONFIG.blueSoulFireEffects && SoulFire.FireTypeModifier.of(this.renderedEntity).getFireType() == SoulFire.FireType.SOUL) { - return SoulFire.getSprite(); + return SoulFire.SPRITE_0.getSprite(); + } else { + return spriteIdentifier.getSprite(); + } + } + + @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;", ordinal = 1)) + private Sprite renderSoulFire1(SpriteIdentifier spriteIdentifier) { + SoulFire.FireTypeModifier.of(renderedEntity).updateFireType(); + if (this.renderedEntity != null && Tweaks.CONFIG.blueSoulFireEffects && SoulFire.FireTypeModifier.of(this.renderedEntity).getFireType() == SoulFire.FireType.SOUL) { + return SoulFire.SPRITE_1.getSprite(); } else { return spriteIdentifier.getSprite(); } diff --git a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java index 2b3d67f..0a2ebdb 100644 --- a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java +++ b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java @@ -2,8 +2,6 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.util.Identifier; @@ -13,10 +11,6 @@ public class SoulFire { public static final SpriteIdentifier SPRITE_0 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_0")); public static final SpriteIdentifier SPRITE_1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_1")); - public static Sprite getSprite() { - return MinecraftClient.getInstance().isInSingleplayer() ? SPRITE_0.getSprite() : SPRITE_1.getSprite(); - } - public enum FireType { NORMAL, SOUL From 8a86f8671596f3e767cf16a64df8cd53a57f926a Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 14 Jul 2020 18:23:31 -0700 Subject: [PATCH 18/53] Added a new tweak: Soul fire is now blue when rendered on the screen and on entities lit on fire by soul fire. --- .../gui/hud/InGameOverlayRendererMixin.java | 2 +- .../entity/EntityRenderDispatcherMixin.java | 16 +++++++++++++--- .../dev/hephaestus/tweaks/util/SoulFire.java | 6 ------ .../resources/assets/tinytweaks/lang/en_us.json | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java index abc7aef..bf391f4 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java @@ -24,7 +24,7 @@ private static Sprite getSoulFireSprite(SpriteIdentifier spriteIdentifier) { SoulFire.FireTypeModifier.of(playerEntity).updateFireType(); if (SoulFire.FireTypeModifier.of(playerEntity).getFireType() == SoulFire.FireType.SOUL) { - return SoulFire.getSprite(); + return SoulFire.SPRITE_1.getSprite(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java index b280605..041705a 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java @@ -27,11 +27,21 @@ private void captureEntity(MatrixStack matrices, VertexConsumerProvider vertexCo this.renderedEntity = entity; } - @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;")) - private Sprite renderSoulFire(SpriteIdentifier spriteIdentifier) { + @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;", ordinal = 0)) + private Sprite renderSoulFire0(SpriteIdentifier spriteIdentifier) { SoulFire.FireTypeModifier.of(renderedEntity).updateFireType(); if (this.renderedEntity != null && Tweaks.CONFIG.blueSoulFireEffects && SoulFire.FireTypeModifier.of(this.renderedEntity).getFireType() == SoulFire.FireType.SOUL) { - return SoulFire.getSprite(); + return SoulFire.SPRITE_0.getSprite(); + } else { + return spriteIdentifier.getSprite(); + } + } + + @Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;", ordinal = 1)) + private Sprite renderSoulFire1(SpriteIdentifier spriteIdentifier) { + SoulFire.FireTypeModifier.of(renderedEntity).updateFireType(); + if (this.renderedEntity != null && Tweaks.CONFIG.blueSoulFireEffects && SoulFire.FireTypeModifier.of(this.renderedEntity).getFireType() == SoulFire.FireType.SOUL) { + return SoulFire.SPRITE_1.getSprite(); } else { return spriteIdentifier.getSprite(); } diff --git a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java index 2b3d67f..0a2ebdb 100644 --- a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java +++ b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java @@ -2,8 +2,6 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.util.Identifier; @@ -13,10 +11,6 @@ public class SoulFire { public static final SpriteIdentifier SPRITE_0 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_0")); public static final SpriteIdentifier SPRITE_1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_1")); - public static Sprite getSprite() { - return MinecraftClient.getInstance().isInSingleplayer() ? SPRITE_0.getSprite() : SPRITE_1.getSprite(); - } - public enum FireType { NORMAL, SOUL diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 3ee441f..09f18a8 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -67,6 +67,7 @@ "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled": "Enabled", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[0]": "Causes nylium, roots, and nether sprouts to spread", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[1]": "Only spread within their respective biomes", + "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate": "Growth Rate", "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate.@Tooltip[0]": "Percent chance of roots/sprouts spreading", "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio": "Ratio of Sprouts to Roots", From 8009c8dd8ee94e08fade00a89c73a24eae5942c2 Mon Sep 17 00:00:00 2001 From: Haven Date: Fri, 17 Jul 2020 11:49:27 -0700 Subject: [PATCH 19/53] Bug fixes: * No longer crashes when destroying grass * Can now ignite villagers, wandering traders, and piglins with flint and steel * No longer crashes with Optifine installed --- gradle.properties | 2 +- .../client/particle/ParticleManagerMixin.java | 20 +++++++++++++++++++ .../mixin/entity/InteractableEntityMixin.java | 9 ++++----- src/main/resources/tweaks.mixins.json | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java diff --git a/gradle.properties b/gradle.properties index 6ef77c8..0925664 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings = 1.16.1+build.21 loader_version = 0.9.0+build.204 #Mod properties -mod_version = 1.0.10 +mod_version = 1.0.11 maven_group = dev.hephaestus archives_base_name = tinytweaks diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java new file mode 100644 index 0000000..9a7bb50 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java @@ -0,0 +1,20 @@ +package dev.hephaestus.tweaks.mixin.client.particle; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.particle.ParticleManager; +import net.minecraft.util.math.Box; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Environment(EnvType.CLIENT) +@Mixin(ParticleManager.class) +public class ParticleManagerMixin { + @Redirect(method = "addBlockBreakingParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/shape/VoxelShape;getBoundingBox()Lnet/minecraft/util/math/Box;")) + private Box makeParticlesForEmptyBlocks(VoxelShape voxelShape) { + return voxelShape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : voxelShape.getBoundingBox(); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java index c7562b9..a54bc37 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java @@ -1,5 +1,8 @@ package dev.hephaestus.tweaks.mixin.entity; +import net.minecraft.entity.mob.PiglinEntity; +import net.minecraft.entity.passive.VillagerEntity; +import net.minecraft.entity.passive.WanderingTraderEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Items; import net.minecraft.util.ActionResult; @@ -9,11 +12,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = { - "net/minecraft/entity/passive/VillagerEntity", - "net/minecraft/entity/passive/WanderingTraderEntity", - "net/minecraft/entity/mob/PiglinEntity" -}) +@Mixin(value = {WanderingTraderEntity.class, PiglinEntity.class, VillagerEntity.class}) public class InteractableEntityMixin { @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) private void useFlintAndSteel(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 155e631..70b22c8 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -43,11 +43,11 @@ "client": [ "client.gui.hud.InGameOverlayRendererMixin", "client.gui.screen.ingame.SignEditScreenMixin", + "client.particle.ParticleManagerMixin", "client.render.CameraMixin", "client.render.entity.BoatEntityRendererMixin", "client.render.entity.EntityRenderDispatcherMixin", "client.render.entity.PlayerEntityRendererMixin", - "client.render.model.ModelLoaderMixin", "dev.ChestBlockEntityRendererMixin", "dev.ShulkerBoxEntityRendererMixin", "entity.SetSoulFireType", From aa325c77fb99d9214eff1e6050d744fe0d55f794 Mon Sep 17 00:00:00 2001 From: Haven Date: Fri, 17 Jul 2020 12:55:43 -0700 Subject: [PATCH 20/53] Changed grass and root spreading methods to be entirely configurable instead of having a base value. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 14 ++++++++---- .../tweaks/mixin/block/NyliumBlockMixin.java | 6 ++--- .../mixin/block/SpreadableBlockMixin.java | 8 +++---- .../assets/tinytweaks/lang/en_us.json | 22 ++++++++++++++----- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 5fd4903..d931d26 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -90,8 +90,11 @@ public static class Rejuvenation { @ConfigEntry.Gui.Tooltip public boolean enabled = true; - @ConfigEntry.Gui.Tooltip(count = 2) - public double growthRate = 0.0125D; + @ConfigEntry.Gui.Tooltip + public double grassGrowthRate = 0.0125D; + + @ConfigEntry.Gui.Tooltip(count = 5) + public double thePowerOfFriendship = 1.25; @ConfigEntry.Gui.Tooltip(count = 2) public float longGrass = 0.01F; @@ -104,8 +107,11 @@ public static class NetherRejuvenation { @ConfigEntry.Gui.Tooltip(count = 2) public boolean enabled = true; - @ConfigEntry.Gui.Tooltip(count = 2) - public double growthRate = 0.0125D; + @ConfigEntry.Gui.Tooltip + public double rootsGrowthRate = 0.0125D; + + @ConfigEntry.Gui.Tooltip(count = 5) + public double thePowerOfFriendship = 1.25; @ConfigEntry.Gui.Tooltip(count = 2) @ConfigEntry.BoundedDiscrete(min = 0, max = 100) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java index f93858f..0af0b38 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java @@ -35,15 +35,15 @@ private void spread(BlockState state, ServerWorld world, BlockPos pos, Random ra for (int y = 0; y <= 1; y++) { for (int z = -1; z <= 1; z++) { Block friend = world.getBlockState(pos.add(x, y, z)).getBlock(); - if (friend instanceof FernBlock || friend instanceof TallPlantBlock) { + if (friend instanceof RootsBlock || friend instanceof SproutsBlock) { friends++; - friends *= 1.25; + friends *= Tweaks.CONFIG.netherRejuvenation.thePowerOfFriendship; } } } } - if (world.getBlockState(pos.up()).isAir() && random.nextFloat() < Tweaks.CONFIG.netherRejuvenation.growthRate + 0.2 * (friends)) { + if (world.getBlockState(pos.up()).isAir() && random.nextFloat() < Tweaks.CONFIG.netherRejuvenation.rootsGrowthRate * (friends)) { float f = random.nextFloat(); double ratio = Tweaks.CONFIG.netherRejuvenation.sproutRootsRatio / 100D; Block block; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java index ec7faf2..12c8980 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java @@ -18,7 +18,7 @@ public class SpreadableBlockMixin { public void growGrass(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { if (Tweaks.CONFIG.rejuvenation.enabled && state.getBlock() == Blocks.GRASS_BLOCK) { Block above = world.getBlockState(pos.up()).getBlock(); - int friends = 0; + int friends = 1; for (int x = -1; x <= 1; x++) { @@ -27,19 +27,19 @@ public void growGrass(BlockState state, ServerWorld world, BlockPos pos, Random Block friend = world.getBlockState(pos.add(x, y, z)).getBlock(); if (friend instanceof FernBlock || friend instanceof TallPlantBlock) { friends++; - friends *= 1.25; + friends *= Tweaks.CONFIG.rejuvenation.thePowerOfFriendship; } } } } - if (above == Blocks.AIR && random.nextFloat() < Tweaks.CONFIG.rejuvenation.growthRate + 0.2 * (friends)) { + if (above == Blocks.AIR && random.nextFloat() < Tweaks.CONFIG.rejuvenation.grassGrowthRate * (friends)) { world.setBlockState(pos.up(), Blocks.GRASS.getDefaultState()); ci.cancel(); } else if (Tweaks.CONFIG.rejuvenation.longGrass > 0.000001 && above == Blocks.GRASS) { Random tallGrassRandom = new Random(); tallGrassRandom.setSeed(pos.asLong()); - if (tallGrassRandom.nextFloat() < Tweaks.CONFIG.rejuvenation.longGrass && random.nextFloat() < Tweaks.CONFIG.rejuvenation.growthRate) { + if (tallGrassRandom.nextFloat() < Tweaks.CONFIG.rejuvenation.longGrass && random.nextFloat() < Tweaks.CONFIG.rejuvenation.grassGrowthRate) { ((TallPlantBlock) Blocks.TALL_GRASS).placeAt(world, pos.up(), 2); ci.cancel(); } diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 09f18a8..e95587b 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -28,9 +28,14 @@ "text.autoconfig.tinytweaks.option.rejuvenation": "Rejuvenation", "text.autoconfig.tinytweaks.option.rejuvenation.enabled": "Enabled", "text.autoconfig.tinytweaks.option.rejuvenation.enabled.@Tooltip": "Grass grows taller over time", - "text.autoconfig.tinytweaks.option.rejuvenation.growthRate": "Grass Growth Rate", - "text.autoconfig.tinytweaks.option.rejuvenation.growthRate.@Tooltip[0]": "Percent chance of grass spreading", - "text.autoconfig.tinytweaks.option.rejuvenation.growthRate.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", + "text.autoconfig.tinytweaks.option.rejuvenation.grassGrowthRate": "Grass Growth Rate", + "text.autoconfig.tinytweaks.option.rejuvenation.grassGrowthRate.@Tooltip": "Percent chance of grass spreading", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship": "The Power of Friendship", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[0]": "Changes how high of an influence adjacent", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[1]": "grass has on the chance of grass growing", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[2]": "", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[3]": "§7§oRepresents the power of a pseudo-", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[4]": "§7§oexponential function, so be careful", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass": "Long Grass", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.@Tooltip[0]": "Percent of grass that can grow into tall grass", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.@Tooltip[1]": "0.0 is disabled, 0.01 is default, 1.0 is all of them", @@ -67,9 +72,14 @@ "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled": "Enabled", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[0]": "Causes nylium, roots, and nether sprouts to spread", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[1]": "Only spread within their respective biomes", - "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate": "Growth Rate", - "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate.@Tooltip[0]": "Percent chance of roots/sprouts spreading", - "text.autoconfig.tinytweaks.option.netherRejuvenation.growthRate.@Tooltip[1]": "0.0 is never, 1.0 is every random tick", + "text.autoconfig.tinytweaks.option.netherRejuvenation.rootsGrowthRate": "Growth Rate", + "text.autoconfig.tinytweaks.option.netherRejuvenation.rootsGrowthRate.@Tooltip": "Percent chance of roots/sprouts spreading", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship": "The Power of Friendship", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[0]": "Changes how high of an influence adjacent", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[1]": "roots have on the chance of roots growing", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[2]": "", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[3]": "§7§oRepresents the power of a pseudo-", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[4]": "§7§oexponential function, so be careful", "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio": "Ratio of Sprouts to Roots", "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio.@Tooltip[0]": "0 is all sprouts and no roots, 100 is all roots and no sprouts", "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio.@Tooltip[1]": "Only effects the Warped Forest biome", From a2684c31ca912dc9456525031fa3091820e7a522 Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 18 Jul 2020 13:30:30 -0700 Subject: [PATCH 21/53] Forgot to make the config option for mossy things apply to water blocks (previously only prevented changing in rain). Also needed to adjust the mixin targets for making cobblestone and such MoistBlocks. --- src/main/java/dev/hephaestus/tweaks/TweaksConfig.java | 3 +-- src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java | 2 +- .../dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java | 6 +++--- .../dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java | 3 ++- src/main/resources/assets/tinytweaks/lang/en_us.json | 6 ++++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index d931d26..10303ea 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -3,7 +3,6 @@ import me.sargunvohra.mcmods.autoconfig1u.ConfigData; import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry; -import sun.nio.ch.Net; @Config(name = "tinytweaks") @Config.Gui.Background("minecraft:textures/block/hay_block_side.png") @@ -73,7 +72,7 @@ public class TweaksConfig implements ConfigData { public NamesAndThings namesAndThings = new NamesAndThings(); @ConfigEntry.Category("misc") - @ConfigEntry.Gui.Tooltip(count = 2) + @ConfigEntry.Gui.Tooltip(count = 4) public boolean mossyThings = true; @ConfigEntry.Category("misc") diff --git a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java index 5d19f94..7e58a01 100644 --- a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java +++ b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java @@ -30,7 +30,7 @@ public static void randomTick(BlockState state, ServerWorld world, BlockPos pos) } if (isSkyVisible) { - if (world.isRaining()) { + if (world.isRaining() && world.getBiome(pos).getRainfall() > 0) { world.setBlockState(pos, Moistener.moisten(state)); } else if (world.isDay() && !isWaterNearby) { world.setBlockState(pos, Moistener.dry(state)); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java index 0f3a68e..5ed70a3 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java @@ -16,19 +16,19 @@ private static Block moistenCobblestone(Block.Settings settings) { } @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 40)) + @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 41)) private static Block dryMossyCobblestone(Block.Settings settings) { return new MoistBlock(settings); } @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 47)) + @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 48)) private static Block moistenStoneBricks(Block.Settings settings) { return new MoistBlock(settings); } @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 48)) + @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 49)) private static Block dryStoneBricks(Block.Settings settings) { return new MoistBlock(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java index b110ced..9c30dff 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/fluid/WaterFluidMixin.java @@ -1,5 +1,6 @@ package dev.hephaestus.tweaks.mixin.fluid; +import dev.hephaestus.tweaks.Tweaks; import dev.hephaestus.tweaks.block.Moistener; import net.minecraft.block.BlockState; import net.minecraft.fluid.Fluid; @@ -15,7 +16,7 @@ public abstract class WaterFluidMixin extends Fluid { @Override protected void onRandomTick(World world, BlockPos pos, FluidState state, Random random) { - if (this.isStill(state)) { + if (this.isStill(state) && Tweaks.CONFIG.mossyThings) { Iterable adjacent = BlockPos.iterate(pos.down().north().west(), pos.south().east()); for (BlockPos potentialPos : adjacent) { diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index e95587b..637e624 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -61,8 +61,10 @@ "text.autoconfig.tinytweaks.option.betterLilyPads.@Tooltip[0]": "Allows boats to pass through lily pads without breaking them", "text.autoconfig.tinytweaks.option.betterLilyPads.@Tooltip[1]": "Also allows entities to rise through the bottom of a lily pad", "text.autoconfig.tinytweaks.option.mossyThings": "Mossy Things", - "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[0]": "Cobblestone, stone bricks, and their stairs/slabs/walls turn mossy when near water or in rain", - "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[1]": "Mossy cobblestone, stone bricks, and their stairs/slabs/walls turn normal in sunlight", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[0]": "Cobblestone, stone bricks, and their stairs/slabs/walls", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[1]": "turn mossy when near water or in rain", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[2]": "Mossy cobblestone, stone bricks, and their stairs/slabs/", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[3]": "walls turn normal in sunlight", "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal": "Burned Logs Drop Charcoal", "text.autoconfig.tinytweaks.option.doubleDoors": "Double Doors & Trapdoors", "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[0]": "Doors and trapdoors open adjacent doors and trapdoors of the same type", From 047725de8c700178ebb37542cec2bca7ed272249 Mon Sep 17 00:00:00 2001 From: Haven Date: Sun, 19 Jul 2020 23:59:51 -0700 Subject: [PATCH 22/53] Should fix #12 --- README.md | 3 +++ .../hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f427ec3..f406064 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,6 @@ A collection of small tweaks for Minecraft. * Editable Signs - No config for this one, just don't use it if you don't want it! * Entity Ignition - Right click mobs with flint and steel to light them on fire * Sturdy Lanterns - Gives lanterns a blast resistance of 6 (allows them to survive Ghast fireballs) + +## Contact Me +I can be found hanging out on the Fabric Discord as Haven King#2790. Feel free to shoot me a message there if you have any questions. \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java index 1fc143d..cfa0202 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java @@ -12,9 +12,9 @@ @Mixin(value = BubbleColumnBlock.class, priority = 2000) public class BubbleColumnBlockMixin { @Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/TickScheduler;schedule(Lnet/minecraft/util/math/BlockPos;Ljava/lang/Object;I)V")) - private void dontFluidTick(TickScheduler tickScheduler, BlockPos pos, Object object, int delay) { + private void dontFluidTick(TickScheduler tickScheduler, BlockPos pos, T object, int delay) { if (Tweaks.CONFIG.bubbleColumnsFlow) { - tickScheduler.schedule(pos, (Fluid) object, delay); + tickScheduler.schedule(pos, object, delay); } } } From ef6fcb829b2c8e98a59ea35db9d9a33309654c14 Mon Sep 17 00:00:00 2001 From: Haven King Date: Sat, 1 Aug 2020 00:09:52 -0700 Subject: [PATCH 23/53] Adds infinite cauldrons that can be made by right clicking a cauldron with a Heart of the Sea. --- build.gradle | 1 - .../dev/hephaestus/tweaks/TweaksConfig.java | 4 + .../mixin/block/CauldronBlockMixin.java | 103 ++++++++++++++++++ .../assets/tinytweaks/lang/en_us.json | 5 +- src/main/resources/tweaks.mixins.json | 1 + 5 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java diff --git a/build.gradle b/build.gradle index b65344f..8d0cc00 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,6 @@ dependencies { modImplementation "net.fabricmc:fabric-language-kotlin:1.3.72+build.1" modImplementation "curse.maven:sodium:3003093" modImplementation "curse.maven:lithium:3000628" - modImplementation "curse.maven:makkit:2986981" modApi "me.shedaniel.cloth:config-2:${project.cloth_config_version}" include "me.shedaniel.cloth:config-2:${project.cloth_config_version}" diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 10303ea..87a10b0 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -85,6 +85,10 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Category("misc") public boolean bubbleColumnsFlow = false; + @ConfigEntry.Category("misc") + @ConfigEntry.Gui.Tooltip + public boolean infiniteCauldrons = true; + public static class Rejuvenation { @ConfigEntry.Gui.Tooltip public boolean enabled = true; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java new file mode 100644 index 0000000..5c0977d --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java @@ -0,0 +1,103 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.CauldronBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Formatting; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Random; + +@Mixin(CauldronBlock.class) +public class CauldronBlockMixin extends Block { + @Unique private static final BooleanProperty INFINITE = BooleanProperty.of("infinite"); + + public CauldronBlockMixin(Settings settings) { + super(settings); + } + + @Inject(method = "", at = @At("TAIL")) + private void addInfiniteState(Block.Settings settings, CallbackInfo ci) { + this.setDefaultState(this.getDefaultState().with(INFINITE, false)); + } + + @Inject(method = "setLevel", at = @At("HEAD"), cancellable = true) + private void dontDecreaseLevelIfInfinite(World world, BlockPos pos, BlockState state, int level, CallbackInfo ci) { + if (level < state.get(Properties.LEVEL_3) && state.get(INFINITE)) { + ci.cancel(); + } + } + + @Inject(method = "appendProperties", at = @At("TAIL")) + private void addInfiniteState(StateManager.Builder builder, CallbackInfo ci) { + builder.add(INFINITE); + } + + @Unique private static boolean LAST_CAULDRON_INFINITE = false; + + @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) + private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + LAST_CAULDRON_INFINITE = false; + ItemStack stack = player.getStackInHand(hand); + + if (Tweaks.CONFIG.infiniteCauldrons && stack.getItem().equals(Items.HEART_OF_THE_SEA) && !state.get(INFINITE)) { + if (world.isClient) { + for(int int_1 = -2; int_1 <= 2; ++int_1) { + for(int int_2 = -2; int_2 <= 2; ++int_2) { + if (int_1 > -2 && int_1 < 2 && int_2 == -1) { + int_2 = 2; + } + + Random random = world.getRandom(); + for(int int_3 = 0; int_3 <= 1; ++int_3) { + world.addParticle(ParticleTypes.ENCHANT, (double)pos.getX() + 0.5D, (double)pos.getY() + 2.0D, (double)pos.getZ() + 0.5D, (double)((float)int_1 + random.nextFloat()) - 0.5D, (float)int_3 - random.nextFloat() - 1.0F, (double)((float)int_2 + random.nextFloat()) - 0.5D); + } + } + } + } else { + world.setBlockState(pos, state.with(INFINITE, true).with(Properties.LEVEL_3, 3)); + + if (!player.isCreative()) { + stack.decrement(1); + } + + world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1F, 1F); + player.sendMessage(new TranslatableText("block.cauldron.makeInfinite").styled(style -> style.withItalic(true).withColor(Formatting.AQUA)), true); + LAST_CAULDRON_INFINITE = true; + cir.setReturnValue(ActionResult.SUCCESS); + } + } else if (!Tweaks.CONFIG.infiniteCauldrons && state.get(INFINITE) && !world.isClient) { + world.setBlockState(pos, state.with(INFINITE, false)); + LAST_CAULDRON_INFINITE = false; + } else { + LAST_CAULDRON_INFINITE = state.get(INFINITE); + } + } + + @ModifyArg(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/CauldronBlock;setLevel(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)V"), index = 2) + private BlockState updateState(BlockState state) { + return state.with(INFINITE, LAST_CAULDRON_INFINITE); + } +} diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 637e624..3bc4d5f 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -91,6 +91,8 @@ "text.autoconfig.tinytweaks.option.blueSoulFireEffects": "Improved Soul Fire", "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[0]": "Makes fire rendered on the hud and entities on fire blue", "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[1]": "when lit on fire by soul fire", + "text.autoconfig.tinytweaks.option.infiniteCauldrons": "Infinite Cauldrons", + "text.autoconfig.tinytweaks.option.infiniteCauldrons.@Tooltip": "Right click a cauldron with a Heart of the Sea to make it infinite", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.true": "§aOn", @@ -138,5 +140,6 @@ "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§cOff", - "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§cOff" + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§cOff", + "block.cauldron.makeInfinite": "This cauldron has been blessed with the heart of the sea" } \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 70b22c8..18b8e89 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -5,6 +5,7 @@ "plugin": "dev.hephaestus.tweaks.mixin.VolatileMixinPlugin", "mixins": [ "block.BubbleColumnBlockMixin", + "block.CauldronBlockMixin", "block.CocoaBlockMixin", "block.CropBlockMixin", "block.DeadBushBlockMixin", From b768b474f4645bec2ec4cde49a59fda81f7c15e6 Mon Sep 17 00:00:00 2001 From: Haven King Date: Sat, 1 Aug 2020 00:22:18 -0700 Subject: [PATCH 24/53] Added config option for slow amount in leaves, re Issue #16. --- src/main/java/dev/hephaestus/tweaks/TweaksConfig.java | 2 ++ .../dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java | 2 +- src/main/resources/assets/tinytweaks/lang/en_us.json | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 87a10b0..5af6965 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -132,6 +132,8 @@ public static class LeavesConfig { @ConfigEntry.Gui.Tooltip public boolean slow = true; + public double slowAmount = 0.75D; + public boolean climb = true; } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java index dd6f6b4..fb1a460 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java @@ -33,6 +33,6 @@ public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos p @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { if (Tweaks.CONFIG.leaves.slow && !(entity instanceof ItemEntity)) - entity.slowMovement(state, new Vec3d(0.75D, 2D, 0.75D)); + entity.setVelocity(entity.getVelocity().multiply(Tweaks.CONFIG.leaves.slowAmount)); } } \ No newline at end of file diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 3bc4d5f..d75f8a2 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -50,6 +50,7 @@ "text.autoconfig.tinytweaks.option.leaves.collide": "Leaf Collision", "text.autoconfig.tinytweaks.option.leaves.slow": "Leaves Slow", "text.autoconfig.tinytweaks.option.leaves.slow.@Tooltip": "Leaves slow non-item entities passing through them", + "text.autoconfig.tinytweaks.option.leaves.slowAmount": "Slow Amount", "text.autoconfig.tinytweaks.option.leaves.climb": "Climbable Trees", "text.autoconfig.tinytweaks.option.leaves.persistentCollide": "Persistent Leaf Collision", "text.autoconfig.tinytweaks.option.leaves.persistentCollide.@Tooltip": "These are leaves placed by the player", From f00733b946e399f0a64303060bf29aaf5eb88fb0 Mon Sep 17 00:00:00 2001 From: Haven King Date: Sat, 1 Aug 2020 00:28:20 -0700 Subject: [PATCH 25/53] Forgot lang keys for the options. --- src/main/resources/assets/tinytweaks/lang/en_us.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index d75f8a2..f1705a2 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -118,6 +118,7 @@ "text.autoconfig.tinytweaks.option.doubleDoors.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§cOff", @@ -142,5 +143,6 @@ "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.false": "§cOff", "block.cauldron.makeInfinite": "This cauldron has been blessed with the heart of the sea" } \ No newline at end of file From f36d11893e969972785f329c4fa2448bb2a54c65 Mon Sep 17 00:00:00 2001 From: Haven King Date: Sat, 1 Aug 2020 11:33:50 -0700 Subject: [PATCH 26/53] Added config option for auto plant delay, and opened the door for auto planting of things other than saplings. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 12 +++++-- .../tweaks/mixin/block/LeavesBlockMixin.java | 12 ++++--- .../tweaks/mixin/entity/ItemEntityMixin.java | 31 +++++++++---------- .../assets/tinytweaks/lang/en_us.json | 12 ++++--- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 5af6965..9015b7b 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -17,8 +17,8 @@ public class TweaksConfig implements ConfigData { public boolean easyHarvestSugarcane = true; @ConfigEntry.Category("plants") - @ConfigEntry.Gui.Tooltip - public boolean saplingsAutoPlant = true; + @ConfigEntry.Gui.CollapsibleObject + public AutoPlanting autoPlanting = new AutoPlanting(); @ConfigEntry.Category("plants") @ConfigEntry.Gui.CollapsibleObject @@ -89,6 +89,14 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.Tooltip public boolean infiniteCauldrons = true; + public static class AutoPlanting { + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean enabled = true; + + @ConfigEntry.Gui.Tooltip + public int delay = 20; + } + public static class Rejuvenation { @ConfigEntry.Gui.Tooltip public boolean enabled = true; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java index fb1a460..a468316 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java @@ -24,15 +24,17 @@ public LeavesBlockMixin(Settings settings) { @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { - if (state.get(LeavesBlock.PERSISTENT)) - return Tweaks.CONFIG.leaves.persistentCollide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); - else - return Tweaks.CONFIG.leaves.collide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); + if (state.get(LeavesBlock.PERSISTENT)) { + return Tweaks.CONFIG.leaves.persistentCollide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); + } else { + return Tweaks.CONFIG.leaves.collide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); + } } @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if (Tweaks.CONFIG.leaves.slow && !(entity instanceof ItemEntity)) + if (Tweaks.CONFIG.leaves.slow && !(entity instanceof ItemEntity)) { entity.setVelocity(entity.getVelocity().multiply(Tweaks.CONFIG.leaves.slowAmount)); + } } } \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java index b09df76..cb5b9b5 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java @@ -32,28 +32,27 @@ public ItemEntityMixin(EntityType type, World world) { @Shadow public abstract ItemStack getStack(); - private static boolean isDirt(Block block) { - return block == Blocks.DIRT || block == Blocks.GRASS_BLOCK || block == Blocks.PODZOL || block == Blocks.COARSE_DIRT || block == Blocks.MYCELIUM; - } - private BlockPos triedToPlantAt; + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;tick()V")) public void plantSaplings(CallbackInfo ci) { - if (Tweaks.CONFIG.saplingsAutoPlant && this.age > 20) { + if (Tweaks.CONFIG.autoPlanting.enabled && this.age >= Tweaks.CONFIG.autoPlanting.delay) { ItemStack stack = this.getStack(); BlockPos pos = this.getBlockPos(); - if (stack.getItem().isIn(ItemTags.SAPLINGS) && this.getBlockPos() != triedToPlantAt && world.getFluidState(pos).isEmpty()) { - stack.useOnBlock(new ItemPlacementContext(world, null, null, stack, world.rayTrace( - new RayTraceContext( - new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), - new Vec3d(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5), - RayTraceContext.ShapeType.COLLIDER, - RayTraceContext.FluidHandling.ANY, - this - ) - ))); + if (this.getBlockPos() != triedToPlantAt && world.getFluidState(pos).isEmpty()) { + if (stack.getItem().isIn(ItemTags.SAPLINGS)) { + stack.useOnBlock(new ItemPlacementContext(world, null, null, stack, world.rayTrace( + new RayTraceContext( + new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), + new Vec3d(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5), + RayTraceContext.ShapeType.COLLIDER, + RayTraceContext.FluidHandling.ANY, + this + ) + ))); - triedToPlantAt = this.getBlockPos(); + triedToPlantAt = this.getBlockPos(); + } } } } diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index f1705a2..7b4508a 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -16,8 +16,12 @@ "text.autoconfig.tinytweaks.option.flintAndSteel.enabled": "Should Burn Entities", "text.autoconfig.tinytweaks.option.flintAndSteel.enabled.@Tooltip": "Right click mobs with flint and steel to light them on fire", "text.autoconfig.tinytweaks.option.flintAndSteel.burnTime": "Burn Time (in seconds)", - "text.autoconfig.tinytweaks.option.saplingsAutoPlant": "Sapling Succession", - "text.autoconfig.tinytweaks.option.saplingsAutoPlant.@Tooltip": "Saplings that fall on dirt or grass will automatically plant", + "text.autoconfig.tinytweaks.option.autoPlanting": "Auto Planting", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled": "Enabled", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[0]": "Plants that fall on their base block plant themselves", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[1]": "§7§oCurrently only applies to saplings", + "text.autoconfig.tinytweaks.option.autoPlanting.delay": "Plant Delay", + "text.autoconfig.tinytweaks.option.autoPlanting.delay.@Tooltip": "Delay (in ticks) before items plant themselves", "text.autoconfig.tinytweaks.option.lanternBlastResistance": "Sturdy Lanterns", "text.autoconfig.tinytweaks.option.lanternBlastResistance.@Tooltip[0]": "Gives lanterns a blast resistance of 6", "text.autoconfig.tinytweaks.option.lanternBlastResistance.@Tooltip[1]": "§cRequires restart", @@ -96,7 +100,7 @@ "text.autoconfig.tinytweaks.option.infiniteCauldrons.@Tooltip": "Right click a cauldron with a Heart of the Sea to make it infinite", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", - "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.rejuvenation.enabled.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.rejuvenation.saplings.boolean.true": "§aOn", @@ -121,7 +125,7 @@ "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", - "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.rejuvenation.enabled.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.rejuvenation.saplings.boolean.false": "§cOff", From b76475a310db8c375e761074e7610141520c77d0 Mon Sep 17 00:00:00 2001 From: Haven King Date: Sat, 1 Aug 2020 11:43:03 -0700 Subject: [PATCH 27/53] Updated README --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f406064..5509c09 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,25 @@ A collection of small tweaks for Minecraft. ## Plant Tweaks * Easy Harvest Crops - Right clicking fully grown clops harvests and replants them * Easy Harvest Sugarcane - Right clicking sugarcane harvests all sugarcane higher than the one you clicked. Preserves the bottom-most block -* Sapling Succession - Saplings that fall on dirt or grass will automatically plant -* Grass Spreading - Grass and long grass spread naturally over time. Also removes hitboxes from grass and long grass. Seeds can be obtained by hoeing the ground under them +* Auto Planting - Plants that fall on dirt or grass will automatically plant (Currently only applies to saplings) +* Grass Spreading - Grass and long grass spread naturally over time +* Plant Hitboxes - Removes hitboxes from long grass. Hitboxes are shown when using shears. Seeds can be gathered by using a hoe on the ground below them * Passable Leaves - Removes collision from leaves * Better Lily Pads - Allows boats to pass through lily pads without breaking them. Also allows entities to rise through the bottom of a lily pad * Farmer Villager Automation - Farmer villagers will deposit excess items into a nearby chest ## Animal Tweaks -* Animals Eat off the Ground - Chickens, cows, horeses, pigs, sheep, and wolves will eat off the ground +* Animals Eat off the Ground - Chickens, cows, horses, pigs, sheep, and wolves will eat off the ground * Wild Wolves Breed - Wild wolves are able to be bred. Allows for some neat natural systems! ## Miscellaneous Tweaks * Bubble Columns Flow - When set to On, bubble columns behave as they do in vanilla. When set to Off, bubble columns don't spread water to their surrounding blocks -* Burned Logs Drop Charcoal - When a log that's on fire is destroyed, it drops a charcoal. Also makes charcoal fireproof +* Burned Logs Drop Charcoal - When a log on fire burns, it drops a charcoal (Also makes charcoal fireproof) * Double Doors - Doors and trapdoors open adjacent doors and trapdoors of the same type. Works when opened by hand or with redstone * Editable Signs - No config for this one, just don't use it if you don't want it! * Entity Ignition - Right click mobs with flint and steel to light them on fire * Sturdy Lanterns - Gives lanterns a blast resistance of 6 (allows them to survive Ghast fireballs) +* Infinite Cauldrons - Right clicking a Cauldron with a Heart of the Sea creates an infinite water source ## Contact Me I can be found hanging out on the Fabric Discord as Haven King#2790. Feel free to shoot me a message there if you have any questions. \ No newline at end of file From e77acc1b0969c28d9536a53171e91c7086d73392 Mon Sep 17 00:00:00 2001 From: Haven King Date: Sat, 1 Aug 2020 11:54:52 -0700 Subject: [PATCH 28/53] Fixes a bug where snow would not generate on trees. --- .../tweaks/mixin/block/LeavesBlockMixin.java | 10 ++++++---- src/main/resources/tweaks.accesswidener | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java index a468316..9a410e2 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java @@ -1,12 +1,10 @@ package dev.hephaestus.tweaks.mixin.block; import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.ShapeContext; +import net.minecraft.block.*; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; +import net.minecraft.text.HoverEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; @@ -24,6 +22,10 @@ public LeavesBlockMixin(Settings settings) { @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { + if (context == EntityShapeContext.ABSENT) { + return VoxelShapes.fullCube(); + } + if (state.get(LeavesBlock.PERSISTENT)) { return Tweaks.CONFIG.leaves.persistentCollide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); } else { diff --git a/src/main/resources/tweaks.accesswidener b/src/main/resources/tweaks.accesswidener index 174ca72..6ca5fae 100644 --- a/src/main/resources/tweaks.accesswidener +++ b/src/main/resources/tweaks.accesswidener @@ -1,3 +1,4 @@ accessWidener v1 named accessible method net/minecraft/item/ItemPlacementContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V -accessible method net/minecraft/block/BubbleColumnBlock calculateDrag (Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z \ No newline at end of file +accessible method net/minecraft/block/BubbleColumnBlock calculateDrag (Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z +accessible field net/minecraft/block/EntityShapeContext ABSENT Lnet/minecraft/block/ShapeContext; \ No newline at end of file From cc256aa5276d608be1531f6a540291790f47c45d Mon Sep 17 00:00:00 2001 From: Samekichi Date: Sun, 2 Aug 2020 03:31:55 +0800 Subject: [PATCH 29/53] Create zh_cn.json --- .../assets/tinytweaks/lang/zh_cn.json | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/main/resources/assets/tinytweaks/lang/zh_cn.json diff --git a/src/main/resources/assets/tinytweaks/lang/zh_cn.json b/src/main/resources/assets/tinytweaks/lang/zh_cn.json new file mode 100644 index 0000000..4528933 --- /dev/null +++ b/src/main/resources/assets/tinytweaks/lang/zh_cn.json @@ -0,0 +1,148 @@ +{ + "text.autoconfig.tinytweaks.title": "细微调整 (Tiny Tweaks)", + "text.autoconfig.boolean.value.true": "启用", + "text.autoconfig.tinytweaks.category.plants": "植物", + "text.autoconfig.tinytweaks.category.animals": "动物", + "text.autoconfig.tinytweaks.category.nether": "下界", + "text.autoconfig.tinytweaks.category.misc": "杂项", + "text.autoconfig.tinytweaks.option.easyHarvestCrops": "一键收获农作物", + "text.autoconfig.tinytweaks.option.easyHarvestCrops.@Tooltip": "右键成熟的农作物以收获并补种它们", + "text.autoconfig.tinytweaks.option.easyHarvestSugarcane": "一键收获甘蔗", + "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.@Tooltip[0]": "右键一格甘蔗以收取高于它的所有甘蔗", + "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.@Tooltip[1]": "( 会保留最底层的甘蔗根 )", + "text.autoconfig.tinytweaks.option.farmerVillagerAutomation": "农夫自动囤粮", + "text.autoconfig.tinytweaks.option.farmerVillagerAutomation.@Tooltip": "农夫村民会将多余的收成存放到附近的箱子里", + "text.autoconfig.tinytweaks.option.flintAndSteel": "对生物用打火石", + "text.autoconfig.tinytweaks.option.flintAndSteel.enabled": "可以点燃生物", + "text.autoconfig.tinytweaks.option.flintAndSteel.enabled.@Tooltip": "用打火石右键生物来点燃它们", + "text.autoconfig.tinytweaks.option.flintAndSteel.burnTime": "燃烧时间 (秒)", + "text.autoconfig.tinytweaks.option.saplingsAutoPlant": "落地成树", + "text.autoconfig.tinytweaks.option.saplingsAutoPlant.@Tooltip": "掉落在泥土或草方块上的树苗会自动种植在上面", + "text.autoconfig.tinytweaks.option.lanternBlastResistance": "坚挺的灯笼", + "text.autoconfig.tinytweaks.option.lanternBlastResistance.@Tooltip[0]": "给予灯笼 6 级的爆炸抗性", + "text.autoconfig.tinytweaks.option.lanternBlastResistance.@Tooltip[1]": "§c需要重启游戏", + "text.autoconfig.tinytweaks.option.animalsEatOffGround": "动物吃草", + "text.autoconfig.tinytweaks.option.animalsEatOffGround.@Tooltip": "鸡, 牛, 马, 猪, 羊和狼会把绿地吃贫瘠", + "text.autoconfig.tinytweaks.option.breedWildWolves": "野生狼群繁殖", + "text.autoconfig.tinytweaks.option.breedWildWolves.@Tooltip": "野生狼群也可以繁殖了!", + "text.autoconfig.tinytweaks.option.rejuvenation": "植物复兴", + "text.autoconfig.tinytweaks.option.rejuvenation.enabled": "启用", + "text.autoconfig.tinytweaks.option.rejuvenation.enabled.@Tooltip": "植物会随时间生长", + "text.autoconfig.tinytweaks.option.rejuvenation.grassGrowthRate": "草丛蔓延率", + "text.autoconfig.tinytweaks.option.rejuvenation.grassGrowthRate.@Tooltip": "草丛蔓延的概率", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship": "邻里草丛的力量", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[0]": "调整目标方块周围的草丛", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[1]": "对其生成草丛概率的影响", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[2]": "", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[3]": "§7§o该数值表示一个伪指数函数的指数,", + "text.autoconfig.tinytweaks.option.rejuvenation.thePowerOfFriendship.@Tooltip[4]": "§7§o所以调整时请务必小心谨慎", + "text.autoconfig.tinytweaks.option.rejuvenation.longGrass": "草丛长高", + "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.@Tooltip[0]": "可以长成高草丛的草的百分比", + "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.@Tooltip[1]": "( 0.0 表示关闭此功能, 0.01 为默认值, 1.0 表示所有草都会长高 )", + "text.autoconfig.tinytweaks.option.rejuvenation.saplings": "树苗复生", + "text.autoconfig.tinytweaks.option.rejuvenation.saplings.@Tooltip": "枯死的灌木在草方块上会恢复成树苗", + "text.autoconfig.tinytweaks.option.plantHitboxes": "植物互动箱", + "text.autoconfig.tinytweaks.option.plantHitboxes.@Tooltip[0]": "当 §a启用§r 时, 与原版相比不会有任何变化", + "text.autoconfig.tinytweaks.option.plantHitboxes.@Tooltip[1]": "当 §c关闭§r 时, 草丛、花卉和海草将不再拥有交互箱", + "text.autoconfig.tinytweaks.option.plantHitboxes.@Tooltip[2]": "( 在草方块上使用锹或锄头,会破坏附着其上的植物 )", + "text.autoconfig.tinytweaks.option.plantHitboxes.@Tooltip[3]": "( 手持剪刀就可以看见交互箱了 )", + "text.autoconfig.tinytweaks.option.leaves": "可穿过的树叶", + "text.autoconfig.tinytweaks.option.leaves.collide": "自然生成树叶的碰撞箱", + "text.autoconfig.tinytweaks.option.leaves.slow": "在树叶中穿行时会减速", + "text.autoconfig.tinytweaks.option.leaves.slow.@Tooltip": "树叶将会减速身处其中的非物品实体", + "text.autoconfig.tinytweaks.option.leaves.slowAmount": "减速幅度", + "text.autoconfig.tinytweaks.option.leaves.climb": "可攀爬的树干", + "text.autoconfig.tinytweaks.option.leaves.persistentCollide": "手动放置树叶的碰撞箱", + "text.autoconfig.tinytweaks.option.leaves.persistentCollide.@Tooltip": "此指玩家手动放置的树叶方块", + "text.autoconfig.tinytweaks.option.namesAndThings": "命名显示", + "text.autoconfig.tinytweaks.option.namesAndThings.containerLabels": "箱子标签", + "text.autoconfig.tinytweaks.option.namesAndThings.containerLabels.@Tooltip": "看向箱子时会显示其名称标签", + "text.autoconfig.tinytweaks.option.namesAndThings.labelScale": "标签尺寸", + "text.autoconfig.tinytweaks.option.betterLilyPads": "更好的睡莲", + "text.autoconfig.tinytweaks.option.betterLilyPads.@Tooltip[0]": "允许船只在不破坏睡莲的情况下穿过它们,", + "text.autoconfig.tinytweaks.option.betterLilyPads.@Tooltip[1]": "同时也允许实体从睡莲下方浮上水面", + "text.autoconfig.tinytweaks.option.mossyThings": "潮湿的家伙", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[0]": "圆石、石砖以及它们的楼梯、台阶和墙体变种", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[1]": "会在接近水源或暴露于雨水中时转化为苔石及其变种方块", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[2]": "而苔石以及它的楼梯、台阶和墙体变种", + "text.autoconfig.tinytweaks.option.mossyThings.@Tooltip[3]": "会在阳光下恢复其原本的样子", + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal": "烧毁的原木会掉落木炭", + "text.autoconfig.tinytweaks.option.doubleDoors": "双门", + "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[0]": "使用一扇门 / 活板门时, 也会同时使用其相邻的同种门 / 活板门", + "text.autoconfig.tinytweaks.option.doubleDoors.@Tooltip[1]": "( 只在用手或改变红石信号时有效 )", + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow": "气泡柱流", + "text.autoconfig.tinytweaks.option.netherRejuvenation": "下界复兴", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled": "启用", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[0]": "菌岩、菌索和下界苗会逐渐蔓延", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.@Tooltip[1]": "( 蔓延范围仅限于对应群系中 )", + "text.autoconfig.tinytweaks.option.netherRejuvenation.rootsGrowthRate": "菌索 / 下界苗蔓延率", + "text.autoconfig.tinytweaks.option.netherRejuvenation.rootsGrowthRate.@Tooltip": "菌索 / 下界苗蔓延的概率", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship": "邻里菌索的力量", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[0]": "调整目标方块周围的菌索", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[1]": "对其生成菌索概率的影响", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[2]": "", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[3]": "§7§o该数值表示一个伪指数函数的指数,", + "text.autoconfig.tinytweaks.option.netherRejuvenation.thePowerOfFriendship.@Tooltip[4]": "§7§o所以调整时请务必小心谨慎", + "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio": "下界苗 / 菌索比例 ( 设定值等于菌索的百分比 )", + "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio.@Tooltip[0]": "0 表示只生成下界苗而没有菌索, 100 表示都是菌索而没有下界苗", + "text.autoconfig.tinytweaks.option.netherRejuvenation.sproutRootsRatio.@Tooltip[1]": "( 仅影响诡异森林群系 )", + "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance": "缠怨藤生成率", + "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance.@Tooltip[0]": "蔓延过程中生成缠怨藤的概率", + "text.autoconfig.tinytweaks.option.netherRejuvenation.vinesChance.@Tooltip[1]": "( 0.0 表示永不生成, 1.0 表示每个随机刻都尝试生成 )", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects": "改进的灵魂火", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[0]": "被灵魂火点燃后, HUD 中的火焰渲染", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[1]": "和实体身上的火焰渲染都会变为蓝色", + "text.autoconfig.tinytweaks.option.infiniteCauldrons": "无限水源的炼药锅", + "text.autoconfig.tinytweaks.option.infiniteCauldrons.@Tooltip": "用海洋之心右键一个炼药锅以使其永不枯竭", + "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.rejuvenation.enabled.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.rejuvenation.saplings.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.farmerVillagerAutomation.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.animalsEatOffGround.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.breedWildWolves.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.flintAndSteel.enabled.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.lanternBlastResistance.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.betterLilyPads.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.namesAndThings.freeRenames.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.namesAndThings.containerLabels.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.plantHitboxes.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.leaves.collide.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.leaves.slow.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.leaves.persistentCollide.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.leaves.climb.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.mossyThings.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.doubleDoors.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.true": "§a启用", + "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.saplingsAutoPlant.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.rejuvenation.enabled.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.rejuvenation.longGrass.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.rejuvenation.saplings.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.farmerVillagerAutomation.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.animalsEatOffGround.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.breedWildWolves.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.flintAndSteel.enabled.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.lanternBlastResistance.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.betterLilyPads.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.namesAndThings.freeRenames.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.namesAndThings.containerLabels.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.plantHitboxes.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.leaves.collide.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.leaves.slow.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.leaves.persistentCollide.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.leaves.climb.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.mossyThings.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.burningLogsDropCharcoal.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.doubleDoors.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§c关闭", + "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.false": "§c关闭", + "block.cauldron.makeInfinite": "这个炼药锅已经被海洋之心所祝福了" +} From 4c22505c9746306562cf4ada2fb205ce85638803 Mon Sep 17 00:00:00 2001 From: Samekichi Date: Sun, 2 Aug 2020 04:12:14 +0800 Subject: [PATCH 30/53] Update zh_cn.json --- src/main/resources/assets/tinytweaks/lang/zh_cn.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/tinytweaks/lang/zh_cn.json b/src/main/resources/assets/tinytweaks/lang/zh_cn.json index 4528933..b595cd1 100644 --- a/src/main/resources/assets/tinytweaks/lang/zh_cn.json +++ b/src/main/resources/assets/tinytweaks/lang/zh_cn.json @@ -144,5 +144,5 @@ "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§c关闭", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§c关闭", "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.false": "§c关闭", - "block.cauldron.makeInfinite": "这个炼药锅已经被海洋之心所祝福了" + "block.cauldron.makeInfinite": "这个炼药锅现已被海洋之心所祝福" } From 6e5632aaa0b507193c28cc067d1494920e3ac825 Mon Sep 17 00:00:00 2001 From: Haven Date: Mon, 17 Aug 2020 08:30:39 -0700 Subject: [PATCH 31/53] Should fix #22 --- build.gradle | 2 +- .../hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8d0cc00..b57a8dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.4.13' + id 'fabric-loom' version '0.4-SNAPSHOT' id 'maven-publish' } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java index cfa0202..7bf1c1e 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java @@ -11,7 +11,7 @@ @Mixin(value = BubbleColumnBlock.class, priority = 2000) public class BubbleColumnBlockMixin { - @Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/TickScheduler;schedule(Lnet/minecraft/util/math/BlockPos;Ljava/lang/Object;I)V")) + @Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/TickScheduler;schedule(Lnet/minecraft/util/math/BlockPos;Ljava/lang/Object;I)V", ordinal = 1)) private void dontFluidTick(TickScheduler tickScheduler, BlockPos pos, T object, int delay) { if (Tweaks.CONFIG.bubbleColumnsFlow) { tickScheduler.schedule(pos, object, delay); From 59f153d7db0b6c212ab69fcae93671c6cfc9c902 Mon Sep 17 00:00:00 2001 From: Haven Date: Mon, 17 Aug 2020 12:35:59 -0700 Subject: [PATCH 32/53] Update to 1.16.2 --- build.gradle | 23 ++++++++++++++----- gradle.properties | 14 +++++------ .../hephaestus/tweaks/block/MoistBlock.java | 2 +- .../entity/ai/goal/GroundFoodMateGoal.java | 2 +- .../tweaks/mixin/block/NyliumBlockMixin.java | 13 +++++++---- .../screen/ingame/SignEditScreenMixin.java | 5 ++-- .../mixin/entity/LivingEntityMixin.java | 2 +- .../entity/passive/ChickenEntityMixin.java | 12 +++------- .../mixin/entity/passive/CowEntityMixin.java | 11 ++------- .../entity/passive/HorseAndDonkeyMixin.java | 11 ++------- .../mixin/entity/passive/PigEntityMixin.java | 11 ++------- .../entity/passive/SheepEntityMixin.java | 11 ++------- .../mixin/entity/passive/WolfEntityMixin.java | 11 ++------- src/main/resources/fabric.mod.json | 3 +++ 14 files changed, 54 insertions(+), 77 deletions(-) diff --git a/build.gradle b/build.gradle index b57a8dc..70b7c80 100644 --- a/build.gradle +++ b/build.gradle @@ -32,15 +32,26 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" compileOnly "com.google.code.findbugs:jsr305:3.0.2" - modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}" - modImplementation "net.fabricmc:fabric-language-kotlin:1.3.72+build.1" - modImplementation "curse.maven:sodium:3003093" - modImplementation "curse.maven:lithium:3000628" + modImplementation ("io.github.prospector:modmenu:${project.mod_menu_version}") { + exclude group: "net.fabricmc.fabric-api" + } + +// modImplementation ("net.fabricmc:fabric-language-kotlin:1.3.72+build.1") { +// exclude group: "net.fabricmc.fabric-api" +// } +// modImplementation "curse.maven:sodium:3003093" +// modImplementation "curse.maven:lithium:3000628" + + modApi ("me.shedaniel.cloth:config-2:${project.cloth_config_version}") { + exclude group: "net.fabricmc.fabric-api" + } - modApi "me.shedaniel.cloth:config-2:${project.cloth_config_version}" include "me.shedaniel.cloth:config-2:${project.cloth_config_version}" - modCompile "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}" + modImplementation ("me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}") { + exclude group: "net.fabricmc.fabric-api" + } + include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" diff --git a/gradle.properties b/gradle.properties index 0925664..ec38208 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,19 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version = 1.16.1 -yarn_mappings = 1.16.1+build.21 -loader_version = 0.9.0+build.204 +minecraft_version = 1.16.2 +yarn_mappings = 1.16.2+build.19 +loader_version = 0.9.1+build.205 #Mod properties -mod_version = 1.0.11 +mod_version = 1.0.12 maven_group = dev.hephaestus archives_base_name = tinytweaks #Dependencies -fabric_version = 0.14.1+build.372-1.16 -cloth_config_version = 4.6.0 +fabric_version = 0.18.0+build.397-1.16 +cloth_config_version = 4.7.0-unstable auto_config_version = 3.2.0-unstable # Dev Mods -mod_menu_version = 1.14.0+build.24 \ No newline at end of file +mod_menu_version = 1.14.6+build.31 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java index 7e58a01..e83b71f 100644 --- a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java +++ b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java @@ -30,7 +30,7 @@ public static void randomTick(BlockState state, ServerWorld world, BlockPos pos) } if (isSkyVisible) { - if (world.isRaining() && world.getBiome(pos).getRainfall() > 0) { + if (world.isRaining() && world.getBiome(pos).getDownfall() > 0) { world.setBlockState(pos, Moistener.moisten(state)); } else if (world.isDay() && !isWaterNearby) { world.setBlockState(pos, Moistener.dry(state)); diff --git a/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java b/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java index 2012b07..e4b39a2 100644 --- a/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java +++ b/src/main/java/dev/hephaestus/tweaks/entity/ai/goal/GroundFoodMateGoal.java @@ -57,7 +57,7 @@ public void tick() { } private ItemEntity findFood() { - List list = animal.world.getEntities(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), null); + List list = animal.world.getEntitiesByClass(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), null); double d = Double.MAX_VALUE; ItemEntity result = null; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java index 0af0b38..d21d3a7 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java @@ -4,8 +4,8 @@ import net.minecraft.block.*; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.registry.Registry; import net.minecraft.world.WorldView; -import net.minecraft.world.biome.Biomes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -18,12 +18,15 @@ public abstract class NyliumBlockMixin { @Shadow private static boolean stayAlive(BlockState state, WorldView world, BlockPos pos) {return true;} - private static boolean canSpread(BlockState state, WorldView worldView, BlockPos pos) { + private static boolean canSpread(BlockState state, ServerWorld world, BlockPos pos) { BlockPos blockPos = pos.up(); - BlockState blockState = worldView.getBlockState(blockPos); + BlockState blockState = world.getBlockState(blockPos); + + + return blockState.isAir() && - (state.getBlock() == Blocks.WARPED_NYLIUM && worldView.getBiome(pos) == Biomes.WARPED_FOREST || - state.getBlock() == Blocks.CRIMSON_NYLIUM && worldView.getBiome(pos) == Biomes.CRIMSON_FOREST); + (state.getBlock() == Blocks.WARPED_NYLIUM && world.getRegistryManager().get(Registry.BIOME_KEY).getId(world.getBiome(pos)).getPath().equals("warped_forest") || + state.getBlock() == Blocks.CRIMSON_NYLIUM && world.getRegistryManager().get(Registry.BIOME_KEY).getId(world.getBiome(pos)).getPath().equals("crimson_forest")); } @Inject(method = "randomTick", at = @At("TAIL")) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java index d11e801..47bd956 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java @@ -5,7 +5,7 @@ import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.gui.screen.ingame.SignEditScreen; import net.minecraft.text.LiteralText; -import net.minecraft.text.StringRenderable; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -23,7 +23,8 @@ public class SignEditScreenMixin { @Inject(method = "init", at = @At("TAIL")) private void setRows(CallbackInfo ci) { for (int i = 0; i < 4; ++i) { - StringRenderable text = sign.getTextBeingEditedOnRow(i, t -> t); + Text text = sign.method_30843(i); + this.field_24285[i] = (text == null ? LiteralText.EMPTY : text).getString(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java index abb11bb..a6ef6ec 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java @@ -23,7 +23,7 @@ public LivingEntityMixin(EntityType type, World world) { @Inject(method = "isClimbing", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) public void onIsClimbing(CallbackInfoReturnable info, BlockPos pos) { - if ((world.getBlockState(pos).getBlock() instanceof LeavesBlock || world.getBlockState(pos.up()).getBlock() instanceof LeavesBlock)) { + if (world.getBlockState(pos).getBlock() instanceof LeavesBlock || world.getBlockState(pos.up()).getBlock() instanceof LeavesBlock || world.getBlockState(pos.up(2)).getBlock() instanceof LeavesBlock) { if (Tweaks.CONFIG.leaves.climb) { boolean logsAdjacent = world.getBlockState(pos.north()).getBlock().isIn(BlockTags.LOGS) || diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/ChickenEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/ChickenEntityMixin.java index b9f0422..8555ba2 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/ChickenEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/ChickenEntityMixin.java @@ -6,6 +6,7 @@ import net.minecraft.entity.passive.ChickenEntity; import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.recipe.Ingredient; +import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -17,7 +18,7 @@ import javax.annotation.Nullable; @Mixin(ChickenEntity.class) -public class ChickenEntityMixin extends AnimalEntity { +public abstract class ChickenEntityMixin extends AnimalEntity { @Shadow @Final private static Ingredient BREEDING_INGREDIENT; protected ChickenEntityMixin(EntityType type, World world) { @@ -26,13 +27,6 @@ protected ChickenEntityMixin(EntityType type, World worl @Inject(method = "initGoals", at = @At("TAIL")) public void addGoal(CallbackInfo ci) { - this.goalSelector.add(4, new GroundFoodMateGoal(this, BREEDING_INGREDIENT)); - } - - @Shadow - @Nullable - @Override - public ChickenEntity createChild(PassiveEntity mate) { - return null; + this.goalSelector.add(2, new GroundFoodMateGoal(this, BREEDING_INGREDIENT)); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/CowEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/CowEntityMixin.java index d04900c..d18d006 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/CowEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/CowEntityMixin.java @@ -17,20 +17,13 @@ import javax.annotation.Nullable; @Mixin(CowEntity.class) -public class CowEntityMixin extends AnimalEntity { +public abstract class CowEntityMixin extends AnimalEntity { protected CowEntityMixin(EntityType type, World world) { super(type, world); } @Inject(method = "initGoals", at = @At("TAIL")) public void addGoal(CallbackInfo ci) { - this.goalSelector.add(4, new GroundFoodMateGoal(this, Ingredient.ofItems(Items.WHEAT))); - } - - @Shadow - @Nullable - @Override - public CowEntity createChild(PassiveEntity mate) { - return null; + this.goalSelector.add(2, new GroundFoodMateGoal(this, Ingredient.ofItems(Items.WHEAT))); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/HorseAndDonkeyMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/HorseAndDonkeyMixin.java index 49c94ea..289cd6c 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/HorseAndDonkeyMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/HorseAndDonkeyMixin.java @@ -15,7 +15,7 @@ import javax.annotation.Nullable; @Mixin(HorseBaseEntity.class) -public class HorseAndDonkeyMixin extends AnimalEntity { +public abstract class HorseAndDonkeyMixin extends AnimalEntity { private static final Ingredient BREEDING_INGREDIENT = Ingredient.ofItems(Items.GOLDEN_APPLE, Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_CARROT); protected HorseAndDonkeyMixin(EntityType type, World world) { @@ -24,13 +24,6 @@ protected HorseAndDonkeyMixin(EntityType type, World wor @Inject(method = "initGoals", at = @At("TAIL")) protected void initGoals(CallbackInfo ci) { - this.goalSelector.add(3, new GroundFoodMateGoal(this, BREEDING_INGREDIENT)); - } - - @Shadow - @Nullable - @Override - public PassiveEntity createChild(PassiveEntity mate) { - return null; + this.goalSelector.add(2, new GroundFoodMateGoal(this, BREEDING_INGREDIENT)); } } \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/PigEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/PigEntityMixin.java index 5cc747e..7551382 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/PigEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/PigEntityMixin.java @@ -17,7 +17,7 @@ import javax.annotation.Nullable; @Mixin(PigEntity.class) -public class PigEntityMixin extends AnimalEntity { +public abstract class PigEntityMixin extends AnimalEntity { @Shadow @Final private static Ingredient BREEDING_INGREDIENT; protected PigEntityMixin(EntityType type, World world) { @@ -26,13 +26,6 @@ protected PigEntityMixin(EntityType type, World world) { @Inject(method = "initGoals", at = @At("TAIL")) public void addGoal(CallbackInfo ci) { - this.goalSelector.add(4, new GroundFoodMateGoal(this, BREEDING_INGREDIENT)); - } - - @Shadow - @Nullable - @Override - public PigEntity createChild(PassiveEntity mate) { - return null; + this.goalSelector.add(3, new GroundFoodMateGoal(this, BREEDING_INGREDIENT)); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/SheepEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/SheepEntityMixin.java index 0afc2ef..4c0921c 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/SheepEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/SheepEntityMixin.java @@ -17,20 +17,13 @@ import javax.annotation.Nullable; @Mixin(SheepEntity.class) -public class SheepEntityMixin extends AnimalEntity { +public abstract class SheepEntityMixin extends AnimalEntity { protected SheepEntityMixin(EntityType type, World world) { super(type, world); } @Inject(method = "initGoals", at = @At("TAIL")) public void addGoal(CallbackInfo ci) { - this.goalSelector.add(3, new GroundFoodMateGoal(this, Ingredient.ofItems(Items.WHEAT))); - } - - @Shadow - @Nullable - @Override - public SheepEntity createChild(PassiveEntity mate) { - return null; + this.goalSelector.add(2, new GroundFoodMateGoal(this, Ingredient.ofItems(Items.WHEAT))); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/WolfEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/WolfEntityMixin.java index 37a1acc..34778e0 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/WolfEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/passive/WolfEntityMixin.java @@ -17,21 +17,14 @@ import javax.annotation.Nullable; @Mixin(WolfEntity.class) -public class WolfEntityMixin extends TameableEntity { +public abstract class WolfEntityMixin extends TameableEntity { protected WolfEntityMixin(EntityType type, World world) { super(type, world); } @Inject(method = "initGoals", at = @At("TAIL")) public void addGoal(CallbackInfo ci) { - this.goalSelector.add(8, new GroundFoodMateGoal(this, this::isBreedingItem)); - } - - @Shadow - @Nullable - @Override - public WolfEntity createChild(PassiveEntity mate) { - return null; + this.goalSelector.add(7, new GroundFoodMateGoal(this, this::isBreedingItem)); } @Redirect(method = "canBreedWith", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;isTamed()Z")) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a3bdc76..a454fd4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,5 +33,8 @@ "depends": { "fabricloader": ">=0.4.0", "fabric": "*" + }, + "breaks": { + "soulfire": "*:" } } \ No newline at end of file From 0039dd30b57bb854564c2da026efa96376497647 Mon Sep 17 00:00:00 2001 From: Haven Date: Mon, 17 Aug 2020 14:30:12 -0700 Subject: [PATCH 33/53] Better lily pads are now better-er (100% compatibility for resource packs). --- .../tweaks/mixin/block/LilyPadBlockMixin.java | 7 +++-- .../tweaks/mixin/block/MoveLilyPadsDown.java | 28 +++++++++++++++++++ .../tweaks/mixin/entity/EntityMixin.java | 24 ++++++++++++++++ .../mixin/entity/LivingEntityMixin.java | 22 +++++++++++++++ .../minecraft/models/block/lily_pad.json | 16 ----------- src/main/resources/tweaks.mixins.json | 2 ++ 6 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java delete mode 100644 src/main/resources/assets/minecraft/models/block/lily_pad.json diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java index 24d6e18..2da0192 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java @@ -30,18 +30,19 @@ public void overwriteEntityCollision(BlockState state, World world, BlockPos pos ci.cancel(); } - private static final VoxelShape COLLIDER = Block.createCuboidShape(1.0D, -0.155D, 1.0D, 15.0D, -1.5D, 15.0D); + private static final VoxelShape OUTLINES = Block.createCuboidShape(1D, -1.75D, 1D, 15D, -0.75D, 15D); + private static final VoxelShape COLLIDER = Block.createCuboidShape(1.0D, -10D, 1.0D, 15.0D, 0, 15.0D); @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) public void overwriteOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (Tweaks.CONFIG.betterLilyPads) - cir.setReturnValue(COLLIDER); + cir.setReturnValue(OUTLINES); } @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (Tweaks.CONFIG.betterLilyPads) - return context.isAbove(COLLIDER, pos, false) ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); + return context.isAbove(COLLIDER, pos, false) ? COLLIDER : VoxelShapes.empty(); else return super.getCollisionShape(state, view, pos, context); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java new file mode 100644 index 0000000..0ad0f31 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java @@ -0,0 +1,28 @@ +package dev.hephaestus.tweaks.mixin.block; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(AbstractBlock.AbstractBlockState.class) +public abstract class MoveLilyPadsDown { + @Shadow public abstract Block getBlock(); + + private static final Vec3d DOWN = new Vec3d(0, -0.1D, 0); + + @Inject(method = "getModelOffset", at = @At("HEAD"), cancellable = true) + private void offsetLilyPadsDown(BlockView world, BlockPos pos, CallbackInfoReturnable cir) { + if (Tweaks.CONFIG.betterLilyPads && this.getBlock() == Blocks.LILY_PAD) { + cir.setReturnValue(DOWN); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java new file mode 100644 index 0000000..e0ef5f4 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java @@ -0,0 +1,24 @@ +package dev.hephaestus.tweaks.mixin.entity; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(Entity.class) +public class EntityMixin { + @Shadow public World world; + + @Redirect(method = "spawnSprintingParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;")) + private BlockState lilyPadsOnWater(World world, BlockPos pos) { + BlockState original = world.getBlockState(pos); + BlockState above = world.getBlockState(pos.up()); + + return original.getBlock().is(Blocks.WATER) && above.getBlock().is(Blocks.LILY_PAD) ? above : original; + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java index a6ef6ec..88b7160 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java @@ -2,16 +2,22 @@ import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.LeavesBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; +import net.minecraft.particle.BlockStateParticleEffect; +import net.minecraft.particle.ParticleType; import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -35,4 +41,20 @@ public void onIsClimbing(CallbackInfoReturnable info, BlockPos pos) { } } } + + @Unique private BlockState landedState; + @Unique private BlockPos landedPosition; + + @Inject(method = "fall", at = @At(value = "NEW", target = "net/minecraft/particle/BlockStateParticleEffect")) + private void captureArgs(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition, CallbackInfo ci) { + this.landedState = landedState; + this.landedPosition = landedPosition; + } + + @Redirect(method = "fall", at = @At(value = "NEW", target = "net/minecraft/particle/BlockStateParticleEffect")) + private BlockStateParticleEffect lilyPadsOnWater(ParticleType particleType, BlockState blockState) { + BlockState above = world.getBlockState(this.landedPosition.up()); + + return new BlockStateParticleEffect(particleType, this.landedState.getBlock().is(Blocks.WATER) && above.getBlock().is(Blocks.LILY_PAD) ? above : this.landedState); + } } diff --git a/src/main/resources/assets/minecraft/models/block/lily_pad.json b/src/main/resources/assets/minecraft/models/block/lily_pad.json deleted file mode 100644 index 953ddaf..0000000 --- a/src/main/resources/assets/minecraft/models/block/lily_pad.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "ambientocclusion": false, - "textures": { - "particle": "block/lily_pad", - "texture": "block/lily_pad" - }, - "elements": [ - { "from": [ 0, -1.55, 0 ], - "to": [ 16, -1.5, 16 ], - "faces": { - "down": { "uv": [ 16, 16, 0, 0 ], "texture": "#texture", "tintindex": 0 }, - "up": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "tintindex": 0 } - } - } - ] -} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 18b8e89..8525c2f 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -17,6 +17,7 @@ "block.LilyPadBlockMixin", "block.MoistBlocksMixin", "block.MoistObjectsMixin", + "block.MoveLilyPadsDown", "block.NetherWartBlockMixin", "block.NyliumBlockMixin", "block.SignBlockMixin", @@ -24,6 +25,7 @@ "block.SugarCaneMixin", "block.TallPlantBlockMixin", "block.TrapDoorMixin", + "entity.EntityMixin", "entity.InteractableEntityMixin", "entity.ItemEntityMixin", "entity.LivingEntityMixin", From 6ba441f1118dc3c8ced630c1282d096eb71b1d37 Mon Sep 17 00:00:00 2001 From: Haven Date: Mon, 17 Aug 2020 15:00:43 -0700 Subject: [PATCH 34/53] Renamed mixins --- ...Mixin.java => BurnedLogsDropCharcoal.java} | 2 +- ...SignBlockMixin.java => EditableSigns.java} | 4 +- ...avesBlockMixin.java => LeafCollision.java} | 4 +- ...kMixin.java => MakeCauldronsInfinite.java} | 4 +- ...n.java => MakeLanternsBlastResistant.java} | 2 +- ...va => NetherRejuvenationNyliumSpread.java} | 2 +- ...java => StopBubbleColumnsFromFlowing.java} | 2 +- .../Collision.java} | 6 +- .../Rendering.java} | 4 +- .../Doors.java} | 4 +- .../TrapDoors.java} | 6 +- .../CocoaBeans.java} | 6 +- .../Crops.java} | 6 +- .../NetherWarts.java} | 6 +- .../SugarCane.java} | 6 +- .../MoistenBlocks.java} | 4 +- .../MoistenPartBlocks.java} | 8 +-- .../FernBlocks.java} | 6 +- .../TallPlants.java} | 6 +- .../RejuvenateDeadBushes.java} | 4 +- .../TallGrassSpread.java} | 4 +- ...RendererMixin.java => RenderSoulFire.java} | 2 +- ...Mixin.java => PopulateSignEditScreen.java} | 2 +- ...n.java => GetParticlesForEmptyBlocks.java} | 2 +- ...spatcherMixin.java => RenderSoulFire.java} | 2 +- .../dev/ChestBlockEntityRendererMixin.java | 2 +- ...ntityMixin.java => AutoPlantSaplings.java} | 4 +- ...tityMixin.java => BurnUsableEntities.java} | 2 +- .../mixin/entity/LivingEntityMixin.java | 16 ----- ...ava => FarmerVillagersDepositSurplus.java} | 2 +- .../betterlilypads/FallingParticles.java | 40 +++++++++++++ .../SprintingParticles.java} | 4 +- src/main/resources/tweaks.mixins.json | 59 ++++++++++--------- 33 files changed, 128 insertions(+), 105 deletions(-) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{FireBlockMixin.java => BurnedLogsDropCharcoal.java} (96%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{SignBlockMixin.java => EditableSigns.java} (88%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{LeavesBlockMixin.java => LeafCollision.java} (93%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{CauldronBlockMixin.java => MakeCauldronsInfinite.java} (97%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{LanternResistanceMixin.java => MakeLanternsBlastResistant.java} (94%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{NyliumBlockMixin.java => NetherRejuvenationNyliumSpread.java} (98%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{BubbleColumnBlockMixin.java => StopBubbleColumnsFromFlowing.java} (95%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{LilyPadBlockMixin.java => betterlilypads/Collision.java} (92%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{MoveLilyPadsDown.java => betterlilypads/Rendering.java} (91%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{DoorBlockMixin.java => doubledoors/Doors.java} (97%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{TrapDoorMixin.java => doubledoors/TrapDoors.java} (95%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{CocoaBlockMixin.java => easyharvest/CocoaBeans.java} (89%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{CropBlockMixin.java => easyharvest/Crops.java} (92%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{NetherWartBlockMixin.java => easyharvest/NetherWarts.java} (90%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{SugarCaneMixin.java => easyharvest/SugarCane.java} (94%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{MoistBlocksMixin.java => mossythings/MoistenBlocks.java} (94%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{MoistObjectsMixin.java => mossythings/MoistenPartBlocks.java} (70%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{FernBlockMixin.java => planthitboxes/FernBlocks.java} (84%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{TallPlantBlockMixin.java => planthitboxes/TallPlants.java} (84%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{DeadBushBlockMixin.java => rejuvenation/RejuvenateDeadBushes.java} (90%) rename src/main/java/dev/hephaestus/tweaks/mixin/block/{SpreadableBlockMixin.java => rejuvenation/TallGrassSpread.java} (96%) rename src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/{InGameOverlayRendererMixin.java => RenderSoulFire.java} (96%) rename src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/{SignEditScreenMixin.java => PopulateSignEditScreen.java} (96%) rename src/main/java/dev/hephaestus/tweaks/mixin/client/particle/{ParticleManagerMixin.java => GetParticlesForEmptyBlocks.java} (95%) rename src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/{EntityRenderDispatcherMixin.java => RenderSoulFire.java} (98%) rename src/main/java/dev/hephaestus/tweaks/mixin/entity/{ItemEntityMixin.java => AutoPlantSaplings.java} (95%) rename src/main/java/dev/hephaestus/tweaks/mixin/entity/{InteractableEntityMixin.java => BurnUsableEntities.java} (96%) rename src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/{FarmerVillagerTaskMixin.java => FarmerVillagersDepositSurplus.java} (98%) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/FallingParticles.java rename src/main/java/dev/hephaestus/tweaks/mixin/entity/{EntityMixin.java => betterlilypads/SprintingParticles.java} (90%) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/BurnedLogsDropCharcoal.java similarity index 96% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/BurnedLogsDropCharcoal.java index ec963aa..8c12ed5 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/FireBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/BurnedLogsDropCharcoal.java @@ -16,7 +16,7 @@ import java.util.Random; @Mixin(FireBlock.class) -public class FireBlockMixin { +public class BurnedLogsDropCharcoal { @Inject(method = "trySpreadingFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 1)) private void beforeSet(World world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo ci) { if (Tweaks.CONFIG.burningLogsDropCharcoal && world.getBlockState(pos).getBlock().isIn(BlockTags.LOGS_THAT_BURN)) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/EditableSigns.java similarity index 88% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/EditableSigns.java index 63e06da..dedde59 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SignBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/EditableSigns.java @@ -14,8 +14,8 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(SignBlock.class) -public class SignBlockMixin extends AbstractSignBlock { - protected SignBlockMixin(Settings settings, SignType type) { +public class EditableSigns extends AbstractSignBlock { + protected EditableSigns(Settings settings, SignType type) { super(settings, type); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java similarity index 93% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java index 9a410e2..6cc3261 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeavesBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java @@ -14,9 +14,9 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(LeavesBlock.class) -public class LeavesBlockMixin extends Block{ +public class LeafCollision extends Block{ - public LeavesBlockMixin(Settings settings) { + public LeafCollision(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java similarity index 97% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java index 5c0977d..c50f16a 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/CauldronBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java @@ -31,10 +31,10 @@ import java.util.Random; @Mixin(CauldronBlock.class) -public class CauldronBlockMixin extends Block { +public class MakeCauldronsInfinite extends Block { @Unique private static final BooleanProperty INFINITE = BooleanProperty.of("infinite"); - public CauldronBlockMixin(Settings settings) { + public MakeCauldronsInfinite(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LanternResistanceMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeLanternsBlastResistant.java similarity index 94% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/LanternResistanceMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/MakeLanternsBlastResistant.java index cc5e0b2..ec065b6 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LanternResistanceMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeLanternsBlastResistant.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Blocks.class) -public class LanternResistanceMixin { +public class MakeLanternsBlastResistant { @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/LanternBlock")) private static LanternBlock redirLantern(Block.Settings settings) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherRejuvenationNyliumSpread.java similarity index 98% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/NetherRejuvenationNyliumSpread.java index d21d3a7..5af82d6 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/NyliumBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherRejuvenationNyliumSpread.java @@ -15,7 +15,7 @@ import java.util.Random; @Mixin(NyliumBlock.class) -public abstract class NyliumBlockMixin { +public abstract class NetherRejuvenationNyliumSpread { @Shadow private static boolean stayAlive(BlockState state, WorldView world, BlockPos pos) {return true;} private static boolean canSpread(BlockState state, ServerWorld world, BlockPos pos) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/StopBubbleColumnsFromFlowing.java similarity index 95% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/StopBubbleColumnsFromFlowing.java index 7bf1c1e..32b43f1 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/BubbleColumnBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/StopBubbleColumnsFromFlowing.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(value = BubbleColumnBlock.class, priority = 2000) -public class BubbleColumnBlockMixin { +public class StopBubbleColumnsFromFlowing { @Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/TickScheduler;schedule(Lnet/minecraft/util/math/BlockPos;Ljava/lang/Object;I)V", ordinal = 1)) private void dontFluidTick(TickScheduler tickScheduler, BlockPos pos, T object, int delay) { if (Tweaks.CONFIG.bubbleColumnsFlow) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/betterlilypads/Collision.java similarity index 92% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/betterlilypads/Collision.java index 2da0192..4d624f4 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LilyPadBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/betterlilypads/Collision.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.betterlilypads; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.*; @@ -17,10 +17,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LilyPadBlock.class) -public abstract class LilyPadBlockMixin extends PlantBlock { +public abstract class Collision extends PlantBlock { @Shadow @Final protected static VoxelShape SHAPE; - protected LilyPadBlockMixin(Settings settings) { + protected Collision(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/betterlilypads/Rendering.java similarity index 91% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/betterlilypads/Rendering.java index 0ad0f31..a540b34 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoveLilyPadsDown.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/betterlilypads/Rendering.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.betterlilypads; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.AbstractBlock; @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractBlock.AbstractBlockState.class) -public abstract class MoveLilyPadsDown { +public abstract class Rendering { @Shadow public abstract Block getBlock(); private static final Vec3d DOWN = new Vec3d(0, -0.1D, 0); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/doubledoors/Doors.java similarity index 97% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/doubledoors/Doors.java index 6d2c499..86e193f 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/DoorBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/doubledoors/Doors.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.doubledoors; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.Block; @@ -24,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(DoorBlock.class) -public abstract class DoorBlockMixin { +public abstract class Doors { @Shadow @Final public static DirectionProperty FACING; @Shadow @Final public static EnumProperty HINGE; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/doubledoors/TrapDoors.java similarity index 95% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/doubledoors/TrapDoors.java index d174bdd..45c1850 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/TrapDoorMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/doubledoors/TrapDoors.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.doubledoors; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.Block; @@ -28,7 +28,7 @@ import javax.annotation.Nullable; @Mixin(TrapdoorBlock.class) -public abstract class TrapDoorMixin extends HorizontalFacingBlock { +public abstract class TrapDoors extends HorizontalFacingBlock { @Shadow @Final public static BooleanProperty OPEN; @Shadow @Final public static BooleanProperty WATERLOGGED; @@ -37,7 +37,7 @@ public abstract class TrapDoorMixin extends HorizontalFacingBlock { @Shadow @Final public static EnumProperty HALF; - protected TrapDoorMixin(Settings settings) { + protected TrapDoors(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/CocoaBeans.java similarity index 89% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/CocoaBeans.java index a0e2880..604e058 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/CocoaBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/CocoaBeans.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.easyharvest; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.*; @@ -14,8 +14,8 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(CocoaBlock.class) -public abstract class CocoaBlockMixin extends HorizontalFacingBlock { - protected CocoaBlockMixin(Settings settings) { super(settings);} +public abstract class CocoaBeans extends HorizontalFacingBlock { + protected CocoaBeans(Settings settings) { super(settings);} @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/Crops.java similarity index 92% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/Crops.java index 2dac629..74ad328 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/CropBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/Crops.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.easyharvest; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.Block; @@ -18,8 +18,8 @@ @SuppressWarnings("deprecation") @Mixin(CropBlock.class) -public abstract class CropBlockMixin extends PlantBlock { - protected CropBlockMixin(Settings settings) { +public abstract class Crops extends PlantBlock { + protected Crops(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/NetherWarts.java similarity index 90% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/NetherWarts.java index ae94da9..2302782 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/NetherWartBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/NetherWarts.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.easyharvest; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.Block; @@ -17,8 +17,8 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(NetherWartBlock.class) -public abstract class NetherWartBlockMixin extends PlantBlock { - protected NetherWartBlockMixin(Settings settings) { super(settings);} +public abstract class NetherWarts extends PlantBlock { + protected NetherWarts(Settings settings) { super(settings);} @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/SugarCane.java similarity index 94% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/SugarCane.java index 0af28f3..15ed304 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SugarCaneMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyharvest/SugarCane.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.easyharvest; import dev.hephaestus.tweaks.Tweaks; import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; @@ -22,8 +22,8 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(SugarCaneBlock.class) -public class SugarCaneMixin extends Block { - public SugarCaneMixin(Settings settings) { +public class SugarCane extends Block { + public SugarCane(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java similarity index 94% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java index 5ed70a3..f639c71 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistBlocksMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.mossythings; import dev.hephaestus.tweaks.block.MoistBlock; import net.minecraft.block.Block; @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Blocks.class) -public class MoistBlocksMixin { +public class MoistenBlocks { @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 9)) private static Block moistenCobblestone(Block.Settings settings) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java similarity index 70% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java index f0878c9..9de5b83 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MoistObjectsMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java @@ -1,18 +1,16 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.mossythings; import dev.hephaestus.tweaks.block.MoistBlock; -import dev.hephaestus.tweaks.block.Moistener; import net.minecraft.block.*; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldView; import org.spongepowered.asm.mixin.Mixin; import java.util.Random; @Mixin({StairsBlock.class, SlabBlock.class, WallBlock.class}) -public abstract class MoistObjectsMixin extends Block { - public MoistObjectsMixin(Settings settings) { +public abstract class MoistenPartBlocks extends Block { + public MoistenPartBlocks(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/planthitboxes/FernBlocks.java similarity index 84% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/planthitboxes/FernBlocks.java index 2311d21..c98b12f 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/FernBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/planthitboxes/FernBlocks.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.planthitboxes; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.*; @@ -12,10 +12,10 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(FernBlock.class) -public class FernBlockMixin extends PlantBlock { +public class FernBlocks extends PlantBlock { @Shadow @Final protected static VoxelShape SHAPE; - protected FernBlockMixin(Settings settings) { + protected FernBlocks(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/planthitboxes/TallPlants.java similarity index 84% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/planthitboxes/TallPlants.java index 3d87c7e..3f49633 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/TallPlantBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/planthitboxes/TallPlants.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.planthitboxes; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.BlockState; @@ -13,8 +13,8 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(TallPlantBlock.class) -public class TallPlantBlockMixin extends PlantBlock { - protected TallPlantBlockMixin(Settings settings) { +public class TallPlants extends PlantBlock { + protected TallPlants(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/DeadBushBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/rejuvenation/RejuvenateDeadBushes.java similarity index 90% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/DeadBushBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/rejuvenation/RejuvenateDeadBushes.java index 2432803..825bde3 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/DeadBushBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/rejuvenation/RejuvenateDeadBushes.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.rejuvenation; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.BlockState; @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(DeadBushBlock.class) -public class DeadBushBlockMixin { +public class RejuvenateDeadBushes { @Inject(method = "canPlantOnTop", at = @At("TAIL"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) public void canBeOnGrass(BlockState floor, BlockView view, BlockPos pos, CallbackInfoReturnable cir) { if (Tweaks.CONFIG.rejuvenation.enabled && floor.getBlock() == Blocks.GRASS_BLOCK) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/rejuvenation/TallGrassSpread.java similarity index 96% rename from src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/block/rejuvenation/TallGrassSpread.java index 12c8980..7a7a8e1 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/SpreadableBlockMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/rejuvenation/TallGrassSpread.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.block; +package dev.hephaestus.tweaks.mixin.block.rejuvenation; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.block.*; @@ -13,7 +13,7 @@ import java.util.Random; @Mixin(SpreadableBlock.class) -public class SpreadableBlockMixin { +public class TallGrassSpread { @Inject(method = "randomTick", at = @At(value = "INVOKE", target = "net/minecraft/block/SpreadableBlock.getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) public void growGrass(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { if (Tweaks.CONFIG.rejuvenation.enabled && state.getBlock() == Blocks.GRASS_BLOCK) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/RenderSoulFire.java similarity index 96% rename from src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/RenderSoulFire.java index bf391f4..d2b6876 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/InGameOverlayRendererMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/hud/RenderSoulFire.java @@ -15,7 +15,7 @@ @Environment(EnvType.CLIENT) @Mixin(InGameOverlayRenderer.class) -public class InGameOverlayRendererMixin { +public class RenderSoulFire { @Redirect(method = "renderFireOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;")) private static Sprite getSoulFireSprite(SpriteIdentifier spriteIdentifier) { ClientPlayerEntity playerEntity = MinecraftClient.getInstance().player; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java similarity index 96% rename from src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java index 47bd956..7466830 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/SignEditScreenMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java @@ -15,7 +15,7 @@ @Mixin(SignEditScreen.class) @Environment(EnvType.CLIENT) -public class SignEditScreenMixin { +public class PopulateSignEditScreen { @Shadow @Final private String[] field_24285; @Shadow @Final private SignBlockEntity sign; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/GetParticlesForEmptyBlocks.java similarity index 95% rename from src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/client/particle/GetParticlesForEmptyBlocks.java index 9a7bb50..5d572a3 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/ParticleManagerMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/particle/GetParticlesForEmptyBlocks.java @@ -12,7 +12,7 @@ @Environment(EnvType.CLIENT) @Mixin(ParticleManager.class) -public class ParticleManagerMixin { +public class GetParticlesForEmptyBlocks { @Redirect(method = "addBlockBreakingParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/shape/VoxelShape;getBoundingBox()Lnet/minecraft/util/math/Box;")) private Box makeParticlesForEmptyBlocks(VoxelShape voxelShape) { return voxelShape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : voxelShape.getBoundingBox(); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/RenderSoulFire.java similarity index 98% rename from src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/RenderSoulFire.java index 041705a..c4df6b9 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/EntityRenderDispatcherMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/RenderSoulFire.java @@ -19,7 +19,7 @@ @Environment(EnvType.CLIENT) @Mixin(EntityRenderDispatcher.class) -public class EntityRenderDispatcherMixin { +public class RenderSoulFire { @Unique private Entity renderedEntity; @Inject(method = "renderFire", at = @At("HEAD")) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/dev/ChestBlockEntityRendererMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/dev/ChestBlockEntityRendererMixin.java index 74ece0e..222f109 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/dev/ChestBlockEntityRendererMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/dev/ChestBlockEntityRendererMixin.java @@ -21,7 +21,7 @@ public ChestBlockEntityRendererMixin(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V")) + @Inject(method = "render(Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V")) public void renderLabel(T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, CallbackInfo ci) { if (Tweaks.CONFIG.namesAndThings.containerLabels && blockEntity instanceof LockableContainerBlockEntity) { LabelRenderer.renderLabel((LockableContainerBlockEntity) blockEntity, dispatcher, matrices, vertexConsumers, tickDelta); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlantSaplings.java similarity index 95% rename from src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlantSaplings.java index cb5b9b5..23f52ec 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ItemEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlantSaplings.java @@ -25,8 +25,8 @@ @Mixin(ItemEntity.class) -public abstract class ItemEntityMixin extends Entity { - public ItemEntityMixin(EntityType type, World world) { +public abstract class AutoPlantSaplings extends Entity { + public AutoPlantSaplings(EntityType type, World world) { super(type, world); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/BurnUsableEntities.java similarity index 96% rename from src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/entity/BurnUsableEntities.java index a54bc37..934c496 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/InteractableEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/BurnUsableEntities.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(value = {WanderingTraderEntity.class, PiglinEntity.class, VillagerEntity.class}) -public class InteractableEntityMixin { +public class BurnUsableEntities { @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) private void useFlintAndSteel(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { if (player.getStackInHand(hand).getItem().equals(Items.FLINT_AND_STEEL)) { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java index 88b7160..6111059 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java @@ -41,20 +41,4 @@ public void onIsClimbing(CallbackInfoReturnable info, BlockPos pos) { } } } - - @Unique private BlockState landedState; - @Unique private BlockPos landedPosition; - - @Inject(method = "fall", at = @At(value = "NEW", target = "net/minecraft/particle/BlockStateParticleEffect")) - private void captureArgs(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition, CallbackInfo ci) { - this.landedState = landedState; - this.landedPosition = landedPosition; - } - - @Redirect(method = "fall", at = @At(value = "NEW", target = "net/minecraft/particle/BlockStateParticleEffect")) - private BlockStateParticleEffect lilyPadsOnWater(ParticleType particleType, BlockState blockState) { - BlockState above = world.getBlockState(this.landedPosition.up()); - - return new BlockStateParticleEffect(particleType, this.landedState.getBlock().is(Blocks.WATER) && above.getBlock().is(Blocks.LILY_PAD) ? above : this.landedState); - } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagersDepositSurplus.java similarity index 98% rename from src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagersDepositSurplus.java index 3eb4390..67438af 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagerTaskMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/ai/brain/task/FarmerVillagersDepositSurplus.java @@ -23,7 +23,7 @@ import javax.annotation.Nullable; @Mixin(FarmerVillagerTask.class) -public class FarmerVillagerTaskMixin { +public class FarmerVillagersDepositSurplus { @Shadow @Nullable private BlockPos currentTarget; private BlockPos storage; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/FallingParticles.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/FallingParticles.java new file mode 100644 index 0000000..8df44cb --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/FallingParticles.java @@ -0,0 +1,40 @@ +package dev.hephaestus.tweaks.mixin.entity.betterlilypads; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.particle.BlockStateParticleEffect; +import net.minecraft.particle.ParticleType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LivingEntity.class) +public abstract class FallingParticles extends Entity { + @Unique private BlockState landedState; + @Unique private BlockPos landedPosition; + + public FallingParticles(EntityType type, World world) { + super(type, world); + } + + @Inject(method = "fall", at = @At(value = "NEW", target = "net/minecraft/particle/BlockStateParticleEffect")) + private void captureArgs(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition, CallbackInfo ci) { + this.landedState = landedState; + this.landedPosition = landedPosition; + } + + @Redirect(method = "fall", at = @At(value = "NEW", target = "net/minecraft/particle/BlockStateParticleEffect")) + private BlockStateParticleEffect lilyPadsOnWater(ParticleType particleType, BlockState blockState) { + BlockState above = this.world.getBlockState(this.landedPosition.up()); + + return new BlockStateParticleEffect(particleType, this.landedState.getBlock().is(Blocks.WATER) && above.getBlock().is(Blocks.LILY_PAD) ? above : this.landedState); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/SprintingParticles.java similarity index 90% rename from src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java rename to src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/SprintingParticles.java index e0ef5f4..816bfab 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/EntityMixin.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/betterlilypads/SprintingParticles.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.entity; +package dev.hephaestus.tweaks.mixin.entity.betterlilypads; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Entity.class) -public class EntityMixin { +public class SprintingParticles { @Shadow public World world; @Redirect(method = "spawnSprintingParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;")) diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 8525c2f..c3e928c 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -4,32 +4,33 @@ "compatibilityLevel": "JAVA_8", "plugin": "dev.hephaestus.tweaks.mixin.VolatileMixinPlugin", "mixins": [ - "block.BubbleColumnBlockMixin", - "block.CauldronBlockMixin", - "block.CocoaBlockMixin", - "block.CropBlockMixin", - "block.DeadBushBlockMixin", - "block.DoorBlockMixin", - "block.FernBlockMixin", - "block.FireBlockMixin", - "block.LanternResistanceMixin", - "block.LeavesBlockMixin", - "block.LilyPadBlockMixin", - "block.MoistBlocksMixin", - "block.MoistObjectsMixin", - "block.MoveLilyPadsDown", - "block.NetherWartBlockMixin", - "block.NyliumBlockMixin", - "block.SignBlockMixin", - "block.SpreadableBlockMixin", - "block.SugarCaneMixin", - "block.TallPlantBlockMixin", - "block.TrapDoorMixin", - "entity.EntityMixin", - "entity.InteractableEntityMixin", - "entity.ItemEntityMixin", + "block.BurnedLogsDropCharcoal", + "block.EditableSigns", + "block.LeafCollision", + "block.MakeCauldronsInfinite", + "block.MakeLanternsBlastResistant", + "block.NetherRejuvenationNyliumSpread", + "block.StopBubbleColumnsFromFlowing", + "block.betterlilypads.Collision", + "block.betterlilypads.Rendering", + "block.doubledoors.Doors", + "block.doubledoors.TrapDoors", + "block.easyharvest.CocoaBeans", + "block.easyharvest.Crops", + "block.easyharvest.NetherWarts", + "block.easyharvest.SugarCane", + "block.mossythings.MoistenBlocks", + "block.mossythings.MoistenPartBlocks", + "block.planthitboxes.FernBlocks", + "block.planthitboxes.TallPlants", + "block.rejuvenation.RejuvenateDeadBushes", + "block.rejuvenation.TallGrassSpread", + "entity.BurnUsableEntities", + "entity.AutoPlantSaplings", "entity.LivingEntityMixin", - "entity.ai.brain.task.FarmerVillagerTaskMixin", + "entity.ai.brain.task.FarmerVillagersDepositSurplus", + "entity.betterlilypads.FallingParticles", + "entity.betterlilypads.SprintingParticles", "entity.passive.ChickenEntityMixin", "entity.passive.CowEntityMixin", "entity.passive.HorseAndDonkeyMixin", @@ -44,13 +45,13 @@ "item.ShovelMixin" ], "client": [ - "client.gui.hud.InGameOverlayRendererMixin", - "client.gui.screen.ingame.SignEditScreenMixin", - "client.particle.ParticleManagerMixin", + "client.gui.hud.RenderSoulFire", + "client.gui.screen.ingame.PopulateSignEditScreen", + "client.particle.GetParticlesForEmptyBlocks", "client.render.CameraMixin", "client.render.entity.BoatEntityRendererMixin", - "client.render.entity.EntityRenderDispatcherMixin", "client.render.entity.PlayerEntityRendererMixin", + "client.render.entity.RenderSoulFire", "dev.ChestBlockEntityRendererMixin", "dev.ShulkerBoxEntityRendererMixin", "entity.SetSoulFireType", From 8338c443e8a5d35d06dd0ff9836c22d22916b69b Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 18 Aug 2020 11:29:36 -0700 Subject: [PATCH 35/53] Added "Better XP" tweak, which causes XP to be given directly to the players that earned it rather than dropping it on the floor. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 4 ++ .../tweaks/block/PlayerProvider.java | 24 +++++++++ .../tweaks/mixin/block/easyxp/Blocks.java | 49 +++++++++++++++++++ .../FurnaceBlockEntityPlayerProvider.java | 31 ++++++++++++ .../block/easyxp/PassPlayerToEntity.java | 19 +++++++ .../entity/easyxp/AnimalEntityBreedXp.java | 38 ++++++++++++++ .../tweaks/mixin/entity/easyxp/FishingXp.java | 28 +++++++++++ .../entity/easyxp/LivingEntityGiveXp.java | 24 +++++++++ .../mixin/entity/easyxp/MateGoalXp.java | 32 ++++++++++++ .../mixin/entity/easyxp/VillagerTradeXp.java | 41 ++++++++++++++++ .../mixin/screen/DepositGrindstoneXp.java | 36 ++++++++++++++ .../assets/tinytweaks/lang/en_us.json | 5 ++ src/main/resources/tweaks.accesswidener | 2 + src/main/resources/tweaks.mixins.json | 13 ++++- 14 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 9015b7b..10b0827 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -89,6 +89,10 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.Tooltip public boolean infiniteCauldrons = true; + @ConfigEntry.Category("misc") + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean easyXp = true; + public static class AutoPlanting { @ConfigEntry.Gui.Tooltip(count = 2) public boolean enabled = true; diff --git a/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java b/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java new file mode 100644 index 0000000..d156083 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java @@ -0,0 +1,24 @@ +package dev.hephaestus.tweaks.block; + +import net.minecraft.server.network.ServerPlayerEntity; + +public interface PlayerProvider { + ThreadLocal STATIC = new ThreadLocal() {{ + this.set(new PlayerProvider() { + private ServerPlayerEntity playerEntity = null; + + @Override + public ServerPlayerEntity getPlayer() { + return this.playerEntity; + } + + @Override + public void setPlayer(ServerPlayerEntity player) { + this.playerEntity = player; + } + }); + }}; + + ServerPlayerEntity getPlayer(); + void setPlayer(ServerPlayerEntity player); +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java new file mode 100644 index 0000000..9a4da86 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java @@ -0,0 +1,49 @@ +package dev.hephaestus.tweaks.mixin.block.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.block.PlayerProvider; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Block.class) +public class Blocks implements PlayerProvider { + @Unique private final ThreadLocal playerEntity = new ThreadLocal<>(); + + @Override + public ServerPlayerEntity getPlayer() { + return this.playerEntity.get(); + } + + @Override + public void setPlayer(ServerPlayerEntity player) { + this.playerEntity.set(player); + } + + @Inject(method = "dropStacks(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/entity/BlockEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/item/ItemStack;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;onStacksDropped(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)V")) + private static void assignPlayerToBlock(BlockState state, World world, BlockPos pos, BlockEntity blockEntity, Entity entity, ItemStack stack, CallbackInfo ci) { + if (entity instanceof ServerPlayerEntity && Tweaks.CONFIG.easyXp) { + ((PlayerProvider) state.getBlock()).setPlayer((ServerPlayerEntity) entity); + } + } + + @Inject(method = "dropExperience", at = @At("HEAD"), cancellable = true) + protected void depositXpToPlayer(ServerWorld world, BlockPos pos, int size, CallbackInfo ci) { + if (this.getPlayer() != null && Tweaks.CONFIG.easyXp) { + this.getPlayer().addExperience(size); + this.setPlayer(null); + ci.cancel(); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java new file mode 100644 index 0000000..60016ac --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java @@ -0,0 +1,31 @@ +package dev.hephaestus.tweaks.mixin.block.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.block.PlayerProvider; +import net.minecraft.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(AbstractFurnaceBlockEntity.class) +public abstract class FurnaceBlockEntityPlayerProvider implements PlayerProvider { + @Shadow private static void dropExperience(World world, Vec3d vec3d, int i, float f) { + throw new RuntimeException(); + } + + @Redirect(method = "method_17761", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;dropExperience(Lnet/minecraft/world/World;Lnet/minecraft/util/math/Vec3d;IF)V")) + private static void depositXpToPlayer(World world, Vec3d vec3d, int i, float f) { + ServerPlayerEntity playerEntity = PlayerProvider.STATIC.get().getPlayer(); + + if (playerEntity != null && Tweaks.CONFIG.easyXp) { + playerEntity.addExperience(i); + PlayerProvider.STATIC.get().setPlayer(null); + } else { + dropExperience(world, vec3d, i, f); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java new file mode 100644 index 0000000..e19a23d --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java @@ -0,0 +1,19 @@ +package dev.hephaestus.tweaks.mixin.block.easyxp; + +import dev.hephaestus.tweaks.block.PlayerProvider; +import net.minecraft.block.AbstractFurnaceBlock; +import net.minecraft.block.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(AbstractFurnaceBlock.class) +public class PassPlayerToEntity { + @Inject(method = "onStateReplaced", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;method_27354(Lnet/minecraft/world/World;Lnet/minecraft/util/math/Vec3d;)Ljava/util/List;")) + private void setStaticPlayer(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved, CallbackInfo ci) { + PlayerProvider.STATIC.get().setPlayer(((PlayerProvider) state.getBlock()).getPlayer()); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java new file mode 100644 index 0000000..70f621e --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java @@ -0,0 +1,38 @@ +package dev.hephaestus.tweaks.mixin.entity.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import javax.annotation.Nullable; + +@Mixin(AnimalEntity.class) +public abstract class AnimalEntityBreedXp extends LivingEntity { + @Shadow @Nullable public abstract ServerPlayerEntity getLovingPlayer(); + + protected AnimalEntityBreedXp(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "breed", at = @At(value = "NEW", target = "net/minecraft/entity/ExperienceOrbEntity"), cancellable = true) + private void depositXpToPlayer(ServerWorld serverWorld, AnimalEntity other, CallbackInfo ci) { + ServerPlayerEntity playerEntity = this.getLovingPlayer(); + if (playerEntity == null && other.getLovingPlayer() != null) { + playerEntity = other.getLovingPlayer(); + } + + if (playerEntity != null && Tweaks.CONFIG.easyXp) { + playerEntity.addExperience(this.getRandom().nextInt(7) + 1); + ci.cancel(); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java new file mode 100644 index 0000000..85aa18f --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java @@ -0,0 +1,28 @@ +package dev.hephaestus.tweaks.mixin.entity.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.FishingBobberEntity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import javax.annotation.Nullable; + +@Mixin(FishingBobberEntity.class) +public abstract class FishingXp { + @Shadow @Nullable public abstract PlayerEntity getPlayerOwner(); + + @Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) + private boolean depositXpToPlayer(World world, Entity entity) { + if (this.getPlayerOwner() != null && Tweaks.CONFIG.easyXp) { + this.getPlayerOwner().addExperience((int) (Math.random() * 6 + 1)); + return false; + } + + return world.spawnEntity(entity); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java new file mode 100644 index 0000000..8cd46ef --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java @@ -0,0 +1,24 @@ +package dev.hephaestus.tweaks.mixin.entity.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(LivingEntity.class) +public class LivingEntityGiveXp { + @Shadow protected PlayerEntity attackingPlayer; + + @Inject(method = "dropXp", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/LivingEntity;getCurrentExperience(Lnet/minecraft/entity/player/PlayerEntity;)I"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) + private void depositXpToPlayer(CallbackInfo ci, int i) { + if (i > 0 && this.attackingPlayer != null && Tweaks.CONFIG.easyXp) { + this.attackingPlayer.addExperience(i); + ci.cancel(); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java new file mode 100644 index 0000000..eb01ff1 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java @@ -0,0 +1,32 @@ +package dev.hephaestus.tweaks.mixin.entity.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.ai.goal.AnimalMateGoal; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.FoxEntity; +import net.minecraft.entity.passive.TurtleEntity; +import net.minecraft.server.network.ServerPlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin({ + FoxEntity.MateGoal.class, + TurtleEntity.MateGoal.class +}) +public abstract class MateGoalXp extends AnimalMateGoal { + public MateGoalXp(AnimalEntity animal, double chance) { + super(animal, chance); + } + + @Inject(method = "breed", at = @At(value = "NEW", target = "net/minecraft/entity/ExperienceOrbEntity"), cancellable = true) + private void depositXpToPlayer(CallbackInfo ci) { + ServerPlayerEntity playerEntity = this.animal.getLovingPlayer(); + + if (playerEntity != null && Tweaks.CONFIG.easyXp) { + playerEntity.addExperience(this.animal.getRandom().nextInt(7) + 1); + ci.cancel(); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java new file mode 100644 index 0000000..a449732 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java @@ -0,0 +1,41 @@ +package dev.hephaestus.tweaks.mixin.entity.easyxp; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.passive.AbstractTraderEntity; +import net.minecraft.entity.passive.VillagerEntity; +import net.minecraft.entity.passive.WanderingTraderEntity; +import net.minecraft.village.TradeOffer; +import net.minecraft.world.ModifiableWorld; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin({VillagerEntity.class, WanderingTraderEntity.class}) +public abstract class VillagerTradeXp extends AbstractTraderEntity { + public VillagerTradeXp(EntityType entityType, World world) { + super(entityType, world); + } + + @Unique private int i; + @Inject(method = "afterUsing", at = @At(value = "NEW", target = "net/minecraft/entity/ExperienceOrbEntity"), locals = LocalCapture.CAPTURE_FAILHARD) + private void captureLocals(TradeOffer offer, CallbackInfo ci, int i) { + this.i = i; + } + + @Redirect(method = "afterUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) + private boolean depositXpToPlayer(World world, Entity entity) { + if (this.getCurrentCustomer() != null && Tweaks.CONFIG.easyXp) { + this.getCurrentCustomer().addExperience(i); + return false; + } else { + return world.spawnEntity(entity); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java new file mode 100644 index 0000000..a41887a --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java @@ -0,0 +1,36 @@ +package dev.hephaestus.tweaks.mixin.screen; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(targets = "net/minecraft/screen/GrindstoneScreenHandler$4") +public abstract class DepositGrindstoneXp { + @Shadow protected abstract int getExperience(World world); + + @Unique private final ThreadLocal player = new ThreadLocal<>(); + + @Inject(method = "onTakeItem", at = @At("HEAD")) + private void captureArgs(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir) { + this.player.set(player); + } + + @SuppressWarnings("UnresolvedMixinReference") + @Inject(method = "method_17417", at = @At("HEAD"), cancellable = true) + private void depositXpToPlayer(World world, BlockPos blockPos, CallbackInfo ci) { + if (Tweaks.CONFIG.easyXp && this.player.get() != null) { + this.player.get().addExperience(this.getExperience(world)); + world.syncWorldEvent(1042, blockPos, 0); + ci.cancel(); + } + } +} diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 7b4508a..dd3cde3 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -98,6 +98,9 @@ "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[1]": "when lit on fire by soul fire", "text.autoconfig.tinytweaks.option.infiniteCauldrons": "Infinite Cauldrons", "text.autoconfig.tinytweaks.option.infiniteCauldrons.@Tooltip": "Right click a cauldron with a Heart of the Sea to make it infinite", + "text.autoconfig.tinytweaks.option.easyXp": "Easy XP", + "text.autoconfig.tinytweaks.option.easyXp.@Tooltip[0]": "XP is given right to the player, instead of spawning", + "text.autoconfig.tinytweaks.option.easyXp.@Tooltip[1]": "experience orbs in the world", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.autoPlanting.enabled.boolean.true": "§aOn", @@ -123,6 +126,7 @@ "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.easyXp.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.autoPlanting.enabled.boolean.false": "§cOff", @@ -148,5 +152,6 @@ "text.autoconfig.tinytweaks.option.bubbleColumnsFlow.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.easyXp.boolean.false": "§cOff", "block.cauldron.makeInfinite": "This cauldron has been blessed with the heart of the sea" } \ No newline at end of file diff --git a/src/main/resources/tweaks.accesswidener b/src/main/resources/tweaks.accesswidener index 6ca5fae..60e98d0 100644 --- a/src/main/resources/tweaks.accesswidener +++ b/src/main/resources/tweaks.accesswidener @@ -1,4 +1,6 @@ accessWidener v1 named +accessible class net/minecraft/entity/passive/FoxEntity$MateGoal +accessible class net/minecraft/entity/passive/TurtleEntity$MateGoal accessible method net/minecraft/item/ItemPlacementContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V accessible method net/minecraft/block/BubbleColumnBlock calculateDrag (Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z accessible field net/minecraft/block/EntityShapeContext ABSENT Lnet/minecraft/block/ShapeContext; \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index c3e928c..8b5f2d7 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -19,18 +19,26 @@ "block.easyharvest.Crops", "block.easyharvest.NetherWarts", "block.easyharvest.SugarCane", + "block.easyxp.Blocks", + "block.easyxp.FurnaceBlockEntityPlayerProvider", + "block.easyxp.PassPlayerToEntity", "block.mossythings.MoistenBlocks", "block.mossythings.MoistenPartBlocks", "block.planthitboxes.FernBlocks", "block.planthitboxes.TallPlants", "block.rejuvenation.RejuvenateDeadBushes", "block.rejuvenation.TallGrassSpread", - "entity.BurnUsableEntities", "entity.AutoPlantSaplings", + "entity.BurnUsableEntities", "entity.LivingEntityMixin", "entity.ai.brain.task.FarmerVillagersDepositSurplus", "entity.betterlilypads.FallingParticles", "entity.betterlilypads.SprintingParticles", + "entity.easyxp.AnimalEntityBreedXp", + "entity.easyxp.FishingXp", + "entity.easyxp.LivingEntityGiveXp", + "entity.easyxp.MateGoalXp", + "entity.easyxp.VillagerTradeXp", "entity.passive.ChickenEntityMixin", "entity.passive.CowEntityMixin", "entity.passive.HorseAndDonkeyMixin", @@ -42,7 +50,8 @@ "item.CharcoalDoesntBurnMixin", "item.FlintAndSteelMixin", "item.HoeItemMixin", - "item.ShovelMixin" + "item.ShovelMixin", + "screen.DepositGrindstoneXp" ], "client": [ "client.gui.hud.RenderSoulFire", From e93c9b544f5db7f4745f23d47dcde67afe0461eb Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 18 Aug 2020 12:20:40 -0700 Subject: [PATCH 36/53] Added color to tipped arrows --- .../entity/TippedArrowEntityRenderer.java | 52 +++++++++++++++++++ src/main/resources/tweaks.mixins.json | 1 + 2 files changed, 53 insertions(+) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/TippedArrowEntityRenderer.java diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/TippedArrowEntityRenderer.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/TippedArrowEntityRenderer.java new file mode 100644 index 0000000..75d481a --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/render/entity/TippedArrowEntityRenderer.java @@ -0,0 +1,52 @@ +package dev.hephaestus.tweaks.mixin.client.render.entity; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.ProjectileEntityRenderer; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.util.math.Vector3f; +import net.minecraft.entity.projectile.ArrowEntity; +import net.minecraft.entity.projectile.PersistentProjectileEntity; +import net.minecraft.util.math.Matrix3f; +import net.minecraft.util.math.Matrix4f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Environment(EnvType.CLIENT) +@Mixin(ProjectileEntityRenderer.class) +public abstract class TippedArrowEntityRenderer extends EntityRenderer { + protected TippedArrowEntityRenderer(EntityRenderDispatcher dispatcher) { + super(dispatcher); + } + + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V")) + private void drawArrowHead(T persistentProjectileEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + if (persistentProjectileEntity instanceof ArrowEntity && ((ArrowEntity) persistentProjectileEntity).getColor() != 0) { + int color = ((ArrowEntity) persistentProjectileEntity).getColor(); + VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(this.getTexture(persistentProjectileEntity))); + MatrixStack.Entry entry = matrixStack.peek(); + Matrix4f matrix4f = entry.getModel(); + Matrix3f matrix3f = entry.getNormal(); + + for (int u = 0; u < 4; ++u) { + matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90.0F)); + draw(matrix4f, matrix3f, vertexConsumer, 5, -2, 0.40625F, 0, i, color); + draw(matrix4f, matrix3f, vertexConsumer, 8, -2, 0.5F, 0, i, color); + draw(matrix4f, matrix3f, vertexConsumer, 8, 2, 0.5F, 0.15625F, i, color); + draw(matrix4f, matrix3f, vertexConsumer, 5, 2, 0.40625F, 0.15625F, i, color); + } + } + } + + private void draw(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, int i, int j, float f, float g, int o, int color) { + vertexConsumer.vertex(matrix4f, (float)i, (float)j, 0.001F).color(color >> 16 & 255, color >> 8 & 255, color & 255, 128).texture(f, g).overlay(OverlayTexture.DEFAULT_UV).light(o).normal(matrix3f, (float) 0, (float) 0, (float) 1).next(); + } +} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 8b5f2d7..66dc403 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -61,6 +61,7 @@ "client.render.entity.BoatEntityRendererMixin", "client.render.entity.PlayerEntityRendererMixin", "client.render.entity.RenderSoulFire", + "client.render.entity.TippedArrowEntityRenderer", "dev.ChestBlockEntityRendererMixin", "dev.ShulkerBoxEntityRendererMixin", "entity.SetSoulFireType", From 084023e946bd502e0950baec0411f768722013d5 Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 18 Aug 2020 12:51:04 -0700 Subject: [PATCH 37/53] Fixes #21 --- .../hephaestus/tweaks/mixin/entity/SetSoulFireType.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java index 15be0fe..73b4384 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java @@ -23,6 +23,8 @@ public abstract class SetSoulFireType implements SoulFire.FireTypeModifier { @Shadow public abstract Box getBoundingBox(); + @Shadow public abstract boolean isInLava(); + private SoulFire.FireType fireType = SoulFire.FireType.NORMAL; @Override @@ -32,6 +34,11 @@ public SoulFire.FireType getFireType() { @Override public void updateFireType() { + if (this.isInLava()) { + this.fireType = SoulFire.FireType.NORMAL; + return; + } + if (this.world.isClient && Tweaks.CONFIG.blueSoulFireEffects) { Box box = this.getBoundingBox(); BlockPos blockPos = new BlockPos(box.minX + 0.001D, box.minY + 0.001D, box.minZ + 0.001D); From 6f060c17d97804ceeb0488939bb539fcc4b67c9e Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 18 Aug 2020 13:55:15 -0700 Subject: [PATCH 38/53] Wheat seeds, pumpkin seeds, melon seeds, beetroot seeds, carrots, and potatoes now plant themselves when over farmland. Any `BlockItem` can be added by adding it to the `tinytweaks:plantable` tag. --- src/main/java/dev/hephaestus/tweaks/TweaksConfig.java | 2 +- src/main/java/dev/hephaestus/tweaks/item/Tags.java | 11 +++++++++++ .../entity/{AutoPlantSaplings.java => AutoPlant.java} | 9 +++++---- src/main/resources/assets/tinytweaks/lang/en_us.json | 4 +++- .../data/tinytweaks/tags/items/plantable.json | 11 +++++++++++ src/main/resources/tweaks.mixins.json | 2 +- 6 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/item/Tags.java rename src/main/java/dev/hephaestus/tweaks/mixin/entity/{AutoPlantSaplings.java => AutoPlant.java} (84%) create mode 100644 src/main/resources/data/tinytweaks/tags/items/plantable.json diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index 10b0827..d711d76 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -94,7 +94,7 @@ public class TweaksConfig implements ConfigData { public boolean easyXp = true; public static class AutoPlanting { - @ConfigEntry.Gui.Tooltip(count = 2) + @ConfigEntry.Gui.Tooltip(count = 4) public boolean enabled = true; @ConfigEntry.Gui.Tooltip diff --git a/src/main/java/dev/hephaestus/tweaks/item/Tags.java b/src/main/java/dev/hephaestus/tweaks/item/Tags.java new file mode 100644 index 0000000..3db4113 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/item/Tags.java @@ -0,0 +1,11 @@ +package dev.hephaestus.tweaks.item; + +import dev.hephaestus.tweaks.Tweaks; +import net.fabricmc.fabric.api.tag.TagRegistry; +import net.minecraft.item.Item; +import net.minecraft.tag.Tag; +import net.minecraft.util.Identifier; + +public class Tags { + public static final Tag PLANTABLE = TagRegistry.item(new Identifier(Tweaks.MOD_ID, "plantable")); +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlantSaplings.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java similarity index 84% rename from src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlantSaplings.java rename to src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java index 23f52ec..ddc9e50 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlantSaplings.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java @@ -1,6 +1,7 @@ package dev.hephaestus.tweaks.mixin.entity; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.item.Tags; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -25,8 +26,8 @@ @Mixin(ItemEntity.class) -public abstract class AutoPlantSaplings extends Entity { - public AutoPlantSaplings(EntityType type, World world) { +public abstract class AutoPlant extends Entity { + public AutoPlant(EntityType type, World world) { super(type, world); } @@ -40,8 +41,8 @@ public void plantSaplings(CallbackInfo ci) { ItemStack stack = this.getStack(); BlockPos pos = this.getBlockPos(); if (this.getBlockPos() != triedToPlantAt && world.getFluidState(pos).isEmpty()) { - if (stack.getItem().isIn(ItemTags.SAPLINGS)) { - stack.useOnBlock(new ItemPlacementContext(world, null, null, stack, world.rayTrace( + if (stack.getItem().isIn(ItemTags.SAPLINGS) || stack.getItem().isIn(Tags.PLANTABLE) && stack.getItem() instanceof BlockItem) { + ((BlockItem) stack.getItem()).place(new ItemPlacementContext(world, null, null, stack, world.rayTrace( new RayTraceContext( new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), new Vec3d(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5), diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index dd3cde3..49024ed 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -19,7 +19,9 @@ "text.autoconfig.tinytweaks.option.autoPlanting": "Auto Planting", "text.autoconfig.tinytweaks.option.autoPlanting.enabled": "Enabled", "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[0]": "Plants that fall on their base block plant themselves", - "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[1]": "§7§oCurrently only applies to saplings", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[1]": "By default applies to saplings, wheat seeds, pumpkin seeds,", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[2]": "melon seeds, beetroot seeds, carrots, and potatoes", + "text.autoconfig.tinytweaks.option.autoPlanting.enabled.@Tooltip[3]": "§7§oCan be modified with datapacks via the \"plantable\" tag", "text.autoconfig.tinytweaks.option.autoPlanting.delay": "Plant Delay", "text.autoconfig.tinytweaks.option.autoPlanting.delay.@Tooltip": "Delay (in ticks) before items plant themselves", "text.autoconfig.tinytweaks.option.lanternBlastResistance": "Sturdy Lanterns", diff --git a/src/main/resources/data/tinytweaks/tags/items/plantable.json b/src/main/resources/data/tinytweaks/tags/items/plantable.json new file mode 100644 index 0000000..1206de6 --- /dev/null +++ b/src/main/resources/data/tinytweaks/tags/items/plantable.json @@ -0,0 +1,11 @@ +{ + "replace": false, + "values": [ + "minecraft:wheat_seeds", + "minecraft:pumpkin_seeds", + "minecraft:melon_seeds", + "minecraft:beetroot_seeds", + "minecraft:carrot", + "minecraft:potato" + ] +} \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 66dc403..51d0561 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -28,7 +28,7 @@ "block.planthitboxes.TallPlants", "block.rejuvenation.RejuvenateDeadBushes", "block.rejuvenation.TallGrassSpread", - "entity.AutoPlantSaplings", + "entity.AutoPlant", "entity.BurnUsableEntities", "entity.LivingEntityMixin", "entity.ai.brain.task.FarmerVillagersDepositSurplus", From 6cbee9c3c717512f3d1b6932ff65b5039762e0a1 Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 18 Aug 2020 13:57:07 -0700 Subject: [PATCH 39/53] Added hard dependency on 1.16.2 --- src/main/resources/fabric.mod.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a454fd4..e50cfc9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,6 +31,7 @@ "tweaks.mixins.json" ], "depends": { + "minecraft": "1.16.2", "fabricloader": ">=0.4.0", "fabric": "*" }, From 4d2b486a162e88b55c1557666ad9e465fef84186 Mon Sep 17 00:00:00 2001 From: Hephaestus-Dev <54509200+Hephaestus-Dev@users.noreply.github.com> Date: Tue, 18 Aug 2020 14:49:51 -0700 Subject: [PATCH 40/53] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5509c09..69c5e0b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A collection of small tweaks for Minecraft. ## Plant Tweaks * Easy Harvest Crops - Right clicking fully grown clops harvests and replants them * Easy Harvest Sugarcane - Right clicking sugarcane harvests all sugarcane higher than the one you clicked. Preserves the bottom-most block -* Auto Planting - Plants that fall on dirt or grass will automatically plant (Currently only applies to saplings) +* Auto Planting - Plants that fall on dirt or grass will automatically plant. Applies to saplings, wheat seeds, pumpkin seeds, melon seeds, beetroot seeds, carrots, and potatoes * Grass Spreading - Grass and long grass spread naturally over time * Plant Hitboxes - Removes hitboxes from long grass. Hitboxes are shown when using shears. Seeds can be gathered by using a hoe on the ground below them * Passable Leaves - Removes collision from leaves @@ -23,6 +23,8 @@ A collection of small tweaks for Minecraft. * Entity Ignition - Right click mobs with flint and steel to light them on fire * Sturdy Lanterns - Gives lanterns a blast resistance of 6 (allows them to survive Ghast fireballs) * Infinite Cauldrons - Right clicking a Cauldron with a Heart of the Sea creates an infinite water source +* Easy XP - All vanilla XP sources give their XP directly to the player that earns them (other than the Ender Dragon) +* Tinted Tipped Arrows - The heads of tipped arrows render the color of their status effect ## Contact Me -I can be found hanging out on the Fabric Discord as Haven King#2790. Feel free to shoot me a message there if you have any questions. \ No newline at end of file +I can be found hanging out on the Fabric Discord as Haven King#2790. Feel free to shoot me a message there if you have any questions. From 57816a4d241ec82c587df9f4ab088caadc776582 Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 18 Aug 2020 15:02:00 -0700 Subject: [PATCH 41/53] Fixes bug in production --- .../{screen => dev}/DepositGrindstoneXp.java | 2 +- .../mixin/prod/DepositGrindstoneXp.java | 36 +++++++++++++++++++ src/main/resources/tweaks.mixins.json | 3 +- 3 files changed, 39 insertions(+), 2 deletions(-) rename src/main/java/dev/hephaestus/tweaks/mixin/{screen => dev}/DepositGrindstoneXp.java (96%) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java similarity index 96% rename from src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java rename to src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java index a41887a..5be9827 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/screen/DepositGrindstoneXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java @@ -1,4 +1,4 @@ -package dev.hephaestus.tweaks.mixin.screen; +package dev.hephaestus.tweaks.mixin.dev; import dev.hephaestus.tweaks.Tweaks; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java new file mode 100644 index 0000000..b00e1f8 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java @@ -0,0 +1,36 @@ +package dev.hephaestus.tweaks.mixin.prod; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(targets = "net/minecraft/screen/GrindstoneScreenHandler$4") +public abstract class DepositGrindstoneXp { + @Shadow protected abstract int getExperience(World world); + + @Unique private final ThreadLocal player = new ThreadLocal<>(); + + @Inject(method = "method_7667", at = @At("HEAD")) + private void captureArgs(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir) { + this.player.set(player); + } + + @SuppressWarnings("UnresolvedMixinReference") + @Inject(method = "method_17417", at = @At("HEAD"), cancellable = true) + private void depositXpToPlayer(World world, BlockPos blockPos, CallbackInfo ci) { + if (Tweaks.CONFIG.easyXp && this.player.get() != null) { + this.player.get().addExperience(this.getExperience(world)); + world.syncWorldEvent(1042, blockPos, 0); + ci.cancel(); + } + } +} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 51d0561..c4f31c4 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -28,6 +28,7 @@ "block.planthitboxes.TallPlants", "block.rejuvenation.RejuvenateDeadBushes", "block.rejuvenation.TallGrassSpread", + "dev.DepositGrindstoneXp", "entity.AutoPlant", "entity.BurnUsableEntities", "entity.LivingEntityMixin", @@ -51,7 +52,7 @@ "item.FlintAndSteelMixin", "item.HoeItemMixin", "item.ShovelMixin", - "screen.DepositGrindstoneXp" + "prod.DepositGrindstoneXp" ], "client": [ "client.gui.hud.RenderSoulFire", From 44c614ac7cfb5a4c08a40fd8be84d070bf311e37 Mon Sep 17 00:00:00 2001 From: Haven Date: Wed, 19 Aug 2020 20:17:38 -0700 Subject: [PATCH 42/53] Had wrong mod id for `onsoulfire` breaking. --- src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e50cfc9..b044540 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,6 +36,6 @@ "fabric": "*" }, "breaks": { - "soulfire": "*:" + "onsoulfire": "*" } } \ No newline at end of file From 5ec13010b3be230bad0add6508be31291713da41 Mon Sep 17 00:00:00 2001 From: Haven Date: Fri, 28 Aug 2020 12:09:12 -0700 Subject: [PATCH 43/53] Moisten Block Compatibility --- .../hephaestus/tweaks/block/MoistBlock.java | 1 - .../hephaestus/tweaks/block/Moistener.java | 4 ++ .../tweaks/mixin/block/LeafCollision.java | 1 - .../mossythings/MoistenAbstractBlock.java | 39 +++++++++++++++++++ .../mixin/block/mossythings/MoistenBlock.java | 19 +++++++++ .../block/mossythings/MoistenBlocks.java | 35 ----------------- .../block/mossythings/MoistenPartBlocks.java | 26 ------------- src/main/resources/tweaks.mixins.json | 4 +- 8 files changed, 64 insertions(+), 65 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenAbstractBlock.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlock.java delete mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java delete mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java diff --git a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java index e83b71f..9ed4c07 100644 --- a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java +++ b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java @@ -6,7 +6,6 @@ import net.minecraft.fluid.Fluids; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldView; import java.util.Random; diff --git a/src/main/java/dev/hephaestus/tweaks/block/Moistener.java b/src/main/java/dev/hephaestus/tweaks/block/Moistener.java index 35eab4f..cabe8cc 100644 --- a/src/main/java/dev/hephaestus/tweaks/block/Moistener.java +++ b/src/main/java/dev/hephaestus/tweaks/block/Moistener.java @@ -25,4 +25,8 @@ public static BlockState dry(BlockState blockState) { public static void canMoisten(Block in, Block out) { CONVERTIBLE.put(in, out); } + + public static boolean canMoisten(Block block) { + return CONVERTIBLE.containsKey(block) || CONVERTIBLE.inverse().containsKey(block); + } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java index 6cc3261..69bf570 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java @@ -15,7 +15,6 @@ @Mixin(LeavesBlock.class) public class LeafCollision extends Block{ - public LeafCollision(Settings settings) { super(settings); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenAbstractBlock.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenAbstractBlock.java new file mode 100644 index 0000000..ac50746 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenAbstractBlock.java @@ -0,0 +1,39 @@ +package dev.hephaestus.tweaks.mixin.block.mossythings; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.block.Moistener; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.BlockState; +import net.minecraft.fluid.Fluids; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Random; + +@Mixin(AbstractBlock.class) +public class MoistenAbstractBlock { + @Inject(method = "scheduledTick", at = @At("HEAD")) + private void doTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { + if (Tweaks.CONFIG.mossyThings && Moistener.canMoisten(state.getBlock())) { + boolean isSkyVisible = false; + boolean isWaterNearby = false; + for (BlockPos adjacent : BlockPos.iterate(pos.up().north().west(), pos.down().south().east())) { + if (world.isSkyVisible(adjacent)) isSkyVisible = true; + if (world.getFluidState(adjacent).getFluid() == Fluids.WATER) isWaterNearby = true; + } + + if (isSkyVisible) { + if (world.isRaining() && world.getBiome(pos).getDownfall() > 0) { + world.setBlockState(pos, Moistener.moisten(state)); + } else if (world.isDay() && !isWaterNearby) { + world.setBlockState(pos, Moistener.dry(state)); + } + + } + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlock.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlock.java new file mode 100644 index 0000000..81c6ace --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlock.java @@ -0,0 +1,19 @@ +package dev.hephaestus.tweaks.mixin.block.mossythings; + +import dev.hephaestus.tweaks.block.Moistener; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Block.class) +public class MoistenBlock { + @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) + private void hasRandomTicks(BlockState state, CallbackInfoReturnable cir) { + if (Moistener.canMoisten(state.getBlock())) { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java deleted file mode 100644 index f639c71..0000000 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenBlocks.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.hephaestus.tweaks.mixin.block.mossythings; - -import dev.hephaestus.tweaks.block.MoistBlock; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(Blocks.class) -public class MoistenBlocks { - @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 9)) - private static Block moistenCobblestone(Block.Settings settings) { - return new MoistBlock(settings); - } - - @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 41)) - private static Block dryMossyCobblestone(Block.Settings settings) { - return new MoistBlock(settings); - } - - @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 48)) - private static Block moistenStoneBricks(Block.Settings settings) { - return new MoistBlock(settings); - } - - @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/block/Block", ordinal = 49)) - private static Block dryStoneBricks(Block.Settings settings) { - return new MoistBlock(settings); - } -} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java deleted file mode 100644 index 9de5b83..0000000 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/mossythings/MoistenPartBlocks.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.hephaestus.tweaks.mixin.block.mossythings; - -import dev.hephaestus.tweaks.block.MoistBlock; -import net.minecraft.block.*; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; - -import java.util.Random; - -@Mixin({StairsBlock.class, SlabBlock.class, WallBlock.class}) -public abstract class MoistenPartBlocks extends Block { - public MoistenPartBlocks(Settings settings) { - super(settings); - } - - @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - MoistBlock.randomTick(state, world, pos); - } - - @Override - public boolean hasRandomTicks(BlockState state) { - return true; - } -} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index c4f31c4..2f45bd0 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -22,8 +22,8 @@ "block.easyxp.Blocks", "block.easyxp.FurnaceBlockEntityPlayerProvider", "block.easyxp.PassPlayerToEntity", - "block.mossythings.MoistenBlocks", - "block.mossythings.MoistenPartBlocks", + "block.mossythings.MoistenAbstractBlock", + "block.mossythings.MoistenBlock", "block.planthitboxes.FernBlocks", "block.planthitboxes.TallPlants", "block.rejuvenation.RejuvenateDeadBushes", From 3350310f87413583a55a68d3edc7b975054b0951 Mon Sep 17 00:00:00 2001 From: Haven Date: Sun, 20 Sep 2020 13:04:52 -0700 Subject: [PATCH 44/53] Updated to 1.16.3 --- gradle.properties | 14 +++--- .../hephaestus/tweaks/block/MoistBlock.java | 45 ------------------- .../screen/ingame/PopulateSignEditScreen.java | 6 +-- .../tweaks/mixin/entity/AutoPlant.java | 11 +++-- .../mixin/entity/easyxp/VillagerTradeXp.java | 7 ++- .../dev/hephaestus/tweaks/util/SoulFire.java | 4 +- src/main/resources/fabric.mod.json | 2 +- 7 files changed, 21 insertions(+), 68 deletions(-) delete mode 100644 src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java diff --git a/gradle.properties b/gradle.properties index ec38208..e1b6369 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,19 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version = 1.16.2 -yarn_mappings = 1.16.2+build.19 -loader_version = 0.9.1+build.205 +minecraft_version = 1.16.3 +yarn_mappings = 1.16.3+build.11 +loader_version = 0.9.3+build.207 #Mod properties -mod_version = 1.0.12 +mod_version = 1.0.13 maven_group = dev.hephaestus archives_base_name = tinytweaks #Dependencies -fabric_version = 0.18.0+build.397-1.16 -cloth_config_version = 4.7.0-unstable -auto_config_version = 3.2.0-unstable +fabric_version = 0.21.0+build.407-1.16 +cloth_config_version = 4.8.1 +auto_config_version = 3.2.2 # Dev Mods mod_menu_version = 1.14.6+build.31 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java b/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java deleted file mode 100644 index 9ed4c07..0000000 --- a/src/main/java/dev/hephaestus/tweaks/block/MoistBlock.java +++ /dev/null @@ -1,45 +0,0 @@ -package dev.hephaestus.tweaks.block; - -import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.Fluids; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; - -import java.util.Random; - -public class MoistBlock extends Block { - public MoistBlock(Settings settings) { - super(settings); - } - - @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - randomTick(state, world, pos); - } - - public static void randomTick(BlockState state, ServerWorld world, BlockPos pos) { - if (Tweaks.CONFIG.mossyThings) { - boolean isSkyVisible = false; - boolean isWaterNearby = false; - for (BlockPos adjacent : BlockPos.iterate(pos.up().north().west(), pos.down().south().east())) { - if (world.isSkyVisible(adjacent)) isSkyVisible = true; - if (world.getFluidState(adjacent).getFluid() == Fluids.WATER) isWaterNearby = true; - } - - if (isSkyVisible) { - if (world.isRaining() && world.getBiome(pos).getDownfall() > 0) { - world.setBlockState(pos, Moistener.moisten(state)); - } else if (world.isDay() && !isWaterNearby) { - world.setBlockState(pos, Moistener.dry(state)); - } - } - } - } - - @Override - public boolean hasRandomTicks(BlockState state) { - return true; - } -} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java index 7466830..05f7549 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/client/gui/screen/ingame/PopulateSignEditScreen.java @@ -16,16 +16,16 @@ @Mixin(SignEditScreen.class) @Environment(EnvType.CLIENT) public class PopulateSignEditScreen { - @Shadow @Final private String[] field_24285; + @Shadow @Final private String[] text; @Shadow @Final private SignBlockEntity sign; @Inject(method = "init", at = @At("TAIL")) private void setRows(CallbackInfo ci) { for (int i = 0; i < 4; ++i) { - Text text = sign.method_30843(i); + Text text = sign.getTextOnRow(i); - this.field_24285[i] = (text == null ? LiteralText.EMPTY : text).getString(); + this.text[i] = (text == null ? LiteralText.EMPTY : text).getString(); } } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java index ddc9e50..575ded8 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/AutoPlant.java @@ -12,11 +12,10 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; import net.minecraft.tag.ItemTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RayTraceContext; +import net.minecraft.world.RaycastContext; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,12 +41,12 @@ public void plantSaplings(CallbackInfo ci) { BlockPos pos = this.getBlockPos(); if (this.getBlockPos() != triedToPlantAt && world.getFluidState(pos).isEmpty()) { if (stack.getItem().isIn(ItemTags.SAPLINGS) || stack.getItem().isIn(Tags.PLANTABLE) && stack.getItem() instanceof BlockItem) { - ((BlockItem) stack.getItem()).place(new ItemPlacementContext(world, null, null, stack, world.rayTrace( - new RayTraceContext( + ((BlockItem) stack.getItem()).place(new ItemPlacementContext(world, null, null, stack, world.raycast( + new RaycastContext( new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), new Vec3d(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5), - RayTraceContext.ShapeType.COLLIDER, - RayTraceContext.FluidHandling.ANY, + RaycastContext.ShapeType.COLLIDER, + RaycastContext.FluidHandling.ANY, this ) ))); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java index a449732..f9f3f61 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java @@ -3,11 +3,10 @@ import dev.hephaestus.tweaks.Tweaks; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; -import net.minecraft.entity.passive.AbstractTraderEntity; +import net.minecraft.entity.passive.MerchantEntity; import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.entity.passive.WanderingTraderEntity; import net.minecraft.village.TradeOffer; -import net.minecraft.world.ModifiableWorld; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -18,8 +17,8 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin({VillagerEntity.class, WanderingTraderEntity.class}) -public abstract class VillagerTradeXp extends AbstractTraderEntity { - public VillagerTradeXp(EntityType entityType, World world) { +public abstract class VillagerTradeXp extends MerchantEntity { + public VillagerTradeXp(EntityType entityType, World world) { super(entityType, world); } diff --git a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java index 0a2ebdb..71f8650 100644 --- a/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java +++ b/src/main/java/dev/hephaestus/tweaks/util/SoulFire.java @@ -8,8 +8,8 @@ @Environment(EnvType.CLIENT) public class SoulFire { - public static final SpriteIdentifier SPRITE_0 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_0")); - public static final SpriteIdentifier SPRITE_1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("block/soul_fire_1")); + public static final SpriteIdentifier SPRITE_0 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new Identifier("block/soul_fire_0")); + public static final SpriteIdentifier SPRITE_1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new Identifier("block/soul_fire_1")); public enum FireType { NORMAL, diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b044540..0508e3a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "tweaks.mixins.json" ], "depends": { - "minecraft": "1.16.2", + "minecraft": ">=1.16.2", "fabricloader": ">=0.4.0", "fabric": "*" }, From 2ab8752df04331049deda403a245bf6e1efe0d51 Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 17 Oct 2020 22:27:33 -0700 Subject: [PATCH 45/53] Fixes EasyXP Issues --- build.gradle | 1 + gradle.properties | 4 +-- .../java/dev/hephaestus/tweaks/Tweaks.java | 5 ++- .../mixin/block/MakeCauldronsInfinite.java | 20 +++++------ .../tweaks/mixin/block/easyxp/Blocks.java | 3 +- .../FurnaceBlockEntityPlayerProvider.java | 4 ++- .../tweaks/mixin/dev/DepositGrindstoneXp.java | 6 ++-- .../entity/easyxp/AnimalEntityBreedXp.java | 3 +- .../tweaks/mixin/entity/easyxp/FishingXp.java | 7 ++-- .../entity/easyxp/LivingEntityGiveXp.java | 6 ++-- .../mixin/entity/easyxp/MateGoalXp.java | 3 +- .../mixin/entity/easyxp/VillagerTradeXp.java | 6 ++-- .../mixin/prod/DepositGrindstoneXp.java | 36 +++++++++++-------- .../dev/hephaestus/tweaks/util/XpUtil.java | 35 ++++++++++++++++++ src/main/resources/tweaks.mixins.json | 3 +- 15 files changed, 101 insertions(+), 41 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/util/XpUtil.java diff --git a/build.gradle b/build.gradle index 70b7c80..ab21074 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ minecraft { } repositories { + mavenLocal() jcenter() maven { url = "https://www.cursemaven.com" diff --git a/gradle.properties b/gradle.properties index e1b6369..d9e504e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties minecraft_version = 1.16.3 yarn_mappings = 1.16.3+build.11 -loader_version = 0.9.3+build.207 +loader_version = 0.10.0+local #Mod properties -mod_version = 1.0.13 +mod_version = 1.0.14 maven_group = dev.hephaestus archives_base_name = tinytweaks diff --git a/src/main/java/dev/hephaestus/tweaks/Tweaks.java b/src/main/java/dev/hephaestus/tweaks/Tweaks.java index e2092b4..e365cf1 100644 --- a/src/main/java/dev/hephaestus/tweaks/Tweaks.java +++ b/src/main/java/dev/hephaestus/tweaks/Tweaks.java @@ -9,13 +9,16 @@ import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.state.property.BooleanProperty; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Unique; public class Tweaks implements ModInitializer, ClientModInitializer { + public static final BooleanProperty INFINITE = BooleanProperty.of("infinite"); - public static Logger LOGGER = LogManager.getLogger(); + public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "tinytweaks"; public static final String MOD_NAME = "TinyTweaks"; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java index c50f16a..bb80dc3 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java @@ -11,7 +11,6 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; @@ -32,7 +31,6 @@ @Mixin(CauldronBlock.class) public class MakeCauldronsInfinite extends Block { - @Unique private static final BooleanProperty INFINITE = BooleanProperty.of("infinite"); public MakeCauldronsInfinite(Settings settings) { super(settings); @@ -40,19 +38,19 @@ public MakeCauldronsInfinite(Settings settings) { @Inject(method = "", at = @At("TAIL")) private void addInfiniteState(Block.Settings settings, CallbackInfo ci) { - this.setDefaultState(this.getDefaultState().with(INFINITE, false)); + this.setDefaultState(this.getDefaultState().with(Tweaks.INFINITE, false)); } @Inject(method = "setLevel", at = @At("HEAD"), cancellable = true) private void dontDecreaseLevelIfInfinite(World world, BlockPos pos, BlockState state, int level, CallbackInfo ci) { - if (level < state.get(Properties.LEVEL_3) && state.get(INFINITE)) { + if (level < state.get(Properties.LEVEL_3) && state.get(Tweaks.INFINITE)) { ci.cancel(); } } @Inject(method = "appendProperties", at = @At("TAIL")) private void addInfiniteState(StateManager.Builder builder, CallbackInfo ci) { - builder.add(INFINITE); + builder.add(Tweaks.INFINITE); } @Unique private static boolean LAST_CAULDRON_INFINITE = false; @@ -62,7 +60,7 @@ private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEnt LAST_CAULDRON_INFINITE = false; ItemStack stack = player.getStackInHand(hand); - if (Tweaks.CONFIG.infiniteCauldrons && stack.getItem().equals(Items.HEART_OF_THE_SEA) && !state.get(INFINITE)) { + if (Tweaks.CONFIG.infiniteCauldrons && stack.getItem().equals(Items.HEART_OF_THE_SEA) && !state.get(Tweaks.INFINITE)) { if (world.isClient) { for(int int_1 = -2; int_1 <= 2; ++int_1) { for(int int_2 = -2; int_2 <= 2; ++int_2) { @@ -77,7 +75,7 @@ private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEnt } } } else { - world.setBlockState(pos, state.with(INFINITE, true).with(Properties.LEVEL_3, 3)); + world.setBlockState(pos, state.with(Tweaks.INFINITE, true).with(Properties.LEVEL_3, 3)); if (!player.isCreative()) { stack.decrement(1); @@ -88,16 +86,16 @@ private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEnt LAST_CAULDRON_INFINITE = true; cir.setReturnValue(ActionResult.SUCCESS); } - } else if (!Tweaks.CONFIG.infiniteCauldrons && state.get(INFINITE) && !world.isClient) { - world.setBlockState(pos, state.with(INFINITE, false)); + } else if (!Tweaks.CONFIG.infiniteCauldrons && state.get(Tweaks.INFINITE) && !world.isClient) { + world.setBlockState(pos, state.with(Tweaks.INFINITE, false)); LAST_CAULDRON_INFINITE = false; } else { - LAST_CAULDRON_INFINITE = state.get(INFINITE); + LAST_CAULDRON_INFINITE = state.get(Tweaks.INFINITE); } } @ModifyArg(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/CauldronBlock;setLevel(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)V"), index = 2) private BlockState updateState(BlockState state) { - return state.with(INFINITE, LAST_CAULDRON_INFINITE); + return state.with(Tweaks.INFINITE, LAST_CAULDRON_INFINITE); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java index 9a4da86..48589f6 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/Blocks.java @@ -2,6 +2,7 @@ import dev.hephaestus.tweaks.Tweaks; import dev.hephaestus.tweaks.block.PlayerProvider; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; @@ -41,7 +42,7 @@ private static void assignPlayerToBlock(BlockState state, World world, BlockPos @Inject(method = "dropExperience", at = @At("HEAD"), cancellable = true) protected void depositXpToPlayer(ServerWorld world, BlockPos pos, int size, CallbackInfo ci) { if (this.getPlayer() != null && Tweaks.CONFIG.easyXp) { - this.getPlayer().addExperience(size); + XpUtil.addXp(this.getPlayer(), size); this.setPlayer(null); ci.cancel(); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java index 60016ac..c8c2bb5 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java @@ -2,6 +2,7 @@ import dev.hephaestus.tweaks.Tweaks; import dev.hephaestus.tweaks.block.PlayerProvider; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.math.Vec3d; @@ -17,12 +18,13 @@ public abstract class FurnaceBlockEntityPlayerProvider implements PlayerProvider throw new RuntimeException(); } + @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "method_17761", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;dropExperience(Lnet/minecraft/world/World;Lnet/minecraft/util/math/Vec3d;IF)V")) private static void depositXpToPlayer(World world, Vec3d vec3d, int i, float f) { ServerPlayerEntity playerEntity = PlayerProvider.STATIC.get().getPlayer(); if (playerEntity != null && Tweaks.CONFIG.easyXp) { - playerEntity.addExperience(i); + XpUtil.addXp(playerEntity, i); PlayerProvider.STATIC.get().setPlayer(null); } else { dropExperience(world, vec3d, i, f); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java index 5be9827..d051514 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/dev/DepositGrindstoneXp.java @@ -1,8 +1,10 @@ package dev.hephaestus.tweaks.mixin.dev; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -27,8 +29,8 @@ private void captureArgs(PlayerEntity player, ItemStack stack, CallbackInfoRetur @SuppressWarnings("UnresolvedMixinReference") @Inject(method = "method_17417", at = @At("HEAD"), cancellable = true) private void depositXpToPlayer(World world, BlockPos blockPos, CallbackInfo ci) { - if (Tweaks.CONFIG.easyXp && this.player.get() != null) { - this.player.get().addExperience(this.getExperience(world)); + if (Tweaks.CONFIG.easyXp && this.player.get() instanceof ServerPlayerEntity) { + XpUtil.addXp((ServerPlayerEntity) this.player.get(), this.getExperience(world)); world.syncWorldEvent(1042, blockPos, 0); ci.cancel(); } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java index 70f621e..017383f 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/AnimalEntityBreedXp.java @@ -1,6 +1,7 @@ package dev.hephaestus.tweaks.mixin.entity.easyxp; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.AnimalEntity; @@ -31,7 +32,7 @@ private void depositXpToPlayer(ServerWorld serverWorld, AnimalEntity other, Call } if (playerEntity != null && Tweaks.CONFIG.easyXp) { - playerEntity.addExperience(this.getRandom().nextInt(7) + 1); + XpUtil.addXp(playerEntity, this.getRandom().nextInt(7) + 1); ci.cancel(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java index 85aa18f..7f71a2e 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/FishingXp.java @@ -1,9 +1,12 @@ package dev.hephaestus.tweaks.mixin.entity.easyxp; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.Entity; +import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.FishingBobberEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -18,8 +21,8 @@ public abstract class FishingXp { @Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) private boolean depositXpToPlayer(World world, Entity entity) { - if (this.getPlayerOwner() != null && Tweaks.CONFIG.easyXp) { - this.getPlayerOwner().addExperience((int) (Math.random() * 6 + 1)); + if (this.getPlayerOwner() != null && Tweaks.CONFIG.easyXp && entity instanceof ExperienceOrbEntity) { + XpUtil.addXp((ServerPlayerEntity) this.getPlayerOwner(), (int) (Math.random() * 6 + 1)); return false; } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java index 8cd46ef..b23c920 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/LivingEntityGiveXp.java @@ -1,8 +1,10 @@ package dev.hephaestus.tweaks.mixin.entity.easyxp; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -16,8 +18,8 @@ public class LivingEntityGiveXp { @Inject(method = "dropXp", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/LivingEntity;getCurrentExperience(Lnet/minecraft/entity/player/PlayerEntity;)I"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) private void depositXpToPlayer(CallbackInfo ci, int i) { - if (i > 0 && this.attackingPlayer != null && Tweaks.CONFIG.easyXp) { - this.attackingPlayer.addExperience(i); + if (i > 0 && this.attackingPlayer instanceof ServerPlayerEntity && Tweaks.CONFIG.easyXp) { + XpUtil.addXp((ServerPlayerEntity) this.attackingPlayer, i); ci.cancel(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java index eb01ff1..998e4b6 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/MateGoalXp.java @@ -1,6 +1,7 @@ package dev.hephaestus.tweaks.mixin.entity.easyxp; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.ai.goal.AnimalMateGoal; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.FoxEntity; @@ -25,7 +26,7 @@ private void depositXpToPlayer(CallbackInfo ci) { ServerPlayerEntity playerEntity = this.animal.getLovingPlayer(); if (playerEntity != null && Tweaks.CONFIG.easyXp) { - playerEntity.addExperience(this.animal.getRandom().nextInt(7) + 1); + XpUtil.addXp(playerEntity, this.animal.getRandom().nextInt(7) + 1); ci.cancel(); } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java index f9f3f61..c83988d 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/easyxp/VillagerTradeXp.java @@ -1,11 +1,13 @@ package dev.hephaestus.tweaks.mixin.entity.easyxp; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.MerchantEntity; import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.entity.passive.WanderingTraderEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.village.TradeOffer; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -30,8 +32,8 @@ private void captureLocals(TradeOffer offer, CallbackInfo ci, int i) { @Redirect(method = "afterUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) private boolean depositXpToPlayer(World world, Entity entity) { - if (this.getCurrentCustomer() != null && Tweaks.CONFIG.easyXp) { - this.getCurrentCustomer().addExperience(i); + if (this.getCurrentCustomer() instanceof ServerPlayerEntity && Tweaks.CONFIG.easyXp) { + XpUtil.addXp((ServerPlayerEntity) this.getCurrentCustomer(), i); return false; } else { return world.spawnEntity(entity); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java index b00e1f8..074d9bb 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java @@ -1,8 +1,11 @@ package dev.hephaestus.tweaks.mixin.prod; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.XpUtil; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.screen.GrindstoneScreenHandler; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -13,24 +16,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net/minecraft/screen/GrindstoneScreenHandler$4") +@Mixin(GrindstoneScreenHandler.class) public abstract class DepositGrindstoneXp { - @Shadow protected abstract int getExperience(World world); + @Mixin(targets = "net/minecraft/screen/GrindstoneScreenHandler$4") + public static abstract class SlotMixin { + @Shadow + protected abstract int getExperience(World world); - @Unique private final ThreadLocal player = new ThreadLocal<>(); + @Unique + private final ThreadLocal player = new ThreadLocal<>(); - @Inject(method = "method_7667", at = @At("HEAD")) - private void captureArgs(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir) { - this.player.set(player); - } + @Inject(method = "onTakeItem", at = @At("HEAD")) + private void captureArgs(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir) { + this.player.set(player); + } - @SuppressWarnings("UnresolvedMixinReference") - @Inject(method = "method_17417", at = @At("HEAD"), cancellable = true) - private void depositXpToPlayer(World world, BlockPos blockPos, CallbackInfo ci) { - if (Tweaks.CONFIG.easyXp && this.player.get() != null) { - this.player.get().addExperience(this.getExperience(world)); - world.syncWorldEvent(1042, blockPos, 0); - ci.cancel(); + @SuppressWarnings("UnresolvedMixinReference") + @Inject(method = "method_17417", at = @At("HEAD"), cancellable = true) + private void depositXpToPlayer(World world, BlockPos blockPos, CallbackInfo ci) { + if (Tweaks.CONFIG.easyXp && this.player.get() instanceof ServerPlayerEntity) { + XpUtil.addXp((ServerPlayerEntity) this.player.get(), this.getExperience(world)); + world.syncWorldEvent(1042, blockPos, 0); + ci.cancel(); + } } } } diff --git a/src/main/java/dev/hephaestus/tweaks/util/XpUtil.java b/src/main/java/dev/hephaestus/tweaks/util/XpUtil.java new file mode 100644 index 0000000..542c8b1 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/util/XpUtil.java @@ -0,0 +1,35 @@ +package dev.hephaestus.tweaks.util; + +import dev.hephaestus.tweaks.Tweaks; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; + +import java.util.Map; +import java.util.Random; + +public class XpUtil { + private static final Random random = new Random(); + public static void addXp(ServerPlayerEntity player, int amount) { + if (amount > 0) { + Map.Entry entry = EnchantmentHelper.chooseEquipmentWith(Enchantments.MENDING, player, ItemStack::isDamaged); + if (entry != null) { + ItemStack itemStack = entry.getValue(); + if (!itemStack.isEmpty() && itemStack.isDamaged()) { + int i = Math.min(amount * 2, itemStack.getDamage()); + amount -= i / 2; + itemStack.setDamage(itemStack.getDamage() - i); + } + } + + player.addExperience(amount); + player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.1F, (random.nextFloat() - random.nextFloat()) * 0.35F + 0.9F); + } else { + Tweaks.log("Huh"); + } + } +} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 2f45bd0..3dfff4d 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -52,7 +52,8 @@ "item.FlintAndSteelMixin", "item.HoeItemMixin", "item.ShovelMixin", - "prod.DepositGrindstoneXp" + "prod.DepositGrindstoneXp", + "prod.DepositGrindstoneXp$SlotMixin" ], "client": [ "client.gui.hud.RenderSoulFire", From b65c8e3715536004069ef6235cd48a47ad11e5d5 Mon Sep 17 00:00:00 2001 From: Haven Date: Sat, 17 Oct 2020 23:26:11 -0700 Subject: [PATCH 46/53] Added a tweak that allows you to double the amount of damage dealt to you when ignited by soul fire. --- .../dev/hephaestus/tweaks/TweaksConfig.java | 4 ++ ...eType.java => SoulFireDoesMoreDamage.java} | 54 ++++++++++++++----- .../assets/tinytweaks/lang/en_us.json | 7 +++ src/main/resources/tweaks.mixins.json | 2 +- 4 files changed, 53 insertions(+), 14 deletions(-) rename src/main/java/dev/hephaestus/tweaks/mixin/entity/{SetSoulFireType.java => SoulFireDoesMoreDamage.java} (50%) diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index d711d76..dd3bacc 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -58,6 +58,10 @@ public class TweaksConfig implements ConfigData { @ConfigEntry.Gui.Tooltip(count = 2) public boolean blueSoulFireEffects = true; + @ConfigEntry.Category("nether") + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean soulFireDoesMoreDamage = false; + // - Miscellaneous! ------------------------------------------------------- @ConfigEntry.Category("misc") @ConfigEntry.Gui.CollapsibleObject diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/SoulFireDoesMoreDamage.java similarity index 50% rename from src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java rename to src/main/java/dev/hephaestus/tweaks/mixin/entity/SoulFireDoesMoreDamage.java index 73b4384..98b369a 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/SetSoulFireType.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/entity/SoulFireDoesMoreDamage.java @@ -2,44 +2,53 @@ import dev.hephaestus.tweaks.Tweaks; import dev.hephaestus.tweaks.util.SoulFire; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Entity.class) -@Environment(EnvType.CLIENT) -public abstract class SetSoulFireType implements SoulFire.FireTypeModifier { - @Shadow public World world; +public abstract class SoulFireDoesMoreDamage implements SoulFire.FireTypeModifier { + @Shadow + public World world; @Shadow public abstract Box getBoundingBox(); @Shadow public abstract boolean isInLava(); - private SoulFire.FireType fireType = SoulFire.FireType.NORMAL; + @Shadow private int fireTicks; + + @Unique private SoulFire.FireType fireType = SoulFire.FireType.NORMAL; @Override public SoulFire.FireType getFireType() { return this.fireType; } + private void setFireType(SoulFire.FireType fireType) { + this.fireType = fireType; + } + @Override public void updateFireType() { if (this.isInLava()) { - this.fireType = SoulFire.FireType.NORMAL; + setFireType(SoulFire.FireType.NORMAL); return; } - if (this.world.isClient && Tweaks.CONFIG.blueSoulFireEffects) { + if (Tweaks.CONFIG.blueSoulFireEffects) { Box box = this.getBoundingBox(); BlockPos blockPos = new BlockPos(box.minX + 0.001D, box.minY + 0.001D, box.minZ + 0.001D); BlockPos blockPos2 = new BlockPos(box.maxX - 0.001D, box.maxY - 0.001D, box.maxZ - 0.001D); @@ -52,9 +61,9 @@ public void updateFireType() { Block fire = this.world.getBlockState(mutable).getBlock(); if (fire == Blocks.SOUL_FIRE) { - this.fireType = SoulFire.FireType.SOUL; + this.setFireType(SoulFire.FireType.SOUL); } else if (fire == Blocks.FIRE) { - this.fireType = SoulFire.FireType.NORMAL; + this.setFireType(SoulFire.FireType.NORMAL); } } } @@ -63,8 +72,27 @@ public void updateFireType() { } } - @Inject(method = "baseTick", at = @At("HEAD")) - private void setFireType(CallbackInfo ci) { - this.updateFireType(); + @Inject(method = "setFireTicks", at = @At("HEAD")) + private void setFireType(int ticks, CallbackInfo ci) { + if (ticks > this.fireTicks) { + this.updateFireType(); + } + } + + @ModifyConstant(method = "baseTick", constant = @Constant(floatValue = 1.0F)) + private float getDamage(float damage) { + return this.getFireType() == SoulFire.FireType.NORMAL ? damage : damage * 2; + } + + @Inject(method = "toTag", at = @At("TAIL")) + private void saveFireType(CompoundTag tag, CallbackInfoReturnable cir) { + tag.putString("TinyTweaksFireType", this.getFireType().name()); + } + + @Inject(method = "fromTag", at = @At("HEAD")) + private void loadFireType(CompoundTag tag, CallbackInfo ci) { + if (tag.contains("TinyTweaksFireType")) { + this.setFireType(SoulFire.FireType.valueOf(tag.getString("TinyTweaksFireType"))); + } } } diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index 49024ed..f1a77fd 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -98,6 +98,9 @@ "text.autoconfig.tinytweaks.option.blueSoulFireEffects": "Improved Soul Fire", "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[0]": "Makes fire rendered on the hud and entities on fire blue", "text.autoconfig.tinytweaks.option.blueSoulFireEffects.@Tooltip[1]": "when lit on fire by soul fire", + "text.autoconfig.tinytweaks.option.soulFireDoesMoreDamage": "Higher Damage Soul Fire", + "text.autoconfig.tinytweaks.option.soulFireDoesMoreDamage.@Tooltip[0]": "Makes entities ignited by soul fire take", + "text.autoconfig.tinytweaks.option.soulFireDoesMoreDamage.@Tooltip[1]": "twice as much damage while burning", "text.autoconfig.tinytweaks.option.infiniteCauldrons": "Infinite Cauldrons", "text.autoconfig.tinytweaks.option.infiniteCauldrons.@Tooltip": "Right click a cauldron with a Heart of the Sea to make it infinite", "text.autoconfig.tinytweaks.option.easyXp": "Easy XP", @@ -129,6 +132,8 @@ "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyXp.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects.boolean.true": "§aOn", + "text.autoconfig.tinytweaks.option.soulFireDoesMoreDamage.boolean.true": "§aOn", "text.autoconfig.tinytweaks.option.easyHarvestCrops.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyHarvestSugarcane.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.autoPlanting.enabled.boolean.false": "§cOff", @@ -155,5 +160,7 @@ "text.autoconfig.tinytweaks.option.netherRejuvenation.enabled.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.infiniteCauldrons.boolean.false": "§cOff", "text.autoconfig.tinytweaks.option.easyXp.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.blueSoulFireEffects.boolean.false": "§cOff", + "text.autoconfig.tinytweaks.option.soulFireDoesMoreDamage.boolean.false": "§cOff", "block.cauldron.makeInfinite": "This cauldron has been blessed with the heart of the sea" } \ No newline at end of file diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 3dfff4d..3cd1af8 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -32,6 +32,7 @@ "entity.AutoPlant", "entity.BurnUsableEntities", "entity.LivingEntityMixin", + "entity.SoulFireDoesMoreDamage", "entity.ai.brain.task.FarmerVillagersDepositSurplus", "entity.betterlilypads.FallingParticles", "entity.betterlilypads.SprintingParticles", @@ -66,7 +67,6 @@ "client.render.entity.TippedArrowEntityRenderer", "dev.ChestBlockEntityRendererMixin", "dev.ShulkerBoxEntityRendererMixin", - "entity.SetSoulFireType", "prod.ChestBlockEntityRendererMixin", "prod.ShulkerBoxEntityRendererMixin" ], From ce1f63b28561b5140061e172c9f4cda75140f7e9 Mon Sep 17 00:00:00 2001 From: Haven Date: Sun, 18 Oct 2020 01:05:48 -0700 Subject: [PATCH 47/53] Added link to CurseForge page --- src/main/resources/fabric.mod.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0508e3a..fcbdbf7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -9,6 +9,7 @@ ], "contributors": [], "contact": { + "website": "https://www.curseforge.com/minecraft/mc-mods/tinytweaks", "sources": "https://github.com/Hephaestus-Dev/TinyTweaks", "issues": "https://github.com/Hephaestus-Dev/TinyTweaks/issues" }, From 015bd1fdf2911176896440c7b35d7ec7f109c7ed Mon Sep 17 00:00:00 2001 From: Haven Date: Mon, 19 Oct 2020 12:46:18 -0700 Subject: [PATCH 48/53] Now uses Climbable for tree climbing capabilities. Tree climbing speed is now configurable. --- build.gradle | 7 +++ gradle.properties | 1 + .../java/dev/hephaestus/tweaks/Tweaks.java | 7 ++- .../dev/hephaestus/tweaks/TweaksConfig.java | 3 ++ .../mixin/entity/LivingEntityMixin.java | 44 ------------------- .../mixin/prod/DepositGrindstoneXp.java | 4 +- .../assets/tinytweaks/lang/en_us.json | 3 ++ src/main/resources/tweaks.mixins.json | 1 - 8 files changed, 21 insertions(+), 49 deletions(-) delete mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java diff --git a/build.gradle b/build.gradle index ab21074..9d16e40 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,9 @@ repositories { url = "http://maven.fabricmc.net/" name = "Fabric" } + maven { + url "https://hephaestus.dev/release" + } } dependencies { @@ -37,6 +40,10 @@ dependencies { exclude group: "net.fabricmc.fabric-api" } + modImplementation ("dev.hephaestus:climbable:${project.climbable_version}") + include "dev.hephaestus:climbable:${project.climbable_version}" + + // modImplementation ("net.fabricmc:fabric-language-kotlin:1.3.72+build.1") { // exclude group: "net.fabricmc.fabric-api" // } diff --git a/gradle.properties b/gradle.properties index d9e504e..71741e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,6 +14,7 @@ archives_base_name = tinytweaks fabric_version = 0.21.0+build.407-1.16 cloth_config_version = 4.8.1 auto_config_version = 3.2.2 +climbable_version = 0.1.3 # Dev Mods mod_menu_version = 1.14.6+build.31 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/Tweaks.java b/src/main/java/dev/hephaestus/tweaks/Tweaks.java index e365cf1..c6ab6cb 100644 --- a/src/main/java/dev/hephaestus/tweaks/Tweaks.java +++ b/src/main/java/dev/hephaestus/tweaks/Tweaks.java @@ -1,5 +1,6 @@ package dev.hephaestus.tweaks; +import dev.hephaestus.climbable.api.ClimbingSpeedRegistry; import dev.hephaestus.tweaks.block.Moistener; import dev.hephaestus.tweaks.client.render.block.entity.BarrelBlockLabelRenderer; import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; @@ -10,10 +11,10 @@ import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.state.property.BooleanProperty; +import net.minecraft.tag.BlockTags; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.spongepowered.asm.mixin.Unique; public class Tweaks implements ModInitializer, ClientModInitializer { public static final BooleanProperty INFINITE = BooleanProperty.of("infinite"); @@ -23,7 +24,7 @@ public class Tweaks implements ModInitializer, ClientModInitializer { public static final String MOD_ID = "tinytweaks"; public static final String MOD_NAME = "TinyTweaks"; - public static final double LILY_PAD_MOD = 0.2109375D /* 27 / 128 */; + public static final double LILY_PAD_MOD = 0.2109375D; public static TweaksConfig CONFIG = new TweaksConfig(); @@ -41,6 +42,8 @@ public void onInitialize() { Moistener.canMoisten(Blocks.STONE_BRICK_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB); Moistener.canMoisten(Blocks.STONE_BRICK_STAIRS, Blocks.MOSSY_STONE_BRICK_STAIRS); Moistener.canMoisten(Blocks.STONE_BRICK_WALL, Blocks.MOSSY_STONE_BRICK_WALL); + + ClimbingSpeedRegistry.registerClimbableTag(BlockTags.LOGS, () -> CONFIG.leaves.treeClimbingSpeed, () -> CONFIG.leaves.climb); } public static void log(Level level, String message, Object... args){ diff --git a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java index dd3bacc..252feac 100644 --- a/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java +++ b/src/main/java/dev/hephaestus/tweaks/TweaksConfig.java @@ -151,6 +151,9 @@ public static class LeavesConfig { public double slowAmount = 0.75D; public boolean climb = true; + + @ConfigEntry.Gui.Tooltip(count = 2) + public double treeClimbingSpeed = 0.75D; } public static class FlintAndSteelConfig { diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java b/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java deleted file mode 100644 index 6111059..0000000 --- a/src/main/java/dev/hephaestus/tweaks/mixin/entity/LivingEntityMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -package dev.hephaestus.tweaks.mixin.entity; - -import dev.hephaestus.tweaks.Tweaks; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.particle.BlockStateParticleEffect; -import net.minecraft.particle.ParticleType; -import net.minecraft.tag.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(LivingEntity.class) -public abstract class LivingEntityMixin extends Entity { - public LivingEntityMixin(EntityType type, World world) { - super(type, world); - } - - @Inject(method = "isClimbing", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) - public void onIsClimbing(CallbackInfoReturnable info, BlockPos pos) { - if (world.getBlockState(pos).getBlock() instanceof LeavesBlock || world.getBlockState(pos.up()).getBlock() instanceof LeavesBlock || world.getBlockState(pos.up(2)).getBlock() instanceof LeavesBlock) { - if (Tweaks.CONFIG.leaves.climb) { - boolean logsAdjacent = - world.getBlockState(pos.north()).getBlock().isIn(BlockTags.LOGS) || - world.getBlockState(pos.east()).getBlock().isIn(BlockTags.LOGS) || - world.getBlockState(pos.south()).getBlock().isIn(BlockTags.LOGS) || - world.getBlockState(pos.west()).getBlock().isIn(BlockTags.LOGS); - - info.setReturnValue(logsAdjacent); - } - } - } -} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java b/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java index 074d9bb..516b5d3 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/prod/DepositGrindstoneXp.java @@ -18,6 +18,7 @@ @Mixin(GrindstoneScreenHandler.class) public abstract class DepositGrindstoneXp { + @SuppressWarnings("UnresolvedMixinReference") @Mixin(targets = "net/minecraft/screen/GrindstoneScreenHandler$4") public static abstract class SlotMixin { @Shadow @@ -26,12 +27,11 @@ public static abstract class SlotMixin { @Unique private final ThreadLocal player = new ThreadLocal<>(); - @Inject(method = "onTakeItem", at = @At("HEAD")) + @Inject(method = "method_7667", remap = false, at = @At("HEAD")) private void captureArgs(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir) { this.player.set(player); } - @SuppressWarnings("UnresolvedMixinReference") @Inject(method = "method_17417", at = @At("HEAD"), cancellable = true) private void depositXpToPlayer(World world, BlockPos blockPos, CallbackInfo ci) { if (Tweaks.CONFIG.easyXp && this.player.get() instanceof ServerPlayerEntity) { diff --git a/src/main/resources/assets/tinytweaks/lang/en_us.json b/src/main/resources/assets/tinytweaks/lang/en_us.json index f1a77fd..2b8db9b 100644 --- a/src/main/resources/assets/tinytweaks/lang/en_us.json +++ b/src/main/resources/assets/tinytweaks/lang/en_us.json @@ -58,6 +58,9 @@ "text.autoconfig.tinytweaks.option.leaves.slow.@Tooltip": "Leaves slow non-item entities passing through them", "text.autoconfig.tinytweaks.option.leaves.slowAmount": "Slow Amount", "text.autoconfig.tinytweaks.option.leaves.climb": "Climbable Trees", + "text.autoconfig.tinytweaks.option.leaves.treeClimbingSpeed": "Tree Climbing Speed", + "text.autoconfig.tinytweaks.option.leaves.treeClimbingSpeed.@Tooltip[0]": "Controls the speed at which you climb trees", + "text.autoconfig.tinytweaks.option.leaves.treeClimbingSpeed.@Tooltip[1]": "1.0 is the default speed for ladders and vines", "text.autoconfig.tinytweaks.option.leaves.persistentCollide": "Persistent Leaf Collision", "text.autoconfig.tinytweaks.option.leaves.persistentCollide.@Tooltip": "These are leaves placed by the player", "text.autoconfig.tinytweaks.option.namesAndThings": "Names and Things", diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 3cd1af8..4c71d91 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -31,7 +31,6 @@ "dev.DepositGrindstoneXp", "entity.AutoPlant", "entity.BurnUsableEntities", - "entity.LivingEntityMixin", "entity.SoulFireDoesMoreDamage", "entity.ai.brain.task.FarmerVillagersDepositSurplus", "entity.betterlilypads.FallingParticles", From 3299e9fdd530825242dd5b7e35fd6b1d97a15bfd Mon Sep 17 00:00:00 2001 From: Haven Date: Tue, 20 Oct 2020 23:53:13 -0700 Subject: [PATCH 49/53] Fixes #29 --- gradle.properties | 4 ++-- src/main/java/dev/hephaestus/tweaks/Tweaks.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 71741e1..421e95e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings = 1.16.3+build.11 loader_version = 0.10.0+local #Mod properties -mod_version = 1.0.14 +mod_version = 1.0.15 maven_group = dev.hephaestus archives_base_name = tinytweaks @@ -14,7 +14,7 @@ archives_base_name = tinytweaks fabric_version = 0.21.0+build.407-1.16 cloth_config_version = 4.8.1 auto_config_version = 3.2.2 -climbable_version = 0.1.3 +climbable_version = 0.2.0 # Dev Mods mod_menu_version = 1.14.6+build.31 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/tweaks/Tweaks.java b/src/main/java/dev/hephaestus/tweaks/Tweaks.java index c6ab6cb..5acdbf3 100644 --- a/src/main/java/dev/hephaestus/tweaks/Tweaks.java +++ b/src/main/java/dev/hephaestus/tweaks/Tweaks.java @@ -43,7 +43,7 @@ public void onInitialize() { Moistener.canMoisten(Blocks.STONE_BRICK_STAIRS, Blocks.MOSSY_STONE_BRICK_STAIRS); Moistener.canMoisten(Blocks.STONE_BRICK_WALL, Blocks.MOSSY_STONE_BRICK_WALL); - ClimbingSpeedRegistry.registerClimbableTag(BlockTags.LOGS, () -> CONFIG.leaves.treeClimbingSpeed, () -> CONFIG.leaves.climb); + ClimbingSpeedRegistry.registerClimbableTag(BlockTags.LOGS, e -> CONFIG.leaves.treeClimbingSpeed, e -> CONFIG.leaves.climb); } public static void log(Level level, String message, Object... args){ From e49581f05542640cc57d13084d75f2e1ad2172d2 Mon Sep 17 00:00:00 2001 From: Haven Date: Thu, 22 Oct 2020 18:18:25 -0700 Subject: [PATCH 50/53] Infinite cauldrons are now entirely server-side. Fixes #34 --- gradle.properties | 2 +- .../java/dev/hephaestus/tweaks/Tweaks.java | 2 - .../mixin/block/MakeCauldronsInfinite.java | 75 ++++++++----------- .../mixin/world/SerializeChunkData.java | 60 +++++++++++++++ .../tweaks/mixin/world/TrackBlockChanges.java | 46 ++++++++++++ .../tweaks/mixin/world/UpgradeChunk.java | 25 +++++++ .../hephaestus/tweaks/util/CauldronChunk.java | 12 +++ src/main/resources/tweaks.mixins.json | 5 +- 8 files changed, 180 insertions(+), 47 deletions(-) create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/world/SerializeChunkData.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/world/TrackBlockChanges.java create mode 100644 src/main/java/dev/hephaestus/tweaks/mixin/world/UpgradeChunk.java create mode 100644 src/main/java/dev/hephaestus/tweaks/util/CauldronChunk.java diff --git a/gradle.properties b/gradle.properties index 421e95e..edaf6f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings = 1.16.3+build.11 loader_version = 0.10.0+local #Mod properties -mod_version = 1.0.15 +mod_version = 1.0.16 maven_group = dev.hephaestus archives_base_name = tinytweaks diff --git a/src/main/java/dev/hephaestus/tweaks/Tweaks.java b/src/main/java/dev/hephaestus/tweaks/Tweaks.java index 5acdbf3..0f8f4d4 100644 --- a/src/main/java/dev/hephaestus/tweaks/Tweaks.java +++ b/src/main/java/dev/hephaestus/tweaks/Tweaks.java @@ -17,8 +17,6 @@ import org.apache.logging.log4j.Logger; public class Tweaks implements ModInitializer, ClientModInitializer { - public static final BooleanProperty INFINITE = BooleanProperty.of("infinite"); - public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "tinytweaks"; diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java index bb80dc3..4d8e1bb 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/MakeCauldronsInfinite.java @@ -1,13 +1,17 @@ package dev.hephaestus.tweaks.mixin.block; import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.CauldronChunk; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.CauldronBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.particle.BlockStateParticleEffect; +import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.state.StateManager; @@ -18,6 +22,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -30,52 +35,39 @@ import java.util.Random; @Mixin(CauldronBlock.class) -public class MakeCauldronsInfinite extends Block { - - public MakeCauldronsInfinite(Settings settings) { - super(settings); - } - - @Inject(method = "", at = @At("TAIL")) - private void addInfiniteState(Block.Settings settings, CallbackInfo ci) { - this.setDefaultState(this.getDefaultState().with(Tweaks.INFINITE, false)); - } - - @Inject(method = "setLevel", at = @At("HEAD"), cancellable = true) - private void dontDecreaseLevelIfInfinite(World world, BlockPos pos, BlockState state, int level, CallbackInfo ci) { - if (level < state.get(Properties.LEVEL_3) && state.get(Tweaks.INFINITE)) { - ci.cancel(); - } - } - - @Inject(method = "appendProperties", at = @At("TAIL")) - private void addInfiniteState(StateManager.Builder builder, CallbackInfo ci) { - builder.add(Tweaks.INFINITE); - } - - @Unique private static boolean LAST_CAULDRON_INFINITE = false; - +public class MakeCauldronsInfinite { @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { - LAST_CAULDRON_INFINITE = false; ItemStack stack = player.getStackInHand(hand); - if (Tweaks.CONFIG.infiniteCauldrons && stack.getItem().equals(Items.HEART_OF_THE_SEA) && !state.get(Tweaks.INFINITE)) { - if (world.isClient) { - for(int int_1 = -2; int_1 <= 2; ++int_1) { - for(int int_2 = -2; int_2 <= 2; ++int_2) { + CauldronChunk cauldronChunk = (CauldronChunk) world.getChunk(pos); + + if (Tweaks.CONFIG.infiniteCauldrons && stack.getItem().equals(Items.HEART_OF_THE_SEA) && !cauldronChunk.isInfinite(pos)) { + if (!world.isClient) { + world.setBlockState(pos, state.with(Properties.LEVEL_3, 3)); + cauldronChunk.setInfinite(pos, true); + + for (int int_1 = -2; int_1 <= 2; ++int_1) { + for (int int_2 = -2; int_2 <= 2; ++int_2) { if (int_1 > -2 && int_1 < 2 && int_2 == -1) { int_2 = 2; } Random random = world.getRandom(); - for(int int_3 = 0; int_3 <= 1; ++int_3) { - world.addParticle(ParticleTypes.ENCHANT, (double)pos.getX() + 0.5D, (double)pos.getY() + 2.0D, (double)pos.getZ() + 0.5D, (double)((float)int_1 + random.nextFloat()) - 0.5D, (float)int_3 - random.nextFloat() - 1.0F, (double)((float)int_2 + random.nextFloat()) - 0.5D); + for (int int_3 = 0; int_3 <= 1; ++int_3) { + ((ServerWorld) world).spawnParticles( + ParticleTypes.ENCHANT, + (double) pos.getX() + 0.5D, + (double) pos.getY() + 2.0D, + (double) pos.getZ() + 0.5D, + 1, + (double) ((float) int_1 + random.nextFloat()) - 0.5D, + (float) int_3 - random.nextFloat() - 1.0F, + (double) ((float) int_2 + random.nextFloat()) - 0.5D, + 1); } } } - } else { - world.setBlockState(pos, state.with(Tweaks.INFINITE, true).with(Properties.LEVEL_3, 3)); if (!player.isCreative()) { stack.decrement(1); @@ -83,19 +75,16 @@ private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEnt world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1F, 1F); player.sendMessage(new TranslatableText("block.cauldron.makeInfinite").styled(style -> style.withItalic(true).withColor(Formatting.AQUA)), true); - LAST_CAULDRON_INFINITE = true; cir.setReturnValue(ActionResult.SUCCESS); } - } else if (!Tweaks.CONFIG.infiniteCauldrons && state.get(Tweaks.INFINITE) && !world.isClient) { - world.setBlockState(pos, state.with(Tweaks.INFINITE, false)); - LAST_CAULDRON_INFINITE = false; - } else { - LAST_CAULDRON_INFINITE = state.get(Tweaks.INFINITE); } } - @ModifyArg(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/CauldronBlock;setLevel(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)V"), index = 2) - private BlockState updateState(BlockState state) { - return state.with(Tweaks.INFINITE, LAST_CAULDRON_INFINITE); + @Inject(method = "setLevel", at = @At("HEAD"), cancellable = true) + private void dontDecreaseLevelIfInfinite(World world, BlockPos pos, BlockState state, int level, CallbackInfo ci) { + CauldronChunk cauldronChunk = (CauldronChunk) world.getChunk(pos); + if (level < state.get(Properties.LEVEL_3) && cauldronChunk.isInfinite(pos)) { + ci.cancel(); + } } } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/world/SerializeChunkData.java b/src/main/java/dev/hephaestus/tweaks/mixin/world/SerializeChunkData.java new file mode 100644 index 0000000..61204dc --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/world/SerializeChunkData.java @@ -0,0 +1,60 @@ +package dev.hephaestus.tweaks.mixin.world; + +import dev.hephaestus.tweaks.util.CauldronChunk; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.LongArrayTag; +import net.minecraft.nbt.Tag; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.structure.StructureManager; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.ChunkSerializer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ProtoChunk; +import net.minecraft.world.chunk.ReadOnlyChunk; +import net.minecraft.world.poi.PointOfInterestStorage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Map; +import java.util.stream.Collectors; + +@Mixin(ChunkSerializer.class) +public class SerializeChunkData { + @Inject(method = "serialize", at = @At("RETURN")) + private static void serializeCauldrons(ServerWorld world, Chunk chunk, CallbackInfoReturnable cir) { + if (chunk instanceof CauldronChunk && ((CauldronChunk) chunk).getCauldrons().size() > 0) { + getOrCreate(cir.getReturnValue(), "TinyTweaks").put("InfiniteCauldrons", new LongArrayTag( + ((CauldronChunk) chunk).getCauldrons().stream() + .filter(Map.Entry::getValue) + .map(e -> e.getKey().asLong()) + .collect(Collectors.toList()))); + } + } + + @Inject(method = "deserialize", at = @At("RETURN")) + private static void deserializeCauldrons(ServerWorld world, StructureManager structureManager, PointOfInterestStorage poiStorage, ChunkPos pos, CompoundTag tag, CallbackInfoReturnable cir) { + CauldronChunk chunk = (CauldronChunk) cir.getReturnValue(); + chunk = chunk instanceof ReadOnlyChunk ? (CauldronChunk) ((ReadOnlyChunk) chunk).getWrappedChunk() : chunk; + + for (Long l : tag.getCompound("TinyTweaks").getLongArray("InfiniteCauldrons")) { + chunk.setInfinite(BlockPos.fromLong(l), true); + } + } + + private static CompoundTag getOrCreate(CompoundTag tag, String key) { + return getOrCreate(tag, key, new CompoundTag()); + } + + @SuppressWarnings("unchecked") + private static T getOrCreate(CompoundTag tag, String key, T newTag) { + if (tag.contains(key, newTag.getType())) { + return (T) tag.get(key); + } else { + tag.put(key, newTag); + return newTag; + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/world/TrackBlockChanges.java b/src/main/java/dev/hephaestus/tweaks/mixin/world/TrackBlockChanges.java new file mode 100644 index 0000000..cafb38d --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/world/TrackBlockChanges.java @@ -0,0 +1,46 @@ +package dev.hephaestus.tweaks.mixin.world; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.CauldronChunk; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; +import net.minecraft.world.chunk.ProtoChunk; +import net.minecraft.world.chunk.WorldChunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +@Mixin(value = {WorldChunk.class, ProtoChunk.class}) +public abstract class TrackBlockChanges implements BlockView, CauldronChunk { + @Unique private final Map cauldrons = new HashMap<>(); + + @Inject(method = "setBlockState", at = @At("HEAD")) + private void captureStateChange(BlockPos pos, BlockState state, boolean moved, CallbackInfoReturnable cir) { + if (this.getBlockState(pos).isOf(Blocks.CAULDRON) && !state.getBlock().is(Blocks.CAULDRON)) { + cauldrons.remove(pos); + } + } + + @Override + public Collection> getCauldrons() { + return this.cauldrons.entrySet(); + } + + @Override + public boolean isInfinite(BlockPos pos) { + return Tweaks.CONFIG.infiniteCauldrons && this.cauldrons.getOrDefault(pos, false); + } + + @Override + public void setInfinite(BlockPos pos, boolean infinite) { + this.cauldrons.put(pos, infinite); + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/world/UpgradeChunk.java b/src/main/java/dev/hephaestus/tweaks/mixin/world/UpgradeChunk.java new file mode 100644 index 0000000..ce5512b --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/mixin/world/UpgradeChunk.java @@ -0,0 +1,25 @@ +package dev.hephaestus.tweaks.mixin.world; + +import dev.hephaestus.tweaks.Tweaks; +import dev.hephaestus.tweaks.util.CauldronChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.ProtoChunk; +import net.minecraft.world.chunk.WorldChunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Map; + +@Mixin(WorldChunk.class) +public abstract class UpgradeChunk implements CauldronChunk { + @Inject(method = "(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/ProtoChunk;)V", at = @At("TAIL")) + private void copyCauldrons(World world, ProtoChunk protoChunk, CallbackInfo ci) { + for (Map.Entry entry : ((CauldronChunk) protoChunk).getCauldrons()) { + this.setInfinite(entry.getKey(), entry.getValue()); + Tweaks.log("FUCKING HELL"); + } + } +} diff --git a/src/main/java/dev/hephaestus/tweaks/util/CauldronChunk.java b/src/main/java/dev/hephaestus/tweaks/util/CauldronChunk.java new file mode 100644 index 0000000..6119333 --- /dev/null +++ b/src/main/java/dev/hephaestus/tweaks/util/CauldronChunk.java @@ -0,0 +1,12 @@ +package dev.hephaestus.tweaks.util; + +import net.minecraft.util.math.BlockPos; + +import java.util.Collection; +import java.util.Map; + +public interface CauldronChunk { + boolean isInfinite(BlockPos pos); + void setInfinite(BlockPos pos, boolean infinite); + Collection> getCauldrons(); +} diff --git a/src/main/resources/tweaks.mixins.json b/src/main/resources/tweaks.mixins.json index 4c71d91..32d7096 100644 --- a/src/main/resources/tweaks.mixins.json +++ b/src/main/resources/tweaks.mixins.json @@ -53,7 +53,10 @@ "item.HoeItemMixin", "item.ShovelMixin", "prod.DepositGrindstoneXp", - "prod.DepositGrindstoneXp$SlotMixin" + "prod.DepositGrindstoneXp$SlotMixin", + "world.SerializeChunkData", + "world.TrackBlockChanges", + "world.UpgradeChunk" ], "client": [ "client.gui.hud.RenderSoulFire", From c1ff748690a6364be51927b6a556ca6b1a91a770 Mon Sep 17 00:00:00 2001 From: Haven Date: Thu, 22 Oct 2020 19:04:37 -0700 Subject: [PATCH 51/53] Leaf collision now operates via the leaves tag. Fixes compatibility issues detailed in #33. --- build.gradle | 2 +- .../tweaks/mixin/block/LeafCollision.java | 50 ++++++++++++------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 9d16e40..e85c903 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.4-SNAPSHOT' + id 'fabric-loom' version '0.5-SNAPSHOT' id 'maven-publish' } diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java index 69bf570..4812c18 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java @@ -4,6 +4,10 @@ import net.minecraft.block.*; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.tag.BlockTags; +import net.minecraft.tag.Tag; import net.minecraft.text.HoverEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -12,30 +16,38 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(LeavesBlock.class) -public class LeafCollision extends Block{ - public LeafCollision(Settings settings) { - super(settings); - } - - @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { - if (context == EntityShapeContext.ABSENT) { - return VoxelShapes.fullCube(); - } +@Mixin(AbstractBlock.AbstractBlockState.class) +public abstract class LeafCollision { + @Shadow public abstract Block getBlock(); - if (state.get(LeavesBlock.PERSISTENT)) { - return Tweaks.CONFIG.leaves.persistentCollide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); - } else { - return Tweaks.CONFIG.leaves.collide ? super.getCollisionShape(state, view, pos, context) : VoxelShapes.empty(); + @Inject(method = "getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;", at = @At("HEAD"), cancellable = true) + private void getCollisionShape(BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (context != EntityShapeContext.ABSENT && this.getBlock().isIn(BlockTags.LEAVES)) { + if (world.getBlockState(pos).get(LeavesBlock.PERSISTENT)) { + cir.setReturnValue(Tweaks.CONFIG.leaves.persistentCollide ? VoxelShapes.fullCube() : VoxelShapes.empty()); + } else { + cir.setReturnValue(Tweaks.CONFIG.leaves.collide ? VoxelShapes.fullCube() : VoxelShapes.empty()); + } } } - @Override - public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if (Tweaks.CONFIG.leaves.slow && !(entity instanceof ItemEntity)) { - entity.setVelocity(entity.getVelocity().multiply(Tweaks.CONFIG.leaves.slowAmount)); + @Inject(method = "onEntityCollision", at = @At("HEAD")) + private void onEntityCollision(World world, BlockPos pos, Entity entity, CallbackInfo ci) { + if (this.getBlock().isIn(BlockTags.LEAVES)) { + entity.fallDistance = entity.fallDistance * 0.7f; + + Vec3d velocity = entity.getVelocity(); + entity.setVelocity(velocity.multiply(0.7D, (velocity.y > 0 ? 1.0D : 0.7D), 0.7D)); + + if (entity.getVelocity().length() > 0.1D) { + entity.handleFallDamage(entity.fallDistance, 0.5f); + } } } } \ No newline at end of file From f1d9ff4b7ddf74488b52b99e8e1f45ef5e644921 Mon Sep 17 00:00:00 2001 From: Haven Date: Thu, 22 Oct 2020 19:15:33 -0700 Subject: [PATCH 52/53] Fix crash when placing leaves --- .../java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java index 4812c18..6e2528e 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/LeafCollision.java @@ -6,6 +6,7 @@ import net.minecraft.entity.ItemEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.state.property.Properties; import net.minecraft.tag.BlockTags; import net.minecraft.tag.Tag; import net.minecraft.text.HoverEvent; @@ -29,7 +30,8 @@ public abstract class LeafCollision { @Inject(method = "getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;", at = @At("HEAD"), cancellable = true) private void getCollisionShape(BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (context != EntityShapeContext.ABSENT && this.getBlock().isIn(BlockTags.LEAVES)) { - if (world.getBlockState(pos).get(LeavesBlock.PERSISTENT)) { + BlockState state = world.getBlockState(pos); + if (state.getBlock().getStateManager().getProperty("persistent") != null && state.get(Properties.PERSISTENT)) { cir.setReturnValue(Tweaks.CONFIG.leaves.persistentCollide ? VoxelShapes.fullCube() : VoxelShapes.empty()); } else { cir.setReturnValue(Tweaks.CONFIG.leaves.collide ? VoxelShapes.fullCube() : VoxelShapes.empty()); From 3c7c733d673373f33684aec4fe38641fc72905b0 Mon Sep 17 00:00:00 2001 From: Haven Date: Fri, 30 Oct 2020 01:04:58 -0700 Subject: [PATCH 53/53] Fixes #26 --- .../tweaks/block/PlayerProvider.java | 30 +++++++++++-------- .../FurnaceBlockEntityPlayerProvider.java | 1 + .../block/easyxp/PassPlayerToEntity.java | 2 ++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java b/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java index d156083..4783091 100644 --- a/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java +++ b/src/main/java/dev/hephaestus/tweaks/block/PlayerProvider.java @@ -3,21 +3,25 @@ import net.minecraft.server.network.ServerPlayerEntity; public interface PlayerProvider { - ThreadLocal STATIC = new ThreadLocal() {{ - this.set(new PlayerProvider() { - private ServerPlayerEntity playerEntity = null; + ThreadLocal STATIC = new ThreadLocal<>(); - @Override - public ServerPlayerEntity getPlayer() { - return this.playerEntity; - } + static void init() { + if (STATIC.get() == null) { + STATIC.set(new PlayerProvider() { + private ServerPlayerEntity playerEntity = null; - @Override - public void setPlayer(ServerPlayerEntity player) { - this.playerEntity = player; - } - }); - }}; + @Override + public ServerPlayerEntity getPlayer() { + return this.playerEntity; + } + + @Override + public void setPlayer(ServerPlayerEntity player) { + this.playerEntity = player; + } + }); + } + } ServerPlayerEntity getPlayer(); void setPlayer(ServerPlayerEntity player); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java index c8c2bb5..6ab2c1f 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/FurnaceBlockEntityPlayerProvider.java @@ -25,6 +25,7 @@ private static void depositXpToPlayer(World world, Vec3d vec3d, int i, float f) if (playerEntity != null && Tweaks.CONFIG.easyXp) { XpUtil.addXp(playerEntity, i); + PlayerProvider.init(); PlayerProvider.STATIC.get().setPlayer(null); } else { dropExperience(world, vec3d, i, f); diff --git a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java index e19a23d..b04b3ab 100644 --- a/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java +++ b/src/main/java/dev/hephaestus/tweaks/mixin/block/easyxp/PassPlayerToEntity.java @@ -3,6 +3,7 @@ import dev.hephaestus.tweaks.block.PlayerProvider; import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.BlockState; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -14,6 +15,7 @@ public class PassPlayerToEntity { @Inject(method = "onStateReplaced", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;method_27354(Lnet/minecraft/world/World;Lnet/minecraft/util/math/Vec3d;)Ljava/util/List;")) private void setStaticPlayer(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved, CallbackInfo ci) { + PlayerProvider.init(); PlayerProvider.STATIC.get().setPlayer(((PlayerProvider) state.getBlock()).getPlayer()); } }