Extraordinary item handlers

- Cobwebs and Powdered Snow can now be attached to contraptions
- Fixed Storage Drawers not providing correct fill levels to Stockpile Switches
- Leaves are now considered transparent by encased fans
- Blocks can now be tagged `#create:movable_empty_collider` to support contraption movement even if their collision shape is empty
This commit is contained in:
simibubi 2022-12-12 15:54:28 +01:00
parent 12065c6b09
commit cd79de0691
9 changed files with 75 additions and 14 deletions

View file

@ -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

View file

@ -6,6 +6,7 @@
"create:sail_frame",
"minecraft:iron_bars",
"#minecraft:campfires",
"#minecraft:fences"
"#minecraft:fences",
"#minecraft:leaves"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"minecraft:cobweb",
"minecraft:powder_snow",
"#minecraft:fence_gates"
]
}

View file

@ -101,6 +101,7 @@ public class AllTags {
CASING,
FAN_TRANSPARENT,
NON_MOVABLE,
MOVABLE_EMPTY_COLLIDER,
ORE_OVERRIDE_STONE,
PASSIVE_BOILER_HEATERS,
SAFE_NBT,

View file

@ -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

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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

View file

@ -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);