From af86a7366a13d3de87a72535e85433e60b5d9e7e Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:33:05 +0100 Subject: [PATCH] Mildly Experienced - Players can now sneak while using exp nuggets to only consume one item at a time - Fixed brass funnels losing their filter when changing from or to a belt/depot funnel - Minecart contraption items can no longer be placed in container items like toolboxes or shulkers (configurable) - Implement #4436, #4419 --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .../com/simibubi/create/compat/curios/Curios.java | 11 +++++++---- .../base/GeneratingKineticTileEntity.java | 2 +- .../mounted/MinecartContraptionItem.java | 5 +++++ .../content/curiosities/ExperienceNuggetItem.java | 9 +++++++-- .../logistics/block/funnel/BeltFunnelBlock.java | 11 +++++++++++ .../logistics/block/funnel/BrassFunnelBlock.java | 2 +- .../content/logistics/block/funnel/FunnelBlock.java | 7 +++++++ .../simibubi/create/foundation/config/CKinetics.java | 3 +++ 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 73fbff319..efbe37479 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -49,6 +49,7 @@ body: label: Mod Version description: The version of the mod you were using when the bug occured options: + - "0.5.0j" - "0.5.0i" - "0.5.0h" - "0.5.0g" diff --git a/src/main/java/com/simibubi/create/compat/curios/Curios.java b/src/main/java/com/simibubi/create/compat/curios/Curios.java index a595bb150..1b85d2f26 100644 --- a/src/main/java/com/simibubi/create/compat/curios/Curios.java +++ b/src/main/java/com/simibubi/create/compat/curios/Curios.java @@ -25,10 +25,13 @@ public class Curios { .get("head"); if (stacksHandler == null) return false; - if (stacksHandler.getSlots() == 0) - return false; - return AllItems.GOGGLES.isIn(stacksHandler.getStacks() - .getStackInSlot(0)); + int slots = stacksHandler.getSlots(); + for (int slot = 0; slot < slots; slot++) + if (AllItems.GOGGLES.isIn(stacksHandler.getStacks() + .getStackInSlot(slot))) + return true; + + return false; }) .orElse(false)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java index d9dfcb467..4236d8ae0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java @@ -92,7 +92,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { float speed = getGeneratedSpeed(); float prevSpeed = this.speed; - if (level.isClientSide) + if (level == null || level.isClientSide) return; if (prevSpeed != speed) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java index 3dd2ff7c1..89940f826 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java @@ -67,6 +67,11 @@ public class MinecartContraptionItem extends Item { public static MinecartContraptionItem chest(Properties builder) { return new MinecartContraptionItem(Type.CHEST, builder); } + + @Override + public boolean canFitInsideContainerItems() { + return AllConfigs.SERVER.kinetics.minecartContraptionInContainers.get(); + } private MinecartContraptionItem(Type minecartTypeIn, Properties builder) { super(builder); diff --git a/src/main/java/com/simibubi/create/content/curiosities/ExperienceNuggetItem.java b/src/main/java/com/simibubi/create/content/curiosities/ExperienceNuggetItem.java index 53b91160e..4407cbd7b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ExperienceNuggetItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ExperienceNuggetItem.java @@ -35,8 +35,9 @@ public class ExperienceNuggetItem extends Item { return InteractionResultHolder.consume(itemInHand); } - int total = Mth.ceil(3f * itemInHand.getCount()); - int maxOrbs = 5; + int amountUsed = pPlayer.isSteppingCarefully() ? 1 : itemInHand.getCount(); + int total = Mth.ceil(3f * amountUsed); + int maxOrbs = amountUsed == 1 ? 1 : 5; int valuePer = Math.max(1, 1 + total / maxOrbs); for (int i = 0; i < maxOrbs; i++) { @@ -61,6 +62,10 @@ public class ExperienceNuggetItem extends Item { pLevel.addFreshEntity(xp); } + itemInHand.shrink(amountUsed); + if (!itemInHand.isEmpty()) + return InteractionResultHolder.success(itemInHand); + pPlayer.setItemInHand(pUsedHand, ItemStack.EMPTY); return InteractionResultHolder.consume(itemInHand); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java index fcaafeae9..37d2bf5b7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java @@ -71,6 +71,17 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS super.createBlockStateDefinition(p_206840_1_.add(SHAPE)); } + public boolean isOfSameType(FunnelBlock otherFunnel) { + return parent.get() == otherFunnel; + } + + @Override + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { + if (newState.getBlock() instanceof FunnelBlock fb && isOfSameType(fb)) + return; + super.onRemove(state, world, pos, newState, isMoving); + } + @Override public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, CollisionContext p_220053_4_) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java index 18a5fa81a..969f141dd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java @@ -12,7 +12,7 @@ public class BrassFunnelBlock extends FunnelBlock { public BrassFunnelBlock(Properties p_i48415_1_) { super(p_i48415_1_); } - + @Override public BlockState getEquivalentBeltFunnel(BlockGetter world, BlockPos pos, BlockState state) { Direction facing = getFacing(state); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java index 930da5e2d..9c7fe7430 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java @@ -64,6 +64,13 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { super.createBlockStateDefinition(builder.add(EXTRACTING)); } + @Override + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { + if (newState.getBlock() instanceof BeltFunnelBlock bfb && bfb.isOfSameType(this)) + return; + super.onRemove(state, world, pos, newState, isMoving); + } + @Override public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEntity pPlacer, ItemStack pStack) { super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack); diff --git a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java index d473b2777..2a81897f6 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java @@ -47,6 +47,8 @@ public class CKinetics extends ConfigBase { public final ConfigBool moveItemsToStorage = b(true, "moveItemsToStorage", Comments.moveItemsToStorage); public final ConfigBool harvestPartiallyGrown = b(false, "harvestPartiallyGrown", Comments.harvestPartiallyGrown); public final ConfigBool harvesterReplants = b(true, "harvesterReplants", Comments.harvesterReplants); + public final ConfigBool minecartContraptionInContainers = + b(false, "minecartContraptionInContainers", Comments.minecartContraptionInContainers); public final CStress stressValues = nested(1, CStress::new, Comments.stress); @@ -117,6 +119,7 @@ public class CKinetics extends ConfigBase { static String spawnerMovement = "Configure how Spawner blocks can be moved by contraptions."; static String amethystMovement = "Configure how Budding Amethyst can be moved by contraptions."; static String obsidianMovement = "Configure how Obsidian blocks can be moved by contraptions."; + static String minecartContraptionInContainers = "Whether minecart contraptions can be placed into container items."; } public enum DeployerAggroSetting {