mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 06:24:29 +01:00
Multifiltration
- Clipboards now copy invertedness of brass diodes - Clipboards can now copy filters, consuming filter items from the players' inventory - Fixed Filters and Attribute Filters not stacking with unmodified, equivalent stacks - Fixed Attribute Filters saving the name tag preview item in their data - Filters and Schedules can now be reset via crafting - Fixed 'upto'-filter amounts not working correctly on inserting belt funnels
This commit is contained in:
parent
c7b0c11abc
commit
ffa85dc889
@ -578,7 +578,7 @@ bf2b0310500213ff853c748c236eb5d01f61658e assets/create/blockstates/yellow_toolbo
|
||||
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
|
||||
e4af08f4e51db9c4a722ebff44a04e8bd9a9dba6 assets/create/lang/en_ud.json
|
||||
b14838ef90096d8877aa4ca10e5b261063a41805 assets/create/lang/en_us.json
|
||||
d2175e6c3f6eb92f6d92c9314014c175239a744e assets/create/lang/en_us.json
|
||||
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
|
||||
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
|
||||
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||
@ -2378,6 +2378,7 @@ d8331026603dacf176ef6475f0d2b4f93e1a71a8 data/create/advancements/recipes/buildi
|
||||
ba80332510acab3f60f30d8b802ee2d450fd51b9 data/create/advancements/recipes/create.base/blasting/zinc_ingot_from_crushed.json
|
||||
4bb60ef5e186f12a9d52e61319db8c78300c64ab data/create/advancements/recipes/create.base/blasting/zinc_ingot_from_ore.json
|
||||
00ff89f208cb9023d7a2657c43d267e21755fb2e data/create/advancements/recipes/create.base/blasting/zinc_ingot_from_raw_ore.json
|
||||
6050a12e82e081cc869b9a2a878b9da27854b022 data/create/advancements/recipes/create.base/crafting/appliances/attribute_filter_clear.json
|
||||
3194b8da04cfb26f070b0a14f210f0117f252993 data/create/advancements/recipes/create.base/crafting/appliances/clipboard.json
|
||||
a1746099602e91fd23fba112016d41c71f9de62e data/create/advancements/recipes/create.base/crafting/appliances/clipboard_clear.json
|
||||
376bda381f3dedb52b03eb1504b103d8ddd1b672 data/create/advancements/recipes/create.base/crafting/appliances/copper_backtank.json
|
||||
@ -2385,10 +2386,12 @@ a1746099602e91fd23fba112016d41c71f9de62e data/create/advancements/recipes/create
|
||||
680c982dd1d3c45bed4d390fc0da5042750c157a data/create/advancements/recipes/create.base/crafting/appliances/copper_diving_helmet.json
|
||||
265a953eaac909fd2817c6dc3d1a08b376579a25 data/create/advancements/recipes/create.base/crafting/appliances/crafting_blueprint.json
|
||||
fa2e18298f7710465d9b0798a69288e846c646fd data/create/advancements/recipes/create.base/crafting/appliances/dough.json
|
||||
048a24b84c19c47802c5aed069001925eedd087d data/create/advancements/recipes/create.base/crafting/appliances/filter_clear.json
|
||||
a9b163744b1c494d07ec256d0367884f9601176d data/create/advancements/recipes/create.base/crafting/appliances/linked_controller.json
|
||||
ab1e704db4a41a8d2cba357942f95c411a80a0c8 data/create/advancements/recipes/create.base/crafting/appliances/netherite_backtank.json
|
||||
f714a7fa70ed9e9b0c145d466357cd1ef4de184b data/create/advancements/recipes/create.base/crafting/appliances/netherite_diving_boots.json
|
||||
99efa64a74ad29cf3b6cc565eabdd9b7e7e0cc40 data/create/advancements/recipes/create.base/crafting/appliances/netherite_diving_helmet.json
|
||||
4f591309b0d47e2940f60e0e43f65fdf250b0dfa data/create/advancements/recipes/create.base/crafting/appliances/schedule_clear.json
|
||||
c4769d7ac9c537eb4409b02883e89d0930514a8b data/create/advancements/recipes/create.base/crafting/appliances/tree_fertilizer.json
|
||||
bb138bedd2aec741fa54b6b52be384fdbd741249 data/create/advancements/recipes/create.base/crafting/curiosities/brown_toolbox.json
|
||||
773faf96b003868e35ceeb0bf738281d066e343b data/create/advancements/recipes/create.base/crafting/curiosities/minecart_coupling.json
|
||||
@ -3855,6 +3858,7 @@ ac91109efa5a253f54257904190b80a400ec6d0c data/create/recipes/compacting/diorite_
|
||||
82316030429530a798020a6a31a3f1718b1123b2 data/create/recipes/copper_tiles_from_ingots_copper_stonecutting.json
|
||||
64e802b3c6fc1c7e9926531cfa625d58505852f6 data/create/recipes/copycat_panel_from_ingots_zinc_stonecutting.json
|
||||
4c4d62d9e95c6e37ab38c49cf472034d750530c7 data/create/recipes/copycat_step_from_ingots_zinc_stonecutting.json
|
||||
fab6c25ea9eeb489121c96002f361ac032ec42c9 data/create/recipes/crafting/appliances/attribute_filter_clear.json
|
||||
005f8ad32598ea98314031e66b06e95e1f8ddd13 data/create/recipes/crafting/appliances/clipboard.json
|
||||
db648fd89bc2030f3e1e9baa0d2b5b69238dec4c data/create/recipes/crafting/appliances/clipboard_clear.json
|
||||
eb18d5972484418fa5a768633e68688ad20d2bd7 data/create/recipes/crafting/appliances/copper_backtank.json
|
||||
@ -3862,10 +3866,12 @@ eb18d5972484418fa5a768633e68688ad20d2bd7 data/create/recipes/crafting/appliances
|
||||
ec38ddb44e4bf8eaaba6f9d27e8469234fc98528 data/create/recipes/crafting/appliances/copper_diving_helmet.json
|
||||
c077375d16b4505e52548613fbc9356993556e6b data/create/recipes/crafting/appliances/crafting_blueprint.json
|
||||
edf96556bb2357f54fd398fe573641afa15239b2 data/create/recipes/crafting/appliances/dough.json
|
||||
96feda6a0556a73851a41c6b7b7be1e8d9d5a028 data/create/recipes/crafting/appliances/filter_clear.json
|
||||
75cdbd88973a8ca943ebe890153b01a344b96b01 data/create/recipes/crafting/appliances/linked_controller.json
|
||||
9ef7bae26db471741096abd2b02f738202913994 data/create/recipes/crafting/appliances/netherite_backtank.json
|
||||
e84952517f02a7c1ba10f12e2e0e32b94f720e58 data/create/recipes/crafting/appliances/netherite_diving_boots.json
|
||||
664421c08143e4eb60332f53da17f70b4be83e74 data/create/recipes/crafting/appliances/netherite_diving_helmet.json
|
||||
9c40eb131b4e8161654e00f47b654abf5ed75804 data/create/recipes/crafting/appliances/schedule_clear.json
|
||||
7b5f863dda3d05a79cb85943a178eba0bd8a7dc7 data/create/recipes/crafting/appliances/slime_ball.json
|
||||
b159ba84428eee6ef6e23df1766f2a18f2c8a63e data/create/recipes/crafting/appliances/tree_fertilizer.json
|
||||
395f5fc62e27448121e3447a24a752be1a91def2 data/create/recipes/crafting/copper/waxed_copper_shingle_slab_from_honeycomb.json
|
||||
|
@ -1099,6 +1099,7 @@
|
||||
"create.logistics.filter.any_amount_short": "Any",
|
||||
"create.logistics.filter.up_to": "Up to",
|
||||
"create.logistics.filter.exactly": "Exactly",
|
||||
"create.logistics.filter.requires_item_in_inventory": "Requires %1$s item in Inventory",
|
||||
"create.logistics.creative_crate.supply": "Infinite Supply",
|
||||
"create.logistics.train_observer.cargo_filter": "Cargo Filter",
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"create:crafting/appliances/attribute_filter_clear"
|
||||
]
|
||||
},
|
||||
"criteria": {
|
||||
"has_item": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"create:attribute_filter"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"trigger": "minecraft:recipe_unlocked",
|
||||
"conditions": {
|
||||
"recipe": "create:crafting/appliances/attribute_filter_clear"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_item",
|
||||
"has_the_recipe"
|
||||
]
|
||||
]
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"create:crafting/appliances/filter_clear"
|
||||
]
|
||||
},
|
||||
"criteria": {
|
||||
"has_item": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"create:filter"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"trigger": "minecraft:recipe_unlocked",
|
||||
"conditions": {
|
||||
"recipe": "create:crafting/appliances/filter_clear"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_item",
|
||||
"has_the_recipe"
|
||||
]
|
||||
]
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"create:crafting/appliances/schedule_clear"
|
||||
]
|
||||
},
|
||||
"criteria": {
|
||||
"has_item": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"create:schedule"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"trigger": "minecraft:recipe_unlocked",
|
||||
"conditions": {
|
||||
"recipe": "create:crafting/appliances/schedule_clear"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_item",
|
||||
"has_the_recipe"
|
||||
]
|
||||
]
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "create:attribute_filter"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "create:attribute_filter"
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "create:filter"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "create:filter"
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "create:schedule"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "create:schedule"
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ public class BeltFunnelInteractionHandler {
|
||||
else
|
||||
continue;
|
||||
|
||||
if (amountToExtract != -1) {
|
||||
if (amountToExtract != -1 && modeToExtract != ExtractionCountMode.UPTO) {
|
||||
toInsert.setCount(Math.min(amountToExtract, toInsert.getCount()));
|
||||
ItemStack remainder = inserting.simulate()
|
||||
.insert(toInsert);
|
||||
|
@ -97,12 +97,16 @@ public class ClipboardValueSettingsHandler {
|
||||
boolean canCopy = smartBE.getAllBehaviours()
|
||||
.stream()
|
||||
.anyMatch(b -> b instanceof ClipboardCloneable cc
|
||||
&& cc.writeToClipboard(new CompoundTag(), target.getDirection()));
|
||||
&& cc.writeToClipboard(new CompoundTag(), target.getDirection()))
|
||||
|| smartBE instanceof ClipboardCloneable ccbe
|
||||
&& ccbe.writeToClipboard(new CompoundTag(), target.getDirection());
|
||||
|
||||
boolean canPaste = tagElement != null && smartBE.getAllBehaviours()
|
||||
boolean canPaste = tagElement != null && (smartBE.getAllBehaviours()
|
||||
.stream()
|
||||
.anyMatch(b -> b instanceof ClipboardCloneable cc && cc.readFromClipboard(
|
||||
tagElement.getCompound(cc.getClipboardKey()), mc.player, target.getDirection(), true));
|
||||
tagElement.getCompound(cc.getClipboardKey()), mc.player, target.getDirection(), true))
|
||||
|| smartBE instanceof ClipboardCloneable ccbe && ccbe.readFromClipboard(
|
||||
tagElement.getCompound(ccbe.getClipboardKey()), mc.player, target.getDirection(), true));
|
||||
|
||||
if (!canCopy && !canPaste)
|
||||
return;
|
||||
@ -164,6 +168,21 @@ public class ClipboardValueSettingsHandler {
|
||||
tag.put(clipboardKey, compoundTag);
|
||||
}
|
||||
|
||||
if (smartBE instanceof ClipboardCloneable ccbe) {
|
||||
anyValid = true;
|
||||
String clipboardKey = ccbe.getClipboardKey();
|
||||
if (paste) {
|
||||
anySuccess |= ccbe.readFromClipboard(tag.getCompound(clipboardKey), player, event.getFace(),
|
||||
world.isClientSide());
|
||||
} else {
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
boolean success = ccbe.writeToClipboard(compoundTag, event.getFace());
|
||||
anySuccess |= success;
|
||||
if (success)
|
||||
tag.put(clipboardKey, compoundTag);
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyValid)
|
||||
return;
|
||||
|
||||
|
@ -4,19 +4,22 @@ import static com.simibubi.create.content.logistics.block.diodes.BrassDiodeBlock
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.content.curiosities.clipboard.ClipboardCloneable;
|
||||
import com.simibubi.create.foundation.blockEntity.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.scrollvalue.ScrollValueBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.DiodeBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public abstract class BrassDiodeBlockEntity extends SmartBlockEntity {
|
||||
public abstract class BrassDiodeBlockEntity extends SmartBlockEntity implements ClipboardCloneable {
|
||||
|
||||
protected int state;
|
||||
ScrollValueBehaviour maxState;
|
||||
@ -81,4 +84,28 @@ public abstract class BrassDiodeBlockEntity extends SmartBlockEntity {
|
||||
return (value / 20 / 60) + "m";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClipboardKey() {
|
||||
return "Block";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromClipboard(CompoundTag tag, Player player, Direction side, boolean simulate) {
|
||||
if (!tag.contains("Inverted"))
|
||||
return false;
|
||||
if (simulate)
|
||||
return true;
|
||||
BlockState blockState = getBlockState();
|
||||
if (blockState.getValue(BrassDiodeBlock.INVERTED) != tag.getBoolean("Inverted"))
|
||||
level.setBlockAndUpdate(worldPosition, blockState.cycle(BrassDiodeBlock.INVERTED));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writeToClipboard(CompoundTag tag, Direction side) {
|
||||
tag.putBoolean("Inverted", getBlockState().getOptionalValue(BrassDiodeBlock.INVERTED)
|
||||
.orElse(false));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -141,7 +141,6 @@ public class AttributeFilterMenu extends AbstractFilterMenu {
|
||||
|
||||
@Override
|
||||
protected void saveData(ItemStack filterItem) {
|
||||
super.saveData(filterItem);
|
||||
filterItem.getOrCreateTag()
|
||||
.putInt("WhitelistMode", whitelistMode.ordinal());
|
||||
ListTag attributes = new ListTag();
|
||||
@ -156,6 +155,9 @@ public class AttributeFilterMenu extends AbstractFilterMenu {
|
||||
});
|
||||
filterItem.getOrCreateTag()
|
||||
.put("MatchedAttributes", attributes);
|
||||
|
||||
if (attributes.isEmpty() && whitelistMode == WhitelistMode.WHITELIST_DISJ)
|
||||
filterItem.setTag(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,24 +81,30 @@ public class FilterItem extends Item implements MenuProvider {
|
||||
|
||||
private List<Component> makeSummary(ItemStack filter) {
|
||||
List<Component> list = new ArrayList<>();
|
||||
if (!filter.hasTag())
|
||||
return list;
|
||||
|
||||
if (type == FilterType.REGULAR) {
|
||||
ItemStackHandler filterItems = getFilterItems(filter);
|
||||
boolean blacklist = filter.getOrCreateTag()
|
||||
.getBoolean("Blacklist");
|
||||
|
||||
list.add((blacklist ? Lang.translateDirect("gui.filter.deny_list") : Lang.translateDirect("gui.filter.allow_list")).withStyle(ChatFormatting.GOLD));
|
||||
list.add((blacklist ? Lang.translateDirect("gui.filter.deny_list")
|
||||
: Lang.translateDirect("gui.filter.allow_list")).withStyle(ChatFormatting.GOLD));
|
||||
int count = 0;
|
||||
for (int i = 0; i < filterItems.getSlots(); i++) {
|
||||
if (count > 3) {
|
||||
list.add(Components.literal("- ...").withStyle(ChatFormatting.DARK_GRAY));
|
||||
list.add(Components.literal("- ...")
|
||||
.withStyle(ChatFormatting.DARK_GRAY));
|
||||
break;
|
||||
}
|
||||
|
||||
ItemStack filterStack = filterItems.getStackInSlot(i);
|
||||
if (filterStack.isEmpty())
|
||||
continue;
|
||||
list.add(Components.literal("- ").append(filterStack.getHoverName()).withStyle(ChatFormatting.GRAY));
|
||||
list.add(Components.literal("- ")
|
||||
.append(filterStack.getHoverName())
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
count++;
|
||||
}
|
||||
|
||||
@ -123,10 +129,12 @@ public class FilterItem extends Item implements MenuProvider {
|
||||
ItemAttribute attribute = ItemAttribute.fromNBT(compound);
|
||||
boolean inverted = compound.getBoolean("Inverted");
|
||||
if (count > 3) {
|
||||
list.add(Components.literal("- ...").withStyle(ChatFormatting.DARK_GRAY));
|
||||
list.add(Components.literal("- ...")
|
||||
.withStyle(ChatFormatting.DARK_GRAY));
|
||||
break;
|
||||
}
|
||||
list.add(Components.literal("- ").append(attribute.format(inverted)));
|
||||
list.add(Components.literal("- ")
|
||||
.append(attribute.format(inverted)));
|
||||
count++;
|
||||
}
|
||||
|
||||
@ -170,6 +178,8 @@ public class FilterItem extends Item implements MenuProvider {
|
||||
ItemStackHandler newInv = new ItemStackHandler(18);
|
||||
if (AllItems.FILTER.get() != stack.getItem())
|
||||
throw new IllegalArgumentException("Cannot get filter items from non-filter: " + stack);
|
||||
if (!stack.hasTag())
|
||||
return newInv;
|
||||
CompoundTag invNBT = stack.getOrCreateTagElement("Items");
|
||||
if (!invNBT.isEmpty())
|
||||
newInv.deserializeNBT(invNBT);
|
||||
@ -189,14 +199,17 @@ public class FilterItem extends Item implements MenuProvider {
|
||||
return true;
|
||||
|
||||
if (!(filter.getItem() instanceof FilterItem))
|
||||
return (matchNBT ? ItemHandlerHelper.canItemStacksStack(filter, stack)
|
||||
: ItemStack.isSame(filter, stack));
|
||||
return (matchNBT ? ItemHandlerHelper.canItemStacksStack(filter, stack) : ItemStack.isSame(filter, stack));
|
||||
|
||||
boolean defaults = !filter.hasTag();
|
||||
|
||||
if (AllItems.FILTER.get() == filter.getItem()) {
|
||||
ItemStackHandler filterItems = getFilterItems(filter);
|
||||
boolean respectNBT = filter.getOrCreateTag()
|
||||
boolean respectNBT = defaults ? false
|
||||
: filter.getTag()
|
||||
.getBoolean("RespectNBT");
|
||||
boolean blacklist = filter.getOrCreateTag()
|
||||
boolean blacklist = defaults ? false
|
||||
: filter.getTag()
|
||||
.getBoolean("Blacklist");
|
||||
for (int slot = 0; slot < filterItems.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = filterItems.getStackInSlot(slot);
|
||||
@ -210,9 +223,11 @@ public class FilterItem extends Item implements MenuProvider {
|
||||
}
|
||||
|
||||
if (AllItems.ATTRIBUTE_FILTER.get() == filter.getItem()) {
|
||||
WhitelistMode whitelistMode = WhitelistMode.values()[filter.getOrCreateTag()
|
||||
WhitelistMode whitelistMode = WhitelistMode.values()[defaults ? 0
|
||||
: filter.getTag()
|
||||
.getInt("WhitelistMode")];
|
||||
ListTag attributes = filter.getOrCreateTag()
|
||||
ListTag attributes = defaults ? new ListTag()
|
||||
: filter.getTag()
|
||||
.getList("MatchedAttributes", Tag.TAG_COMPOUND);
|
||||
for (Tag inbt : attributes) {
|
||||
CompoundTag compound = (CompoundTag) inbt;
|
||||
@ -275,11 +290,15 @@ public class FilterItem extends Item implements MenuProvider {
|
||||
return fluidEqual;
|
||||
}
|
||||
|
||||
boolean defaults = !filter.hasTag();
|
||||
|
||||
if (AllItems.FILTER.get() == filter.getItem()) {
|
||||
ItemStackHandler filterItems = getFilterItems(filter);
|
||||
boolean respectNBT = filter.getOrCreateTag()
|
||||
boolean respectNBT = defaults ? false
|
||||
: filter.getTag()
|
||||
.getBoolean("RespectNBT");
|
||||
boolean blacklist = filter.getOrCreateTag()
|
||||
boolean blacklist = defaults ? false
|
||||
: filter.getTag()
|
||||
.getBoolean("Blacklist");
|
||||
for (int slot = 0; slot < filterItems.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = filterItems.getStackInSlot(slot);
|
||||
|
@ -65,6 +65,14 @@ public class FilterMenu extends AbstractFilterMenu {
|
||||
CompoundTag tag = filterItem.getOrCreateTag();
|
||||
tag.putBoolean("RespectNBT", respectNBT);
|
||||
tag.putBoolean("Blacklist", blacklist);
|
||||
|
||||
if (respectNBT || blacklist)
|
||||
return;
|
||||
for (int i = 0; i < ghostInventory.getSlots(); i++)
|
||||
if (!ghostInventory.getStackInSlot(i)
|
||||
.isEmpty())
|
||||
return;
|
||||
filterItem.setTag(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,10 +16,13 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehaviour;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBoard;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsFormatter;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@ -37,6 +40,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
public class FilteringBehaviour extends BlockEntityBehaviour implements ValueSettingsBehaviour {
|
||||
|
||||
@ -276,10 +281,17 @@ public class FilteringBehaviour extends BlockEntityBehaviour implements ValueSet
|
||||
player.getItemInHand(hand)
|
||||
.shrink(1);
|
||||
}
|
||||
if (getFilter().getItem() instanceof FilterItem)
|
||||
}
|
||||
|
||||
if (getFilter().getItem() instanceof FilterItem) {
|
||||
if (!player.isCreative() || ItemHelper
|
||||
.extract(new InvWrapper(player.getInventory()),
|
||||
stack -> ItemHandlerHelper.canItemStacksStack(stack, getFilter()), true)
|
||||
.isEmpty())
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(getFilter());
|
||||
}
|
||||
|
||||
if (toApply.getItem() instanceof FilterItem)
|
||||
toApply.setCount(1);
|
||||
|
||||
@ -308,8 +320,6 @@ public class FilteringBehaviour extends BlockEntityBehaviour implements ValueSet
|
||||
public boolean writeToClipboard(CompoundTag tag, Direction side) {
|
||||
ValueSettingsBehaviour.super.writeToClipboard(tag, side);
|
||||
ItemStack filter = getFilter(side);
|
||||
if (filter.getItem() instanceof FilterItem)
|
||||
return true;
|
||||
tag.put("Filter", filter.serializeNBT());
|
||||
return true;
|
||||
}
|
||||
@ -321,10 +331,48 @@ public class FilteringBehaviour extends BlockEntityBehaviour implements ValueSet
|
||||
return upstreamResult;
|
||||
if (simulate)
|
||||
return true;
|
||||
if (getFilter(side).getItem() instanceof FilterItem)
|
||||
if (getWorld().isClientSide)
|
||||
return true;
|
||||
|
||||
ItemStack refund = ItemStack.EMPTY;
|
||||
if (getFilter(side).getItem() instanceof FilterItem && !player.isCreative())
|
||||
refund = getFilter(side).copy();
|
||||
|
||||
ItemStack copied = ItemStack.of(tag.getCompound("Filter"));
|
||||
|
||||
if (copied.getItem() instanceof FilterItem filterType && !player.isCreative()) {
|
||||
InvWrapper inv = new InvWrapper(player.getInventory());
|
||||
|
||||
for (boolean preferStacksWithoutData : Iterate.trueAndFalse) {
|
||||
if (refund.getItem() != filterType && ItemHelper
|
||||
.extract(inv, stack -> stack.getItem() == filterType && preferStacksWithoutData != stack.hasTag(),
|
||||
1, false)
|
||||
.isEmpty())
|
||||
continue;
|
||||
|
||||
if (!refund.isEmpty() && refund.getItem() != filterType)
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(getFilter(side).copy());
|
||||
return setFilter(side, ItemStack.of(tag.getCompound("Filter")));
|
||||
.placeItemBackInInventory(refund);
|
||||
|
||||
setFilter(side, copied);
|
||||
return true;
|
||||
}
|
||||
|
||||
player.displayClientMessage(Lang
|
||||
.translate("logistics.filter.requires_item_in_inventory", copied.getHoverName()
|
||||
.copy()
|
||||
.withStyle(ChatFormatting.WHITE))
|
||||
.style(ChatFormatting.RED)
|
||||
.component(), true);
|
||||
AllSoundEvents.DENY.playOnServer(player.level, player.blockPosition(), 1, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!refund.isEmpty())
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(refund);
|
||||
|
||||
return setFilter(side, copied);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1030,9 +1030,10 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||
.pattern("P")
|
||||
.pattern("G")),
|
||||
|
||||
CLIPBOARD_CLEAR = create(AllItems.CLIPBOARD).withSuffix("_clear")
|
||||
.unlockedBy(AllItems.CLIPBOARD::get)
|
||||
.viaShapeless(b -> b.requires(AllItems.CLIPBOARD.get())),
|
||||
CLIPBOARD_CLEAR = clearData(AllItems.CLIPBOARD),
|
||||
SCHEDULE_CLEAR = clearData(AllItems.SCHEDULE),
|
||||
FILTER_CLEAR = clearData(AllItems.FILTER),
|
||||
ATTRIBUTE_FILTER_CLEAR = clearData(AllItems.ATTRIBUTE_FILTER),
|
||||
|
||||
DIVING_HELMET = create(AllItems.COPPER_DIVING_HELMET).unlockedBy(I::copper)
|
||||
.viaShaped(b -> b.define('G', Tags.Items.GLASS)
|
||||
@ -1237,6 +1238,12 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||
return result;
|
||||
}
|
||||
|
||||
GeneratedRecipe clearData(ItemProviderEntry<? extends ItemLike> item) {
|
||||
return create(item).withSuffix("_clear")
|
||||
.unlockedBy(item::get)
|
||||
.viaShapeless(b -> b.requires(item.get()));
|
||||
}
|
||||
|
||||
class GeneratedRecipeBuilder {
|
||||
|
||||
private String path;
|
||||
|
@ -226,6 +226,7 @@
|
||||
"create.logistics.filter.any_amount_short": "Any",
|
||||
"create.logistics.filter.up_to": "Up to",
|
||||
"create.logistics.filter.exactly": "Exactly",
|
||||
"create.logistics.filter.requires_item_in_inventory": "Requires %1$s item in Inventory",
|
||||
|
||||
"create.logistics.creative_crate.supply": "Infinite Supply",
|
||||
"create.logistics.train_observer.cargo_filter": "Cargo Filter",
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 851 B |
Loading…
Reference in New Issue
Block a user