Compare commits

..

No commits in common. "f8c8842fa96b9ce43cb26d8933512f2d1dd76eb3" and "590982069367acc83f592fefd98c9a3faa572cdc" have entirely different histories.

56 changed files with 566 additions and 899 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = '1.13.0' version = '1.12.3'
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'PrettyPipes' archivesBaseName = 'PrettyPipes'
@ -24,7 +24,7 @@ if (System.getenv('BUILD_NUMBER') != null) {
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft { minecraft {
mappings channel: 'official', version: '1.19' mappings channel: 'official', version: '1.18.2'
runs { runs {
client { client {
@ -105,11 +105,11 @@ configurations {
} }
dependencies { dependencies {
minecraft 'net.minecraftforge:forge:1.19-41.0.45' minecraft 'net.minecraftforge:forge:1.18.2-40.0.32'
embed 'org.jgrapht:jgrapht-core:1.5.1' embed 'org.jgrapht:jgrapht-core:1.5.1'
compileOnly fg.deobf("mezz.jei:jei-1.19-common-api:11.0.0.206") compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.5.174:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.19-forge:11.0.0.206") runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.5.174")
// to test the rf requiring and crafting stuff // to test the rf requiring and crafting stuff
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732") /* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")

View file

@ -52,7 +52,6 @@ import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MenuType;
@ -66,14 +65,18 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken; import net.minecraftforge.common.capabilities.CapabilityToken;
import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent; import net.minecraftforge.registries.IForgeRegistry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@ -83,7 +86,7 @@ public final class Registry {
public static final CreativeModeTab TAB = new CreativeModeTab(PrettyPipes.ID) { public static final CreativeModeTab TAB = new CreativeModeTab(PrettyPipes.ID) {
@Override @Override
public ItemStack makeIcon() { public ItemStack makeIcon() {
return new ItemStack(Registry.wrenchItem); return new ItemStack(wrenchItem);
} }
}; };
@ -122,84 +125,89 @@ public final class Registry {
public static MenuType<FilterModifierModuleContainer> filterModifierModuleContainer; public static MenuType<FilterModifierModuleContainer> filterModifierModuleContainer;
@SubscribeEvent @SubscribeEvent
public static void register(RegisterEvent event) { public static void registerBlocks(RegistryEvent.Register<Block> event) {
event.register(ForgeRegistries.Keys.BLOCKS, h -> { event.getRegistry().registerAll(
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeBlock = new PipeBlock()); pipeBlock = new PipeBlock().setRegistryName("pipe"),
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlock = new ItemTerminalBlock()); itemTerminalBlock = new ItemTerminalBlock().setRegistryName("item_terminal"),
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlock = new CraftingTerminalBlock()); craftingTerminalBlock = new CraftingTerminalBlock().setRegistryName("crafting_terminal"),
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlock = new PressurizerBlock()); pressurizerBlock = new PressurizerBlock().setRegistryName("pressurizer")
}); );
event.register(ForgeRegistries.Keys.ITEMS, 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().tab(Registry.TAB)));
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());
Registry.registerTieredModule(h, "extraction_module", ExtractionModuleItem::new);
Registry.registerTieredModule(h, "filter_module", FilterModuleItem::new);
Registry.registerTieredModule(h, "speed_module", SpeedModuleItem::new);
Registry.registerTieredModule(h, "low_priority_module", LowPriorityModuleItem::new);
Registry.registerTieredModule(h, "high_priority_module", HighPriorityModuleItem::new);
Registry.registerTieredModule(h, "retrieval_module", RetrievalModuleItem::new);
Registry.registerTieredModule(h, "crafting_module", CraftingModuleItem::new);
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));
}
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));
}
ForgeRegistries.BLOCKS.getEntries().stream()
.filter(b -> b.getKey().location().getNamespace().equals(PrettyPipes.ID))
.forEach(b -> h.register(b.getKey().location(), new BlockItem(b.getValue(), new Item.Properties().tab(Registry.TAB))));
});
event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, 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));
});
event.register(ForgeRegistries.Keys.ENTITY_TYPES, h ->
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameEntity = EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame")));
event.register(ForgeRegistries.Keys.CONTAINER_TYPES, h -> {
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeContainer = IForgeMenuType.create((windowId, inv, data) -> new MainPipeContainer(Registry.pipeContainer, windowId, inv.player, data.readBlockPos())));
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalContainer = IForgeMenuType.create((windowId, inv, data) -> new ItemTerminalContainer(Registry.itemTerminalContainer, windowId, inv.player, data.readBlockPos())));
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalContainer = IForgeMenuType.create((windowId, inv, data) -> new CraftingTerminalContainer(Registry.craftingTerminalContainer, windowId, inv.player, data.readBlockPos())));
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerContainer = IForgeMenuType.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");
Registry.retrievalModuleContainer = Registry.registerPipeContainer(h, "retrieval_module");
Registry.stackSizeModuleContainer = Registry.registerPipeContainer(h, "stack_size_module");
Registry.filterIncreaseModuleContainer = Registry.registerPipeContainer(h, "filter_increase_module");
Registry.craftingModuleContainer = Registry.registerPipeContainer(h, "crafting_module");
Registry.filterModifierModuleContainer = Registry.registerPipeContainer(h, "filter_modifier_module");
});
} }
private static <T extends AbstractPipeContainer<?>> MenuType<T> registerPipeContainer(RegisterEvent.RegisterHelper<MenuType<?>> helper, String name) { @SubscribeEvent
var type = (MenuType<T>) IForgeMenuType.create((windowId, inv, data) -> { public static void registerItems(RegistryEvent.Register<Item> event) {
var registry = event.getRegistry();
registry.registerAll(
wrenchItem = new WrenchItem().setRegistryName("wrench"),
new Item(new Item.Properties().tab(TAB)).setRegistryName("blank_module"),
pipeFrameItem = new PipeFrameItem().setRegistryName("pipe_frame")
);
registry.registerAll(createTieredModule("extraction_module", ExtractionModuleItem::new));
registry.registerAll(createTieredModule("filter_module", FilterModuleItem::new));
registry.registerAll(createTieredModule("speed_module", SpeedModuleItem::new));
registry.registerAll(createTieredModule("low_priority_module", LowPriorityModuleItem::new));
registry.registerAll(createTieredModule("high_priority_module", HighPriorityModuleItem::new));
registry.registerAll(createTieredModule("retrieval_module", RetrievalModuleItem::new));
registry.register(new StackSizeModuleItem("stack_size_module"));
registry.registerAll(Arrays.stream(ItemEquality.Type.values()).map(t -> new FilterModifierModuleItem(t.name().toLowerCase(Locale.ROOT) + "_filter_modifier", t)).toArray(Item[]::new));
registry.register(new RedstoneModuleItem("redstone_module"));
registry.register(new FilterIncreaseModuleItem("filter_increase_modifier"));
registry.registerAll(createTieredModule("crafting_module", CraftingModuleItem::new));
registry.registerAll(Arrays.stream(SortingModuleItem.Type.values()).map(t -> new SortingModuleItem(t.name().toLowerCase(Locale.ROOT) + "_sorting_modifier", t)).toArray(Item[]::new));
ForgeRegistries.BLOCKS.getValues().stream()
.filter(b -> b.getRegistryName().getNamespace().equals(PrettyPipes.ID))
.forEach(b -> registry.register(new BlockItem(b, new Item.Properties().tab(TAB)).setRegistryName(b.getRegistryName())));
}
@SubscribeEvent
public static void registerBlockEntities(RegistryEvent.Register<BlockEntityType<?>> event) {
event.getRegistry().registerAll(
pipeBlockEntity = (BlockEntityType<PipeBlockEntity>) BlockEntityType.Builder.of(PipeBlockEntity::new, pipeBlock).build(null).setRegistryName("pipe"),
itemTerminalBlockEntity = (BlockEntityType<ItemTerminalBlockEntity>) BlockEntityType.Builder.of(ItemTerminalBlockEntity::new, itemTerminalBlock).build(null).setRegistryName("item_terminal"),
craftingTerminalBlockEntity = (BlockEntityType<CraftingTerminalBlockEntity>) BlockEntityType.Builder.of(CraftingTerminalBlockEntity::new, craftingTerminalBlock).build(null).setRegistryName("crafting_terminal"),
pressurizerBlockEntity = (BlockEntityType<PressurizerBlockEntity>) BlockEntityType.Builder.of(PressurizerBlockEntity::new, pressurizerBlock).build(null).setRegistryName("pressurizer")
);
}
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
event.getRegistry().registerAll(
pipeFrameEntity = (EntityType<PipeFrameEntity>) EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame").setRegistryName("pipe_frame")
);
}
@SubscribeEvent
public static void registerContainers(RegistryEvent.Register<MenuType<?>> event) {
event.getRegistry().registerAll(
pipeContainer = (MenuType<MainPipeContainer>) IForgeMenuType.create((windowId, inv, data) -> new MainPipeContainer(pipeContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("pipe"),
itemTerminalContainer = (MenuType<ItemTerminalContainer>) IForgeMenuType.create((windowId, inv, data) -> new ItemTerminalContainer(itemTerminalContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("item_terminal"),
craftingTerminalContainer = (MenuType<CraftingTerminalContainer>) IForgeMenuType.create((windowId, inv, data) -> new CraftingTerminalContainer(craftingTerminalContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("crafting_terminal"),
pressurizerContainer = (MenuType<PressurizerContainer>) IForgeMenuType.create((windowId, inv, data) -> new PressurizerContainer(pressurizerContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("pressurizer"),
extractionModuleContainer = createPipeContainer("extraction_module"),
filterModuleContainer = createPipeContainer("filter_module"),
retrievalModuleContainer = createPipeContainer("retrieval_module"),
stackSizeModuleContainer = createPipeContainer("stack_size_module"),
filterIncreaseModuleContainer = createPipeContainer("filter_increase_module"),
craftingModuleContainer = createPipeContainer("crafting_module"),
filterModifierModuleContainer = createPipeContainer("filter_modifier_module")
);
}
private static <T extends AbstractPipeContainer<?>> MenuType<T> createPipeContainer(String name) {
return (MenuType<T>) IForgeMenuType.create((windowId, inv, data) -> {
var tile = Utility.getBlockEntity(PipeBlockEntity.class, inv.player.level, data.readBlockPos()); var tile = Utility.getBlockEntity(PipeBlockEntity.class, inv.player.level, data.readBlockPos());
var moduleIndex = data.readInt(); var moduleIndex = data.readInt();
var moduleStack = tile.modules.getStackInSlot(moduleIndex); var moduleStack = tile.modules.getStackInSlot(moduleIndex);
return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex); return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex);
}); }).setRegistryName(name);
helper.register(new ResourceLocation(PrettyPipes.ID, name), type);
return type;
} }
private static void registerTieredModule(RegisterEvent.RegisterHelper<Item> helper, String name, BiFunction<String, ModuleTier, ModuleItem> item) { private static Item[] createTieredModule(String name, BiFunction<String, ModuleTier, ModuleItem> item) {
List<Item> items = new ArrayList<>();
for (var tier : ModuleTier.values()) for (var tier : ModuleTier.values())
helper.register(new ResourceLocation(PrettyPipes.ID, tier.name().toLowerCase(Locale.ROOT) + "_" + name), item.apply(name, tier)); items.add(item.apply(name, tier).setRegistryName(tier.name().toLowerCase(Locale.ROOT) + "_" + name));
return items.toArray(new Item[0]);
} }
public static void setup(FMLCommonSetupEvent event) { public static void setup(FMLCommonSetupEvent event) {
@ -209,21 +217,21 @@ public final class Registry {
public static final class Client { public static final class Client {
public static void setup(FMLClientSetupEvent event) { public static void setup(FMLClientSetupEvent event) {
ItemBlockRenderTypes.setRenderLayer(Registry.pipeBlock, RenderType.cutout()); ItemBlockRenderTypes.setRenderLayer(pipeBlock, RenderType.cutout());
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new); BlockEntityRenderers.register(pipeBlockEntity, PipeRenderer::new);
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new); EntityRenderers.register(pipeFrameEntity, PipeFrameRenderer::new);
MenuScreens.register(Registry.pipeContainer, MainPipeGui::new); MenuScreens.register(pipeContainer, MainPipeGui::new);
MenuScreens.register(Registry.itemTerminalContainer, ItemTerminalGui::new); MenuScreens.register(itemTerminalContainer, ItemTerminalGui::new);
MenuScreens.register(Registry.pressurizerContainer, PressurizerGui::new); MenuScreens.register(pressurizerContainer, PressurizerGui::new);
MenuScreens.register(Registry.craftingTerminalContainer, CraftingTerminalGui::new); MenuScreens.register(craftingTerminalContainer, CraftingTerminalGui::new);
MenuScreens.register(Registry.extractionModuleContainer, ExtractionModuleGui::new); MenuScreens.register(extractionModuleContainer, ExtractionModuleGui::new);
MenuScreens.register(Registry.filterModuleContainer, FilterModuleGui::new); MenuScreens.register(filterModuleContainer, FilterModuleGui::new);
MenuScreens.register(Registry.retrievalModuleContainer, RetrievalModuleGui::new); MenuScreens.register(retrievalModuleContainer, RetrievalModuleGui::new);
MenuScreens.register(Registry.stackSizeModuleContainer, StackSizeModuleGui::new); MenuScreens.register(stackSizeModuleContainer, StackSizeModuleGui::new);
MenuScreens.register(Registry.filterIncreaseModuleContainer, FilterIncreaseModuleGui::new); MenuScreens.register(filterIncreaseModuleContainer, FilterIncreaseModuleGui::new);
MenuScreens.register(Registry.craftingModuleContainer, CraftingModuleGui::new); MenuScreens.register(craftingModuleContainer, CraftingModuleGui::new);
MenuScreens.register(Registry.filterModifierModuleContainer, FilterModifierModuleGui::new); MenuScreens.register(filterModifierModuleContainer, FilterModifierModuleGui::new);
} }
} }
} }

View file

@ -7,8 +7,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.*;
import net.minecraft.network.chat.Style;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Containers; import net.minecraft.world.Containers;
@ -55,9 +54,9 @@ public final class Utility {
if (Screen.hasShiftDown()) { if (Screen.hasShiftDown()) {
var content = I18n.get("info." + PrettyPipes.ID + "." + name).split("\n"); var content = I18n.get("info." + PrettyPipes.ID + "." + name).split("\n");
for (var s : content) for (var s : content)
tooltip.add(Component.literal(s).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); tooltip.add(new TextComponent(s).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY)));
} else { } else {
tooltip.add(Component.translatable("info." + PrettyPipes.ID + ".shift").setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_GRAY))); tooltip.add(new TranslatableComponent("info." + PrettyPipes.ID + ".shift").setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_GRAY)));
} }
} }

View file

@ -1,25 +1,17 @@
package de.ellpeck.prettypipes.compat.jei; package de.ellpeck.prettypipes.compat.jei;
import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.misc.ItemEquality; import de.ellpeck.prettypipes.misc.ItemEquality;
import de.ellpeck.prettypipes.packets.PacketCraftingModuleTransfer; import de.ellpeck.prettypipes.packets.PacketCraftingModuleTransfer;
import de.ellpeck.prettypipes.packets.PacketHandler; import de.ellpeck.prettypipes.packets.PacketHandler;
import de.ellpeck.prettypipes.pipe.modules.craft.CraftingModuleContainer; import de.ellpeck.prettypipes.pipe.modules.craft.CraftingModuleContainer;
import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.gui.IRecipeLayout;
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.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.CraftingRecipe;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Optional;
public class CraftingModuleTransferHandler implements IRecipeTransferHandler<CraftingModuleContainer, CraftingRecipe> { public class CraftingModuleTransferHandler implements IRecipeTransferHandler<CraftingModuleContainer, CraftingRecipe> {
@ -29,27 +21,23 @@ public class CraftingModuleTransferHandler implements IRecipeTransferHandler<Cra
} }
@Override @Override
public Optional<MenuType<CraftingModuleContainer>> getMenuType() { public Class<CraftingRecipe> getRecipeClass() {
return Optional.of(Registry.craftingModuleContainer); return CraftingRecipe.class;
} }
@Override @Override
public RecipeType<CraftingRecipe> getRecipeType() { public IRecipeTransferError transferRecipe(CraftingModuleContainer container, CraftingRecipe recipe, IRecipeLayout recipeLayout, Player player, boolean maxTransfer, boolean doTransfer) {
return RecipeTypes.CRAFTING;
}
@Override
public @Nullable IRecipeTransferError transferRecipe(CraftingModuleContainer container, CraftingRecipe recipe, IRecipeSlotsView slots, Player player, boolean maxTransfer, boolean doTransfer) {
if (!doTransfer) if (!doTransfer)
return null; return null;
var ingredients = recipeLayout.getItemStacks().getGuiIngredients();
var inputs = new ArrayList<ItemStack>(); var inputs = new ArrayList<ItemStack>();
var outputs = new ArrayList<ItemStack>(); var outputs = new ArrayList<ItemStack>();
for (var entry : slots.getSlotViews()) { for (var entry : ingredients.entrySet()) {
var allIngredients = entry.getIngredients(VanillaTypes.ITEM_STACK).toList(); var allIngredients = entry.getValue().getAllIngredients();
if (allIngredients.isEmpty()) if (allIngredients.isEmpty())
continue; continue;
var remain = allIngredients.get(0).copy(); var remain = allIngredients.get(0).copy();
var toAdd = entry.getRole() == RecipeIngredientRole.INPUT ? inputs : outputs; var toAdd = entry.getValue().isInput() ? inputs : outputs;
for (var stack : toAdd) { for (var stack : toAdd) {
if (ItemEquality.compareItems(stack, remain)) { if (ItemEquality.compareItems(stack, remain)) {
var fits = Math.min(stack.getMaxStackSize() - stack.getCount(), remain.getCount()); var fits = Math.min(stack.getMaxStackSize() - stack.getCount(), remain.getCount());

View file

@ -1,25 +1,17 @@
package de.ellpeck.prettypipes.compat.jei; package de.ellpeck.prettypipes.compat.jei;
import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.packets.PacketGhostSlot; import de.ellpeck.prettypipes.packets.PacketGhostSlot;
import de.ellpeck.prettypipes.packets.PacketHandler; import de.ellpeck.prettypipes.packets.PacketHandler;
import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalContainer; import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalContainer;
import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.gui.IRecipeLayout;
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.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.CraftingRecipe;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import javax.annotation.Nullable;
import java.util.List; import java.util.HashMap;
import java.util.Optional; import java.util.Map;
import java.util.stream.Collectors;
public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<CraftingTerminalContainer, CraftingRecipe> { public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<CraftingTerminalContainer, CraftingRecipe> {
@ -29,23 +21,21 @@ public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<C
} }
@Override @Override
public Optional<MenuType<CraftingTerminalContainer>> getMenuType() { public Class<CraftingRecipe> getRecipeClass() {
return Optional.of(Registry.craftingTerminalContainer); return CraftingRecipe.class;
} }
@Nullable
@Override @Override
public RecipeType<CraftingRecipe> getRecipeType() { public IRecipeTransferError transferRecipe(CraftingTerminalContainer container, CraftingRecipe recipe, IRecipeLayout recipeLayout, Player player, boolean maxTransfer, boolean doTransfer) {
return RecipeTypes.CRAFTING;
}
@Override
public @Nullable IRecipeTransferError transferRecipe(CraftingTerminalContainer container, CraftingRecipe recipe, IRecipeSlotsView slots, Player player, boolean maxTransfer, boolean doTransfer) {
if (!doTransfer) if (!doTransfer)
return null; return null;
List<PacketGhostSlot.Entry> stacks = new ArrayList<>(); Map<Integer, PacketGhostSlot.Entry> stacks = new HashMap<>();
var ingredients = slots.getSlotViews(RecipeIngredientRole.INPUT); var ingredients = recipeLayout.getItemStacks().getGuiIngredients();
for (var entry : ingredients) for (var entry : ingredients.entrySet()) {
stacks.add(new PacketGhostSlot.Entry(entry.getIngredients(VanillaTypes.ITEM_STACK).collect(Collectors.toList()))); if (entry.getValue().isInput())
stacks.put(entry.getKey() - 1, new PacketGhostSlot.Entry(entry.getValue().getAllIngredients()));
}
PacketHandler.sendToServer(new PacketGhostSlot(container.getTile().getBlockPos(), stacks)); PacketHandler.sendToServer(new PacketGhostSlot(container.getTile().getBlockPos(), stacks));
return null; return null;
} }

View file

@ -5,7 +5,7 @@ import de.ellpeck.prettypipes.misc.PlayerPrefs;
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui; import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
import mezz.jei.api.IModPlugin; import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin; import mezz.jei.api.JeiPlugin;
import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.constants.VanillaRecipeCategoryUid;
import mezz.jei.api.gui.handlers.IGuiContainerHandler; import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.IRecipeTransferRegistration; import mezz.jei.api.registration.IRecipeTransferRegistration;
@ -14,11 +14,12 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.renderer.Rect2i; import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -48,7 +49,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
@Override @Override
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) { public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
registration.addRecipeTransferHandler(new CraftingTerminalTransferHandler(), RecipeTypes.CRAFTING); registration.addRecipeTransferHandler(new CraftingTerminalTransferHandler(), VanillaRecipeCategoryUid.CRAFTING);
registration.addUniversalRecipeTransferHandler(new CraftingModuleTransferHandler()); registration.addUniversalRecipeTransferHandler(new CraftingModuleTransferHandler());
} }
@ -73,7 +74,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
var screen = event.getScreen(); var screen = event.getScreen();
if (!(screen instanceof ItemTerminalGui terminal)) if (!(screen instanceof ItemTerminalGui terminal))
return; return;
terminal.addRenderableWidget(this.jeiSyncButton = new Button(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20, Component.literal(""), button -> { terminal.addRenderableWidget(this.jeiSyncButton = new Button(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20, new TextComponent(""), button -> {
var preferences = PlayerPrefs.get(); var preferences = PlayerPrefs.get();
preferences.syncJei = !preferences.syncJei; preferences.syncJei = !preferences.syncJei;
preferences.save(); preferences.save();
@ -91,14 +92,14 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
var sync = PlayerPrefs.get().syncJei; var sync = PlayerPrefs.get().syncJei;
if (event instanceof ScreenEvent.DrawScreenEvent.Post) { if (event instanceof ScreenEvent.DrawScreenEvent.Post) {
if (this.jeiSyncButton.isHoveredOrFocused()) if (this.jeiSyncButton.isHoveredOrFocused())
terminal.renderTooltip(event.getPoseStack(), Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY()); terminal.renderTooltip(event.getPoseStack(), new TranslatableComponent("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
} else if (event instanceof ScreenEvent.DrawScreenEvent.Pre) { } else if (event instanceof ScreenEvent.DrawScreenEvent.Pre) {
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J")); this.jeiSyncButton.setMessage(new TextComponent((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
} }
} }
@SubscribeEvent @SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) { public void onClientTick(ClientTickEvent event) {
if (!PlayerPrefs.get().syncJei) if (!PlayerPrefs.get().syncJei)
return; return;

View file

@ -42,7 +42,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData(); super.defineSynchedData();
this.entityData.define(PipeFrameEntity.AMOUNT, -1); this.entityData.define(AMOUNT, -1);
} }
@Override @Override
@ -53,7 +53,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
if (this.tickCount % 40 != 0) if (this.tickCount % 40 != 0)
return; return;
var network = PipeNetwork.get(this.level); var network = PipeNetwork.get(this.level);
var attached = PipeFrameEntity.getAttachedPipe(this.level, this.pos, this.direction); var attached = getAttachedPipe(this.level, this.pos, this.direction);
if (attached != null) { if (attached != null) {
var node = network.getNodeFromPipe(attached); var node = network.getNodeFromPipe(attached);
if (node != null) { if (node != null) {
@ -61,17 +61,17 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
var items = network.getOrderedNetworkItems(node); var items = network.getOrderedNetworkItems(node);
var amount = items.stream().mapToInt(i -> i.getItemAmount(this.level, stack)).sum(); var amount = items.stream().mapToInt(i -> i.getItemAmount(this.level, stack)).sum();
this.entityData.set(PipeFrameEntity.AMOUNT, amount); this.entityData.set(AMOUNT, amount);
return; return;
} }
} }
} }
this.entityData.set(PipeFrameEntity.AMOUNT, -1); this.entityData.set(AMOUNT, -1);
} }
@Override @Override
public boolean survives() { public boolean survives() {
return super.survives() && PipeFrameEntity.canPlace(this.level, this.pos, this.direction); return super.survives() && canPlace(this.level, this.pos, this.direction);
} }
private static BlockPos getAttachedPipe(Level world, BlockPos pos, Direction direction) { private static BlockPos getAttachedPipe(Level world, BlockPos pos, Direction direction) {
@ -85,11 +85,11 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
} }
public static boolean canPlace(Level world, BlockPos pos, Direction direction) { public static boolean canPlace(Level world, BlockPos pos, Direction direction) {
return PipeFrameEntity.getAttachedPipe(world, pos, direction) != null; return getAttachedPipe(world, pos, direction) != null;
} }
public int getAmount() { public int getAmount() {
return this.entityData.get(PipeFrameEntity.AMOUNT); return this.entityData.get(AMOUNT);
} }
@Override @Override

View file

@ -15,7 +15,6 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
@ -66,6 +65,6 @@ public class PipeFrameItem extends Item {
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) { public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn); super.appendHoverText(stack, worldIn, tooltip, flagIn);
Utility.addTooltip(ForgeRegistries.ITEMS.getKey(this).getPath(), tooltip); Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
} }
} }

View file

@ -20,7 +20,6 @@ import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.List; import java.util.List;
@ -109,7 +108,7 @@ public class WrenchItem extends Item {
@Override @Override
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) { public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
Utility.addTooltip(ForgeRegistries.ITEMS.getKey(this).getPath(), tooltip); Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
} }
@Override @Override

View file

@ -3,7 +3,7 @@ package de.ellpeck.prettypipes.misc;
import de.ellpeck.prettypipes.PrettyPipes; import de.ellpeck.prettypipes.PrettyPipes;
import de.ellpeck.prettypipes.network.PipeNetwork; import de.ellpeck.prettypipes.network.PipeNetwork;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent;
@ -33,9 +33,9 @@ public final class Events {
var dump = PipeNetwork.get(source.getLevel()).toString(); var dump = PipeNetwork.get(source.getLevel()).toString();
try { try {
Files.writeString(file, dump, StandardCharsets.UTF_8); Files.writeString(file, dump, StandardCharsets.UTF_8);
source.sendSuccess(Component.literal("Wrote network dump to file " + file.toAbsolutePath()), true); source.sendSuccess(new TextComponent("Wrote network dump to file " + file.toAbsolutePath()), true);
} catch (IOException e) { } catch (IOException e) {
source.sendFailure(Component.literal("Failed to write network dump to file " + file.toAbsolutePath())); source.sendFailure(new TextComponent("Failed to write network dump to file " + file.toAbsolutePath()));
return -1; return -1;
} }
return 0; return 0;
@ -43,13 +43,13 @@ public final class Events {
.then(Commands.literal("uncache").executes(c -> { .then(Commands.literal("uncache").executes(c -> {
var source = c.getSource(); var source = c.getSource();
PipeNetwork.get(source.getLevel()).clearCaches(); PipeNetwork.get(source.getLevel()).clearCaches();
source.sendSuccess(Component.literal("Cleared all pipe caches in the world"), true); source.sendSuccess(new TextComponent("Cleared all pipe caches in the world"), true);
return 0; return 0;
})) }))
.then(Commands.literal("unlock").executes(c -> { .then(Commands.literal("unlock").executes(c -> {
var source = c.getSource(); var source = c.getSource();
PipeNetwork.get(source.getLevel()).unlock(); PipeNetwork.get(source.getLevel()).unlock();
source.sendSuccess(Component.literal("Resolved all network locks in the world"), true); source.sendSuccess(new TextComponent("Resolved all network locks in the world"), true);
return 0; return 0;
}))); })));
} }

View file

@ -11,7 +11,7 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.inventory.Slot; import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -51,17 +51,17 @@ public class ItemFilter extends ItemStackHandler {
public List<AbstractWidget> getButtons(Screen gui, int x, int y) { public List<AbstractWidget> getButtons(Screen gui, int x, int y) {
List<AbstractWidget> buttons = new ArrayList<>(); List<AbstractWidget> buttons = new ArrayList<>();
if (this.canModifyWhitelist) { if (this.canModifyWhitelist) {
Supplier<Component> whitelistText = () -> Component.translatable("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist")); var whitelistText = (Supplier<TranslatableComponent>) () -> new TranslatableComponent("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist"));
buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> { buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> {
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0); PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
button.setMessage(whitelistText.get()); button.setMessage(whitelistText.get());
})); }));
} }
if (this.canPopulateFromInventories) { if (this.canPopulateFromInventories) {
buttons.add(new Button(x + 72, y, 70, 20, Component.translatable("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) { buttons.add(new Button(x + 72, y, 70, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
@Override @Override
public void renderToolTip(PoseStack matrix, int x, int y) { public void renderToolTip(PoseStack matrix, int x, int y) {
gui.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y); gui.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y);
} }
}); });
} }
@ -107,7 +107,7 @@ public class ItemFilter extends ItemStackHandler {
} }
private boolean isFiltered(ItemStack stack) { private boolean isFiltered(ItemStack stack) {
var types = ItemFilter.getEqualityTypes(this.pipe); var types = getEqualityTypes(this.pipe);
// also check if any filter increase modules have the item we need // also check if any filter increase modules have the item we need
for (ItemStackHandler handler : this.pipe.getFilters()) { for (ItemStackHandler handler : this.pipe.getFilters()) {
for (var i = 0; i < handler.getSlots(); i++) { for (var i = 0; i < handler.getSlots(); i++) {
@ -164,7 +164,6 @@ public class ItemFilter extends ItemStackHandler {
ItemFilter getFilter(); ItemFilter getFilter();
default void onFilterPopulated() { default void onFilterPopulated() {}
}
} }
} }

View file

@ -16,6 +16,6 @@ public enum ItemOrder {
} }
public ItemOrder next() { public ItemOrder next() {
return ItemOrder.values()[(this.ordinal() + 1) % ItemOrder.values().length]; return values()[(this.ordinal() + 1) % values().length];
} }
} }

View file

@ -4,11 +4,9 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui; import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import java.util.Optional; import java.util.Optional;
@ -23,7 +21,7 @@ public class ItemTerminalWidget extends AbstractWidget {
public boolean craftable; public boolean craftable;
public ItemTerminalWidget(int xIn, int yIn, int gridX, int gridY, ItemTerminalGui screen) { public ItemTerminalWidget(int xIn, int yIn, int gridX, int gridY, ItemTerminalGui screen) {
super(xIn, yIn, 16, 16, Component.literal("")); super(xIn, yIn, 16, 16, new TextComponent(""));
this.gridX = gridX; this.gridX = gridX;
this.gridY = gridY; this.gridY = gridY;
this.screen = screen; this.screen = screen;
@ -43,7 +41,7 @@ public class ItemTerminalWidget extends AbstractWidget {
this.setBlitOffset(100); this.setBlitOffset(100);
renderer.blitOffset = 100; renderer.blitOffset = 100;
if (this.selected) if (this.selected)
GuiComponent.fill(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433); fill(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433);
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
renderer.renderGuiItem(this.stack, this.x, this.y); renderer.renderGuiItem(this.stack, this.x, this.y);
var amount = !this.craftable ? this.stack.getCount() : 0; var amount = !this.craftable ? this.stack.getCount() : 0;
@ -67,8 +65,8 @@ public class ItemTerminalWidget extends AbstractWidget {
var tooltip = this.screen.getTooltipFromItem(this.stack); var tooltip = this.screen.getTooltipFromItem(this.stack);
if (this.stack.getCount() >= 1000) { if (this.stack.getCount() >= 1000) {
var comp = tooltip.get(0); var comp = tooltip.get(0);
if (comp instanceof MutableComponent m) { if (comp instanceof TextComponent text) {
tooltip.set(0, m.append(Component.literal(" (" + this.stack.getCount() + ')').withStyle(ChatFormatting.BOLD))); tooltip.set(0, text.append(new TextComponent(" (" + this.stack.getCount() + ')').withStyle(ChatFormatting.BOLD)));
} }
} }
this.screen.renderTooltip(matrix, tooltip, Optional.empty(), mouseX, mouseY); this.screen.renderTooltip(matrix, tooltip, Optional.empty(), mouseX, mouseY);

View file

@ -20,30 +20,30 @@ public class PlayerPrefs {
public boolean syncJei = true; public boolean syncJei = true;
public void save() { public void save() {
var file = PlayerPrefs.getFile(); var file = getFile();
if (file.exists()) if (file.exists())
file.delete(); file.delete();
try (var writer = new FileWriter(file)) { try (var writer = new FileWriter(file)) {
PlayerPrefs.GSON.toJson(this, writer); GSON.toJson(this, writer);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static PlayerPrefs get() { public static PlayerPrefs get() {
if (PlayerPrefs.instance == null) { if (instance == null) {
var file = PlayerPrefs.getFile(); var file = getFile();
if (file.exists()) { if (file.exists()) {
try (var reader = new FileReader(file)) { try (var reader = new FileReader(file)) {
PlayerPrefs.instance = PlayerPrefs.GSON.fromJson(reader, PlayerPrefs.class); instance = GSON.fromJson(reader, PlayerPrefs.class);
return PlayerPrefs.instance; return instance;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
PlayerPrefs.instance = new PlayerPrefs(); instance = new PlayerPrefs();
} }
return PlayerPrefs.instance; return instance;
} }
private static File getFile() { private static File getFile() {

View file

@ -3,9 +3,7 @@ package de.ellpeck.prettypipes.network;
import de.ellpeck.prettypipes.misc.EquatableItemStack; import de.ellpeck.prettypipes.misc.EquatableItemStack;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
public class NetworkItem { public class NetworkItem {

View file

@ -1,11 +1,12 @@
package de.ellpeck.prettypipes.network; package de.ellpeck.prettypipes.network;
import de.ellpeck.prettypipes.misc.ItemEquality; import de.ellpeck.prettypipes.misc.ItemEquality;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@ -101,6 +102,6 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
@Override @Override
public void deserializeNBT(CompoundTag nbt) { public void deserializeNBT(CompoundTag nbt) {
this.pipePos = NbtUtils.readBlockPos(nbt.getCompound("pipe_pos")); this.pipePos = NbtUtils.readBlockPos(nbt.getCompound("pipe_pos"));
this.direction = Direction.values()[nbt.getInt("direction")]; this.direction = Direction.values()[(nbt.getInt("direction"))];
} }
} }

View file

@ -60,7 +60,7 @@ public class PipeItem implements IPipeItem {
} }
public PipeItem(ItemStack stack, float speed) { public PipeItem(ItemStack stack, float speed) {
this(PipeItem.TYPE, stack, speed); this(TYPE, stack, speed);
} }
public PipeItem(ResourceLocation type, CompoundTag nbt) { public PipeItem(ResourceLocation type, CompoundTag nbt) {
@ -78,7 +78,7 @@ public class PipeItem implements IPipeItem {
public void setDestination(BlockPos startInventory, BlockPos destInventory, GraphPath<BlockPos, NetworkEdge> path) { public void setDestination(BlockPos startInventory, BlockPos destInventory, GraphPath<BlockPos, NetworkEdge> path) {
this.startInventory = startInventory; this.startInventory = startInventory;
this.destInventory = destInventory; this.destInventory = destInventory;
this.path = PipeItem.compilePath(path); this.path = compilePath(path);
this.currGoalPos = this.getStartPipe(); this.currGoalPos = this.getStartPipe();
this.currentTile = 0; this.currentTile = 0;
@ -126,7 +126,7 @@ public class PipeItem implements IPipeItem {
currPipe = next; currPipe = next;
} }
} else { } else {
var dist = this.currGoalPos.distToLowCornerSqr(this.x - 0.5F, this.y - 0.5F, this.z - 0.5F); var dist = (this.currGoalPos).distToLowCornerSqr(this.x - 0.5F, this.y - 0.5F, this.z - 0.5F);
if (dist < currSpeed * currSpeed) { if (dist < currSpeed * currSpeed) {
// we're past the start of the pipe, so move to the center of the next pipe // we're past the start of the pipe, so move to the center of the next pipe
BlockPos nextPos; BlockPos nextPos;

View file

@ -53,8 +53,8 @@ public class PacketCraftingModuleTransfer {
public void run() { public void run() {
Player player = ctx.get().getSender(); Player player = ctx.get().getSender();
if (player.containerMenu instanceof CraftingModuleContainer container) { if (player.containerMenu instanceof CraftingModuleContainer container) {
PacketCraftingModuleTransfer.copy(container.input, message.inputs); copy(container.input, message.inputs);
PacketCraftingModuleTransfer.copy(container.output, message.outputs); copy(container.output, message.outputs);
container.modified = true; container.modified = true;
container.broadcastChanges(); container.broadcastChanges();
} }

View file

@ -17,7 +17,9 @@ import net.minecraft.world.item.Items;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -25,9 +27,9 @@ import java.util.stream.Collectors;
public class PacketGhostSlot { public class PacketGhostSlot {
private BlockPos pos; private BlockPos pos;
private List<Entry> stacks; private Map<Integer, Entry> stacks;
public PacketGhostSlot(BlockPos pos, List<Entry> stacks) { public PacketGhostSlot(BlockPos pos, Map<Integer, Entry> stacks) {
this.pos = pos; this.pos = pos;
this.stacks = stacks; this.stacks = stacks;
} }
@ -39,17 +41,19 @@ public class PacketGhostSlot {
public static PacketGhostSlot fromBytes(FriendlyByteBuf buf) { public static PacketGhostSlot fromBytes(FriendlyByteBuf buf) {
var packet = new PacketGhostSlot(); var packet = new PacketGhostSlot();
packet.pos = buf.readBlockPos(); packet.pos = buf.readBlockPos();
packet.stacks = new ArrayList<>(); packet.stacks = new HashMap<>();
for (var i = buf.readInt(); i > 0; i--) for (var i = buf.readInt(); i > 0; i--)
packet.stacks.add(new Entry(buf)); packet.stacks.put(buf.readInt(), new Entry(buf));
return packet; return packet;
} }
public static void toBytes(PacketGhostSlot packet, FriendlyByteBuf buf) { public static void toBytes(PacketGhostSlot packet, FriendlyByteBuf buf) {
buf.writeBlockPos(packet.pos); buf.writeBlockPos(packet.pos);
buf.writeInt(packet.stacks.size()); buf.writeInt(packet.stacks.size());
for (var entry : packet.stacks) for (var entry : packet.stacks.entrySet()) {
entry.write(buf); buf.writeInt(entry.getKey());
entry.getValue().write(buf);
}
} }
@SuppressWarnings("Convert2Lambda") @SuppressWarnings("Convert2Lambda")
@ -89,7 +93,7 @@ public class PacketGhostSlot {
private final TagKey<Item> tag; private final TagKey<Item> tag;
public Entry(List<ItemStack> stacks) { public Entry(List<ItemStack> stacks) {
var tag = Entry.getTagForStacks(stacks); var tag = getTagForStacks(stacks);
if (tag != null) { if (tag != null) {
this.stacks = null; this.stacks = null;
this.tag = tag; this.tag = tag;

View file

@ -16,24 +16,24 @@ public final class PacketHandler {
private static SimpleChannel network; private static SimpleChannel network;
public static void setup() { public static void setup() {
PacketHandler.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(PrettyPipes.ID, "network"), () -> PacketHandler.VERSION, PacketHandler.VERSION::equals, PacketHandler.VERSION::equals); network = NetworkRegistry.newSimpleChannel(new ResourceLocation(PrettyPipes.ID, "network"), () -> VERSION, VERSION::equals, VERSION::equals);
PacketHandler.network.registerMessage(0, PacketItemEnterPipe.class, PacketItemEnterPipe::toBytes, PacketItemEnterPipe::fromBytes, PacketItemEnterPipe::onMessage); network.registerMessage(0, PacketItemEnterPipe.class, PacketItemEnterPipe::toBytes, PacketItemEnterPipe::fromBytes, PacketItemEnterPipe::onMessage);
PacketHandler.network.registerMessage(1, PacketButton.class, PacketButton::toBytes, PacketButton::fromBytes, PacketButton::onMessage); network.registerMessage(1, PacketButton.class, PacketButton::toBytes, PacketButton::fromBytes, PacketButton::onMessage);
PacketHandler.network.registerMessage(2, PacketNetworkItems.class, PacketNetworkItems::toBytes, PacketNetworkItems::fromBytes, PacketNetworkItems::onMessage); network.registerMessage(2, PacketNetworkItems.class, PacketNetworkItems::toBytes, PacketNetworkItems::fromBytes, PacketNetworkItems::onMessage);
PacketHandler.network.registerMessage(3, PacketRequest.class, PacketRequest::toBytes, PacketRequest::fromBytes, PacketRequest::onMessage); network.registerMessage(3, PacketRequest.class, PacketRequest::toBytes, PacketRequest::fromBytes, PacketRequest::onMessage);
PacketHandler.network.registerMessage(4, PacketGhostSlot.class, PacketGhostSlot::toBytes, PacketGhostSlot::fromBytes, PacketGhostSlot::onMessage); network.registerMessage(4, PacketGhostSlot.class, PacketGhostSlot::toBytes, PacketGhostSlot::fromBytes, PacketGhostSlot::onMessage);
PacketHandler.network.registerMessage(5, PacketCraftingModuleTransfer.class, PacketCraftingModuleTransfer::toBytes, PacketCraftingModuleTransfer::fromBytes, PacketCraftingModuleTransfer::onMessage); network.registerMessage(5, PacketCraftingModuleTransfer.class, PacketCraftingModuleTransfer::toBytes, PacketCraftingModuleTransfer::fromBytes, PacketCraftingModuleTransfer::onMessage);
} }
public static void sendToAllLoaded(Level world, BlockPos pos, Object message) { public static void sendToAllLoaded(Level world, BlockPos pos, Object message) {
PacketHandler.network.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), message); network.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), message);
} }
public static void sendTo(Player player, Object message) { public static void sendTo(Player player, Object message) {
PacketHandler.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message); network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message);
} }
public static void sendToServer(Object message) { public static void sendToServer(Object message) {
PacketHandler.network.send(PacketDistributor.SERVER.noArg(), message); network.send(PacketDistributor.SERVER.noArg(), message);
} }
} }

View file

@ -5,9 +5,9 @@ import de.ellpeck.prettypipes.network.NetworkEdge;
import de.ellpeck.prettypipes.network.PipeItem; import de.ellpeck.prettypipes.network.PipeItem;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -46,7 +46,7 @@ public interface IPipeItem extends INBTSerializable<CompoundTag> {
static IPipeItem load(CompoundTag nbt) { static IPipeItem load(CompoundTag nbt) {
var type = new ResourceLocation(nbt.getString("type")); var type = new ResourceLocation(nbt.getString("type"));
var func = IPipeItem.TYPES.get(type); var func = TYPES.get(type);
return func != null ? func.apply(type, nbt) : null; return func != null ? func.apply(type, nbt) : null;
} }
} }

View file

@ -50,26 +50,26 @@ public class PipeBlock extends BaseEntityBlock {
public static final Map<Direction, EnumProperty<ConnectionType>> DIRECTIONS = new HashMap<>(); public static final Map<Direction, EnumProperty<ConnectionType>> DIRECTIONS = new HashMap<>();
private static final Map<Pair<BlockState, BlockState>, VoxelShape> SHAPE_CACHE = new HashMap<>(); private static final Map<Pair<BlockState, BlockState>, VoxelShape> SHAPE_CACHE = new HashMap<>();
private static final Map<Pair<BlockState, BlockState>, VoxelShape> COLL_SHAPE_CACHE = new HashMap<>(); private static final Map<Pair<BlockState, BlockState>, VoxelShape> COLL_SHAPE_CACHE = new HashMap<>();
private static final VoxelShape CENTER_SHAPE = Block.box(5, 5, 5, 11, 11, 11); private static final VoxelShape CENTER_SHAPE = box(5, 5, 5, 11, 11, 11);
public static final Map<Direction, VoxelShape> DIR_SHAPES = ImmutableMap.<Direction, VoxelShape>builder() public static final Map<Direction, VoxelShape> DIR_SHAPES = ImmutableMap.<Direction, VoxelShape>builder()
.put(Direction.UP, Block.box(5, 10, 5, 11, 16, 11)) .put(Direction.UP, box(5, 10, 5, 11, 16, 11))
.put(Direction.DOWN, Block.box(5, 0, 5, 11, 6, 11)) .put(Direction.DOWN, box(5, 0, 5, 11, 6, 11))
.put(Direction.NORTH, Block.box(5, 5, 0, 11, 11, 6)) .put(Direction.NORTH, box(5, 5, 0, 11, 11, 6))
.put(Direction.SOUTH, Block.box(5, 5, 10, 11, 11, 16)) .put(Direction.SOUTH, box(5, 5, 10, 11, 11, 16))
.put(Direction.EAST, Block.box(10, 5, 5, 16, 11, 11)) .put(Direction.EAST, box(10, 5, 5, 16, 11, 11))
.put(Direction.WEST, Block.box(0, 5, 5, 6, 11, 11)) .put(Direction.WEST, box(0, 5, 5, 6, 11, 11))
.build(); .build();
static { static {
for (var dir : Direction.values()) for (var dir : Direction.values())
PipeBlock.DIRECTIONS.put(dir, EnumProperty.create(dir.getName(), ConnectionType.class)); DIRECTIONS.put(dir, EnumProperty.create(dir.getName(), ConnectionType.class));
} }
public PipeBlock() { public PipeBlock() {
super(Block.Properties.of(Material.STONE).strength(2).sound(SoundType.STONE).noOcclusion()); super(Block.Properties.of(Material.STONE).strength(2).sound(SoundType.STONE).noOcclusion());
var state = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false); var state = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false);
for (var prop : PipeBlock.DIRECTIONS.values()) for (var prop : DIRECTIONS.values())
state = state.setValue(prop, ConnectionType.DISCONNECTED); state = state.setValue(prop, ConnectionType.DISCONNECTED);
this.registerDefaultState(state); this.registerDefaultState(state);
} }
@ -100,7 +100,7 @@ public class PipeBlock extends BaseEntityBlock {
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(PipeBlock.DIRECTIONS.values().toArray(new EnumProperty[0])); builder.add(DIRECTIONS.values().toArray(new EnumProperty[0]));
builder.add(BlockStateProperties.WATERLOGGED); builder.add(BlockStateProperties.WATERLOGGED);
} }
@ -114,7 +114,7 @@ public class PipeBlock extends BaseEntityBlock {
var newState = this.createState(worldIn, pos, state); var newState = this.createState(worldIn, pos, state);
if (newState != state) { if (newState != state) {
worldIn.setBlockAndUpdate(pos, newState); worldIn.setBlockAndUpdate(pos, newState);
PipeBlock.onStateChanged(worldIn, pos, newState); onStateChanged(worldIn, pos, newState);
} }
} }
@ -133,17 +133,17 @@ public class PipeBlock extends BaseEntityBlock {
@Override @Override
public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
PipeBlock.onStateChanged(worldIn, pos, state); onStateChanged(worldIn, pos, state);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return this.cacheAndGetShape(state, worldIn, pos, s -> s.getShape(worldIn, pos, context), PipeBlock.SHAPE_CACHE, null); return this.cacheAndGetShape(state, worldIn, pos, s -> s.getShape(worldIn, pos, context), SHAPE_CACHE, null);
} }
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return this.cacheAndGetShape(state, worldIn, pos, s -> s.getCollisionShape(worldIn, pos, context), PipeBlock.COLL_SHAPE_CACHE, s -> { return this.cacheAndGetShape(state, worldIn, pos, s -> s.getCollisionShape(worldIn, pos, context), COLL_SHAPE_CACHE, s -> {
// make the shape a bit higher so we can jump up onto a higher block // make the shape a bit higher so we can jump up onto a higher block
var newShape = new MutableObject<VoxelShape>(Shapes.empty()); var newShape = new MutableObject<VoxelShape>(Shapes.empty());
s.forAllBoxes((x1, y1, z1, x2, y2, z2) -> newShape.setValue(Shapes.join(Shapes.create(x1, y1, z1, x2, y2 + 3 / 16F, z2), newShape.getValue(), BooleanOp.OR))); s.forAllBoxes((x1, y1, z1, x2, y2, z2) -> newShape.setValue(Shapes.join(Shapes.create(x1, y1, z1, x2, y2 + 3 / 16F, z2), newShape.getValue(), BooleanOp.OR)));
@ -166,10 +166,10 @@ public class PipeBlock extends BaseEntityBlock {
var key = Pair.of(state, cover); var key = Pair.of(state, cover);
var shape = cache.get(key); var shape = cache.get(key);
if (shape == null) { if (shape == null) {
shape = PipeBlock.CENTER_SHAPE; shape = CENTER_SHAPE;
for (var entry : PipeBlock.DIRECTIONS.entrySet()) { for (var entry : DIRECTIONS.entrySet()) {
if (state.getValue(entry.getValue()).isConnected()) if (state.getValue(entry.getValue()).isConnected())
shape = Shapes.or(shape, PipeBlock.DIR_SHAPES.get(entry.getKey())); shape = Shapes.or(shape, DIR_SHAPES.get(entry.getKey()));
} }
if (shapeModifier != null) if (shapeModifier != null)
shape = shapeModifier.apply(shape); shape = shapeModifier.apply(shape);
@ -187,7 +187,7 @@ public class PipeBlock extends BaseEntityBlock {
state = state.setValue(BlockStateProperties.WATERLOGGED, true); state = state.setValue(BlockStateProperties.WATERLOGGED, true);
for (var dir : Direction.values()) { for (var dir : Direction.values()) {
var prop = PipeBlock.DIRECTIONS.get(dir); var prop = DIRECTIONS.get(dir);
var type = this.getConnectionType(world, pos, dir, state); var type = this.getConnectionType(world, pos, dir, state);
// don't reconnect on blocked faces // don't reconnect on blocked faces
if (type.isConnected() && curr.getValue(prop) == ConnectionType.BLOCKED) if (type.isConnected() && curr.getValue(prop) == ConnectionType.BLOCKED)
@ -215,8 +215,8 @@ public class PipeBlock extends BaseEntityBlock {
if (blockHandler != null) if (blockHandler != null)
return ConnectionType.CONNECTED; return ConnectionType.CONNECTED;
var offState = world.getBlockState(offset); var offState = world.getBlockState(offset);
if (PipeBlock.hasLegsTo(world, offState, offset, direction)) { if (hasLegsTo(world, offState, offset, direction)) {
if (PipeBlock.DIRECTIONS.values().stream().noneMatch(d -> state.getValue(d) == ConnectionType.LEGS)) if (DIRECTIONS.values().stream().noneMatch(d -> state.getValue(d) == ConnectionType.LEGS))
return ConnectionType.LEGS; return ConnectionType.LEGS;
} }
return ConnectionType.DISCONNECTED; return ConnectionType.DISCONNECTED;
@ -226,7 +226,7 @@ public class PipeBlock extends BaseEntityBlock {
if (state.getBlock() instanceof WallBlock || state.getBlock() instanceof FenceBlock) if (state.getBlock() instanceof WallBlock || state.getBlock() instanceof FenceBlock)
return direction == Direction.DOWN; return direction == Direction.DOWN;
if (state.getMaterial() == Material.STONE || state.getMaterial() == Material.METAL) if (state.getMaterial() == Material.STONE || state.getMaterial() == Material.METAL)
return Block.canSupportCenter(world, pos, direction.getOpposite()); return canSupportCenter(world, pos, direction.getOpposite());
return false; return false;
} }
@ -240,7 +240,7 @@ public class PipeBlock extends BaseEntityBlock {
var connections = 0; var connections = 0;
var force = false; var force = false;
for (var dir : Direction.values()) { for (var dir : Direction.values()) {
var value = newState.getValue(PipeBlock.DIRECTIONS.get(dir)); var value = newState.getValue(DIRECTIONS.get(dir));
if (!value.isConnected()) if (!value.isConnected())
continue; continue;
connections++; connections++;
@ -271,7 +271,7 @@ public class PipeBlock extends BaseEntityBlock {
@Override @Override
public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) { public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) {
PipeBlock.dropItems(worldIn, pos, player); dropItems(worldIn, pos, player);
super.playerWillDestroy(worldIn, pos, state, player); super.playerWillDestroy(worldIn, pos, state, player);
} }
@ -302,7 +302,7 @@ public class PipeBlock extends BaseEntityBlock {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return BaseEntityBlock.createTickerHelper(type, Registry.pipeBlockEntity, PipeBlockEntity::tick); return createTickerHelper(type, Registry.pipeBlockEntity, PipeBlockEntity::tick);
} }
public static void dropItems(Level worldIn, BlockPos pos, Player player) { public static void dropItems(Level worldIn, BlockPos pos, Player player) {

View file

@ -17,6 +17,7 @@ import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.Connection; import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Containers; import net.minecraft.world.Containers;
@ -381,7 +382,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.translatable("container." + PrettyPipes.ID + ".pipe"); return new TranslatableComponent("container." + PrettyPipes.ID + ".pipe");
} }
@Nullable @Nullable

View file

@ -7,9 +7,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.util.RandomSource;
import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer; import net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer;
import java.util.Random; import java.util.Random;
@ -42,7 +40,7 @@ public class PipeRenderer implements BlockEntityRenderer<PipeBlockEntity> {
if (!ItemBlockRenderTypes.canRenderInLayer(tile.cover, layer)) if (!ItemBlockRenderTypes.canRenderInLayer(tile.cover, layer))
continue; continue;
ForgeHooksClient.setRenderType(layer); ForgeHooksClient.setRenderType(layer);
renderer.getModelRenderer().tesselateBlock(tile.getLevel(), renderer.getBlockModel(tile.cover), tile.cover, tile.getBlockPos(), matrixStack, source.getBuffer(layer), true, RandomSource.create(), tile.cover.getSeed(tile.getBlockPos()), overlay, EmptyModelData.INSTANCE); renderer.getModelRenderer().tesselateBlock(tile.getLevel(), renderer.getBlockModel(tile.cover), tile.cover, tile.getBlockPos(), matrixStack, source.getBuffer(layer), true, new Random(), tile.cover.getSeed(tile.getBlockPos()), overlay);
} }
ForgeHooksClient.setRenderType(null); ForgeHooksClient.setRenderType(null);
ForgeBlockModelRenderer.clearCache(); ForgeBlockModelRenderer.clearCache();

View file

@ -79,7 +79,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
@Override @Override
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) { protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE); RenderSystem.setShaderTexture(0, TEXTURE);
this.blit(matrix, this.leftPos, this.topPos + 32, 0, 0, 176, 171); this.blit(matrix, this.leftPos, this.topPos + 32, 0, 0, 176, 171);
for (var tab : this.tabs) for (var tab : this.tabs)
@ -143,7 +143,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
AbstractPipeGui.this.itemRenderer.renderGuiItem(this.moduleStack, this.x + 6, this.y + itemOffset); AbstractPipeGui.this.itemRenderer.renderGuiItem(this.moduleStack, this.x + 6, this.y + itemOffset);
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE); RenderSystem.setShaderTexture(0, TEXTURE);
} }
private void drawForeground(PoseStack matrix, int mouseX, int mouseY) { private void drawForeground(PoseStack matrix, int mouseX, int mouseY) {

View file

@ -7,7 +7,6 @@ import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class HighPriorityModuleItem extends ModuleItem { public class HighPriorityModuleItem extends ModuleItem {
private final int priority; private final int priority;
public HighPriorityModuleItem(String name, ModuleTier tier) { public HighPriorityModuleItem(String name, ModuleTier tier) {

View file

@ -7,7 +7,6 @@ import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class LowPriorityModuleItem extends ModuleItem { public class LowPriorityModuleItem extends ModuleItem {
private final int priority; private final int priority;
public LowPriorityModuleItem(String name, ModuleTier tier) { public LowPriorityModuleItem(String name, ModuleTier tier) {

View file

@ -7,8 +7,9 @@ import net.minecraft.world.item.ItemStack;
public class RedstoneModuleItem extends ModuleItem { public class RedstoneModuleItem extends ModuleItem {
public RedstoneModuleItem() { public RedstoneModuleItem(String name) {
super("redstone_module"); super(name);
this.setRegistryName(name);
} }
@Override @Override

View file

@ -15,6 +15,7 @@ public class SortingModuleItem extends ModuleItem {
public SortingModuleItem(String name, Type type) { public SortingModuleItem(String name, Type type) {
super(name); super(name);
this.type = type; this.type = type;
this.setRegistryName(name);
} }
@Override @Override

View file

@ -7,7 +7,6 @@ import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class SpeedModuleItem extends ModuleItem { public class SpeedModuleItem extends ModuleItem {
private final float speedIncrease; private final float speedIncrease;
public SpeedModuleItem(String name, ModuleTier tier) { public SpeedModuleItem(String name, ModuleTier tier) {

View file

@ -17,7 +17,7 @@ public class CraftingModuleGui extends AbstractPipeGui<CraftingModuleContainer>
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) { protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
super.renderBg(matrix, partialTicks, mouseX, mouseY); super.renderBg(matrix, partialTicks, mouseX, mouseY);
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE); RenderSystem.setShaderTexture(0, TEXTURE);
this.blit(matrix, this.leftPos + 176 / 2 - 16 / 2, this.topPos + 32 + 18 * 2, 176, 80, 16, 16); this.blit(matrix, this.leftPos + 176 / 2 - 16 / 2, this.topPos + 32 + 18 * 2, 176, 80, 16, 16);
} }
} }

View file

@ -147,7 +147,7 @@ public class CraftingModuleItem extends ModuleItem {
var out = output.getStackInSlot(i); var out = output.getStackInSlot(i);
if (!out.isEmpty() && ItemEquality.compareItems(out, stack, equalityTypes)) { if (!out.isEmpty() && ItemEquality.compareItems(out, stack, equalityTypes)) {
// figure out how many crafting operations we can actually do with the input items we have in the network // figure out how many crafting operations we can actually do with the input items we have in the network
var availableCrafts = CraftingTerminalBlockEntity.getAvailableCrafts(tile, input.getSlots(), input::getStackInSlot, k -> true, s -> items, unavailableConsumer, CraftingModuleItem.addDependency(dependencyChain, module), equalityTypes); var availableCrafts = CraftingTerminalBlockEntity.getAvailableCrafts(tile, input.getSlots(), input::getStackInSlot, k -> true, s -> items, unavailableConsumer, addDependency(dependencyChain, module), equalityTypes);
if (availableCrafts > 0) if (availableCrafts > 0)
craftable += out.getCount() * availableCrafts; craftable += out.getCount() * availableCrafts;
} }
@ -179,7 +179,7 @@ public class CraftingModuleItem extends ModuleItem {
continue; continue;
var copy = in.copy(); var copy = in.copy();
copy.setCount(in.getCount() * toCraft); copy.setCount(in.getCount() * toCraft);
var ret = ItemTerminalBlockEntity.requestItemLater(tile.getLevel(), tile.getBlockPos(), items, unavailableConsumer, copy, CraftingModuleItem.addDependency(dependencyChain, module), equalityTypes); var ret = ItemTerminalBlockEntity.requestItemLater(tile.getLevel(), tile.getBlockPos(), items, unavailableConsumer, copy, addDependency(dependencyChain, module), equalityTypes);
tile.craftIngredientRequests.addAll(ret.getLeft()); tile.craftIngredientRequests.addAll(ret.getLeft());
} }

View file

@ -5,6 +5,7 @@ import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
public class FilterIncreaseModuleContainer extends AbstractPipeContainer<FilterIncreaseModuleItem> implements ItemFilter.IFilteredContainer { public class FilterIncreaseModuleContainer extends AbstractPipeContainer<FilterIncreaseModuleItem> implements ItemFilter.IFilteredContainer {

View file

@ -12,8 +12,9 @@ import net.minecraft.world.item.ItemStack;
public class FilterIncreaseModuleItem extends ModuleItem { public class FilterIncreaseModuleItem extends ModuleItem {
public FilterIncreaseModuleItem() { public FilterIncreaseModuleItem(String name) {
super("filter_increase_modifier"); super(name);
this.setRegistryName(name);
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package de.ellpeck.prettypipes.pipe.modules.insertion; package de.ellpeck.prettypipes.pipe.modules.insertion;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;

View file

@ -126,7 +126,7 @@ public class FilterModifierModuleGui extends AbstractPipeGui<FilterModifierModul
text = ChatFormatting.BOLD + text; text = ChatFormatting.BOLD + text;
FilterModifierModuleGui.this.font.draw(matrix, text, this.x, this.y, color); FilterModifierModuleGui.this.font.draw(matrix, text, this.x, this.y, color);
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE); RenderSystem.setShaderTexture(0, TEXTURE);
} }
private boolean onClicked(double mouseX, double mouseY, int button) { private boolean onClicked(double mouseX, double mouseY, int button) {

View file

@ -19,6 +19,7 @@ public class FilterModifierModuleItem extends ModuleItem {
public FilterModifierModuleItem(String name, ItemEquality.Type type) { public FilterModifierModuleItem(String name, ItemEquality.Type type) {
super(name); super(name);
this.type = type; this.type = type;
this.setRegistryName(name);
} }
@Override @Override
@ -38,7 +39,7 @@ public class FilterModifierModuleItem extends ModuleItem {
public ItemEquality getEqualityType(ItemStack stack) { public ItemEquality getEqualityType(ItemStack stack) {
if (this.type == ItemEquality.Type.TAG) { if (this.type == ItemEquality.Type.TAG) {
return ItemEquality.tag(FilterModifierModuleItem.getFilterTag(stack)); return ItemEquality.tag(getFilterTag(stack));
} else { } else {
return this.type.getDefaultInstance(); return this.type.getDefaultInstance();
} }

View file

@ -6,6 +6,7 @@ import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View file

@ -1,6 +1,7 @@
package de.ellpeck.prettypipes.pipe.modules.retrieval; package de.ellpeck.prettypipes.pipe.modules.retrieval;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;

View file

@ -4,13 +4,16 @@ import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.items.IModule; import de.ellpeck.prettypipes.items.IModule;
import de.ellpeck.prettypipes.items.ModuleItem; import de.ellpeck.prettypipes.items.ModuleItem;
import de.ellpeck.prettypipes.items.ModuleTier; import de.ellpeck.prettypipes.items.ModuleTier;
import de.ellpeck.prettypipes.misc.ItemEquality;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.network.PipeNetwork; import de.ellpeck.prettypipes.network.PipeNetwork;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair;
public class RetrievalModuleItem extends ModuleItem { public class RetrievalModuleItem extends ModuleItem {

View file

@ -9,6 +9,7 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -22,7 +23,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
@Override @Override
protected void init() { protected void init() {
super.init(); super.init();
var textField = this.addRenderableWidget(new EditBox(this.font, this.leftPos + 7, this.topPos + 17 + 32 + 10, 40, 20, Component.translatable("info." + PrettyPipes.ID + ".max_stack_size")) { var textField = this.addRenderableWidget(new EditBox(this.font, this.leftPos + 7, this.topPos + 17 + 32 + 10, 40, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".max_stack_size")) {
@Override @Override
public void insertText(String textToWrite) { public void insertText(String textToWrite) {
var ret = new StringBuilder(); var ret = new StringBuilder();
@ -42,7 +43,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
var amount = Integer.parseInt(s); var amount = Integer.parseInt(s);
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, amount); PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, amount);
}); });
Supplier<Component> buttonText = () -> Component.translatable("info." + PrettyPipes.ID + ".limit_to_max_" + (StackSizeModuleItem.getLimitToMaxStackSize(this.menu.moduleStack) ? "on" : "off")); var buttonText = (Supplier<TranslatableComponent>) () -> new TranslatableComponent("info." + PrettyPipes.ID + ".limit_to_max_" + (StackSizeModuleItem.getLimitToMaxStackSize(this.menu.moduleStack) ? "on" : "off"));
this.addRenderableWidget(new Button(this.leftPos + 7, this.topPos + 17 + 32 + 10 + 22, 120, 20, buttonText.get(), b -> { this.addRenderableWidget(new Button(this.leftPos + 7, this.topPos + 17 + 32 + 10 + 22, 120, 20, buttonText.get(), b -> {
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON); PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON);
b.setMessage(buttonText.get()); b.setMessage(buttonText.get());

View file

@ -13,8 +13,9 @@ import net.minecraftforge.items.IItemHandler;
public class StackSizeModuleItem extends ModuleItem { public class StackSizeModuleItem extends ModuleItem {
public StackSizeModuleItem() { public StackSizeModuleItem(String name) {
super("stack_size_module"); super(name);
this.setRegistryName(name);
} }
public static int getMaxStackSize(ItemStack module) { public static int getMaxStackSize(ItemStack module) {
@ -42,8 +43,8 @@ public class StackSizeModuleItem extends ModuleItem {
@Override @Override
public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) { public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) {
var max = StackSizeModuleItem.getMaxStackSize(module); var max = getMaxStackSize(module);
if (StackSizeModuleItem.getLimitToMaxStackSize(module)) if (getLimitToMaxStackSize(module))
max = Math.min(max, stack.getMaxStackSize()); max = Math.min(max, stack.getMaxStackSize());
var amount = 0; var amount = 0;
for (var i = 0; i < destination.getSlots(); i++) { for (var i = 0; i < destination.getSlots(); i++) {

View file

@ -2,6 +2,7 @@ package de.ellpeck.prettypipes.pressurizer;
import de.ellpeck.prettypipes.Registry; import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.Utility; import de.ellpeck.prettypipes.Utility;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@ -23,7 +24,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
@ -57,13 +57,13 @@ public class PressurizerBlock extends BaseEntityBlock {
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) { public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
Utility.addTooltip(ForgeRegistries.BLOCKS.getKey(this).getPath(), tooltip); Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
} }
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return level.isClientSide ? null : BaseEntityBlock.createTickerHelper(type, Registry.pressurizerBlockEntity, PressurizerBlockEntity::tick); return level.isClientSide ? null : createTickerHelper(type, Registry.pressurizerBlockEntity, PressurizerBlockEntity::tick);
} }
@Override @Override

View file

@ -11,6 +11,7 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection; import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.MenuProvider; import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -85,7 +86,7 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider,
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.translatable("container." + PrettyPipes.ID + ".pressurizer"); return new TranslatableComponent("container." + PrettyPipes.ID + ".pressurizer");
} }
@Nullable @Nullable

View file

@ -6,6 +6,7 @@ import de.ellpeck.prettypipes.PrettyPipes;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -25,7 +26,7 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
super.render(matrix, mouseX, mouseY, partialTicks); super.render(matrix, mouseX, mouseY, partialTicks);
this.renderTooltip(matrix, mouseX, mouseY); this.renderTooltip(matrix, mouseX, mouseY);
if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12) if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12)
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".energy", this.menu.tile.getEnergy(), this.menu.tile.getMaxEnergy()), mouseX, mouseY); this.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".energy", this.menu.tile.getEnergy(), this.menu.tile.getMaxEnergy()), mouseX, mouseY);
} }
@Override @Override
@ -37,7 +38,7 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
@Override @Override
protected void renderBg(PoseStack matrixStack, float partialTicks, int x, int y) { protected void renderBg(PoseStack matrixStack, float partialTicks, int x, int y) {
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, PressurizerGui.TEXTURE); RenderSystem.setShaderTexture(0, TEXTURE);
this.blit(matrixStack, this.leftPos, this.topPos, 0, 0, 176, 137); this.blit(matrixStack, this.leftPos, this.topPos, 0, 0, 176, 137);
var energy = (int) (this.menu.tile.getEnergyPercentage() * 124); var energy = (int) (this.menu.tile.getEnergyPercentage() * 124);
this.blit(matrixStack, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12); this.blit(matrixStack, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12);

View file

@ -3,7 +3,6 @@ package de.ellpeck.prettypipes.terminal;
import de.ellpeck.prettypipes.Registry; import de.ellpeck.prettypipes.Registry;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -19,6 +18,6 @@ public class CraftingTerminalBlock extends ItemTerminalBlock {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return BaseEntityBlock.createTickerHelper(type, Registry.craftingTerminalBlockEntity, ItemTerminalBlockEntity::tick); return createTickerHelper(type, Registry.craftingTerminalBlockEntity, ItemTerminalBlockEntity::tick);
} }
} }

View file

@ -17,6 +17,7 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
@ -58,7 +59,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
return this.craftItems.getStackInSlot(slot).isEmpty() && !this.ghostItems.getStackInSlot(slot).isEmpty(); return this.craftItems.getStackInSlot(slot).isEmpty() && !this.ghostItems.getStackInSlot(slot).isEmpty();
} }
public void setGhostItems(List<PacketGhostSlot.Entry> stacks) { public void setGhostItems(Map<Integer, PacketGhostSlot.Entry> stacks) {
this.updateItems(); this.updateItems();
for (var i = 0; i < this.ghostItems.getSlots(); i++) { for (var i = 0; i < this.ghostItems.getSlots(); i++) {
var items = stacks.get(i).getStacks(); var items = stacks.get(i).getStacks();
@ -95,9 +96,9 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
} }
if (!this.level.isClientSide) { if (!this.level.isClientSide) {
List<PacketGhostSlot.Entry> clients = new ArrayList<>(); Map<Integer, PacketGhostSlot.Entry> clients = new HashMap<>();
for (var i = 0; i < this.ghostItems.getSlots(); i++) for (var i = 0; i < this.ghostItems.getSlots(); i++)
clients.add(new PacketGhostSlot.Entry(Collections.singletonList(this.ghostItems.getStackInSlot(i)))); clients.put(i, new PacketGhostSlot.Entry(Collections.singletonList(this.ghostItems.getStackInSlot(i))));
PacketHandler.sendToAllLoaded(this.level, this.getBlockPos(), new PacketGhostSlot(this.getBlockPos(), clients)); PacketHandler.sendToAllLoaded(this.level, this.getBlockPos(), new PacketGhostSlot(this.getBlockPos(), clients));
} }
} }
@ -110,10 +111,10 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
network.startProfile("terminal_request_crafting"); network.startProfile("terminal_request_crafting");
this.updateItems(); this.updateItems();
// get the amount of crafts that we can do // get the amount of crafts that we can do
var lowestAvailable = CraftingTerminalBlockEntity.getAvailableCrafts(pipe, this.craftItems.getSlots(), i -> ItemHandlerHelper.copyStackWithSize(this.getRequestedCraftItem(i), 1), this::isGhostItem, s -> { var lowestAvailable = getAvailableCrafts(pipe, this.craftItems.getSlots(), i -> ItemHandlerHelper.copyStackWithSize(this.getRequestedCraftItem(i), 1), this::isGhostItem, s -> {
var item = this.networkItems.get(s); var item = this.networkItems.get(s);
return item != null ? item.getLocations() : Collections.emptyList(); return item != null ? item.getLocations() : Collections.emptyList();
}, ItemTerminalBlockEntity.onItemUnavailable(player, force), new Stack<>(), ItemEquality.NBT); }, onItemUnavailable(player, force), new Stack<>(), ItemEquality.NBT);
// if we're forcing, just pretend we have one available // if we're forcing, just pretend we have one available
if (lowestAvailable <= 0 && force) if (lowestAvailable <= 0 && force)
lowestAvailable = maxAmount; lowestAvailable = maxAmount;
@ -127,11 +128,11 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
continue; continue;
requested = requested.copy(); requested = requested.copy();
requested.setCount(lowestAvailable); requested.setCount(lowestAvailable);
this.requestItemImpl(requested, ItemTerminalBlockEntity.onItemUnavailable(player, force)); this.requestItemImpl(requested, onItemUnavailable(player, force));
} }
player.sendSystemMessage(Component.translatable("info." + PrettyPipes.ID + ".sending_ingredients", lowestAvailable).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN))); player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".sending_ingredients", lowestAvailable).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN)), UUID.randomUUID());
} else { } else {
player.sendSystemMessage(Component.translatable("info." + PrettyPipes.ID + ".hold_alt")); player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".hold_alt"), UUID.randomUUID());
} }
network.endProfile(); network.endProfile();
} }
@ -150,7 +151,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.translatable("container." + PrettyPipes.ID + ".crafting_terminal"); return new TranslatableComponent("container." + PrettyPipes.ID + ".crafting_terminal");
} }
@Nullable @Nullable

View file

@ -5,6 +5,7 @@ import de.ellpeck.prettypipes.Utility;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -23,10 +24,10 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.UUID;
public class ItemTerminalBlock extends BaseEntityBlock { public class ItemTerminalBlock extends BaseEntityBlock {
@ -42,7 +43,7 @@ public class ItemTerminalBlock extends BaseEntityBlock {
var reason = tile.getInvalidTerminalReason(); var reason = tile.getInvalidTerminalReason();
if (reason != null) { if (reason != null) {
if (!worldIn.isClientSide) if (!worldIn.isClientSide)
player.sendSystemMessage(Component.translatable(reason).withStyle(ChatFormatting.RED)); player.sendMessage(new TranslatableComponent(reason).withStyle(ChatFormatting.RED), UUID.randomUUID());
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
if (!worldIn.isClientSide) { if (!worldIn.isClientSide) {
@ -75,13 +76,13 @@ public class ItemTerminalBlock extends BaseEntityBlock {
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) { public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
Utility.addTooltip(ForgeRegistries.BLOCKS.getKey(this).getPath(), tooltip); Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
} }
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return BaseEntityBlock.createTickerHelper(type, Registry.itemTerminalBlockEntity, ItemTerminalBlockEntity::tick); return createTickerHelper(type, Registry.itemTerminalBlockEntity, ItemTerminalBlockEntity::tick);
} }
} }

View file

@ -22,6 +22,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.MenuProvider; import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -162,11 +163,11 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
.filter(s -> ItemEquality.compareItems(s, filter) && s.hasTag() && s.getTag().hashCode() == nbtHash) .filter(s -> ItemEquality.compareItems(s, filter) && s.hasTag() && s.getTag().hashCode() == nbtHash)
.findFirst().orElse(filter); .findFirst().orElse(filter);
} }
var requested = this.requestItemImpl(stack, ItemTerminalBlockEntity.onItemUnavailable(player, false)); var requested = this.requestItemImpl(stack, onItemUnavailable(player, false));
if (requested > 0) { if (requested > 0) {
player.sendSystemMessage(Component.translatable("info." + PrettyPipes.ID + ".sending", requested, stack.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN))); player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".sending", requested, stack.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN)), UUID.randomUUID());
} else { } else {
ItemTerminalBlockEntity.onItemUnavailable(player, false).accept(stack); onItemUnavailable(player, false).accept(stack);
} }
network.endProfile(); network.endProfile();
} }
@ -174,7 +175,7 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
public int requestItemImpl(ItemStack stack, Consumer<ItemStack> unavailableConsumer) { public int requestItemImpl(ItemStack stack, Consumer<ItemStack> unavailableConsumer) {
var item = this.networkItems.get(new EquatableItemStack(stack, ItemEquality.NBT)); var item = this.networkItems.get(new EquatableItemStack(stack, ItemEquality.NBT));
Collection<NetworkLocation> locations = item == null ? Collections.emptyList() : item.getLocations(); Collection<NetworkLocation> locations = item == null ? Collections.emptyList() : item.getLocations();
var ret = ItemTerminalBlockEntity.requestItemLater(this.level, this.getConnectedPipe().getBlockPos(), locations, unavailableConsumer, stack, new Stack<>(), ItemEquality.NBT); var ret = requestItemLater(this.level, this.getConnectedPipe().getBlockPos(), locations, unavailableConsumer, stack, new Stack<>(), ItemEquality.NBT);
this.existingRequests.addAll(ret.getLeft()); this.existingRequests.addAll(ret.getLeft());
return stack.getCount() - ret.getRight().getCount(); return stack.getCount() - ret.getRight().getCount();
} }
@ -247,7 +248,7 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.translatable("container." + PrettyPipes.ID + ".item_terminal"); return new TranslatableComponent("container." + PrettyPipes.ID + ".item_terminal");
} }
@Nullable @Nullable
@ -318,7 +319,7 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
return s -> { return s -> {
if (ignore) if (ignore)
return; return;
player.sendSystemMessage(Component.translatable("info." + PrettyPipes.ID + ".not_found", s.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.RED))); player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".not_found", s.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.RED)), UUID.randomUUID());
}; };
} }
} }

View file

@ -6,8 +6,8 @@ import de.ellpeck.prettypipes.PrettyPipes;
import de.ellpeck.prettypipes.packets.PacketButton; import de.ellpeck.prettypipes.packets.PacketButton;
import de.ellpeck.prettypipes.packets.PacketHandler; import de.ellpeck.prettypipes.packets.PacketHandler;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -24,10 +24,10 @@ public class CraftingTerminalGui extends ItemTerminalGui {
@Override @Override
protected void init() { protected void init() {
super.init(); super.init();
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + 8, this.topPos + 100, 50, 20, Component.translatable("info." + PrettyPipes.ID + ".request"), button -> { this.requestButton = this.addRenderableWidget(new Button(this.leftPos + 8, this.topPos + 100, 50, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".request"), button -> {
var amount = ItemTerminalGui.requestModifier(); var amount = requestModifier();
// also allow holding backspace instead of alt for people whose alt key is inaccessible (linux?) // 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; var force = hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;
PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force)); PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force));
})); }));
this.tick(); this.tick();
@ -70,7 +70,7 @@ public class CraftingTerminalGui extends ItemTerminalGui {
@Override @Override
protected ResourceLocation getTexture() { protected ResourceLocation getTexture() {
return CraftingTerminalGui.TEXTURE; return TEXTURE;
} }
@Override @Override

View file

@ -15,11 +15,12 @@ import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Widget; import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -64,14 +65,14 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
protected void init() { protected void init() {
super.init(); super.init();
this.search = this.addRenderableWidget(new EditBox(this.font, this.leftPos + this.getXOffset() + 97, this.topPos + 6, 86, 8, Component.literal(""))); this.search = this.addRenderableWidget(new EditBox(this.font, this.leftPos + this.getXOffset() + 97, this.topPos + 6, 86, 8, new TextComponent("")));
this.search.setBordered(false); this.search.setBordered(false);
this.lastSearchText = ""; this.lastSearchText = "";
if (this.items != null) if (this.items != null)
this.updateWidgets(); this.updateWidgets();
this.plusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12, Component.literal("+"), button -> { this.plusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12, new TextComponent("+"), button -> {
var modifier = ItemTerminalGui.requestModifier(); var modifier = requestModifier();
if (modifier > 1 && this.requestAmount == 1) { if (modifier > 1 && this.requestAmount == 1) {
this.requestAmount = modifier; this.requestAmount = modifier;
} else { } else {
@ -81,15 +82,15 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
if (this.requestAmount > 384) if (this.requestAmount > 384)
this.requestAmount = 384; this.requestAmount = 384;
})); }));
this.minusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12, Component.literal("-"), button -> { this.minusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12, new TextComponent("-"), button -> {
this.requestAmount -= ItemTerminalGui.requestModifier(); this.requestAmount -= requestModifier();
if (this.requestAmount < 1) if (this.requestAmount < 1)
this.requestAmount = 1; this.requestAmount = 1;
})); }));
this.minusButton.active = false; this.minusButton.active = false;
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20, Component.translatable("info." + PrettyPipes.ID + ".request"), button -> { this.requestButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".request"), button -> {
var widget = this.streamWidgets().filter(w -> w.selected).findFirst(); var widget = this.streamWidgets().filter(w -> w.selected).findFirst();
if (widget.isEmpty()) if (!widget.isPresent())
return; return;
var stack = widget.get().stack.copy(); var stack = widget.get().stack.copy();
stack.setCount(1); stack.setCount(1);
@ -97,7 +98,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
this.requestAmount = 1; this.requestAmount = 1;
})); }));
this.requestButton.active = false; this.requestButton.active = false;
this.orderButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos, 20, 20, Component.literal(""), button -> { this.orderButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos, 20, 20, new TextComponent(""), button -> {
if (this.sortedItems == null) if (this.sortedItems == null)
return; return;
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
@ -105,7 +106,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
prefs.save(); prefs.save();
this.updateWidgets(); this.updateWidgets();
})); }));
this.ascendingButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos + 22, 20, 20, Component.literal(""), button -> { this.ascendingButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos + 22, 20, 20, new TextComponent(""), button -> {
if (this.sortedItems == null) if (this.sortedItems == null)
return; return;
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
@ -113,7 +114,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
prefs.save(); prefs.save();
this.updateWidgets(); this.updateWidgets();
})); }));
this.cancelCraftingButton = this.addRenderableWidget(new Button(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20, Component.translatable("info." + PrettyPipes.ID + ".cancel_all"), b -> { this.cancelCraftingButton = this.addRenderableWidget(new Button(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".cancel_all"), b -> {
})); }));
this.cancelCraftingButton.visible = false; this.cancelCraftingButton.visible = false;
for (var y = 0; y < 4; y++) { for (var y = 0; y < 4; y++) {
@ -206,8 +207,8 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
public void updateWidgets() { public void updateWidgets() {
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
this.ascendingButton.setMessage(Component.literal(prefs.terminalAscending ? "^" : "v")); this.ascendingButton.setMessage(new TextComponent(prefs.terminalAscending ? "^" : "v"));
this.orderButton.setMessage(Component.literal(prefs.terminalItemOrder.name().substring(0, 1))); this.orderButton.setMessage(new TextComponent(prefs.terminalItemOrder.name().substring(0, 1)));
this.cancelCraftingButton.visible = this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty(); this.cancelCraftingButton.visible = this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty();
var comparator = prefs.terminalItemOrder.comparator; var comparator = prefs.terminalItemOrder.comparator;
@ -279,13 +280,13 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
if (this.sortedItems != null) { if (this.sortedItems != null) {
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
if (this.orderButton.isHoveredOrFocused()) if (this.orderButton.isHoveredOrFocused())
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY); this.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
if (this.ascendingButton.isHoveredOrFocused()) if (this.ascendingButton.isHoveredOrFocused())
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY); this.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
} }
if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) { if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) {
var tooltip = I18n.get("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n"); var tooltip = I18n.get("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n");
this.renderComponentTooltip(matrix, Arrays.stream(tooltip).map(Component::literal).collect(Collectors.toList()), mouseX, mouseY); this.renderComponentTooltip(matrix, Arrays.stream(tooltip).map(TextComponent::new).collect(Collectors.toList()), mouseX, mouseY);
} }
if (!this.hoveredCrafting.isEmpty()) if (!this.hoveredCrafting.isEmpty())
this.renderTooltip(matrix, this.hoveredCrafting, mouseX, mouseY); this.renderTooltip(matrix, this.hoveredCrafting, mouseX, mouseY);
@ -324,7 +325,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
this.hoveredCrafting = ItemStack.EMPTY; this.hoveredCrafting = ItemStack.EMPTY;
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) { if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, ItemTerminalGui.TEXTURE); RenderSystem.setShaderTexture(0, TEXTURE);
this.blit(matrix, this.leftPos + this.imageWidth, this.topPos + 4, 191, 0, 65, 89); this.blit(matrix, this.leftPos + this.imageWidth, this.topPos + 4, 191, 0, 65, 89);
var x = 0; var x = 0;
@ -348,7 +349,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
} }
protected ResourceLocation getTexture() { protected ResourceLocation getTexture() {
return ItemTerminalGui.TEXTURE; return TEXTURE;
} }
@Override @Override
@ -376,9 +377,9 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
} }
public static int requestModifier() { public static int requestModifier() {
if (Screen.hasControlDown()) { if (hasControlDown()) {
return 10; return 10;
} else if (Screen.hasShiftDown()) { } else if (hasShiftDown()) {
return 64; return 64;
} else { } else {
return 1; return 1;

View file

@ -4,20 +4,20 @@
# Note that there are a couple of TOML lists in this file. # Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml # Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader = "javafml" #mandatory modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version # A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion = "[28,)" #mandatory (28 is current forge version) loaderVersion="[28,)" #mandatory (28 is current forge version)
# A URL to refer people to when problems occur with this mod # A URL to refer people to when problems occur with this mod
issueTrackerURL = "https://github.com/Ellpeck/PrettyPipes" #optional issueTrackerURL="https://github.com/Ellpeck/PrettyPipes" #optional
license = "MIT" license="MIT"
# A list of mods - how many allowed here is determined by the individual mod loader # A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory [[mods]] #mandatory
# The modid of the mod # The modid of the mod
modId = "prettypipes" #mandatory modId="prettypipes" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version = "${file.jarVersion}" version="${file.jarVersion}"
# A display name for the mod # A display name for the mod
displayName = "Pretty Pipes" #mandatory displayName="Pretty Pipes" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here> # A URL to query for updates for this mod. See the JSON update specification <here>
#updateJSONURL="http://myurl.me/" #optional #updateJSONURL="http://myurl.me/" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI # A URL for the "homepage" for this mod, displayed in the mod UI
@ -27,7 +27,7 @@ displayName = "Pretty Pipes" #mandatory
# A text field displayed in the mod UI # A text field displayed in the mod UI
#credits="" #optional #credits="" #optional
# A text field displayed in the mod UI # A text field displayed in the mod UI
authors = "Ellpeck" #optional authors="Ellpeck" #optional
# The description text for the mod (multi line!) (#mandatory) # The description text for the mod (multi line!) (#mandatory)
description = ''' description='''
wow pipes, how creative''' wow pipes, how creative'''

View file

@ -1,370 +1,154 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block", "parent": "block/block",
"textures": { "textures": {
"0": "prettypipes:block/pipe", "0": "prettypipes:block/pipe",
"particle": "prettypipes:block/pipe" "particle": "prettypipes:block/pipe"
}, },
"elements": [ "elements": [
{ {
"from": [5, 5, 5], "from": [5, 5, 5],
"to": [6, 11, 6], "to": [6, 11, 6],
"faces": { "faces": {
"north": { "north": {"uv": [0, 0, 1, 6], "texture": "#0"},
"uv": [0, 0, 1, 6], "east": {"uv": [0, 0, 1, 6], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 1, 6], "texture": "#0"},
}, "west": {"uv": [0, 0, 1, 6], "texture": "#0"},
"east": { "up": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 1, 6], "down": {"uv": [0, 0, 1, 1], "texture": "#0"}
"texture": "#0" }
}, },
"south": { {
"uv": [0, 0, 1, 6], "from": [5, 5, 10],
"texture": "#0" "to": [6, 11, 11],
}, "faces": {
"west": { "north": {"uv": [0, 0, 1, 6], "texture": "#0"},
"uv": [0, 0, 1, 6], "east": {"uv": [0, 0, 1, 6], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 1, 6], "texture": "#0"},
}, "west": {"uv": [0, 0, 1, 6], "texture": "#0"},
"up": { "up": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 1, 1], "down": {"uv": [0, 0, 1, 1], "texture": "#0"}
"texture": "#0" }
}, },
"down": { {
"uv": [0, 0, 1, 1], "from": [10, 5, 10],
"texture": "#0" "to": [11, 11, 11],
} "faces": {
} "north": {"uv": [0, 0, 1, 6], "texture": "#0"},
}, "east": {"uv": [0, 0, 1, 6], "texture": "#0"},
{ "south": {"uv": [0, 0, 1, 6], "texture": "#0"},
"from": [5, 5, 10], "west": {"uv": [0, 0, 1, 6], "texture": "#0"},
"to": [6, 11, 11], "up": {"uv": [0, 0, 1, 1], "texture": "#0"},
"faces": { "down": {"uv": [0, 0, 1, 1], "texture": "#0"}
"north": { }
"uv": [0, 0, 1, 6], },
"texture": "#0" {
}, "from": [10, 5, 5],
"east": { "to": [11, 11, 6],
"uv": [0, 0, 1, 6], "faces": {
"texture": "#0" "north": {"uv": [0, 0, 1, 6], "texture": "#0"},
}, "east": {"uv": [0, 0, 1, 6], "texture": "#0"},
"south": { "south": {"uv": [0, 0, 1, 6], "texture": "#0"},
"uv": [0, 0, 1, 6], "west": {"uv": [0, 0, 1, 6], "texture": "#0"},
"texture": "#0" "up": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "down": {"uv": [0, 0, 1, 1], "texture": "#0"}
"west": { }
"uv": [0, 0, 1, 6], },
"texture": "#0" {
}, "from": [6, 10, 10],
"up": { "to": [10, 11, 11],
"uv": [0, 0, 1, 1], "faces": {
"texture": "#0" "north": {"uv": [0, 0, 4, 1], "texture": "#0"},
}, "east": {"uv": [0, 0, 1, 1], "texture": "#0"},
"down": { "south": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 1, 1], "west": {"uv": [0, 0, 1, 1], "texture": "#0"},
"texture": "#0" "up": {"uv": [0, 0, 4, 1], "texture": "#0"},
} "down": {"uv": [0, 0, 4, 1], "texture": "#0"}
} }
}, },
{ {
"from": [10, 5, 10], "from": [6, 5, 10],
"to": [11, 11, 11], "to": [10, 6, 11],
"faces": { "faces": {
"north": { "north": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 1, 6], "east": {"uv": [0, 0, 1, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 4, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 1, 1], "texture": "#0"},
"east": { "up": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 1, 6], "down": {"uv": [0, 0, 4, 1], "texture": "#0"}
"texture": "#0" }
}, },
"south": { {
"uv": [0, 0, 1, 6], "from": [6, 5, 5],
"texture": "#0" "to": [10, 6, 6],
}, "faces": {
"west": { "north": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 1, 6], "east": {"uv": [0, 0, 1, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 4, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 1, 1], "texture": "#0"},
"up": { "up": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 1, 1], "down": {"uv": [0, 0, 4, 1], "texture": "#0"}
"texture": "#0" }
}, },
"down": { {
"uv": [0, 0, 1, 1], "from": [5, 5, 6],
"texture": "#0" "to": [6, 6, 10],
} "faces": {
} "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "east": {"uv": [0, 0, 4, 1], "texture": "#0"},
{ "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
"from": [10, 5, 5], "west": {"uv": [0, 0, 4, 1], "texture": "#0"},
"to": [11, 11, 6], "up": {"uv": [0, 0, 1, 4], "texture": "#0"},
"faces": { "down": {"uv": [0, 0, 1, 4], "texture": "#0"}
"north": { }
"uv": [0, 0, 1, 6], },
"texture": "#0" {
}, "from": [5, 10, 6],
"east": { "to": [6, 11, 10],
"uv": [0, 0, 1, 6], "faces": {
"texture": "#0" "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "east": {"uv": [0, 0, 4, 1], "texture": "#0"},
"south": { "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 1, 6], "west": {"uv": [0, 0, 4, 1], "texture": "#0"},
"texture": "#0" "up": {"uv": [0, 0, 1, 4], "texture": "#0"},
}, "down": {"uv": [0, 0, 1, 4], "texture": "#0"}
"west": { }
"uv": [0, 0, 1, 6], },
"texture": "#0" {
}, "from": [10, 10, 6],
"up": { "to": [11, 11, 10],
"uv": [0, 0, 1, 1], "faces": {
"texture": "#0" "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "east": {"uv": [0, 0, 4, 1], "texture": "#0"},
"down": { "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 1, 1], "west": {"uv": [0, 0, 4, 1], "texture": "#0"},
"texture": "#0" "up": {"uv": [0, 0, 1, 4], "texture": "#0"},
} "down": {"uv": [0, 0, 1, 4], "texture": "#0"}
} }
}, },
{ {
"from": [6, 10, 10], "from": [10, 5, 6],
"to": [10, 11, 11], "to": [11, 6, 10],
"faces": { "faces": {
"north": { "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 4, 1], "east": {"uv": [0, 0, 4, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 4, 1], "texture": "#0"},
"east": { "up": {"uv": [0, 0, 1, 4], "texture": "#0"},
"uv": [0, 0, 1, 1], "down": {"uv": [0, 0, 1, 4], "texture": "#0"}
"texture": "#0" }
}, },
"south": { {
"uv": [0, 0, 4, 1], "from": [6, 10, 5],
"texture": "#0" "to": [10, 11, 6],
}, "faces": {
"west": { "north": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 1, 1], "east": {"uv": [0, 0, 1, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 4, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 1, 1], "texture": "#0"},
"up": { "up": {"uv": [0, 0, 4, 1], "texture": "#0"},
"uv": [0, 0, 4, 1], "down": {"uv": [0, 0, 4, 1], "texture": "#0"}
"texture": "#0" }
}, }
"down": { ]
"uv": [0, 0, 4, 1],
"texture": "#0"
}
}
},
{
"from": [6, 5, 10],
"to": [10, 6, 11],
"faces": {
"north": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"down": {
"uv": [0, 0, 4, 1],
"texture": "#0"
}
}
},
{
"from": [6, 5, 5],
"to": [10, 6, 6],
"faces": {
"north": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"down": {
"uv": [0, 0, 4, 1],
"texture": "#0"
}
}
},
{
"from": [5, 5, 6],
"to": [6, 6, 10],
"faces": {
"north": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 1, 4],
"texture": "#0"
},
"down": {
"uv": [0, 0, 1, 4],
"texture": "#0"
}
}
},
{
"from": [5, 10, 6],
"to": [6, 11, 10],
"faces": {
"north": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 1, 4],
"texture": "#0"
},
"down": {
"uv": [0, 0, 1, 4],
"texture": "#0"
}
}
},
{
"from": [10, 10, 6],
"to": [11, 11, 10],
"faces": {
"north": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 1, 4],
"texture": "#0"
},
"down": {
"uv": [0, 0, 1, 4],
"texture": "#0"
}
}
},
{
"from": [10, 5, 6],
"to": [11, 6, 10],
"faces": {
"north": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 1, 4],
"texture": "#0"
},
"down": {
"uv": [0, 0, 1, 4],
"texture": "#0"
}
}
},
{
"from": [6, 10, 5],
"to": [10, 11, 6],
"faces": {
"north": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 4, 1],
"texture": "#0"
},
"down": {
"uv": [0, 0, 4, 1],
"texture": "#0"
}
}
}
]
} }

View file

@ -1,137 +1,57 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"textures": { "textures": {
"0": "prettypipes:block/pipe", "0": "prettypipes:block/pipe",
"particle": "prettypipes:block/pipe" "particle": "prettypipes:block/pipe"
}, },
"elements": [ "elements": [
{ {
"from": [5, 10, 0], "from": [5, 10, 0],
"to": [6, 11, 5], "to": [6, 11, 5],
"faces": { "faces": {
"north": { "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 1, 1], "east": {"uv": [0, 0, 5, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 5, 1], "texture": "#0"},
"east": { "up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
"uv": [0, 0, 5, 1], "down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
"texture": "#0" }
}, },
"south": { {
"uv": [0, 0, 1, 1], "from": [5, 5, 0],
"texture": "#0" "to": [6, 6, 5],
}, "faces": {
"west": { "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 5, 1], "east": {"uv": [0, 0, 5, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 5, 1], "texture": "#0"},
"up": { "up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
"uv": [0, 0, 5, 1], "down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
"rotation": 90, }
"texture": "#0" },
}, {
"down": { "from": [10, 5, 0],
"uv": [0, 0, 5, 1], "to": [11, 6, 5],
"rotation": 270, "faces": {
"texture": "#0" "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
} "east": {"uv": [0, 0, 5, 1], "texture": "#0"},
} "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 5, 1], "texture": "#0"},
{ "up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
"from": [5, 5, 0], "down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
"to": [6, 6, 5], }
"faces": { },
"north": { {
"uv": [0, 0, 1, 1], "from": [10, 10, 0],
"texture": "#0" "to": [11, 11, 5],
}, "faces": {
"east": { "north": {"uv": [0, 0, 1, 1], "texture": "#0"},
"uv": [0, 0, 5, 1], "east": {"uv": [0, 0, 5, 1], "texture": "#0"},
"texture": "#0" "south": {"uv": [0, 0, 1, 1], "texture": "#0"},
}, "west": {"uv": [0, 0, 5, 1], "texture": "#0"},
"south": { "up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
"uv": [0, 0, 1, 1], "down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
"texture": "#0" }
}, }
"west": { ]
"uv": [0, 0, 5, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 5, 1],
"rotation": 90,
"texture": "#0"
},
"down": {
"uv": [0, 0, 5, 1],
"rotation": 270,
"texture": "#0"
}
}
},
{
"from": [10, 5, 0],
"to": [11, 6, 5],
"faces": {
"north": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 5, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 5, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 5, 1],
"rotation": 90,
"texture": "#0"
},
"down": {
"uv": [0, 0, 5, 1],
"rotation": 270,
"texture": "#0"
}
}
},
{
"from": [10, 10, 0],
"to": [11, 11, 5],
"faces": {
"north": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"east": {
"uv": [0, 0, 5, 1],
"texture": "#0"
},
"south": {
"uv": [0, 0, 1, 1],
"texture": "#0"
},
"west": {
"uv": [0, 0, 5, 1],
"texture": "#0"
},
"up": {
"uv": [0, 0, 5, 1],
"rotation": 90,
"texture": "#0"
},
"down": {
"uv": [0, 0, 5, 1],
"rotation": 270,
"texture": "#0"
}
}
}
]
} }

View file

@ -1,66 +1,33 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block", "parent": "block/block",
"textures": { "textures": {
"1": "prettypipes:block/pipe_legs", "1": "prettypipes:block/pipe_legs",
"particle": "prettypipes:block/pipe" "particle": "prettypipes:block/pipe"
}, },
"elements": [ "elements": [
{ {
"from": [6, 4, 6], "from": [6, 4, 6],
"to": [10, 5, 10], "to": [10, 5, 10],
"faces": { "faces": {
"north": { "north": {"uv": [0, 7, 4, 8], "texture": "#1"},
"uv": [0, 7, 4, 8], "east": {"uv": [0, 7, 4, 8], "texture": "#1"},
"texture": "#1" "south": {"uv": [0, 7, 4, 8], "texture": "#1"},
}, "west": {"uv": [0, 7, 4, 8], "texture": "#1"},
"east": { "up": {"uv": [1, 1, 5, 5], "texture": "#1"},
"uv": [0, 7, 4, 8], "down": {"uv": [1, 1, 5, 5], "texture": "#1"}
"texture": "#1" }
}, },
"south": { {
"uv": [0, 7, 4, 8], "from": [7, 0, 7],
"texture": "#1" "to": [9, 4, 9],
}, "faces": {
"west": { "north": {"uv": [1, 1, 3, 5], "texture": "#1"},
"uv": [0, 7, 4, 8], "east": {"uv": [1, 1, 3, 5], "texture": "#1"},
"texture": "#1" "south": {"uv": [1, 1, 3, 5], "texture": "#1"},
}, "west": {"uv": [1, 1, 3, 5], "texture": "#1"},
"up": { "down": {"uv": [1, 1, 3, 3], "texture": "#1"}
"uv": [1, 1, 5, 5], }
"texture": "#1" }
}, ]
"down": {
"uv": [1, 1, 5, 5],
"texture": "#1"
}
}
},
{
"from": [7, 0, 7],
"to": [9, 4, 9],
"faces": {
"north": {
"uv": [1, 1, 3, 5],
"texture": "#1"
},
"east": {
"uv": [1, 1, 3, 5],
"texture": "#1"
},
"south": {
"uv": [1, 1, 3, 5],
"texture": "#1"
},
"west": {
"uv": [1, 1, 3, 5],
"texture": "#1"
},
"down": {
"uv": [1, 1, 3, 3],
"texture": "#1"
}
}
}
]
} }

View file

@ -1,9 +1,7 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"id": "prettypipes", "id": "prettypipes",
"version": "0.0.0", "version": "0.0.0",
"contributors": ["SoniEx2"], "contributors": [ "SoniEx2" ],
"depends": { "depends": { "forge": "*" }
"forge": "*"
}
} }