From f9a62efc196dcd5c3a5edd488ea3696f1cefa4d7 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Wed, 4 Dec 2024 20:52:35 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixed=20decoration=20tabl?= =?UTF-8?q?e=20to=20drop=20its=20contents=20when=20broken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../block/DecorationTableBlock.java | 8 +++++++- .../block/DecorationTableBlockEntity.java | 12 ++++++++---- .../client/render/BarrelBakedModelBase.java | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index a2129d727..ad0439d5f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedstorage mod_name=Sophisticated Storage mod_license=GNU General Public License v3.0 -mod_version=0.11.2 +mod_version=0.11.3 mod_group_id=sophisticatedstorage mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional storage containers. diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlock.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlock.java index 89cbed41c..656e7060e 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlock.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlock.java @@ -21,11 +21,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.p3pp3rf1y.sophisticatedcore.util.BlockBase; import net.p3pp3rf1y.sophisticatedstorage.common.gui.DecorationTableMenu; +import net.p3pp3rf1y.sophisticatedstorage.init.ModBlocks; import javax.annotation.Nullable; public class DecorationTableBlock extends BlockBase implements EntityBlock { - //TODO block loot table and axe tag public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; protected static final VoxelShape SHAPE = Shapes.or( Block.box(0, 12, 0, 16, 16, 16), @@ -69,6 +69,12 @@ public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid); } + @Override + protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston) { + level.getBlockEntity(pos, ModBlocks.DECORATION_TABLE_BLOCK_ENTITY_TYPE.get()).ifPresent(DecorationTableBlockEntity::dropContents); + super.onRemove(state, level, pos, newState, movedByPiston); + } + @Nullable @Override public DecorationTableBlockEntity newBlockEntity(BlockPos pos, BlockState state) { diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlockEntity.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlockEntity.java index cd84da75b..2e9df50bb 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlockEntity.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlockEntity.java @@ -120,7 +120,7 @@ private void updateResult() { (InventoryHelper.isEmpty(decorativeBlocks) || !(storage.getItem() instanceof BarrelBlockItem) || isTintedStorage(storage) - ) && colorsTransparentOrSameAs(storage))) { //TODO once dyes and materials can be combined make sure to create combined result here + ) && colorsTransparentOrSameAs(storage))) { result = ItemStack.EMPTY; return; } @@ -140,7 +140,6 @@ private void updateResult() { return; } - //TODO remove the check for tinted barrel here once barrel model can support combination of tinted and material if (InventoryHelper.isEmpty(decorativeBlocks)) { result = ItemStack.EMPTY; return; @@ -158,7 +157,6 @@ private void updateResult() { return; } - //TODO if dyed and any of the parts doesn't have material make sure that dye shows result = storage.copy(); result.setCount(1); @@ -391,7 +389,7 @@ private void saveData(CompoundTag tag, HolderLookup.Provider registries) { } public void consumeIngredientsOnCraft() { - if (InventoryHelper.isEmpty(decorativeBlocks)) { //TODO once dyes and materials can be combined make sure to consume from both here and change the dye calculation to only count with parts visible + if (InventoryHelper.isEmpty(decorativeBlocks)) { consumeDyes(); } else { consumeMaterials(); @@ -568,4 +566,10 @@ public void setAccentColor(int accentColor) { public Map getPartsStored() { return remainingParts; } + + public void dropContents() { + InventoryHelper.dropItems(decorativeBlocks, level, worldPosition); + InventoryHelper.dropItems(dyes, level, worldPosition); + InventoryHelper.dropItems(storageBlock, level, worldPosition); + } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/client/render/BarrelBakedModelBase.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/client/render/BarrelBakedModelBase.java index d0d400689..547d5e768 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/client/render/BarrelBakedModelBase.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/client/render/BarrelBakedModelBase.java @@ -772,7 +772,7 @@ public BakedModel resolve(BakedModel model, ItemStack stack, @Nullable ClientLev boolean hasAccentColor = StorageBlockItem.getAccentColorFromStack(stack).isPresent(); Map materials = BarrelBlockItem.getMaterials(stack); String woodName = WoodStorageBlockItem.getWoodType(stack).map(WoodType::name) - .orElse(barrelBakedModel.barrelHasAccentColor && barrelBakedModel.barrelHasMainColor && materials.isEmpty() ? null : WoodType.ACACIA.name()); //TODO possibly remove materials check from here if a separate dynamic model is going to be used for materials + .orElse(barrelBakedModel.barrelHasAccentColor && barrelBakedModel.barrelHasMainColor && materials.isEmpty() ? null : WoodType.ACACIA.name()); boolean packed = WoodStorageBlockItem.isPacked(stack); boolean barrelShowsTier = StorageBlockItem.showsTier(stack); Item item = stack.getItem();