diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index e036c16b1..526866b25 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -5628,7 +5628,8 @@ ac265a674626e0e832330086fd18fe0be37fc327 data/create/recipes/weathered_copper_ti 5942a571f79c40524bbf408775cf91de4715f2b6 data/create/recipes/weathered_copper_tile_stairs_from_weathered_copper_tiles_stonecutting.json 2a2700b43614f86d3294726595cb28ed7dca4387 data/create/tags/blocks/brittle.json d99d5c67bdffff60789a19bd51a5c5267c75e0a4 data/create/tags/blocks/casing.json -ecdd4e6acda027a01b41d6d2d431f9675cd29b93 data/create/tags/blocks/fan_transparent.json +2b4c93e5a752ebf54217594766f30d8d60cb4343 data/create/tags/blocks/fan_transparent.json +ee6d2b53d81f2bed492662b6c06f46c4f2b9ef9b data/create/tags/blocks/movable_empty_collider.json 6e5d3b2123fbb00e7f439c091623619502551bca data/create/tags/blocks/non_movable.json 10781e8cfcbb3486327aace3aa00e437fb44b331 data/create/tags/blocks/ore_override_stone.json 760adb521c2e475a6414f97291f46c02d294fa74 data/create/tags/blocks/passive_boiler_heaters.json diff --git a/src/generated/resources/data/create/tags/blocks/fan_transparent.json b/src/generated/resources/data/create/tags/blocks/fan_transparent.json index 0b37cfd36..6d6d04226 100644 --- a/src/generated/resources/data/create/tags/blocks/fan_transparent.json +++ b/src/generated/resources/data/create/tags/blocks/fan_transparent.json @@ -6,6 +6,7 @@ "create:sail_frame", "minecraft:iron_bars", "#minecraft:campfires", - "#minecraft:fences" + "#minecraft:fences", + "#minecraft:leaves" ] } \ No newline at end of file diff --git a/src/generated/resources/data/create/tags/blocks/movable_empty_collider.json b/src/generated/resources/data/create/tags/blocks/movable_empty_collider.json new file mode 100644 index 000000000..e31c42d8d --- /dev/null +++ b/src/generated/resources/data/create/tags/blocks/movable_empty_collider.json @@ -0,0 +1,8 @@ +{ + "replace": false, + "values": [ + "minecraft:cobweb", + "minecraft:powder_snow", + "#minecraft:fence_gates" + ] +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 228d44367..4fd21480e 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -101,6 +101,7 @@ public class AllTags { CASING, FAN_TRANSPARENT, NON_MOVABLE, + MOVABLE_EMPTY_COLLIDER, ORE_OVERRIDE_STONE, PASSIVE_BOILER_HEATERS, SAFE_NBT, diff --git a/src/main/java/com/simibubi/create/compat/Mods.java b/src/main/java/com/simibubi/create/compat/Mods.java index 52201bb24..60a28cdc8 100644 --- a/src/main/java/com/simibubi/create/compat/Mods.java +++ b/src/main/java/com/simibubi/create/compat/Mods.java @@ -13,7 +13,8 @@ import net.minecraftforge.fml.ModList; public enum Mods { DYNAMICTREES, TCONSTRUCT, - CURIOS; + CURIOS, + STORAGEDRAWERS; /** * @return a boolean of whether the mod is loaded or not based on mod id diff --git a/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java b/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java new file mode 100644 index 000000000..45fa06186 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java @@ -0,0 +1,41 @@ +package com.simibubi.create.compat.storageDrawers; + +import com.simibubi.create.compat.Mods; +import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.items.IItemHandler; + +public class StorageDrawers { + + public static boolean isDrawer(BlockEntity tile) { + return tile != null && Mods.STORAGEDRAWERS.asId() + .equals(tile.getType() + .getRegistryName() + .getNamespace()); + } + + public static float getTrueFillLevel(IItemHandler inv, FilteringBehaviour filtering) { + float occupied = 0; + float totalSpace = 0; + + for (int slot = 1; slot < inv.getSlots(); slot++) { + ItemStack stackInSlot = inv.getStackInSlot(slot); + int space = inv.getSlotLimit(slot); + int count = stackInSlot.getCount(); + if (space == 0) + continue; + + totalSpace += 1; + if (filtering.test(stackInSlot)) + occupied += count * (1f / space); + } + + if (totalSpace == 0) + return 0; + + return occupied / totalSpace; + } + +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java index 6c8ac0fe6..ce06099e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java @@ -46,7 +46,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.DiodeBlock; import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; -import net.minecraft.world.level.block.FenceGateBlock; import net.minecraft.world.level.block.FlowerPotBlock; import net.minecraft.world.level.block.GrindstoneBlock; import net.minecraft.world.level.block.HorizontalDirectionalBlock; @@ -175,15 +174,13 @@ public class BlockMovementChecks { private static boolean isMovementNecessaryFallback(BlockState state, Level world, BlockPos pos) { if (isBrittle(state)) return true; - if (state.getBlock() instanceof FenceGateBlock) - return true; - if (state.getMaterial() + if (!state.getMaterial() .isReplaceable()) - return false; - if (state.getCollisionShape(world, pos) + return true; + if (!state.getCollisionShape(world, pos) .isEmpty()) - return false; - return true; + return true; + return AllBlockTags.MOVABLE_EMPTY_COLLIDER.matches(state); } private static boolean isMovementAllowedFallback(BlockState state, Level world, BlockPos pos) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java index 6a467744d..1e66ec0c9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.logistics.block.redstone; import java.util.List; +import com.simibubi.create.compat.storageDrawers.StorageDrawers; import com.simibubi.create.content.logistics.block.display.DisplayLinkBlock; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -16,6 +17,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; @@ -95,10 +97,14 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { BlockPos target = worldPosition.relative(getBlockState().getOptionalValue(StockpileSwitchBlock.FACING) .orElse(Direction.NORTH)); + BlockEntity targetTile = level.getBlockEntity(target); - if (level.getBlockEntity(target) instanceof StockpileSwitchObservable observable) { + if (targetTile instanceof StockpileSwitchObservable observable) { currentLevel = observable.getPercent() / 100f; - + + } else if (StorageDrawers.isDrawer(targetTile) && observedInventory.hasInventory()) { + currentLevel = StorageDrawers.getTrueFillLevel(observedInventory.getInventory(), filtering); + } else if (observedInventory.hasInventory() || observedTank.hasInventory()) { if (observedInventory.hasInventory()) { // Item inventory diff --git a/src/main/java/com/simibubi/create/foundation/data/TagGen.java b/src/main/java/com/simibubi/create/foundation/data/TagGen.java index 3305c1462..bbe045c4b 100644 --- a/src/main/java/com/simibubi/create/foundation/data/TagGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/TagGen.java @@ -73,11 +73,16 @@ public class TagGen { .add(Blocks.BELL, Blocks.COCOA, Blocks.FLOWER_POT) .addTag(BlockTags.BEDS) .addTag(BlockTags.DOORS); + + prov.tag(AllBlockTags.MOVABLE_EMPTY_COLLIDER.tag) + .add(Blocks.COBWEB, Blocks.POWDER_SNOW) + .addTag(BlockTags.FENCE_GATES); prov.tag(AllBlockTags.FAN_TRANSPARENT.tag) .add(Blocks.IRON_BARS) .addTag(BlockTags.CAMPFIRES) - .addTag(BlockTags.FENCES); + .addTag(BlockTags.FENCES) + .addTag(BlockTags.LEAVES); prov.tag(AllBlockTags.ORE_OVERRIDE_STONE.tag) .addTag(BlockTags.STONE_ORE_REPLACEABLES);