From 428507038dccf3f8e2a272411c578f5fdabcc759 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Thu, 19 May 2022 18:44:31 +0200 Subject: [PATCH 1/5] T00lb0x - fixed NPE when hitting toolbox hotkey on the same tick as it was placed - fixes #2914 --- .../create/content/curiosities/toolbox/ToolboxHandler.java | 2 ++ .../content/curiosities/toolbox/ToolboxHandlerClient.java | 6 ++---- .../content/curiosities/toolbox/ToolboxTileEntity.java | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java index d83fa6462..2c80bc741 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.curiosities.toolbox; import java.util.List; +import java.util.Objects; import java.util.WeakHashMap; import java.util.stream.Collectors; @@ -111,6 +112,7 @@ public class ToolboxHandler { .sorted((p1, p2) -> Double.compare(distance(location, p1), distance(location, p2))) .limit(maxAmount) .map(toolboxes.get(world)::get) + .filter(ToolboxTileEntity::isFullyInitialized) .collect(Collectors.toList()); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java index 3bcd6701f..2834b92b7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java @@ -6,6 +6,7 @@ import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTE import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTED_ON; import java.util.Collections; +import java.util.Comparator; import java.util.List; import com.google.common.collect.ImmutableList; @@ -111,10 +112,7 @@ public class ToolboxHandlerClient { Level level = player.level; List toolboxes = ToolboxHandler.getNearest(player.level, player, 8); - - if (!toolboxes.isEmpty()) - Collections.sort(toolboxes, (te1, te2) -> te1.getUniqueId() - .compareTo(te2.getUniqueId())); + toolboxes.sort(Comparator.comparing(ToolboxTileEntity::getUniqueId)); CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java index e80788d53..1d0fed5a3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java @@ -380,6 +380,11 @@ public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider, return uniqueId; } + public boolean isFullyInitialized() { + // returns true when uniqueId has been initialized + return uniqueId != null; + } + public void setCustomName(Component customName) { this.customName = customName; } From 657f42c67a2e217de5f25ffe2ebc30dc7ef3c710 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Thu, 19 May 2022 19:33:39 +0200 Subject: [PATCH 2/5] Off by .5 error - Contraptions no longer jump half a block when assembled on a cart assembler - fixes #2880 --- .../structureMovement/mounted/CartAssemblerTileEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java index 29f90ea2d..c22259db3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java @@ -162,7 +162,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay OrientedContraptionEntity entity = OrientedContraptionEntity.create(world, contraption, initialOrientation); if (couplingFound) entity.setCouplingId(cart.getUUID()); - entity.setPos(pos.getX(), pos.getY(), pos.getZ()); + entity.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5); world.addFreshEntity(entity); entity.startRiding(cart); From f8180ee91d92779f6ca600327e06d74f7a51997f Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Thu, 19 May 2022 21:18:21 +0200 Subject: [PATCH 3/5] Smarter funnel extraction - Funnels will no longer deadlock their extraction size if the first item of an inventory has a low max stack size but can't even be extracted because of filtering. - fixes #2919 --- .../java/com/simibubi/create/foundation/item/ItemHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 995a0eebc..b2a454fb8 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java @@ -229,7 +229,7 @@ public class ItemHelper { for (int slot = 0; slot < inv.getSlots(); slot++) { if (extracting.isEmpty()) { ItemStack stackInSlot = inv.getStackInSlot(slot); - if (stackInSlot.isEmpty()) + if (stackInSlot.isEmpty() || !test.test(stackInSlot)) continue; int maxExtractionCountForItem = amountFunction.apply(stackInSlot); if (maxExtractionCountForItem == 0) From f724504b44f74f989d083d8c16dbe4d15741fdbb Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Thu, 19 May 2022 22:45:35 +0200 Subject: [PATCH 4/5] Azaleas can dream - Azaleas (and all other Bonemealable blocks tagged with #minecraft:saplings) are now eligible for tree fertilizer - fix #2942 --- .../curiosities/TreeFertilizerItem.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java index efc548e31..d2b15211c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java @@ -4,14 +4,18 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationS import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BlockTags; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.BoneMealItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.AzaleaBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; public class TreeFertilizerItem extends Item { @@ -24,7 +28,7 @@ public class TreeFertilizerItem extends Item { BlockState state = context.getLevel() .getBlockState(context.getClickedPos()); Block block = state.getBlock(); - if (block instanceof SaplingBlock) { + if (block instanceof BonemealableBlock bonemealableBlock && state.is(BlockTags.SAPLINGS)) { if (context.getLevel().isClientSide) { BoneMealItem.addGrowthParticles(context.getLevel(), context.getClickedPos(), 100); @@ -38,11 +42,11 @@ public class TreeFertilizerItem extends Item { if (context.getLevel() .getBlockState(saplingPos.offset(pos)) .getBlock() == block) - world.setBlockAndUpdate(pos.above(10), state.setValue(SaplingBlock.STAGE, 1)); + world.setBlockAndUpdate(pos.above(10), withStage(state, 1)); } - ((SaplingBlock) block).performBonemeal(world, world.getRandom(), BlockPos.ZERO.above(10), - state.setValue(SaplingBlock.STAGE, 1)); + bonemealableBlock.performBonemeal(world, world.getRandom(), BlockPos.ZERO.above(10), + withStage(state, 1)); for (BlockPos pos : world.blocksAdded.keySet()) { BlockPos actualPos = pos.offset(saplingPos).below(10); @@ -76,6 +80,12 @@ public class TreeFertilizerItem extends Item { return super.useOn(context); } + private BlockState withStage(BlockState original, int stage) { + if (!original.hasProperty(BlockStateProperties.STAGE)) + return original; + return original.setValue(BlockStateProperties.STAGE, 1); + } + private static class TreesDreamWorld extends PlacementSimulationServerWorld { private final BlockPos saplingPos; private final BlockState soil; From 8ee62cc506094bf079e4c29892527732d871cb62 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Thu, 19 May 2022 23:22:40 +0200 Subject: [PATCH 5/5] Good Gold - Nether Gold crushing now gives 18 nuggets instead of 7.5. This is between overworld gold ore and deepslate gold ore and actually above what furnace smelting would give. - closes #3019 --- src/generated/resources/.cache/cache | 2 +- .../data/create/recipes/crushing/nether_gold_ore.json | 6 +----- .../create/foundation/data/recipe/CrushingRecipeGen.java | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index df0d768d3..684ccbaf6 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -4105,7 +4105,7 @@ a7c97582bae243ab04ff5ff9914b24af25d40d59 data/create/recipes/crushing/iron_horse 554b6555888fe01de349efaaab36b68a338ac397 data/create/recipes/crushing/iron_ore.json c9a9d6d28a7eac1210108d52840b60b26d58bcfe data/create/recipes/crushing/lapis_ore.json e870d049abc5cd5f389f70414c67e76ddc14060d data/create/recipes/crushing/leather_horse_armor.json -cc5a817901d6f0d68e4ceb3e65d7f2187ab37ceb data/create/recipes/crushing/nether_gold_ore.json +cab15acd2d62f1d70e0972b443f7987048d5183a data/create/recipes/crushing/nether_gold_ore.json 6cd97c6f12687790943db810f85036b02586c753 data/create/recipes/crushing/nether_quartz_ore.json 6e424d7e9f7d8b585384053a713db28f9d36448b data/create/recipes/crushing/nether_wart_block.json 8003e7db3ee11066b365c251f04f84028820de94 data/create/recipes/crushing/netherrack.json diff --git a/src/generated/resources/data/create/recipes/crushing/nether_gold_ore.json b/src/generated/resources/data/create/recipes/crushing/nether_gold_ore.json index da323cc75..314ad7599 100644 --- a/src/generated/resources/data/create/recipes/crushing/nether_gold_ore.json +++ b/src/generated/resources/data/create/recipes/crushing/nether_gold_ore.json @@ -8,11 +8,7 @@ "results": [ { "item": "minecraft:gold_nugget", - "count": 7 - }, - { - "item": "minecraft:gold_nugget", - "chance": 0.5 + "count": 18 }, { "item": "create:experience_nugget", diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java index bae6790ca..65f37968c 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java @@ -95,7 +95,7 @@ public class CrushingRecipeGen extends ProcessingRecipeGen { DEEP_REDSTONE_ORE = deepslateOre(() -> Items.DEEPSLATE_REDSTONE_ORE, () -> Items.REDSTONE, 7.5f, 350), DEEP_LAPIS_ORE = deepslateOre(() -> Items.DEEPSLATE_LAPIS_ORE, () -> Items.LAPIS_LAZULI, 12.5f, 350), - NETHER_GOLD_ORE = netherOre(() -> Items.NETHER_GOLD_ORE, () -> Items.GOLD_NUGGET, 7.5f, 350), + NETHER_GOLD_ORE = netherOre(() -> Items.NETHER_GOLD_ORE, () -> Items.GOLD_NUGGET, 18, 350), NETHER_QUARTZ_ORE = netherOre(() -> Items.NETHER_QUARTZ_ORE, () -> Items.QUARTZ, 2.25f, 350), RAW_COPPER_ORE = rawOre(() -> Items.RAW_COPPER, AllItems.CRUSHED_COPPER::get, 1),