From 4b59528b31612b6c32429c62933ba98a5e039a48 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 11 Sep 2024 00:23:14 +0100 Subject: [PATCH 1/9] Fix race in Contraption simplifiedEntityColliders update This issue is most obvious in elevators with multiple doors. When the collider gets invalidated multiple times in quick succession, multiple futures are created. If a future which was started before all door state updates were finalized completed after all other futures, the final simplifiedEntityColliders would be outdated and invalid (containing ghost doors, or in the case of an elevator in motion, missing door collisions). This commit addresses this issue in two ways: First by cancelling any existing future to ensure that any future which completes was started after the most recent invalidation. Second by removing the null assignment of simplifiedEntityColliderProvider from the future. This prevents the future from becoming null after a null check and before a cancellation (the only time where the null value matters). Cancelling a future twice is not an issue so there's no need to track if the future is null other than to avoid a null dereference. --- .../com/simibubi/create/content/contraptions/Contraption.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java index f38e1c78e..d004d9ae2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java @@ -1386,6 +1386,9 @@ public abstract class Contraption { private void gatherBBsOffThread() { getContraptionWorld(); + if (simplifiedEntityColliderProvider != null) { + simplifiedEntityColliderProvider.cancel(false); + } simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> { VoxelShape combinedShape = Shapes.empty(); for (Entry entry : blocks.entrySet()) { @@ -1402,7 +1405,6 @@ public abstract class Contraption { }) .thenAccept(r -> { simplifiedEntityColliders = Optional.of(r); - simplifiedEntityColliderProvider = null; }); } From ac61d249cce3b93a06b4e67f6ce2e3c1729ba933 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 16 Sep 2024 17:29:10 -0400 Subject: [PATCH 2/9] fix blocks having unsafe nbt values --- .../foundation/utility/NBTProcessors.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java index f685969c9..eab609906 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java @@ -58,7 +58,7 @@ public final class NBTProcessors { addProcessor(AllBlockEntityTypes.CREATIVE_CRATE.get(), itemProcessor("Filter")); addProcessor(AllBlockEntityTypes.PLACARD.get(), itemProcessor("Item")); } - + // Triggered by block tag, not BE type private static final UnaryOperator signProcessor = data -> { for (int i = 0; i < 4; ++i) @@ -86,14 +86,22 @@ public final class NBTProcessors { } public static ItemStack withUnsafeNBTDiscarded(ItemStack stack) { - if (stack.getTag() == null) + CompoundTag tag = stack.getTag(); + if (tag == null) return stack; ItemStack copy = stack.copy(); - stack.getTag() - .getAllKeys() + copy.setTag(withUnsafeNBTDiscarded(tag)); + return copy; + } + + public static CompoundTag withUnsafeNBTDiscarded(CompoundTag tag) { + if (tag == null) + return null; + CompoundTag copy = tag.copy(); + tag.getAllKeys() .stream() .filter(NBTProcessors::isUnsafeItemNBTKey) - .forEach(copy::removeTagKey); + .forEach(copy::remove); return copy; } @@ -136,7 +144,7 @@ public final class NBTProcessors { return signProcessor.apply(compound); if (blockEntity.onlyOpCanSetNbt()) return null; - return compound; + return withUnsafeNBTDiscarded(compound); } } From c59c749ed54d9769232d4b7b94e32fd9c90dd58d Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 4 Sep 2024 18:20:13 -0400 Subject: [PATCH 3/9] fix: items in ponders being culled incorrectly - Items shouldn't be culled in ponder worlds, the cullingFrustum is wrong and ponders are unpredictable --- .../create/content/kinetics/belt/BeltRenderer.java | 2 +- .../blockEntity/renderer/SafeBlockEntityRenderer.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java index cd5af645f..469a839f2 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java @@ -233,7 +233,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer { be.getBlockPos().getZ()) .add(offsetVec); - if (this.shouldCullItem(itemPos)) { + if (this.shouldCullItem(itemPos, be.getLevel())) { continue; } diff --git a/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/SafeBlockEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/SafeBlockEntityRenderer.java index f26940d4c..d9b8d4c69 100644 --- a/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/SafeBlockEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/SafeBlockEntityRenderer.java @@ -2,10 +2,13 @@ package com.simibubi.create.foundation.blockEntity.renderer; import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.foundation.ponder.PonderWorld; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.AABB; @@ -28,7 +31,10 @@ public abstract class SafeBlockEntityRenderer implements .getBlock() == Blocks.AIR; } - public boolean shouldCullItem(Vec3 itemPos) { + public boolean shouldCullItem(Vec3 itemPos, Level level) { + if (level instanceof PonderWorld) + return false; + Frustum frustum = Minecraft.getInstance().levelRenderer.capturedFrustum != null ? Minecraft.getInstance().levelRenderer.capturedFrustum : Minecraft.getInstance().levelRenderer.cullingFrustum; From 84911a3de5b38153d96330224f7066a6dcc9d06d Mon Sep 17 00:00:00 2001 From: IThundxr Date: Fri, 6 Sep 2024 16:10:15 -0400 Subject: [PATCH 4/9] Fix #6906 --- .../com/simibubi/create/foundation/mixin/BlockItemMixin.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java index a9c6d514b..f4031bcb2 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java @@ -9,7 +9,6 @@ import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; @@ -22,7 +21,7 @@ public class BlockItemMixin { @Inject(method = "place", at = @At("HEAD"), cancellable = true) private void create$fixDeployerPlacement(BlockPlaceContext pContext, CallbackInfoReturnable cir) { BlockState state = pContext.getLevel().getBlockState(((UseOnContextAccessor) pContext).create$getHitResult().getBlockPos()); - if (state != Blocks.AIR.defaultBlockState() && pContext.getPlayer() instanceof DeployerFakePlayer) { + if (!state.canBeReplaced() && pContext.getPlayer() instanceof DeployerFakePlayer) { cir.setReturnValue(InteractionResult.PASS); } } From 5905e8bc931434c7d178c83442f153eed315a2a7 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:48:36 +0200 Subject: [PATCH 5/9] Bringing the Cheat - Clipboards now validate their data item #6928 - Backport #6911 --- gradle.properties | 2 +- src/main/java/com/simibubi/create/Create.java | 2 +- .../content/equipment/clipboard/ClipboardBlockEntity.java | 2 ++ .../com/simibubi/create/foundation/mixin/BlockItemMixin.java | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4c75a885b..6bb0ec39d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G org.gradle.daemon = false # mod version info -mod_version = 0.5.1.h +mod_version = 0.5.1.i artifact_minecraft_version = 1.18.2 minecraft_version = 1.18.2 diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index b4657f70f..145b1c4db 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -61,7 +61,7 @@ public class Create { public static final String ID = "create"; public static final String NAME = "Create"; - public static final String VERSION = "0.5.1h"; + public static final String VERSION = "0.5.1i"; public static final Logger LOGGER = LogUtils.getLogger(); diff --git a/src/main/java/com/simibubi/create/content/equipment/clipboard/ClipboardBlockEntity.java b/src/main/java/com/simibubi/create/content/equipment/clipboard/ClipboardBlockEntity.java index 7d1afe661..2537f6a88 100644 --- a/src/main/java/com/simibubi/create/content/equipment/clipboard/ClipboardBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/equipment/clipboard/ClipboardBlockEntity.java @@ -68,6 +68,8 @@ public class ClipboardBlockEntity extends SmartBlockEntity { protected void read(CompoundTag tag, boolean clientPacket) { super.read(tag, clientPacket); dataContainer = ItemStack.of(tag.getCompound("Item")); + if (!AllBlocks.CLIPBOARD.isIn(dataContainer)) + dataContainer = AllBlocks.CLIPBOARD.asStack(); if (clientPacket) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> readClientSide(tag)); diff --git a/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java index f4031bcb2..afeaad404 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/BlockItemMixin.java @@ -21,7 +21,7 @@ public class BlockItemMixin { @Inject(method = "place", at = @At("HEAD"), cancellable = true) private void create$fixDeployerPlacement(BlockPlaceContext pContext, CallbackInfoReturnable cir) { BlockState state = pContext.getLevel().getBlockState(((UseOnContextAccessor) pContext).create$getHitResult().getBlockPos()); - if (!state.canBeReplaced() && pContext.getPlayer() instanceof DeployerFakePlayer) { + if (!state.getMaterial().isReplaceable() && pContext.getPlayer() instanceof DeployerFakePlayer) { cir.setReturnValue(InteractionResult.PASS); } } From 8f5c91c1950e215a5987e2f6de6c427e13368583 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:22:12 +0200 Subject: [PATCH 6/9] I 2 didn't C the 'i' in that id - Fixed incorrect IC2 compatibility recipes #6917 #6916 --- src/generated/resources/.cache/cache | 10 +++++----- ...compat_ic2.json => ingot_aluminium_compat_ic2.json} | 4 ++-- ...compat_ic2.json => ingot_aluminium_compat_ic2.json} | 4 ++-- ...compat_ic2.json => ingot_aluminium_compat_ic2.json} | 2 +- ...compat_ic2.json => ingot_aluminium_compat_ic2.json} | 2 +- .../recipes/splashing/ic2/crushed_raw_aluminum.json | 2 +- .../create/foundation/data/recipe/CompatMetals.java | 6 ++++++ .../foundation/data/recipe/StandardRecipeGen.java | 2 +- .../foundation/data/recipe/WashingRecipeGen.java | 2 +- 9 files changed, 20 insertions(+), 14 deletions(-) rename src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/{ingot_aluminum_compat_ic2.json => ingot_aluminium_compat_ic2.json} (82%) rename src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/{ingot_aluminum_compat_ic2.json => ingot_aluminium_compat_ic2.json} (82%) rename src/generated/resources/data/create/recipes/blasting/{ingot_aluminum_compat_ic2.json => ingot_aluminium_compat_ic2.json} (86%) rename src/generated/resources/data/create/recipes/smelting/{ingot_aluminum_compat_ic2.json => ingot_aluminium_compat_ic2.json} (86%) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 5910315fa..56c7550b6 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -2359,7 +2359,7 @@ aec7192be51a921f7c2f9e52ca64e65cf92abf1f data/create/advancements/pipe_organ.jso abf054890da41c46221fddc2474e18d077b3c1a2 data/create/advancements/precision_mechanism.json 9eb2508128ae938f0e654f3b316aa324dd6a18e8 data/create/advancements/pulley_maxed.json 99361c643eb6fd9e0a97420f6b5d3df8bf7dbc3f data/create/advancements/recipes/building_blocks/andesite_from_stone_types_andesite_stonecutting.json -0989187987645c6b13ed453e0499a59962b8c767 data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_ic2.json +28d60ca8f6505017965426f65d842facafe44fec data/create/advancements/recipes/building_blocks/blasting/ingot_aluminium_compat_ic2.json 29a2f29f50306abaac8aa361102d3a30677fcd85 data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_immersiveengineering.json c6095aa02996b040d7a1ead9d32d720cd311ae7e data/create/advancements/recipes/building_blocks/blasting/ingot_lead_compat_immersiveengineering.json 60e56e5c1d38762c04634f9c8e43c5e42a002046 data/create/advancements/recipes/building_blocks/blasting/ingot_lead_compat_mekanism.json @@ -2389,7 +2389,7 @@ d252ea6ae1f88ab2286357d3a05a643eec7d92c3 data/create/advancements/recipes/buildi 78972bdf05d79e5357ff5771caa13d631e2c2740 data/create/advancements/recipes/building_blocks/smelting/glass_from_horizontal_framed_glass.json c8edb1be5163aaeebdd94f4c25ef45bf839200c0 data/create/advancements/recipes/building_blocks/smelting/glass_from_tiled_glass.json c70af1a552a80137cf25780b481387a585e551f3 data/create/advancements/recipes/building_blocks/smelting/glass_from_vertical_framed_glass.json -96fdd3a575b158b657ddd0709a05ffa7ab4b0457 data/create/advancements/recipes/building_blocks/smelting/ingot_aluminum_compat_ic2.json +9a36450a9b8f0752202eb4dfb48d0c10051270c5 data/create/advancements/recipes/building_blocks/smelting/ingot_aluminium_compat_ic2.json 4b86c2a3784cc837ab8b49c678517b53db188916 data/create/advancements/recipes/building_blocks/smelting/ingot_aluminum_compat_immersiveengineering.json cd59dee91b03d293a8e6501acc734261858cdb56 data/create/advancements/recipes/building_blocks/smelting/ingot_lead_compat_immersiveengineering.json 80e276bd06ac555aa9203247a24f97c779cb80db data/create/advancements/recipes/building_blocks/smelting/ingot_lead_compat_mekanism.json @@ -3864,7 +3864,7 @@ a133d4d2542c0b9309873d06a72e7efff4cee219 data/create/recipes/asurine_pillar_from 288d80210f7efb4664e2e9c9d9111049863e5f60 data/create/recipes/birch_window_pane.json 70b34d9573875b9bc15f8d71baac81ecd7c0ab60 data/create/recipes/blasting/copper_ingot_from_crushed.json 9f9f50e6f65d3077ee7c39403fffb31fea3bb408 data/create/recipes/blasting/gold_ingot_from_crushed.json -1002fb0e5f3ab0068c381ebc6488b868671d9f66 data/create/recipes/blasting/ingot_aluminum_compat_ic2.json +7f7f9f631e3c96af0446ad5d87ac47fb7f70d08d data/create/recipes/blasting/ingot_aluminium_compat_ic2.json 172904335190876e7b52bad7031b7d8f3fba426e data/create/recipes/blasting/ingot_aluminum_compat_immersiveengineering.json 9ba4fc584e7a275cf5b3785fead3dd21fd0d2172 data/create/recipes/blasting/ingot_lead_compat_immersiveengineering.json 020618b989b39ab6e6d5ce5fcf786afc23fb0dc0 data/create/recipes/blasting/ingot_lead_compat_mekanism.json @@ -5752,7 +5752,7 @@ daaa640dbfaa86685de636b89afe2fdd74cd0cf9 data/create/recipes/smelting/glass_pane 48bdeff8ca1ae7bf732fc870fb0fa294de56188a data/create/recipes/smelting/glass_pane_from_tiled_glass_pane.json 7035be7cce5a38c794d9cc872801329af81bac46 data/create/recipes/smelting/glass_pane_from_vertical_framed_glass_pane.json a4fb256e4cc6cd9e450b054e8489f26655f6a1d2 data/create/recipes/smelting/gold_ingot_from_crushed.json -1d173fd2909e08c70d52051789e838757df6a1fa data/create/recipes/smelting/ingot_aluminum_compat_ic2.json +373278db29392d1a9823e71f09b28ed55789cd2b data/create/recipes/smelting/ingot_aluminium_compat_ic2.json 57996aea2f6456c936e248e4fd84fa5387fd3c4f data/create/recipes/smelting/ingot_aluminum_compat_immersiveengineering.json cadbfc99cab88f87a431cc8853e280d3871c4542 data/create/recipes/smelting/ingot_lead_compat_immersiveengineering.json 1b029da974db92f0bfa456c6aae9ffb709441ea7 data/create/recipes/smelting/ingot_lead_compat_mekanism.json @@ -5803,7 +5803,7 @@ fa9294fb2fbe22110ae122a616379b73ccf1d5c3 data/create/recipes/splashing/galospher c4d680eed98791fe45fa93aeeae9e8dbd508d6f5 data/create/recipes/splashing/gravel.json 7af4d9ae50af13da0d4fc814687f9586ff872798 data/create/recipes/splashing/gray_concrete_powder.json 23fb61c0e4bcca58fa7241db9cbef07bf4bd9a9b data/create/recipes/splashing/green_concrete_powder.json -82707bd9a72c35926ebf116fea1c4d9aea9a127a data/create/recipes/splashing/ic2/crushed_raw_aluminum.json +2c934a49e7766b12dd708e557a8b0ebc5600753b data/create/recipes/splashing/ic2/crushed_raw_aluminum.json f18f823c0274518a13da3be2850b916a6ece2900 data/create/recipes/splashing/ic2/crushed_raw_silver.json 71b4e6a4d62ec437f02bd2029455eb7ba5bb3943 data/create/recipes/splashing/ic2/crushed_raw_tin.json 8da1397c440f27a5af4cbfc169bcf74f83bf3c8a data/create/recipes/splashing/ic2/crushed_raw_uranium.json diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_ic2.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_aluminium_compat_ic2.json similarity index 82% rename from src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_ic2.json rename to src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_aluminium_compat_ic2.json index 8d7973e25..6d99a0525 100644 --- a/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_ic2.json +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_aluminium_compat_ic2.json @@ -2,7 +2,7 @@ "parent": "minecraft:recipes/root", "rewards": { "recipes": [ - "create:blasting/ingot_aluminum_compat_ic2" + "create:blasting/ingot_aluminium_compat_ic2" ] }, "criteria": { @@ -21,7 +21,7 @@ "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { - "recipe": "create:blasting/ingot_aluminum_compat_ic2" + "recipe": "create:blasting/ingot_aluminium_compat_ic2" } } }, diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_aluminum_compat_ic2.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_aluminium_compat_ic2.json similarity index 82% rename from src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_aluminum_compat_ic2.json rename to src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_aluminium_compat_ic2.json index abf18f140..7abca1eaf 100644 --- a/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_aluminum_compat_ic2.json +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_aluminium_compat_ic2.json @@ -2,7 +2,7 @@ "parent": "minecraft:recipes/root", "rewards": { "recipes": [ - "create:smelting/ingot_aluminum_compat_ic2" + "create:smelting/ingot_aluminium_compat_ic2" ] }, "criteria": { @@ -21,7 +21,7 @@ "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { - "recipe": "create:smelting/ingot_aluminum_compat_ic2" + "recipe": "create:smelting/ingot_aluminium_compat_ic2" } } }, diff --git a/src/generated/resources/data/create/recipes/blasting/ingot_aluminum_compat_ic2.json b/src/generated/resources/data/create/recipes/blasting/ingot_aluminium_compat_ic2.json similarity index 86% rename from src/generated/resources/data/create/recipes/blasting/ingot_aluminum_compat_ic2.json rename to src/generated/resources/data/create/recipes/blasting/ingot_aluminium_compat_ic2.json index 326a58369..08f0c18dd 100644 --- a/src/generated/resources/data/create/recipes/blasting/ingot_aluminum_compat_ic2.json +++ b/src/generated/resources/data/create/recipes/blasting/ingot_aluminium_compat_ic2.json @@ -3,7 +3,7 @@ "ingredient": { "item": "create:crushed_raw_aluminum" }, - "result": "ic2:ingot_aluminum", + "result": "ic2:ingot_aluminium", "experience": 0.1, "cookingtime": 100, "conditions": [ diff --git a/src/generated/resources/data/create/recipes/smelting/ingot_aluminum_compat_ic2.json b/src/generated/resources/data/create/recipes/smelting/ingot_aluminium_compat_ic2.json similarity index 86% rename from src/generated/resources/data/create/recipes/smelting/ingot_aluminum_compat_ic2.json rename to src/generated/resources/data/create/recipes/smelting/ingot_aluminium_compat_ic2.json index 6fb0e09de..92152e36c 100644 --- a/src/generated/resources/data/create/recipes/smelting/ingot_aluminum_compat_ic2.json +++ b/src/generated/resources/data/create/recipes/smelting/ingot_aluminium_compat_ic2.json @@ -3,7 +3,7 @@ "ingredient": { "item": "create:crushed_raw_aluminum" }, - "result": "ic2:ingot_aluminum", + "result": "ic2:ingot_aluminium", "experience": 0.1, "cookingtime": 200, "conditions": [ diff --git a/src/generated/resources/data/create/recipes/splashing/ic2/crushed_raw_aluminum.json b/src/generated/resources/data/create/recipes/splashing/ic2/crushed_raw_aluminum.json index 26e5bbfd3..8871bb3ca 100644 --- a/src/generated/resources/data/create/recipes/splashing/ic2/crushed_raw_aluminum.json +++ b/src/generated/resources/data/create/recipes/splashing/ic2/crushed_raw_aluminum.json @@ -7,7 +7,7 @@ ], "results": [ { - "item": "ic2:nugget_aluminum", + "item": "ic2:nugget_aluminium", "count": 9 } ], diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CompatMetals.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CompatMetals.java index 5a87e23a5..bb1b7ea54 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CompatMetals.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CompatMetals.java @@ -32,6 +32,12 @@ public enum CompatMetals { public String getName() { return name; } + + public String getName(Mods mod) { + if (this == ALUMINUM && mod == IC2) // include in mods.builder if this happens again + return "aluminium"; + return name; + } /** * These mods must provide an ingot and nugget variant of the corresponding metal. diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java index 1dae805e9..08cf018d2 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java @@ -1223,8 +1223,8 @@ public class StandardRecipeGen extends CreateRecipeProvider { } GeneratedRecipe blastModdedCrushedMetal(ItemEntry ingredient, CompatMetals metal) { - String metalName = metal.getName(); for (Mods mod : metal.getMods()) { + String metalName = metal.getName(mod); ResourceLocation ingot = mod.ingotOf(metalName); String modId = mod.getId(); create(ingot).withSuffix("_compat_" + modId) diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java index 6811c3607..4940ba3e6 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java @@ -133,8 +133,8 @@ public class WashingRecipeGen extends ProcessingRecipeGen { } public GeneratedRecipe moddedCrushedOre(ItemEntry crushed, CompatMetals metal) { - String metalName = metal.getName(); for (Mods mod : metal.getMods()) { + String metalName = metal.getName(mod); ResourceLocation nugget = mod.nuggetOf(metalName); create(mod.getId() + "/" + crushed.getId() .getPath(), From a99f05d8b0da4188f4fc3da9bde6fad3ff015aac Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:56:13 +0200 Subject: [PATCH 7/9] Toolbugs - Attempt to improve handling of toolbox storage on contraptions #6940 --- .../content/contraptions/MountedStorage.java | 6 ++++++ .../equipment/toolbox/ToolboxInventory.java | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/MountedStorage.java b/src/main/java/com/simibubi/create/content/contraptions/MountedStorage.java index ad9b0c859..3b86dafc6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/MountedStorage.java +++ b/src/main/java/com/simibubi/create/content/contraptions/MountedStorage.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions; import com.simibubi.create.AllBlockEntityTypes; import com.simibubi.create.AllTags.AllBlockTags; +import com.simibubi.create.content.equipment.toolbox.ToolboxInventory; import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterBlockEntity; import com.simibubi.create.content.logistics.crate.BottomlessItemHandler; import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity; @@ -177,6 +178,8 @@ public class MountedStorage { CompoundTag tag = handler.serializeNBT(); if (noFuel) NBTHelper.putMarker(tag, "NoFuel"); + if (handler instanceof ToolboxInventory) + NBTHelper.putMarker(tag, "Toolbox"); if (!(handler instanceof BottomlessItemHandler)) return tag; @@ -191,6 +194,9 @@ public class MountedStorage { storage.handler = new ItemStackHandler(); if (nbt == null) return storage; + if (nbt.contains("Toolbox")) + storage.handler = new ToolboxInventory(null); + storage.valid = true; storage.noFuel = nbt.contains("NoFuel"); diff --git a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxInventory.java b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxInventory.java index a9d69e9ca..bb16f4feb 100644 --- a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxInventory.java +++ b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxInventory.java @@ -83,7 +83,7 @@ public class ToolboxInventory extends ItemStackHandler { } } settling = false; - blockEntity.sendData(); + notifyUpdate(); } @Override @@ -109,7 +109,7 @@ public class ToolboxInventory extends ItemStackHandler { if (!stack.isEmpty() && filters.get(compartment) .isEmpty()) { filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1)); - blockEntity.sendData(); + notifyUpdate(); } } @@ -121,7 +121,7 @@ public class ToolboxInventory extends ItemStackHandler { if (!stack.isEmpty() && filters.get(compartment) .isEmpty()) { filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1)); - blockEntity.sendData(); + notifyUpdate(); } } return insertItem; @@ -136,10 +136,9 @@ public class ToolboxInventory extends ItemStackHandler { @Override protected void onContentsChanged(int slot) { - if (!settling && !blockEntity.getLevel().isClientSide) + if (!settling && (blockEntity == null || !blockEntity.getLevel().isClientSide)) settle(slot / STACKS_PER_COMPARTMENT); - blockEntity.sendData(); - blockEntity.setChanged(); + notifyUpdate(); super.onContentsChanged(slot); } @@ -208,4 +207,9 @@ public class ToolboxInventory extends ItemStackHandler { return ItemHandlerHelper.canItemStacksStack(stack1, stack2); } + private void notifyUpdate() { + if (blockEntity != null) + blockEntity.notifyUpdate(); + } + } From 8e50ad4cfd286dcef741da4c47c5b5161972243a Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:43:50 +0200 Subject: [PATCH 8/9] Stack of Spades - Protect item handlers against invalid item stack sizes - Fix some held or dropped items not updating count when inserted into item handlers --- .../content/fluids/drain/ItemDrainItemHandler.java | 4 +++- .../create/content/kinetics/belt/BeltBlock.java | 2 ++ .../belt/transport/ItemHandlerBeltSegment.java | 5 ++++- .../kinetics/deployer/DeployerItemHandler.java | 4 +++- .../content/logistics/chute/ChuteItemHandler.java | 5 ++++- .../create/content/logistics/funnel/FunnelBlock.java | 2 +- .../logistics/tunnel/BrassTunnelItemHandler.java | 6 +++++- .../simibubi/create/foundation/item/ItemHelper.java | 12 ++++++++++++ 8 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainItemHandler.java b/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainItemHandler.java index d69e16c55..44da916ea 100644 --- a/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainItemHandler.java +++ b/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainItemHandler.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.fluids.drain; import com.simibubi.create.content.fluids.transfer.GenericItemEmptying; import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack; +import com.simibubi.create.foundation.item.ItemHelper; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; @@ -38,7 +39,8 @@ public class ItemDrainItemHandler implements IItemHandler { if (stack.getCount() > 1 && GenericItemEmptying.canItemBeEmptied(blockEntity.getLevel(), stack)) { returned = ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1); stack = ItemHandlerHelper.copyStackWithSize(stack, 1); - } + } else + returned = ItemHelper.limitCountToMaxStackSize(stack, simulate); if (!simulate) { TransportedItemStack heldItem = new TransportedItemStack(stack); diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java index 64c37cc2c..944e4a399 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java @@ -218,6 +218,8 @@ public class BeltBlock extends HorizontalKineticBlock .copy(), false); if (remainder.isEmpty()) itemEntity.discard(); + else if (remainder.getCount() != itemEntity.getItem().getCount()) + itemEntity.setItem(remainder); }); return; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/ItemHandlerBeltSegment.java b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/ItemHandlerBeltSegment.java index 0a5248c5f..15f20c86d 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/ItemHandlerBeltSegment.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/ItemHandlerBeltSegment.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.kinetics.belt.transport; +import com.simibubi.create.foundation.item.ItemHelper; + import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -29,6 +31,7 @@ public class ItemHandlerBeltSegment implements IItemHandler { @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { if (this.beltInventory.canInsertAt(offset)) { + ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate); if (!simulate) { TransportedItemStack newStack = new TransportedItemStack(stack); newStack.insertedAt = offset; @@ -38,7 +41,7 @@ public class ItemHandlerBeltSegment implements IItemHandler { this.beltInventory.belt.setChanged(); this.beltInventory.belt.sendData(); } - return ItemStack.EMPTY; + return remainder; } return stack; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerItemHandler.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerItemHandler.java index ecabcf2ed..ac106c825 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerItemHandler.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerItemHandler.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.kinetics.deployer; import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; +import com.simibubi.create.foundation.item.ItemHelper; import net.minecraft.world.InteractionHand; import net.minecraft.world.item.ItemStack; @@ -52,9 +53,10 @@ public class DeployerItemHandler implements IItemHandlerModifiable { ItemStack held = getHeld(); if (held.isEmpty()) { + ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate); if (!simulate) set(stack); - return ItemStack.EMPTY; + return remainder; } if (!ItemHandlerHelper.canItemStacksStack(held, stack)) diff --git a/src/main/java/com/simibubi/create/content/logistics/chute/ChuteItemHandler.java b/src/main/java/com/simibubi/create/content/logistics/chute/ChuteItemHandler.java index 72a77ff01..7179a1d26 100644 --- a/src/main/java/com/simibubi/create/content/logistics/chute/ChuteItemHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/chute/ChuteItemHandler.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.chute; +import com.simibubi.create.foundation.item.ItemHelper; + import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -25,9 +27,10 @@ public class ChuteItemHandler implements IItemHandler { public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { if (!blockEntity.canAcceptItem(stack)) return stack; + ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate); if (!simulate) blockEntity.setItem(stack); - return ItemStack.EMPTY; + return remainder; } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlock.java index d617c9e42..460819ad9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlock.java @@ -93,7 +93,7 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { withBlockEntityDo(worldIn, pos, be -> { ItemStack toInsert = heldItem.copy(); ItemStack remainder = tryInsert(worldIn, pos, toInsert, false); - if (!ItemStack.matches(remainder, toInsert)) + if (!ItemStack.matches(remainder, toInsert) || remainder.getCount() != heldItem.getCount()) player.setItemInHand(handIn, remainder); }); return InteractionResult.SUCCESS; diff --git a/src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelItemHandler.java b/src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelItemHandler.java index 430755c50..0db27450a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelItemHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelItemHandler.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.tunnel; +import com.simibubi.create.foundation.item.ItemHelper; + import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; @@ -33,9 +35,11 @@ public class BrassTunnelItemHandler implements IItemHandler { if (!blockEntity.canTakeItems()) return stack; + + ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate); if (!simulate) blockEntity.setStackToDistribute(stack, null); - return ItemStack.EMPTY; + return remainder; } @Override diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java index 1f4e09d18..9ea14a53c 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java @@ -276,4 +276,16 @@ public class ItemHelper { } return -1; } + + public static ItemStack limitCountToMaxStackSize(ItemStack stack, boolean simulate) { + int count = stack.getCount(); + int max = stack.getMaxStackSize(); + if (count <= max) + return ItemStack.EMPTY; + ItemStack remainder = ItemHandlerHelper.copyStackWithSize(stack, count - max); + if (!simulate) + stack.setCount(max); + return remainder; + } + } From 034babf125667217716cb483f07a093bb6e6cd91 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:11:56 +0200 Subject: [PATCH 9/9] I have so much to show you - Prevent basins from endlessly queueing up particle information when no players are near #6837 --- .../create/content/processing/basin/BasinBlockEntity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java b/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java index 54db269a5..01592ee97 100644 --- a/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java @@ -412,7 +412,8 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf if (filter != null && !filter.test(itemStack)) continue; - visualizedOutputItems.add(IntAttached.withZero(itemStack)); + if (visualizedOutputItems.size() < 3) + visualizedOutputItems.add(IntAttached.withZero(itemStack)); update = true; remainder = ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false); @@ -446,7 +447,8 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf update = true; iterator.remove(); - visualizedOutputFluids.add(IntAttached.withZero(fluidStack)); + if (visualizedOutputFluids.size() < 3) + visualizedOutputFluids.add(IntAttached.withZero(fluidStack)); } }