mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-10-30 02:40:51 +01:00
bunch of work
This commit is contained in:
parent
68c68ae5b7
commit
2e05cd7b70
29 changed files with 211 additions and 194 deletions
|
@ -68,24 +68,26 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static net.neoforged.fml.common.EventBusSubscriber.*;
|
||||
|
||||
@EventBusSubscriber(bus = Bus.MOD)
|
||||
public final class Registry {
|
||||
|
||||
public static BlockCapability<IPipeConnectable, Direction> pipeConnectableCapability = BlockCapability.createSided(new ResourceLocation(PrettyPipes.ID, "pipe_connectable"), IPipeConnectable.class);
|
||||
public static BlockCapability<IPipeConnectable, Direction> pipeConnectableCapability = BlockCapability.createSided(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe_connectable"), IPipeConnectable.class);
|
||||
|
||||
public static Item wrenchItem;
|
||||
public static Item pipeFrameItem;
|
||||
|
@ -119,19 +121,19 @@ public final class Registry {
|
|||
@SubscribeEvent
|
||||
public static void register(RegisterEvent event) {
|
||||
event.register(Registries.BLOCK, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeBlock = new PipeBlock(Properties.of().strength(2).sound(SoundType.STONE).noOcclusion()));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlock = new ItemTerminalBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlock = new CraftingTerminalBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlock = new PressurizerBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe"), Registry.pipeBlock = new PipeBlock(Properties.of().strength(2).sound(SoundType.STONE).noOcclusion()));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlock = new ItemTerminalBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlock = new CraftingTerminalBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlock = new PressurizerBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
});
|
||||
|
||||
event.register(Registries.ITEM, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "wrench"), Registry.wrenchItem = new WrenchItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "blank_module"), new Item(new Item.Properties()));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameItem = new PipeFrameItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "stack_size_module"), new StackSizeModuleItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "redstone_module"), new RedstoneModuleItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "filter_increase_modifier"), new FilterIncreaseModuleItem());
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "wrench"), Registry.wrenchItem = new WrenchItem());
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "blank_module"), new Item(new Item.Properties()));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameItem = new PipeFrameItem());
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "stack_size_module"), new StackSizeModuleItem());
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "redstone_module"), new RedstoneModuleItem());
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "filter_increase_modifier"), new FilterIncreaseModuleItem());
|
||||
|
||||
Registry.registerTieredModule(h, "extraction_module", ExtractionModuleItem::new);
|
||||
Registry.registerTieredModule(h, "filter_module", FilterModuleItem::new);
|
||||
|
@ -143,11 +145,11 @@ public final class Registry {
|
|||
|
||||
for (var type : ItemEquality.Type.values()) {
|
||||
var name = type.name().toLowerCase(Locale.ROOT) + "_filter_modifier";
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, name), new FilterModifierModuleItem(name, type));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, name), new FilterModifierModuleItem(name, type));
|
||||
}
|
||||
for (var type : SortingModuleItem.Type.values()) {
|
||||
var name = type.name().toLowerCase(Locale.ROOT) + "_sorting_modifier";
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, name), new SortingModuleItem(name, type));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, name), new SortingModuleItem(name, type));
|
||||
}
|
||||
|
||||
BuiltInRegistries.BLOCK.entrySet().stream()
|
||||
|
@ -156,20 +158,20 @@ public final class Registry {
|
|||
});
|
||||
|
||||
event.register(Registries.BLOCK_ENTITY_TYPE, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeBlockEntity = BlockEntityType.Builder.of(PipeBlockEntity::new, Registry.pipeBlock).build(null));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlockEntity = BlockEntityType.Builder.of(ItemTerminalBlockEntity::new, Registry.itemTerminalBlock).build(null));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlockEntity = BlockEntityType.Builder.of(CraftingTerminalBlockEntity::new, Registry.craftingTerminalBlock).build(null));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlockEntity = BlockEntityType.Builder.of(PressurizerBlockEntity::new, Registry.pressurizerBlock).build(null));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe"), Registry.pipeBlockEntity = BlockEntityType.Builder.of(PipeBlockEntity::new, Registry.pipeBlock).build(null));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlockEntity = BlockEntityType.Builder.of(ItemTerminalBlockEntity::new, Registry.itemTerminalBlock).build(null));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlockEntity = BlockEntityType.Builder.of(CraftingTerminalBlockEntity::new, Registry.craftingTerminalBlock).build(null));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlockEntity = BlockEntityType.Builder.of(PressurizerBlockEntity::new, Registry.pressurizerBlock).build(null));
|
||||
});
|
||||
|
||||
event.register(Registries.ENTITY_TYPE, h ->
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameEntity = EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame")));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameEntity = EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame")));
|
||||
|
||||
event.register(Registries.MENU, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeContainer = IMenuTypeExtension.create((windowId, inv, data) -> new MainPipeContainer(Registry.pipeContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalContainer = IMenuTypeExtension.create((windowId, inv, data) -> new ItemTerminalContainer(Registry.itemTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalContainer = IMenuTypeExtension.create((windowId, inv, data) -> new CraftingTerminalContainer(Registry.craftingTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerContainer = IMenuTypeExtension.create((windowId, inv, data) -> new PressurizerContainer(Registry.pressurizerContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe"), Registry.pipeContainer = IMenuTypeExtension.create((windowId, inv, data) -> new MainPipeContainer(Registry.pipeContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalContainer = IMenuTypeExtension.create((windowId, inv, data) -> new ItemTerminalContainer(Registry.itemTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalContainer = IMenuTypeExtension.create((windowId, inv, data) -> new CraftingTerminalContainer(Registry.craftingTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pressurizer"), Registry.pressurizerContainer = IMenuTypeExtension.create((windowId, inv, data) -> new PressurizerContainer(Registry.pressurizerContainer, windowId, inv.player, data.readBlockPos())));
|
||||
|
||||
Registry.extractionModuleContainer = Registry.registerPipeContainer(h, "extraction_module");
|
||||
Registry.filterModuleContainer = Registry.registerPipeContainer(h, "filter_module");
|
||||
|
@ -181,7 +183,7 @@ public final class Registry {
|
|||
});
|
||||
|
||||
event.register(BuiltInRegistries.CREATIVE_MODE_TAB.key(), h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "tab"), CreativeModeTab.builder()
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "tab"), CreativeModeTab.builder()
|
||||
.title(Component.translatable("item_group." + PrettyPipes.ID + ".tab"))
|
||||
.icon(() -> new ItemStack(Registry.wrenchItem))
|
||||
.displayItems((params, output) -> BuiltInRegistries.ITEM.entrySet().stream()
|
||||
|
@ -192,7 +194,7 @@ public final class Registry {
|
|||
});
|
||||
|
||||
event.register(Registries.RECIPE_SERIALIZER, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "module_clearing"), ModuleClearingRecipe.SERIALIZER);
|
||||
h.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "module_clearing"), ModuleClearingRecipe.SERIALIZER);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -207,7 +209,7 @@ public final class Registry {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerPayloads(final RegisterPayloadHandlerEvent event) {
|
||||
public static void registerPayloads(final RegisterPayloadHandlersEvent event) {
|
||||
var registrar = event.registrar(PrettyPipes.ID);
|
||||
registrar.play(PacketItemEnterPipe.ID, PacketItemEnterPipe::new, PacketItemEnterPipe::onMessage);
|
||||
registrar.play(PacketButton.ID, PacketButton::new, PacketButton::onMessage);
|
||||
|
@ -224,13 +226,13 @@ public final class Registry {
|
|||
var moduleStack = tile.modules.getStackInSlot(moduleIndex);
|
||||
return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex);
|
||||
});
|
||||
helper.register(new ResourceLocation(PrettyPipes.ID, name), type);
|
||||
helper.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, name), type);
|
||||
return type;
|
||||
}
|
||||
|
||||
private static void registerTieredModule(RegisterEvent.RegisterHelper<Item> helper, String name, BiFunction<String, ModuleTier, ModuleItem> item) {
|
||||
for (var tier : ModuleTier.values())
|
||||
helper.register(new ResourceLocation(PrettyPipes.ID, tier.name().toLowerCase(Locale.ROOT) + "_" + name), item.apply(name, tier));
|
||||
helper.register(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, tier.name().toLowerCase(Locale.ROOT) + "_" + name), item.apply(name, tier));
|
||||
}
|
||||
|
||||
@EventBusSubscriber(bus = Bus.MOD, value = Dist.CLIENT)
|
||||
|
@ -240,18 +242,21 @@ public final class Registry {
|
|||
public static void setup(FMLClientSetupEvent event) {
|
||||
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new);
|
||||
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new);
|
||||
}
|
||||
|
||||
MenuScreens.register(Registry.pipeContainer, MainPipeGui::new);
|
||||
MenuScreens.register(Registry.itemTerminalContainer, ItemTerminalGui::new);
|
||||
MenuScreens.register(Registry.pressurizerContainer, PressurizerGui::new);
|
||||
MenuScreens.register(Registry.craftingTerminalContainer, CraftingTerminalGui::new);
|
||||
MenuScreens.register(Registry.extractionModuleContainer, ExtractionModuleGui::new);
|
||||
MenuScreens.register(Registry.filterModuleContainer, FilterModuleGui::new);
|
||||
MenuScreens.register(Registry.retrievalModuleContainer, RetrievalModuleGui::new);
|
||||
MenuScreens.register(Registry.stackSizeModuleContainer, StackSizeModuleGui::new);
|
||||
MenuScreens.register(Registry.filterIncreaseModuleContainer, FilterIncreaseModuleGui::new);
|
||||
MenuScreens.register(Registry.craftingModuleContainer, CraftingModuleGui::new);
|
||||
MenuScreens.register(Registry.filterModifierModuleContainer, FilterModifierModuleGui::new);
|
||||
@SubscribeEvent
|
||||
public static void registerMenuScreens(RegisterMenuScreensEvent event) {
|
||||
event.register(Registry.pipeContainer, MainPipeGui::new);
|
||||
event.register(Registry.itemTerminalContainer, ItemTerminalGui::new);
|
||||
event.register(Registry.pressurizerContainer, PressurizerGui::new);
|
||||
event.register(Registry.craftingTerminalContainer, CraftingTerminalGui::new);
|
||||
event.register(Registry.extractionModuleContainer, ExtractionModuleGui::new);
|
||||
event.register(Registry.filterModuleContainer, FilterModuleGui::new);
|
||||
event.register(Registry.retrievalModuleContainer, RetrievalModuleGui::new);
|
||||
event.register(Registry.stackSizeModuleContainer, StackSizeModuleGui::new);
|
||||
event.register(Registry.filterIncreaseModuleContainer, FilterIncreaseModuleGui::new);
|
||||
event.register(Registry.craftingModuleContainer, CraftingModuleGui::new);
|
||||
event.register(Registry.filterModifierModuleContainer, FilterModifierModuleGui::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.client.gui.screens.Screen;
|
|||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -30,6 +31,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public final class Utility {
|
||||
|
||||
public static <T extends BlockEntity> T getBlockEntity(Class<T> type, BlockGetter world, BlockPos pos) {
|
||||
|
@ -104,10 +106,10 @@ public final class Utility {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static ListTag serializeAll(Collection<? extends INBTSerializable<CompoundTag>> items) {
|
||||
public static ListTag serializeAll(HolderLookup.Provider provider, Collection<? extends INBTSerializable<CompoundTag>> items) {
|
||||
var list = new ListTag();
|
||||
for (INBTSerializable<CompoundTag> item : items)
|
||||
list.add(item.serializeNBT());
|
||||
list.add(item.serializeNBT(provider));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -143,5 +145,7 @@ public final class Utility {
|
|||
public interface IMergeItemStack {
|
||||
|
||||
boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,25 +4,21 @@ import de.ellpeck.prettypipes.Registry;
|
|||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||
import de.ellpeck.prettypipes.packets.PacketCraftingModuleTransfer;
|
||||
import de.ellpeck.prettypipes.pipe.modules.craft.CraftingModuleContainer;
|
||||
import mezz.jei.api.constants.RecipeTypes;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||
import mezz.jei.api.recipe.RecipeType;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import mezz.jei.api.recipe.transfer.IUniversalRecipeTransferHandler;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CraftingModuleTransferHandler implements IRecipeTransferHandler<CraftingModuleContainer, RecipeHolder<CraftingRecipe>> {
|
||||
public class CraftingModuleTransferHandler implements IUniversalRecipeTransferHandler<CraftingModuleContainer> {
|
||||
|
||||
@Override
|
||||
public Class<CraftingModuleContainer> getContainerClass() {
|
||||
|
@ -35,21 +31,16 @@ public class CraftingModuleTransferHandler implements IRecipeTransferHandler<Cra
|
|||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<RecipeHolder<CraftingRecipe>> getRecipeType() {
|
||||
return RecipeTypes.CRAFTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IRecipeTransferError transferRecipe(CraftingModuleContainer container, RecipeHolder<CraftingRecipe> recipe, IRecipeSlotsView slots, Player player, boolean maxTransfer, boolean doTransfer) {
|
||||
public @Nullable IRecipeTransferError transferRecipe(CraftingModuleContainer container, Object recipe, IRecipeSlotsView recipeSlots, Player player, boolean maxTransfer, boolean doTransfer) {
|
||||
if (!doTransfer)
|
||||
return null;
|
||||
var inputs = new ArrayList<ItemStack>();
|
||||
var outputs = new ArrayList<ItemStack>();
|
||||
for (var entry : slots.getSlotViews()) {
|
||||
for (var entry : recipeSlots.getSlotViews()) {
|
||||
var allIngredients = entry.getIngredients(VanillaTypes.ITEM_STACK).toList();
|
||||
if (allIngredients.isEmpty())
|
||||
continue;
|
||||
var remain = allIngredients.get(0).copy();
|
||||
var remain = allIngredients.getFirst().copy();
|
||||
var toAdd = entry.getRole() == RecipeIngredientRole.INPUT ? inputs : outputs;
|
||||
for (var stack : toAdd) {
|
||||
if (ItemEquality.compareItems(stack, remain)) {
|
||||
|
@ -63,7 +54,7 @@ public class CraftingModuleTransferHandler implements IRecipeTransferHandler<Cra
|
|||
if (!remain.isEmpty())
|
||||
toAdd.add(remain);
|
||||
}
|
||||
PacketDistributor.SERVER.noArg().send(new PacketCraftingModuleTransfer(inputs, outputs));
|
||||
PacketDistributor.sendToServer(new PacketCraftingModuleTransfer(inputs, outputs));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<C
|
|||
var ingredients = slots.getSlotViews(RecipeIngredientRole.INPUT);
|
||||
for (var entry : ingredients)
|
||||
stacks.add(new PacketGhostSlot.Entry(player.level(), entry.getIngredients(VanillaTypes.ITEM_STACK).collect(Collectors.toList())));
|
||||
PacketDistributor.SERVER.noArg().send(new PacketGhostSlot(container.getTile().getBlockPos(), stacks));
|
||||
PacketDistributor.sendToServer(new PacketGhostSlot(container.getTile().getBlockPos(), stacks));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@ import net.minecraft.client.gui.components.Button;
|
|||
import net.minecraft.client.renderer.Rect2i;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -38,7 +38,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getPluginUid() {
|
||||
return new ResourceLocation(PrettyPipes.ID, "jei_plugin");
|
||||
return ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "jei_plugin");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +103,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
public void onClientTick(ClientTickEvent event) {
|
||||
if (!PlayerPrefs.get().syncJei)
|
||||
return;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import de.ellpeck.prettypipes.network.PipeNetwork;
|
|||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
|
@ -41,9 +41,9 @@ public class PipeFrameEntity extends ItemFrame implements IEntityWithComplexSpaw
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(PipeFrameEntity.AMOUNT, -1);
|
||||
protected void defineSynchedData(SynchedEntityData.Builder pBuilder) {
|
||||
super.defineSynchedData(pBuilder);
|
||||
pBuilder.define(PipeFrameEntity.AMOUNT, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,14 +154,15 @@ public class PipeFrameEntity extends ItemFrame implements IEntityWithComplexSpaw
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(FriendlyByteBuf buffer) {
|
||||
public void writeSpawnData(RegistryFriendlyByteBuf buffer) {
|
||||
buffer.writeBlockPos(this.pos);
|
||||
buffer.writeInt(this.direction.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData(FriendlyByteBuf additionalData) {
|
||||
public void readSpawnData(RegistryFriendlyByteBuf additionalData) {
|
||||
this.pos = additionalData.readBlockPos();
|
||||
this.direction = Direction.values()[additionalData.readInt()];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,10 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
@ -35,9 +33,9 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
super.appendHoverText(stack, worldIn, tooltip, flagIn);
|
||||
Utility.addTooltip(this.name, tooltip);
|
||||
public void appendHoverText(ItemStack pStack, TooltipContext pContext, List<Component> pTooltipComponents, TooltipFlag pTooltipFlag) {
|
||||
super.appendHoverText(pStack, pContext, pTooltipComponents, pTooltipFlag);
|
||||
Utility.addTooltip(this.name, pTooltipComponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,4 +107,5 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,7 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class PipeFrameItem extends Item {
|
||||
|
@ -64,8 +62,9 @@ public class PipeFrameItem extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
super.appendHoverText(stack, worldIn, tooltip, flagIn);
|
||||
Utility.addTooltip(BuiltInRegistries.ITEM.getKey(this).getPath(), tooltip);
|
||||
public void appendHoverText(ItemStack pStack, TooltipContext pContext, List<Component> pTooltipComponents, TooltipFlag pTooltipFlag) {
|
||||
super.appendHoverText(pStack, pContext, pTooltipComponents, pTooltipFlag);
|
||||
Utility.addTooltip(BuiltInRegistries.ITEM.getKey(this).getPath(), pTooltipComponents);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import de.ellpeck.prettypipes.Utility;
|
|||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
@ -17,7 +18,6 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
|
||||
|
@ -107,8 +107,8 @@ public class WrenchItem extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
Utility.addTooltip(BuiltInRegistries.ITEM.getKey(this).getPath(), tooltip);
|
||||
public void appendHoverText(ItemStack pStack, TooltipContext pContext, List<Component> pTooltipComponents, TooltipFlag pTooltipFlag) {
|
||||
Utility.addTooltip(BuiltInRegistries.ITEM.getKey(this).getPath(), pTooltipComponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,7 +122,7 @@ public class WrenchItem extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
|
||||
public boolean supportsEnchantment(ItemStack stack, Holder<Enchantment> enchantment) {
|
||||
return enchantment == Enchantments.SILK_TOUCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import de.ellpeck.prettypipes.network.PipeNetwork;
|
|||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -13,7 +13,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
@EventBusSubscriber
|
||||
public final class Events {
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.client.gui.components.Button;
|
|||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
|
@ -130,16 +131,16 @@ public class ItemFilter extends ItemStackHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
var nbt = super.serializeNBT();
|
||||
public CompoundTag serializeNBT(HolderLookup.Provider provider) {
|
||||
var nbt = super.serializeNBT(provider);
|
||||
if (this.canModifyWhitelist)
|
||||
nbt.putBoolean("whitelist", this.isWhitelist);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
super.deserializeNBT(nbt);
|
||||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
super.deserializeNBT(provider, nbt);
|
||||
if (this.canModifyWhitelist)
|
||||
this.isWhitelist = nbt.getBoolean("whitelist");
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -17,9 +15,10 @@ public class ModuleClearingRecipe extends CustomRecipe {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingContainer container, Level level) {
|
||||
public boolean matches(CraftingInput container, Level level) {
|
||||
var foundModule = false;
|
||||
for (var stack : container.getItems()) {
|
||||
for (var i = 0; i < container.size(); i++) {
|
||||
var stack = container.getItem(i);
|
||||
if (!foundModule && stack.getItem() instanceof IModule) {
|
||||
foundModule = true;
|
||||
} else if (!stack.isEmpty()) {
|
||||
|
@ -30,11 +29,13 @@ public class ModuleClearingRecipe extends CustomRecipe {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingContainer container, RegistryAccess access) {
|
||||
var module = container.getItems().stream().filter(i -> i.getItem() instanceof IModule).findFirst().orElse(ItemStack.EMPTY);
|
||||
if (!module.isEmpty())
|
||||
module = new ItemStack(module.getItem());
|
||||
return module;
|
||||
public ItemStack assemble(CraftingInput container, HolderLookup.Provider pRegistries) {
|
||||
for (var i = 0; i < container.size(); i++) {
|
||||
var stack = container.getItem(i);
|
||||
if (stack.getItem() instanceof IModule)
|
||||
return new ItemStack(stack.getItem());
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,4 +50,5 @@ public class PlayerPrefs {
|
|||
var location = Minecraft.getInstance().gameDirectory;
|
||||
return new File(location, PrettyPipes.ID + "prefs");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.prettypipes.network;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
@ -18,20 +19,20 @@ public class NetworkEdge extends DefaultWeightedEdge implements INBTSerializable
|
|||
public NetworkEdge() {
|
||||
}
|
||||
|
||||
public NetworkEdge(CompoundTag nbt) {
|
||||
this.deserializeNBT(nbt);
|
||||
public NetworkEdge(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.deserializeNBT(provider, nbt);
|
||||
}
|
||||
|
||||
public BlockPos getStartPipe() {
|
||||
return this.pipes.get(0);
|
||||
return this.pipes.getFirst();
|
||||
}
|
||||
|
||||
public BlockPos getEndPipe() {
|
||||
return this.pipes.get(this.pipes.size() - 1);
|
||||
return this.pipes.getLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
public CompoundTag serializeNBT(HolderLookup.Provider provider) {
|
||||
var nbt = new CompoundTag();
|
||||
var list = new ListTag();
|
||||
for (var pos : this.pipes)
|
||||
|
@ -41,10 +42,11 @@ public class NetworkEdge extends DefaultWeightedEdge implements INBTSerializable
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.pipes.clear();
|
||||
var list = nbt.getList("pipes", Tag.TAG_COMPOUND);
|
||||
for (var i = 0; i < list.size(); i++)
|
||||
this.pipes.add(NbtUtils.readBlockPos(list.getCompound(i)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.prettypipes.network;
|
|||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -28,8 +29,8 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
|||
this.direction = direction;
|
||||
}
|
||||
|
||||
public NetworkLocation(CompoundTag nbt) {
|
||||
this.deserializeNBT(nbt);
|
||||
public NetworkLocation(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.deserializeNBT(provider, nbt);
|
||||
}
|
||||
|
||||
public List<Integer> getStackSlots(Level world, ItemStack stack, ItemEquality... equalityTypes) {
|
||||
|
@ -91,7 +92,7 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
public CompoundTag serializeNBT(HolderLookup.Provider provider) {
|
||||
var nbt = new CompoundTag();
|
||||
nbt.put("pipe_pos", NbtUtils.writeBlockPos(this.pipePos));
|
||||
nbt.putInt("direction", this.direction.ordinal());
|
||||
|
@ -99,8 +100,9 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
this.pipePos = NbtUtils.readBlockPos(nbt.getCompound("pipe_pos"));
|
||||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.pipePos = NbtUtils.readBlockPos(nbt, "pipe_pos").orElse(null);
|
||||
this.direction = Direction.values()[nbt.getInt("direction")];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.network;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.common.util.INBTSerializable;
|
||||
|
@ -20,24 +21,24 @@ public class NetworkLock implements INBTSerializable<CompoundTag> {
|
|||
this.stack = stack;
|
||||
}
|
||||
|
||||
public NetworkLock(CompoundTag nbt) {
|
||||
this.deserializeNBT(nbt);
|
||||
public NetworkLock(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.deserializeNBT(provider, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
public CompoundTag serializeNBT(HolderLookup.Provider provider) {
|
||||
var nbt = new CompoundTag();
|
||||
nbt.putUUID("id", this.lockId);
|
||||
nbt.put("location", this.location.serializeNBT());
|
||||
nbt.put("stack", this.stack.save(new CompoundTag()));
|
||||
nbt.put("location", this.location.serializeNBT(provider));
|
||||
nbt.put("stack", this.stack.save(provider));
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.lockId = nbt.getUUID("id");
|
||||
this.location = new NetworkLocation(nbt.getCompound("location"));
|
||||
this.stack = ItemStack.of(nbt.getCompound("stack"));
|
||||
this.location = new NetworkLocation(provider, nbt.getCompound("location"));
|
||||
this.stack = ItemStack.parseOptional(provider, nbt.getCompound("stack"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,4 +57,5 @@ public class NetworkLock implements INBTSerializable<CompoundTag> {
|
|||
public String toString() {
|
||||
return "NetworkLock{" + "location=" + this.location.pipePos + ", stack=" + this.stack + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
@ -33,7 +34,7 @@ import java.util.function.Consumer;
|
|||
|
||||
public class PipeItem implements IPipeItem {
|
||||
|
||||
public static final ResourceLocation TYPE = new ResourceLocation(PrettyPipes.ID, "pipe_item");
|
||||
public static final ResourceLocation TYPE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "pipe_item");
|
||||
|
||||
public ItemStack stack;
|
||||
public float speed;
|
||||
|
@ -63,10 +64,10 @@ public class PipeItem implements IPipeItem {
|
|||
this(PipeItem.TYPE, stack, speed);
|
||||
}
|
||||
|
||||
public PipeItem(ResourceLocation type, CompoundTag nbt) {
|
||||
public PipeItem(HolderLookup.Provider provider, ResourceLocation type, CompoundTag nbt) {
|
||||
this.type = type;
|
||||
this.path = new ArrayList<>();
|
||||
this.deserializeNBT(nbt);
|
||||
this.deserializeNBT(provider, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -221,12 +222,12 @@ public class PipeItem implements IPipeItem {
|
|||
}
|
||||
|
||||
protected BlockPos getStartPipe() {
|
||||
return this.path.get(0);
|
||||
return this.path.getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getDestPipe() {
|
||||
return this.path.get(this.path.size() - 1);
|
||||
return this.path.getLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -240,10 +241,10 @@ public class PipeItem implements IPipeItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
public CompoundTag serializeNBT(HolderLookup.Provider provider) {
|
||||
var nbt = new CompoundTag();
|
||||
nbt.putString("type", this.type.toString());
|
||||
nbt.put("stack", this.stack.save(new CompoundTag()));
|
||||
nbt.put("stack", this.stack.save(provider));
|
||||
nbt.putFloat("speed", this.speed);
|
||||
nbt.put("start_inv", NbtUtils.writeBlockPos(this.startInventory));
|
||||
nbt.put("dest_inv", NbtUtils.writeBlockPos(this.destInventory));
|
||||
|
@ -261,12 +262,12 @@ public class PipeItem implements IPipeItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
this.stack = ItemStack.of(nbt.getCompound("stack"));
|
||||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
this.stack = ItemStack.parseOptional(provider, nbt.getCompound("stack"));
|
||||
this.speed = nbt.getFloat("speed");
|
||||
this.startInventory = NbtUtils.readBlockPos(nbt.getCompound("start_inv"));
|
||||
this.destInventory = NbtUtils.readBlockPos(nbt.getCompound("dest_inv"));
|
||||
this.currGoalPos = NbtUtils.readBlockPos(nbt.getCompound("curr_goal"));
|
||||
this.startInventory = NbtUtils.readBlockPos(nbt, "start_inv").orElse(null);
|
||||
this.destInventory = NbtUtils.readBlockPos(nbt, "dest_inv").orElse(null);
|
||||
this.currGoalPos = NbtUtils.readBlockPos(nbt, "curr_goal").orElse(null);
|
||||
this.retryOnObstruction = nbt.getBoolean("drop_on_obstruction");
|
||||
this.currentTile = nbt.getInt("tile");
|
||||
this.x = nbt.getFloat("x");
|
||||
|
@ -344,7 +345,7 @@ public class PipeItem implements IPipeItem {
|
|||
// add the single pipe twice if there's only one
|
||||
// this is a dirty hack, but it works fine so eh
|
||||
for (var i = 0; i < 2; i++)
|
||||
ret.add(nodes.get(0));
|
||||
ret.add(nodes.getFirst());
|
||||
return ret;
|
||||
}
|
||||
for (var i = 0; i < nodes.size() - 1; i++) {
|
||||
|
@ -368,4 +369,5 @@ public class PipeItem implements IPipeItem {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,12 +12,14 @@ import de.ellpeck.prettypipes.pipe.PipeBlock;
|
|||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.saveddata.SavedData;
|
||||
|
@ -60,17 +62,17 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
|||
this.dijkstra = new DijkstraShortestPath<>(this.graph);
|
||||
}
|
||||
|
||||
public PipeNetwork(CompoundTag nbt) {
|
||||
public PipeNetwork(CompoundTag nbt, HolderLookup.Provider provider) {
|
||||
this();
|
||||
var nodes = nbt.getList("nodes", Tag.TAG_COMPOUND);
|
||||
for (var i = 0; i < nodes.size(); i++)
|
||||
this.graph.addVertex(NbtUtils.readBlockPos(nodes.getCompound(i)));
|
||||
var edges = nbt.getList("edges", Tag.TAG_COMPOUND);
|
||||
for (var i = 0; i < edges.size(); i++)
|
||||
this.addEdge(new NetworkEdge(edges.getCompound(i)));
|
||||
this.addEdge(new NetworkEdge(provider, edges.getCompound(i)));
|
||||
for (var item : Utility.deserializeAll(nbt.getList("items", Tag.TAG_COMPOUND), IPipeItem::load))
|
||||
this.pipeItems.put(item.getCurrentPipe(), item);
|
||||
for (var lock : Utility.deserializeAll(nbt.getList("locks", Tag.TAG_COMPOUND), NetworkLock::new))
|
||||
for (var lock : Utility.deserializeAll(nbt.getList("locks", Tag.TAG_COMPOUND), t -> new NetworkLock(provider, t)))
|
||||
this.createNetworkLock(lock);
|
||||
}
|
||||
|
||||
|
@ -108,14 +110,14 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag nbt) {
|
||||
public CompoundTag save(CompoundTag nbt, HolderLookup.Provider provider) {
|
||||
var nodes = new ListTag();
|
||||
for (var node : this.graph.vertexSet())
|
||||
nodes.add(NbtUtils.writeBlockPos(node));
|
||||
nbt.put("nodes", nodes);
|
||||
var edges = new ListTag();
|
||||
for (var edge : this.graph.edgeSet())
|
||||
edges.add(edge.serializeNBT());
|
||||
edges.add(edge.serializeNBT(provider));
|
||||
nbt.put("edges", edges);
|
||||
nbt.put("items", Utility.serializeAll(this.pipeItems.values()));
|
||||
nbt.put("locks", Utility.serializeAll(this.networkLocks.values()));
|
||||
|
@ -199,7 +201,7 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
|||
var item = itemSupplier.apply(startPipe.getItemSpeed(stack));
|
||||
item.setDestination(startInventory, destInventory, path);
|
||||
startPipe.addNewItem(item);
|
||||
PacketDistributor.TRACKING_CHUNK.with(this.level.getChunkAt(startPipePos)).send(new PacketItemEnterPipe(startPipePos, item));
|
||||
PacketDistributor.sendToPlayersTrackingChunk((ServerLevel) this.level, new ChunkPos(startPipePos), new PacketItemEnterPipe(startPipePos, item));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
|||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -92,9 +93,9 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag compound) {
|
||||
super.saveAdditional(compound);
|
||||
compound.put("modules", this.modules.serializeNBT());
|
||||
public void saveAdditional(CompoundTag compound, HolderLookup.Provider provider) {
|
||||
super.saveAdditional(compound, provider);
|
||||
compound.put("modules", this.modules.serializeNBT(provider));
|
||||
compound.putInt("module_drop_check", this.moduleDropCheck);
|
||||
compound.put("requests", Utility.serializeAll(this.craftIngredientRequests));
|
||||
if (this.cover != null)
|
||||
|
@ -103,49 +104,49 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
for (var triple : this.craftResultRequests) {
|
||||
var nbt = new CompoundTag();
|
||||
nbt.putLong("dest_pipe", triple.getLeft().asLong());
|
||||
nbt.put("item", triple.getRight().save(new CompoundTag()));
|
||||
nbt.put("item", triple.getRight().save(provider));
|
||||
results.add(nbt);
|
||||
}
|
||||
compound.put("craft_results", results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compound) {
|
||||
this.modules.deserializeNBT(compound.getCompound("modules"));
|
||||
public void loadAdditional(CompoundTag compound, HolderLookup.Provider provider) {
|
||||
this.modules.deserializeNBT(provider, compound.getCompound("modules"));
|
||||
this.moduleDropCheck = compound.getInt("module_drop_check");
|
||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(this.level != null ? this.level.holderLookup(Registries.BLOCK) : BuiltInRegistries.BLOCK.asLookup(), compound.getCompound("cover")) : null;
|
||||
this.craftIngredientRequests.clear();
|
||||
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), NetworkLock::new));
|
||||
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), l -> new NetworkLock(provider, l)));
|
||||
this.craftResultRequests.clear();
|
||||
var results = compound.getList("craft_results", Tag.TAG_COMPOUND);
|
||||
for (var i = 0; i < results.size(); i++) {
|
||||
var nbt = results.getCompound(i);
|
||||
this.craftResultRequests.add(Pair.of(
|
||||
BlockPos.of(nbt.getLong("dest_pipe")),
|
||||
ItemStack.of(nbt.getCompound("item"))));
|
||||
ItemStack.parseOptional(provider, nbt.getCompound("item"))));
|
||||
}
|
||||
super.load(compound);
|
||||
super.loadAdditional(compound, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag() {
|
||||
public CompoundTag getUpdateTag(HolderLookup.Provider provider) {
|
||||
// sync pipe items on load
|
||||
var nbt = this.saveWithoutMetadata();
|
||||
var nbt = this.saveWithoutMetadata(provider);
|
||||
nbt.put("items", Utility.serializeAll(this.getItems()));
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag(CompoundTag nbt) {
|
||||
this.load(nbt);
|
||||
public void handleUpdateTag(CompoundTag nbt, HolderLookup.Provider provider) {
|
||||
this.loadWithComponents(nbt, provider);
|
||||
var items = this.getItems();
|
||||
items.clear();
|
||||
items.addAll(Utility.deserializeAll(nbt.getList("items", Tag.TAG_COMPOUND), IPipeItem::load));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
this.load(pkt.getTag());
|
||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider provider) {
|
||||
this.loadWithComponents(pkt.getTag(), provider);
|
||||
}
|
||||
|
||||
public List<IPipeItem> getItems() {
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
|
||||
public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extends AbstractContainerScreen<T> {
|
||||
|
||||
protected static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/pipe.png");
|
||||
protected static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "textures/gui/pipe.png");
|
||||
private final List<Tab> tabs = new ArrayList<>();
|
||||
private final ItemStack[] lastItems = new ItemStack[this.menu.tile.modules.getSlots()];
|
||||
|
||||
|
@ -144,7 +144,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
return false;
|
||||
if (mouseX < this.x || mouseY < this.y || mouseX >= this.x + 28 || mouseY >= this.y + 32)
|
||||
return false;
|
||||
PacketDistributor.SERVER.noArg().send(new PacketButton(AbstractPipeGui.this.menu.tile.getBlockPos(), PacketButton.ButtonResult.PIPE_TAB, this.index));
|
||||
PacketDistributor.sendToServer(new PacketButton(AbstractPipeGui.this.menu.tile.getBlockPos(), PacketButton.ButtonResult.PIPE_TAB, this.index));
|
||||
AbstractPipeGui.this.getMinecraft().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import de.ellpeck.prettypipes.pipe.ConnectionType;
|
|||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -51,30 +52,30 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag compound) {
|
||||
super.saveAdditional(compound);
|
||||
public void saveAdditional(CompoundTag compound, HolderLookup.Provider provider) {
|
||||
super.saveAdditional(compound, provider);
|
||||
compound.putInt("energy", this.getEnergy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
public void loadAdditional(CompoundTag nbt, HolderLookup.Provider provider) {
|
||||
this.storage.setEnergyStored(nbt.getInt("energy"));
|
||||
super.load(nbt);
|
||||
super.loadAdditional(nbt, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag() {
|
||||
return this.saveWithoutMetadata();
|
||||
public CompoundTag getUpdateTag(HolderLookup.Provider provider) {
|
||||
return this.saveWithoutMetadata(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag(CompoundTag tag) {
|
||||
this.load(tag);
|
||||
public void handleUpdateTag(CompoundTag tag, HolderLookup.Provider provider) {
|
||||
this.loadWithComponents(tag, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
this.load(pkt.getTag());
|
||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider provider) {
|
||||
this.loadWithComponents(pkt.getTag(), provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.world.entity.player.Inventory;
|
|||
|
||||
public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer> {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/pressurizer.png");
|
||||
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "textures/gui/pressurizer.png");
|
||||
|
||||
public PressurizerGui(PressurizerContainer screenContainer, Inventory inv, Component titleIn) {
|
||||
super(screenContainer, inv, titleIn);
|
||||
|
|
|
@ -16,10 +16,12 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||
|
@ -98,7 +100,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
List<PacketGhostSlot.Entry> clients = new ArrayList<>();
|
||||
for (var i = 0; i < this.ghostItems.getSlots(); i++)
|
||||
clients.add(new PacketGhostSlot.Entry(this.level, Collections.singletonList(this.ghostItems.getStackInSlot(i))));
|
||||
PacketDistributor.TRACKING_CHUNK.with(this.level.getChunkAt(this.getBlockPos())).send(new PacketGhostSlot(this.getBlockPos(), clients));
|
||||
PacketDistributor.sendToPlayersTrackingChunk((ServerLevel) this.level, new ChunkPos(this.getBlockPos()), new PacketGhostSlot(this.getBlockPos(), clients));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,11 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
|
@ -23,7 +22,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTerminalBlock extends BaseEntityBlock {
|
||||
|
@ -40,19 +38,19 @@ public class ItemTerminalBlock extends BaseEntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult result) {
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, worldIn, pos);
|
||||
protected InteractionResult useWithoutItem(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, BlockHitResult pHitResult) {
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, pLevel, pPos);
|
||||
if (tile == null)
|
||||
return InteractionResult.PASS;
|
||||
var reason = tile.getInvalidTerminalReason();
|
||||
if (reason != null) {
|
||||
if (!worldIn.isClientSide)
|
||||
player.sendSystemMessage(Component.translatable(reason).withStyle(ChatFormatting.RED));
|
||||
if (!pLevel.isClientSide)
|
||||
pPlayer.sendSystemMessage(Component.translatable(reason).withStyle(ChatFormatting.RED));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
if (!worldIn.isClientSide) {
|
||||
player.openMenu(tile, pos);
|
||||
tile.updateItems(player);
|
||||
if (!pLevel.isClientSide) {
|
||||
pPlayer.openMenu(tile, pPos);
|
||||
tile.updateItems(pPlayer);
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
@ -79,8 +77,8 @@ public class ItemTerminalBlock extends BaseEntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
Utility.addTooltip(BuiltInRegistries.BLOCK.getKey(this).getPath(), tooltip);
|
||||
public void appendHoverText(ItemStack pStack, Item.TooltipContext pContext, List<Component> pTooltipComponents, TooltipFlag pTooltipFlag) {
|
||||
Utility.addTooltip(BuiltInRegistries.BLOCK.getKey(this).getPath(), pTooltipComponents);
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable
|
||||
|
|
|
@ -17,6 +17,7 @@ import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -228,18 +229,18 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag compound) {
|
||||
super.saveAdditional(compound);
|
||||
compound.put("items", this.items.serializeNBT());
|
||||
public void saveAdditional(CompoundTag compound, HolderLookup.Provider pRegistries) {
|
||||
super.saveAdditional(compound, pRegistries);
|
||||
compound.put("items", this.items.serializeNBT(pRegistries));
|
||||
compound.put("requests", Utility.serializeAll(this.existingRequests));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compound) {
|
||||
this.items.deserializeNBT(compound.getCompound("items"));
|
||||
protected void loadAdditional(CompoundTag compound, HolderLookup.Provider pRegistries) {
|
||||
this.items.deserializeNBT(pRegistries, compound.getCompound("items"));
|
||||
this.existingRequests.clear();
|
||||
this.existingRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), NetworkLock::new));
|
||||
super.load(compound);
|
||||
this.existingRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), l -> new NetworkLock(pRegistries, l)));
|
||||
super.loadAdditional(compound, pRegistries);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,9 +48,9 @@ public class CraftingTerminalContainer extends ItemTerminalContainer {
|
|||
super.slotsChanged(inventoryIn);
|
||||
if (!this.player.level().isClientSide) {
|
||||
var ret = ItemStack.EMPTY;
|
||||
var optional = this.player.level().getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftInventory, this.player.level());
|
||||
var optional = this.player.level().getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftInventory.asCraftInput(), this.player.level());
|
||||
if (optional.isPresent())
|
||||
ret = optional.get().value().assemble(this.craftInventory, this.player.level().registryAccess());
|
||||
ret = optional.get().value().assemble(this.craftInventory.asCraftInput(), this.player.level().registryAccess());
|
||||
this.craftResult.setItem(0, ret);
|
||||
((ServerPlayer) this.player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, 0, 0, ret));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
|||
|
||||
public class CraftingTerminalGui extends ItemTerminalGui {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/crafting_terminal.png");
|
||||
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "textures/gui/crafting_terminal.png");
|
||||
private Button requestButton;
|
||||
|
||||
public CraftingTerminalGui(ItemTerminalContainer screenContainer, Inventory inv, Component titleIn) {
|
||||
|
@ -28,7 +28,7 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
var amount = ItemTerminalGui.requestModifier();
|
||||
// also allow holding backspace instead of alt for people whose alt key is inaccessible (linux?)
|
||||
var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;
|
||||
PacketDistributor.SERVER.noArg().send(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force));
|
||||
PacketDistributor.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force));
|
||||
}).bounds(this.leftPos + 8, this.topPos + 100, 50, 20).build());
|
||||
this.tick();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.network.chat.Component;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
@ -29,9 +30,10 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContainer> {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/item_terminal.png");
|
||||
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "textures/gui/item_terminal.png");
|
||||
|
||||
public List<ItemStack> currentlyCrafting;
|
||||
public EditBox search;
|
||||
|
@ -91,7 +93,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
return;
|
||||
var stack = widget.get().stack.copy();
|
||||
stack.setCount(1);
|
||||
PacketDistributor.SERVER.noArg().send(new PacketRequest(this.menu.tile.getBlockPos(), stack, this.requestAmount));
|
||||
PacketDistributor.sendToServer(new PacketRequest(this.menu.tile.getBlockPos(), stack, this.requestAmount));
|
||||
this.requestAmount = 1;
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20).build());
|
||||
this.requestButton.active = false;
|
||||
|
@ -159,7 +161,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
// and vanilla buttons are activated when the click starts, so we'll always invoke jei accidentally by default
|
||||
if (button == 0 && this.cancelCraftingButton.visible && this.cancelCraftingButton.isHovered()) {
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
PacketDistributor.SERVER.noArg().send(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CANCEL_CRAFTING));
|
||||
PacketDistributor.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CANCEL_CRAFTING));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +234,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
search = search.substring(1);
|
||||
} else if (search.startsWith("#")) {
|
||||
// search item description
|
||||
var hoverText = s.getLeft().getTooltipLines(this.minecraft.player,
|
||||
var hoverText = s.getLeft().getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player,
|
||||
this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL);
|
||||
toCompare = hoverText.stream().map(Component::getString).collect(Collectors.joining("\n"));
|
||||
search = search.substring(1);
|
||||
|
|
Loading…
Reference in a new issue