Merge remote-tracking branch 'upstream/mc1.18/dev' into

mc1.18/global-railways

Conflicts:
	src/generated/resources/.cache/cache
	src/main/java/com/simibubi/create/AllTags.java
	src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java
	src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java
	src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java
	src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java
This commit is contained in:
PepperCode1 2022-07-06 12:31:49 -07:00
commit 9970c2bd4e
16 changed files with 143 additions and 168 deletions

View file

@ -5628,12 +5628,12 @@ ac265a674626e0e832330086fd18fe0be37fc327 data/create/recipes/weathered_copper_ti
5942a571f79c40524bbf408775cf91de4715f2b6 data/create/recipes/weathered_copper_tile_stairs_from_weathered_copper_tiles_stonecutting.json 5942a571f79c40524bbf408775cf91de4715f2b6 data/create/recipes/weathered_copper_tile_stairs_from_weathered_copper_tiles_stonecutting.json
2d549ea56fb226c0e31e66c0391996093f8bece9 data/create/tags/blocks/brittle.json 2d549ea56fb226c0e31e66c0391996093f8bece9 data/create/tags/blocks/brittle.json
d99d5c67bdffff60789a19bd51a5c5267c75e0a4 data/create/tags/blocks/casing.json d99d5c67bdffff60789a19bd51a5c5267c75e0a4 data/create/tags/blocks/casing.json
330bfb3850ba3964b10b1bccbc3cbb9b012cae54 data/create/tags/blocks/fan_heaters.json 418c6da531d6206e3cbe4049dce3db23c4270bed data/create/tags/blocks/fan_heaters.json
57b942386a15c874d1ca9cd6a8032c11a5599fc2 data/create/tags/blocks/fan_transparent.json 443f75adbf3d2f6fb0aad4b344372669470065b8 data/create/tags/blocks/fan_transparent.json
6e5d3b2123fbb00e7f439c091623619502551bca data/create/tags/blocks/non_movable.json 6e5d3b2123fbb00e7f439c091623619502551bca data/create/tags/blocks/non_movable.json
10781e8cfcbb3486327aace3aa00e437fb44b331 data/create/tags/blocks/ore_override_stone.json 10781e8cfcbb3486327aace3aa00e437fb44b331 data/create/tags/blocks/ore_override_stone.json
197ed7ee3b284045c005011d28c38ac5b2e44d8c data/create/tags/blocks/passive_boiler_heaters.json 197ed7ee3b284045c005011d28c38ac5b2e44d8c data/create/tags/blocks/passive_boiler_heaters.json
90eae7075c4588540560185eea40a1f37b2663d8 data/create/tags/blocks/safe_nbt.json 74f4ba5f6f61c30e27947c6fb4557e888d018285 data/create/tags/blocks/safe_nbt.json
6cdeeac1689f7b5bfd9bc40b462143d8eaf3ad0b data/create/tags/blocks/seats.json 6cdeeac1689f7b5bfd9bc40b462143d8eaf3ad0b data/create/tags/blocks/seats.json
d063e12c9ef75f39518c6d129ea35d833464d547 data/create/tags/blocks/toolboxes.json d063e12c9ef75f39518c6d129ea35d833464d547 data/create/tags/blocks/toolboxes.json
50936b211d94167a35ec78c89954082a336b6269 data/create/tags/blocks/valve_handles.json 50936b211d94167a35ec78c89954082a336b6269 data/create/tags/blocks/valve_handles.json

View file

@ -3,11 +3,9 @@
"values": [ "values": [
"create:blaze_burner", "create:blaze_burner",
"create:lit_blaze_burner", "create:lit_blaze_burner",
"#minecraft:fire",
"#minecraft:campfires",
"minecraft:magma_block", "minecraft:magma_block",
"minecraft:campfire", "minecraft:lava"
"minecraft:lava",
"minecraft:fire",
"minecraft:soul_fire",
"minecraft:soul_campfire"
] ]
} }

View file

@ -5,8 +5,7 @@
"create:lit_blaze_burner", "create:lit_blaze_burner",
"create:sail_frame", "create:sail_frame",
"#minecraft:fences", "#minecraft:fences",
"minecraft:iron_bars", "#minecraft:campfires",
"minecraft:campfire", "minecraft:iron_bars"
"minecraft:soul_campfire"
] ]
} }

View file

@ -25,6 +25,7 @@
"create:placard", "create:placard",
"create:pulse_repeater", "create:pulse_repeater",
"create:pulse_extender", "create:pulse_extender",
"#minecraft:signs" "#minecraft:signs",
"#minecraft:banners"
] ]
} }

View file

@ -397,12 +397,16 @@ public class AllTags {
AllBlockTags.BRITTLE.add(Blocks.FLOWER_POT, Blocks.BELL, Blocks.COCOA); AllBlockTags.BRITTLE.add(Blocks.FLOWER_POT, Blocks.BELL, Blocks.COCOA);
AllBlockTags.FAN_TRANSPARENT.includeAll(BlockTags.FENCES); AllBlockTags.FAN_TRANSPARENT.includeAll(BlockTags.FENCES);
AllBlockTags.FAN_TRANSPARENT.add(Blocks.IRON_BARS, Blocks.CAMPFIRE, Blocks.SOUL_CAMPFIRE); AllBlockTags.FAN_TRANSPARENT.includeAll(BlockTags.CAMPFIRES);
AllBlockTags.FAN_TRANSPARENT.add(Blocks.IRON_BARS);
AllBlockTags.FAN_HEATERS.add(Blocks.MAGMA_BLOCK, Blocks.CAMPFIRE, Blocks.LAVA, Blocks.FIRE, Blocks.SOUL_FIRE, AllBlockTags.FAN_HEATERS.includeAll(BlockTags.FIRE);
Blocks.SOUL_CAMPFIRE); AllBlockTags.FAN_HEATERS.includeAll(BlockTags.CAMPFIRES);
AllBlockTags.FAN_HEATERS.add(Blocks.MAGMA_BLOCK, Blocks.LAVA);
AllBlockTags.FAN_HEATERS.includeIn(AllBlockTags.PASSIVE_BOILER_HEATERS); AllBlockTags.FAN_HEATERS.includeIn(AllBlockTags.PASSIVE_BOILER_HEATERS);
AllBlockTags.SAFE_NBT.includeAll(BlockTags.SIGNS); AllBlockTags.SAFE_NBT.includeAll(BlockTags.SIGNS);
AllBlockTags.SAFE_NBT.includeAll(BlockTags.BANNERS);
AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.RAILS); AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.RAILS);
AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.BUTTONS); AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.BUTTONS);

View file

@ -138,21 +138,20 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
return; return;
List<ItemRequirement.StackRequirement> requiredItems = requirement.getRequiredItems(); List<ItemRequirement.StackRequirement> requiredItems = requirement.getRequiredItems();
ItemStack firstRequired = requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0).item; ItemStack contextStack = requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0).stack;
if (!context.contraption.hasUniversalCreativeCrate) { if (!context.contraption.hasUniversalCreativeCrate) {
IItemHandler iItemHandler = context.contraption.getSharedInventory(); IItemHandler iItemHandler = context.contraption.getSharedInventory();
for (ItemRequirement.StackRequirement required : requiredItems) { for (ItemRequirement.StackRequirement required : requiredItems) {
int amountFound = ItemHelper ItemStack stack= ItemHelper
.extract(iItemHandler, s -> ItemRequirement.validate(required.item, s), ExtractionCountMode.UPTO, .extract(iItemHandler, required::matches, ExtractionCountMode.EXACTLY,
required.item.getCount(), true) required.stack.getCount(), true);
.getCount(); if (stack.isEmpty())
if (amountFound < required.item.getCount())
return; return;
} }
for (ItemRequirement.StackRequirement required : requiredItems) for (ItemRequirement.StackRequirement required : requiredItems)
ItemHelper.extract(iItemHandler, s -> ItemRequirement.validate(required.item, s), contextStack = ItemHelper.extract(iItemHandler, required::matches,
ExtractionCountMode.UPTO, required.item.getCount(), false); ExtractionCountMode.EXACTLY, required.stack.getCount(), false);
} }
CompoundTag data = null; CompoundTag data = null;
@ -165,7 +164,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
} }
BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, pos); BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, pos);
BlockHelper.placeSchematicBlock(world, blockState, pos, firstRequired, data); BlockHelper.placeSchematicBlock(world, blockState, pos, contextStack, data);
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP))
blocksnapshot.restore(true, false); blocksnapshot.restore(true, false);
} }

View file

@ -107,7 +107,7 @@ public class SailBlock extends WrenchableDirectionalBlock {
return InteractionResult.PASS; return InteractionResult.PASS;
} }
protected void applyDye(BlockState state, Level world, BlockPos pos, Vec3 hit, @Nullable DyeColor color) { public void applyDye(BlockState state, Level world, BlockPos pos, Vec3 hit, @Nullable DyeColor color) {
BlockState newState = BlockState newState =
(color == null ? AllBlocks.SAIL_FRAME : AllBlocks.DYED_SAILS.get(color)).getDefaultState(); (color == null ? AllBlocks.SAIL_FRAME : AllBlocks.DYED_SAILS.get(color)).getDefaultState();
newState = BlockHelper.copyProperties(state, newState); newState = BlockHelper.copyProperties(state, newState);

View file

@ -255,10 +255,10 @@ public class CartAssemblerBlock extends BaseRailBlock
@Override @Override
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
ArrayList<ItemStack> reuiredItems = new ArrayList<>(); ArrayList<ItemStack> requiredItems = new ArrayList<>();
reuiredItems.add(new ItemStack(getRailItem(state))); requiredItems.add(new ItemStack(getRailItem(state)));
reuiredItems.add(new ItemStack(asItem())); requiredItems.add(new ItemStack(asItem()));
return new ItemRequirement(ItemUseType.CONSUME, reuiredItems); return new ItemRequirement(ItemUseType.CONSUME, requiredItems);
} }
@Override @Override

View file

@ -0,0 +1,11 @@
package com.simibubi.create.content.schematics;
import net.minecraft.world.level.block.state.BlockState;
public interface ISpecialBlockEntityItemRequirement {
default ItemRequirement getRequiredItems(BlockState state) {
return ItemRequirement.INVALID;
}
}

View file

@ -2,18 +2,18 @@ package com.simibubi.create.content.schematics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ArmorStand; import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.AbstractBannerBlock;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DirtPathBlock; import net.minecraft.world.level.block.DirtPathBlock;
@ -21,41 +21,28 @@ import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.block.SeaPickleBlock; import net.minecraft.world.level.block.SeaPickleBlock;
import net.minecraft.world.level.block.SnowLayerBlock; import net.minecraft.world.level.block.SnowLayerBlock;
import net.minecraft.world.level.block.TurtleEggBlock; import net.minecraft.world.level.block.TurtleEggBlock;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.SlabType; import net.minecraft.world.level.block.state.properties.SlabType;
public class ItemRequirement { public class ItemRequirement {
public static final ItemRequirement NONE = new ItemRequirement(Collections.emptyList());
public static final ItemRequirement INVALID = new ItemRequirement(Collections.emptyList());
public enum ItemUseType { protected List<StackRequirement> requiredItems;
CONSUME, DAMAGE
}
public static class StackRequirement {
public final ItemStack item;
public final ItemUseType usage;
public StackRequirement(ItemUseType usage, ItemStack item) {
this.item = item;
this.usage = usage;
}
}
List<StackRequirement> requiredItems;
public static final ItemRequirement INVALID = new ItemRequirement();
public static final ItemRequirement NONE = new ItemRequirement();
private ItemRequirement() {
}
public ItemRequirement(List<StackRequirement> requiredItems) { public ItemRequirement(List<StackRequirement> requiredItems) {
this.requiredItems = requiredItems; this.requiredItems = requiredItems;
} }
public ItemRequirement(ItemUseType usage, ItemStack items) { public ItemRequirement(StackRequirement stackRequirement) {
this(Arrays.asList(new StackRequirement(usage, items))); this(List.of(stackRequirement));
}
public ItemRequirement(ItemUseType usage, ItemStack stack) {
this(new StackRequirement(stack, usage));
} }
public ItemRequirement(ItemUseType usage, Item item) { public ItemRequirement(ItemUseType usage, Item item) {
@ -63,28 +50,26 @@ public class ItemRequirement {
} }
public ItemRequirement(ItemUseType usage, List<ItemStack> requiredItems) { public ItemRequirement(ItemUseType usage, List<ItemStack> requiredItems) {
this(requiredItems.stream().map(req -> new StackRequirement(usage, req)).collect(Collectors.toList())); this(requiredItems.stream().map(req -> new StackRequirement(req, usage)).collect(Collectors.toList()));
} }
public static ItemRequirement of(BlockState state, BlockEntity te) { public static ItemRequirement of(BlockState state, BlockEntity te) {
Block block = state.getBlock(); Block block = state.getBlock();
ItemRequirement baseRequirement; ItemRequirement requirement;
if (block instanceof ISpecialBlockItemRequirement) { if (block instanceof ISpecialBlockItemRequirement specialBlock) {
baseRequirement = ((ISpecialBlockItemRequirement) block).getRequiredItems(state, te); requirement = specialBlock.getRequiredItems(state, te);
} else { } else {
baseRequirement = ofBlockState(state); requirement = defaultOf(state, te);
} }
// Behaviours can add additional required items if (te instanceof ISpecialBlockEntityItemRequirement specialBE)
if (te instanceof SmartTileEntity) requirement = requirement.union(specialBE.getRequiredItems(state));
baseRequirement = baseRequirement.with(((SmartTileEntity) te).getRequiredItems());
return baseRequirement; return requirement;
} }
private static ItemRequirement ofBlockState(BlockState state) { private static ItemRequirement defaultOf(BlockState state, BlockEntity te) {
Block block = state.getBlock(); Block block = state.getBlock();
if (block == Blocks.AIR) if (block == Blocks.AIR)
return NONE; return NONE;
@ -95,22 +80,24 @@ public class ItemRequirement {
// double slab needs two items // double slab needs two items
if (state.hasProperty(BlockStateProperties.SLAB_TYPE) && state.getValue(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE) if (state.hasProperty(BlockStateProperties.SLAB_TYPE) && state.getValue(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE)
return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, 2))); return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, 2));
if (block instanceof TurtleEggBlock) if (block instanceof TurtleEggBlock)
return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(TurtleEggBlock.EGGS).intValue()))); return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, state.getValue(TurtleEggBlock.EGGS).intValue()));
if (block instanceof SeaPickleBlock) if (block instanceof SeaPickleBlock)
return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(SeaPickleBlock.PICKLES).intValue()))); return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, state.getValue(SeaPickleBlock.PICKLES).intValue()));
if (block instanceof SnowLayerBlock) if (block instanceof SnowLayerBlock)
return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(SnowLayerBlock.LAYERS).intValue()))); return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, state.getValue(SnowLayerBlock.LAYERS).intValue()));
if (block instanceof FarmBlock || block instanceof DirtPathBlock) if (block instanceof FarmBlock || block instanceof DirtPathBlock)
return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(Items.DIRT))); return new ItemRequirement(ItemUseType.CONSUME, Items.DIRT);
if (block instanceof AbstractBannerBlock && te instanceof BannerBlockEntity bannerBE)
return new ItemRequirement(new StrictNbtStackRequirement(bannerBE.getItem(), ItemUseType.CONSUME));
return new ItemRequirement(ItemUseType.CONSUME, item); return new ItemRequirement(ItemUseType.CONSUME, item);
} }
public static ItemRequirement of(Entity entity) { public static ItemRequirement of(Entity entity) {
if (entity instanceof ISpecialEntityItemRequirement) if (entity instanceof ISpecialEntityItemRequirement specialEntity)
return ((ISpecialEntityItemRequirement) entity).getRequiredItems(); return specialEntity.getRequiredItems();
if (entity instanceof ItemFrame itemFrame) { if (entity instanceof ItemFrame itemFrame) {
ItemStack frame = new ItemStack(Items.ITEM_FRAME); ItemStack frame = new ItemStack(Items.ITEM_FRAME);
@ -147,11 +134,7 @@ public class ItemRequirement {
return requiredItems; return requiredItems;
} }
public static boolean validate(ItemStack required, ItemStack present) { public ItemRequirement union(ItemRequirement other) {
return required.isEmpty() || required.getItem() == present.getItem();
}
public ItemRequirement with(ItemRequirement other) {
if (this.isInvalid() || other.isInvalid()) if (this.isInvalid() || other.isInvalid())
return INVALID; return INVALID;
if (this.isEmpty()) if (this.isEmpty())
@ -164,4 +147,32 @@ public class ItemRequirement {
); );
} }
public enum ItemUseType {
CONSUME, DAMAGE
}
public static class StackRequirement {
public final ItemStack stack;
public final ItemUseType usage;
public StackRequirement(ItemStack stack, ItemUseType usage) {
this.stack = stack;
this.usage = usage;
}
public boolean matches(ItemStack other) {
return stack.sameItem(other);
}
}
public static class StrictNbtStackRequirement extends StackRequirement {
public StrictNbtStackRequirement(ItemStack stack, ItemUseType usage) {
super(stack, usage);
}
@Override
public boolean matches(ItemStack other) {
return ItemStack.isSameItemSameTags(stack, other);
}
}
} }

View file

@ -45,9 +45,9 @@ public class MaterialChecklist {
for (ItemRequirement.StackRequirement stack : requirement.requiredItems) { for (ItemRequirement.StackRequirement stack : requirement.requiredItems) {
if (stack.usage == ItemUseType.DAMAGE) if (stack.usage == ItemUseType.DAMAGE)
putOrIncrement(damageRequired, stack.item); putOrIncrement(damageRequired, stack.stack);
if (stack.usage == ItemUseType.CONSUME) if (stack.usage == ItemUseType.CONSUME)
putOrIncrement(required, stack.item); putOrIncrement(required, stack.stack);
} }
} }

View file

@ -383,7 +383,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
List<ItemRequirement.StackRequirement> requiredItems = requirement.getRequiredItems(); List<ItemRequirement.StackRequirement> requiredItems = requirement.getRequiredItems();
if (!requirement.isEmpty()) { if (!requirement.isEmpty()) {
for (ItemRequirement.StackRequirement required : requiredItems) { for (ItemRequirement.StackRequirement required : requiredItems) {
if (!grabItemsFromAttachedInventories(required.item, required.usage, true)) { if (!grabItemsFromAttachedInventories(required, true)) {
if (skipMissing) { if (skipMissing) {
statusMsg = "skipping"; statusMsg = "skipping";
blockSkipped = true; blockSkipped = true;
@ -394,7 +394,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
return; return;
} }
missingItem = required.item; missingItem = required.stack;
state = State.PAUSED; state = State.PAUSED;
statusMsg = "missingBlock"; statusMsg = "missingBlock";
return; return;
@ -402,12 +402,12 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
} }
for (ItemRequirement.StackRequirement required : requiredItems) for (ItemRequirement.StackRequirement required : requiredItems)
grabItemsFromAttachedInventories(required.item, required.usage, false); grabItemsFromAttachedInventories(required, false);
} }
// Success // Success
state = State.RUNNING; state = State.RUNNING;
ItemStack icon = requirement.isEmpty() || requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0).item; ItemStack icon = requirement.isEmpty() || requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0).stack;
printer.handleCurrentTarget((target, blockState, tile) -> { printer.handleCurrentTarget((target, blockState, tile) -> {
// Launch block // Launch block
statusMsg = blockState.getBlock() != Blocks.AIR ? "placing" : "clearing"; statusMsg = blockState.getBlock() != Blocks.AIR ? "placing" : "clearing";
@ -476,19 +476,21 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
return item == Items.AIR ? ItemStack.EMPTY : new ItemStack(item); return item == Items.AIR ? ItemStack.EMPTY : new ItemStack(item);
} }
protected boolean grabItemsFromAttachedInventories(ItemStack required, ItemUseType usage, boolean simulate) { protected boolean grabItemsFromAttachedInventories(ItemRequirement.StackRequirement required, boolean simulate) {
if (hasCreativeCrate) if (hasCreativeCrate)
return true; return true;
attachedInventories.removeIf(cap -> !cap.isPresent()); attachedInventories.removeIf(cap -> !cap.isPresent());
ItemUseType usage = required.usage;
// Find and apply damage // Find and apply damage
if (usage == ItemUseType.DAMAGE) { if (usage == ItemUseType.DAMAGE) {
for (LazyOptional<IItemHandler> cap : attachedInventories) { for (LazyOptional<IItemHandler> cap : attachedInventories) {
IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE); IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE);
for (int slot = 0; slot < iItemHandler.getSlots(); slot++) { for (int slot = 0; slot < iItemHandler.getSlots(); slot++) {
ItemStack extractItem = iItemHandler.extractItem(slot, 1, true); ItemStack extractItem = iItemHandler.extractItem(slot, 1, true);
if (!ItemRequirement.validate(required, extractItem)) if (!required.matches(extractItem))
continue; continue;
if (!extractItem.isDamageableItem()) if (!extractItem.isDamageableItem())
continue; continue;
@ -508,36 +510,36 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
return true; return true;
} }
} }
return false;
} }
// Find and remove // Find and remove
boolean success = false; boolean success = false;
if (usage == ItemUseType.CONSUME) { int amountFound = 0;
int amountFound = 0; for (LazyOptional<IItemHandler> cap : attachedInventories) {
for (LazyOptional<IItemHandler> cap : attachedInventories) { IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE);
IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE); amountFound += ItemHelper
amountFound += ItemHelper .extract(iItemHandler, required::matches, ExtractionCountMode.UPTO,
.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO, required.stack.getCount(), true)
required.getCount(), true) .getCount();
.getCount();
if (amountFound < required.getCount()) if (amountFound < required.stack.getCount())
continue; continue;
success = true; success = true;
break; break;
}
} }
if (!simulate && success) { if (!simulate && success) {
int amountFound = 0; amountFound = 0;
for (LazyOptional<IItemHandler> cap : attachedInventories) { for (LazyOptional<IItemHandler> cap : attachedInventories) {
IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE); IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE);
amountFound += ItemHelper amountFound += ItemHelper
.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO, .extract(iItemHandler, required::matches, ExtractionCountMode.UPTO,
required.getCount(), false) required.stack.getCount(), false)
.getCount(); .getCount();
if (amountFound < required.getCount()) if (amountFound < required.stack.getCount())
continue; continue;
break; break;
} }

View file

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import com.simibubi.create.api.event.TileEntityBehaviourEvent; import com.simibubi.create.api.event.TileEntityBehaviourEvent;
import com.simibubi.create.content.schematics.ISpecialBlockEntityItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.foundation.advancement.AdvancementBehaviour; import com.simibubi.create.foundation.advancement.AdvancementBehaviour;
import com.simibubi.create.foundation.advancement.CreateAdvancement; import com.simibubi.create.foundation.advancement.CreateAdvancement;
@ -25,7 +26,7 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
public abstract class SmartTileEntity extends CachedRenderBBTileEntity implements IPartialSafeNBT, IInteractionChecker { public abstract class SmartTileEntity extends CachedRenderBBTileEntity implements IPartialSafeNBT, IInteractionChecker, ISpecialBlockEntityItemRequirement {
private final Map<BehaviourType<?>, TileEntityBehaviour> behaviours = new HashMap<>(); private final Map<BehaviourType<?>, TileEntityBehaviour> behaviours = new HashMap<>();
private boolean initialized = false; private boolean initialized = false;
@ -179,7 +180,7 @@ public abstract class SmartTileEntity extends CachedRenderBBTileEntity implement
public ItemRequirement getRequiredItems() { public ItemRequirement getRequiredItems() {
return behaviours.values() return behaviours.values()
.stream() .stream()
.reduce(ItemRequirement.NONE, (r, b) -> r.with(b.getRequiredItems()), (r, r1) -> r.with(r1)); .reduce(ItemRequirement.NONE, (r, b) -> r.union(b.getRequiredItems()), (r, r1) -> r.union(r1));
} }
protected void removeBehaviour(BehaviourType<?> type) { protected void removeBehaviour(BehaviourType<?> type) {

View file

@ -124,8 +124,8 @@ public class SidedFilteringBehaviour extends FilteringBehaviour {
public ItemRequirement getRequiredItems() { public ItemRequirement getRequiredItems() {
return sidedFilters.values().stream().reduce( return sidedFilters.values().stream().reduce(
ItemRequirement.NONE, ItemRequirement.NONE,
(a, b) -> a.with(b.getRequiredItems()), (a, b) -> a.union(b.getRequiredItems()),
(a, b) -> a.with(b) (a, b) -> a.union(b)
); );
} }

View file

@ -6,7 +6,6 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.tileEntity.IMergeableTE; import com.simibubi.create.foundation.tileEntity.IMergeableTE;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -234,7 +233,7 @@ public class BlockHelper {
state = ((IPlantable) state.getBlock()).getPlant(world, target); state = ((IPlantable) state.getBlock()).getPlant(world, target);
if (world.dimensionType() if (world.dimensionType()
.ultraWarm() && FluidHelper.isTag(state.getFluidState(), FluidTags.WATER)) { .ultraWarm() && state.getFluidState().is(FluidTags.WATER)) {
int i = target.getX(); int i = target.getX();
int j = target.getY(); int j = target.getY();
int k = target.getZ(); int k = target.getZ();

View file

@ -81,65 +81,13 @@
"to": [10.4, 9, 9], "to": [10.4, 9, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [9, 11, 8]}, "rotation": {"angle": 0, "axis": "y", "origin": [9, 11, 8]},
"faces": { "faces": {
"north": { "north": {"uv": [4, 10, 12, 12], "texture": "#5"},
"uv": [ "east": {"uv": [4, 10, 6, 14], "rotation": 90, "texture": "#5"},
4, "south": {"uv": [12, 10, 4, 12], "texture": "#5"},
10, "west": {"uv": [4, 10, 6, 14], "rotation": 90, "texture": "#5"},
12, "up": {"uv": [4, 10, 12, 14], "rotation": 180, "texture": "#5"},
12 "down": {"uv": [4, 10, 12, 13], "rotation": 180, "texture": "#5"}
], }
"texture": "#5"
},
"east": {
"uv": [
4,
10,
6,
14
],
"rotation": 90,
"texture": "#5"
},
"south": {
"uv": [
12,
10,
4,
12
],
"texture": "#5"
},
"west": {
"uv": [
4,
10,
6,
14
],
"rotation": 90,
"texture": "#5"
},
"up": {
"uv": [
4,
10,
12,
14
],
"rotation": 180,
"texture": "#5"
},
"down": {
"uv": [
4,
10,
12,
13
],
"rotation": 180,
"texture": "#5"
}
}
}, },
{ {
"name": "gear case", "name": "gear case",
@ -162,6 +110,7 @@
"translation": [0, 3.25, 0] "translation": [0, 3.25, 0]
}, },
"thirdperson_lefthand": { "thirdperson_lefthand": {
"rotation": [0, -90, 0],
"translation": [0, 3.75, 0] "translation": [0, 3.75, 0]
}, },
"firstperson_righthand": { "firstperson_righthand": {
@ -191,7 +140,8 @@
{ {
"name": "item", "name": "item",
"origin": [8, 8, 8], "origin": [8, 8, 8],
"color": 0,
"children": [0, 1, 2, 3, 4, 5, 6] "children": [0, 1, 2, 3, 4, 5, 6]
} }
] ]
} }