mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Is it gone or just empty
- Fixed item copying recipes and components sticking around on unconfigured items - Added moving interaction for copper doors and trapdoors
This commit is contained in:
parent
412a05e513
commit
13582f508a
11 changed files with 58 additions and 13 deletions
|
@ -63,7 +63,7 @@ public class AllInteractionBehaviours {
|
|||
|
||||
DoorMovingInteraction doorBehaviour = new DoorMovingInteraction();
|
||||
registerBehaviourProvider(state -> {
|
||||
if (state.is(BlockTags.WOODEN_DOORS)) {
|
||||
if (state.is(BlockTags.MOB_INTERACTABLE_DOORS)) {
|
||||
return doorBehaviour;
|
||||
}
|
||||
return null;
|
||||
|
@ -71,7 +71,7 @@ public class AllInteractionBehaviours {
|
|||
|
||||
TrapdoorMovingInteraction trapdoorBehaviour = new TrapdoorMovingInteraction();
|
||||
registerBehaviourProvider(state -> {
|
||||
if (state.is(BlockTags.WOODEN_TRAPDOORS)) {
|
||||
if (state.is(BlockTags.TRAPDOORS) && !state.is(Blocks.IRON_TRAPDOOR)) {
|
||||
return trapdoorBehaviour;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.createmod.catnip.gui.ScreenOpener;
|
|||
import net.createmod.catnip.platform.CatnipServices;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
|
@ -76,5 +77,10 @@ public class ClipboardBlockItem extends BlockItem implements SupportsItemCopying
|
|||
public void registerModelOverrides() {
|
||||
CatnipServices.PLATFORM.executeOnClientOnly(() -> () -> ClipboardOverrides.registerModelOverridesClient(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataComponentType<?> getComponentType() {
|
||||
return AllDataComponents.CLIPBOARD_PAGES;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public record ClipboardEditPacket(int hotbarSlot, DataComponentPatch dataCompone
|
|||
if (processedData.isEmpty()) {
|
||||
clearComponents(cbe.dataContainer);
|
||||
} else {
|
||||
cbe.dataContainer.remove(AllDataComponents.CLIPBOARD_PREVIOUSLY_OPENED_PAGE);
|
||||
cbe.dataContainer.applyComponents(processedData);
|
||||
}
|
||||
cbe.onEditedBy(sender);
|
||||
|
@ -54,6 +55,7 @@ public record ClipboardEditPacket(int hotbarSlot, DataComponentPatch dataCompone
|
|||
if (processedData.isEmpty()) {
|
||||
clearComponents(itemStack);
|
||||
} else {
|
||||
itemStack.remove(AllDataComponents.CLIPBOARD_PREVIOUSLY_OPENED_PAGE);
|
||||
itemStack.applyComponents(processedData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.simibubi.create.AllDataComponents;
|
||||
|
@ -19,8 +18,6 @@ import net.minecraft.network.codec.ByteBufCodecs;
|
|||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.UnmodifiableView;
|
||||
|
||||
public class ClipboardEntry {
|
||||
public static final Codec<ClipboardEntry> CODEC = RecordCodecBuilder.create(i -> i.group(
|
||||
Codec.BOOL.fieldOf("checked").forGetter(c -> c.checked),
|
||||
|
|
|
@ -343,8 +343,11 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
pages.removeIf(List::isEmpty);
|
||||
|
||||
for (int i = 0; i < pages.size(); i++)
|
||||
if (pages.get(i) == currentEntries)
|
||||
if (pages.get(i) == currentEntries) {
|
||||
item.set(AllDataComponents.CLIPBOARD_PREVIOUSLY_OPENED_PAGE, i);
|
||||
if (i == 0)
|
||||
item.remove(AllDataComponents.CLIPBOARD_PREVIOUSLY_OPENED_PAGE);
|
||||
}
|
||||
|
||||
send();
|
||||
|
||||
|
@ -361,6 +364,15 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
private void send() {
|
||||
ClipboardEntry.saveAll(pages, item);
|
||||
ClipboardOverrides.switchTo(ClipboardType.WRITTEN, item);
|
||||
|
||||
if (pages.isEmpty()) {
|
||||
item.remove(AllDataComponents.CLIPBOARD_PAGES);
|
||||
item.remove(AllDataComponents.CLIPBOARD_PREVIOUSLY_OPENED_PAGE);
|
||||
item.remove(AllDataComponents.CLIPBOARD_READ_ONLY);
|
||||
item.remove(AllDataComponents.CLIPBOARD_TYPE);
|
||||
item.remove(AllDataComponents.CLIPBOARD_COPIED_VALUES);
|
||||
}
|
||||
|
||||
CatnipServices.NETWORK.sendToServer(new ClipboardEditPacket(targetSlot, item.getComponentsPatch(), targetedBlock));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,13 @@ public abstract class AbstractFilterMenu extends GhostItemMenu<ItemStack> {
|
|||
|
||||
@Override
|
||||
protected void saveData(ItemStack contentHolder) {
|
||||
contentHolder.set(AllDataComponents.FILTER_ITEMS, ItemHelper.containerContentsFromHandler(ghostInventory));
|
||||
for (int i = 0; i < ghostInventory.getSlots(); i++) {
|
||||
if (!ghostInventory.getStackInSlot(i).isEmpty()) {
|
||||
contentHolder.set(AllDataComponents.FILTER_ITEMS, ItemHelper.containerContentsFromHandler(ghostInventory));
|
||||
return;
|
||||
}
|
||||
}
|
||||
contentHolder.remove(AllDataComponents.FILTER_ITEMS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -124,7 +124,7 @@ public class AttributeFilterMenu extends AbstractFilterMenu {
|
|||
protected void initAndReadInventory(ItemStack filterItem) {
|
||||
super.initAndReadInventory(filterItem);
|
||||
selectedAttributes = new ArrayList<>();
|
||||
whitelistMode = filterItem.get(AllDataComponents.ATTRIBUTE_FILTER_WHITELIST_MODE);
|
||||
whitelistMode = filterItem.getOrDefault(AllDataComponents.ATTRIBUTE_FILTER_WHITELIST_MODE, AttributeFilterWhitelistMode.WHITELIST_DISJ);
|
||||
List<ItemAttribute.ItemAttributeEntry> attributes = filterItem.getOrDefault(AllDataComponents.ATTRIBUTE_FILTER_MATCHED_ATTRIBUTES, new ArrayList<>());
|
||||
selectedAttributes.addAll(attributes);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class FilterItem extends Item implements MenuProvider, SupportsItemCopyin
|
|||
|
||||
private List<Component> makeSummary(ItemStack filter) {
|
||||
List<Component> list = new ArrayList<>();
|
||||
if (!filter.isComponentsPatchEmpty())
|
||||
if (filter.isComponentsPatchEmpty())
|
||||
return list;
|
||||
|
||||
if (type == FilterType.REGULAR) {
|
||||
|
@ -235,4 +235,13 @@ public class FilterItem extends Item implements MenuProvider, SupportsItemCopyin
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataComponentType<?> getComponentType() {
|
||||
return switch (type) {
|
||||
case ATTRIBUTE -> AllDataComponents.ATTRIBUTE_FILTER_MATCHED_ATTRIBUTES;
|
||||
case PACKAGE -> AllDataComponents.PACKAGE_ADDRESS;
|
||||
case REGULAR -> AllDataComponents.FILTER_ITEMS;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,10 @@ public class PackageFilterMenu extends AbstractFilterMenu {
|
|||
@Override
|
||||
protected void saveData(ItemStack filterItem) {
|
||||
super.saveData(filterItem);
|
||||
filterItem.set(AllDataComponents.PACKAGE_ADDRESS, address);
|
||||
if (address.isBlank())
|
||||
filterItem.remove(AllDataComponents.PACKAGE_ADDRESS);
|
||||
else
|
||||
filterItem.set(AllDataComponents.PACKAGE_ADDRESS, address);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.createmod.catnip.data.Couple;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -164,5 +165,10 @@ public class ScheduleItem extends Item implements MenuProvider, SupportsItemCopy
|
|||
public Component getDisplayName() {
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataComponentType<?> getComponentType() {
|
||||
return AllDataComponents.TRAIN_SCHEDULE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,12 +6,14 @@ import com.simibubi.create.AllRecipeTypes;
|
|||
|
||||
import net.createmod.catnip.data.IntAttached;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.enchantment.ItemEnchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class ItemCopyingRecipe extends CustomRecipe {
|
||||
|
@ -20,18 +22,20 @@ public class ItemCopyingRecipe extends CustomRecipe {
|
|||
|
||||
public default ItemStack createCopy(ItemStack original, int count) {
|
||||
ItemStack copyWithCount = original.copyWithCount(count);
|
||||
copyWithCount.remove(DataComponents.ENCHANTMENTS);
|
||||
copyWithCount.set(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY);
|
||||
copyWithCount.remove(DataComponents.STORED_ENCHANTMENTS);
|
||||
return copyWithCount;
|
||||
}
|
||||
|
||||
public default boolean canCopyFromItem(ItemStack item) {
|
||||
return item.isComponentsPatchEmpty();
|
||||
return item.has(getComponentType());
|
||||
}
|
||||
|
||||
public default boolean canCopyToItem(ItemStack item) {
|
||||
return !item.isComponentsPatchEmpty();
|
||||
return !item.has(getComponentType());
|
||||
}
|
||||
|
||||
public DataComponentType<?> getComponentType();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue