Skip to content

Commit

Permalink
Merge pull request #551 from P3pp3rF1y/1.20.x-dev
Browse files Browse the repository at this point in the history
fix: 🐛 Fixed decoration table to drop its contents when broken
  • Loading branch information
P3pp3rF1y authored Dec 4, 2024
2 parents 89dfa09 + dc5e35f commit 3ab4d09
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedstorage
mod_group_id=sophisticatedstorage
mod_version=0.11.0
mod_version=0.11.1
sonar_project_key=sophisticatedstorage:SophisticatedStorage
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedStorage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand All @@ -24,8 +23,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.network.NetworkHooks;
import net.p3pp3rf1y.sophisticatedcore.util.BlockBase;
import net.p3pp3rf1y.sophisticatedcore.util.WorldHelper;
import net.p3pp3rf1y.sophisticatedstorage.common.gui.DecorationTableMenu;
import net.p3pp3rf1y.sophisticatedstorage.init.ModBlocks;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -74,6 +73,12 @@ public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos,
return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);
}

@Override
public 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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;
}
Expand All @@ -139,7 +139,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;
Expand All @@ -157,7 +156,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);

Expand Down Expand Up @@ -390,7 +388,7 @@ private void saveData(CompoundTag tag) {
}

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();
Expand Down Expand Up @@ -566,4 +564,10 @@ public void setAccentColor(int accentColor) {
public Map<ResourceLocation, Integer> getPartsStored() {
return remainingParts;
}

public void dropContents() {
InventoryHelper.dropItems(decorativeBlocks, level, worldPosition);
InventoryHelper.dropItems(dyes, level, worldPosition);
InventoryHelper.dropItems(storageBlock, level, worldPosition);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ public BakedModel resolve(BakedModel model, ItemStack stack, @Nullable ClientLev
boolean hasAccentColor = StorageBlockItem.getAccentColorFromStack(stack).isPresent();
Map<BarrelMaterial, ResourceLocation> 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();
Expand Down

0 comments on commit 3ab4d09

Please sign in to comment.