mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-25 21:18:34 +01:00
Compare commits
No commits in common. "1b061759e13b1e4cb3408cecc666ea841652b720" and "590982069367acc83f592fefd98c9a3faa572cdc" have entirely different histories.
1b061759e1
...
5909820693
44 changed files with 259 additions and 462 deletions
|
@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.12.4'
|
||||
version = '1.12.3'
|
||||
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'PrettyPipes'
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public final class Registry {
|
|||
public static final CreativeModeTab TAB = new CreativeModeTab(PrettyPipes.ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(Registry.wrenchItem);
|
||||
return new ItemStack(wrenchItem);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -127,10 +127,10 @@ public final class Registry {
|
|||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||
event.getRegistry().registerAll(
|
||||
Registry.pipeBlock = new PipeBlock().setRegistryName("pipe"),
|
||||
Registry.itemTerminalBlock = new ItemTerminalBlock().setRegistryName("item_terminal"),
|
||||
Registry.craftingTerminalBlock = new CraftingTerminalBlock().setRegistryName("crafting_terminal"),
|
||||
Registry.pressurizerBlock = new PressurizerBlock().setRegistryName("pressurizer")
|
||||
pipeBlock = new PipeBlock().setRegistryName("pipe"),
|
||||
itemTerminalBlock = new ItemTerminalBlock().setRegistryName("item_terminal"),
|
||||
craftingTerminalBlock = new CraftingTerminalBlock().setRegistryName("crafting_terminal"),
|
||||
pressurizerBlock = new PressurizerBlock().setRegistryName("pressurizer")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -138,59 +138,59 @@ public final class Registry {
|
|||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
var registry = event.getRegistry();
|
||||
registry.registerAll(
|
||||
Registry.wrenchItem = new WrenchItem().setRegistryName("wrench"),
|
||||
new Item(new Item.Properties().tab(Registry.TAB)).setRegistryName("blank_module"),
|
||||
Registry.pipeFrameItem = new PipeFrameItem().setRegistryName("pipe_frame")
|
||||
wrenchItem = new WrenchItem().setRegistryName("wrench"),
|
||||
new Item(new Item.Properties().tab(TAB)).setRegistryName("blank_module"),
|
||||
pipeFrameItem = new PipeFrameItem().setRegistryName("pipe_frame")
|
||||
);
|
||||
registry.registerAll(Registry.createTieredModule("extraction_module", ExtractionModuleItem::new));
|
||||
registry.registerAll(Registry.createTieredModule("filter_module", FilterModuleItem::new));
|
||||
registry.registerAll(Registry.createTieredModule("speed_module", SpeedModuleItem::new));
|
||||
registry.registerAll(Registry.createTieredModule("low_priority_module", LowPriorityModuleItem::new));
|
||||
registry.registerAll(Registry.createTieredModule("high_priority_module", HighPriorityModuleItem::new));
|
||||
registry.registerAll(Registry.createTieredModule("retrieval_module", RetrievalModuleItem::new));
|
||||
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(Registry.createTieredModule("crafting_module", CraftingModuleItem::new));
|
||||
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(Registry.TAB)).setRegistryName(b.getRegistryName())));
|
||||
.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(
|
||||
Registry.pipeBlockEntity = (BlockEntityType<PipeBlockEntity>) BlockEntityType.Builder.of(PipeBlockEntity::new, Registry.pipeBlock).build(null).setRegistryName("pipe"),
|
||||
Registry.itemTerminalBlockEntity = (BlockEntityType<ItemTerminalBlockEntity>) BlockEntityType.Builder.of(ItemTerminalBlockEntity::new, Registry.itemTerminalBlock).build(null).setRegistryName("item_terminal"),
|
||||
Registry.craftingTerminalBlockEntity = (BlockEntityType<CraftingTerminalBlockEntity>) BlockEntityType.Builder.of(CraftingTerminalBlockEntity::new, Registry.craftingTerminalBlock).build(null).setRegistryName("crafting_terminal"),
|
||||
Registry.pressurizerBlockEntity = (BlockEntityType<PressurizerBlockEntity>) BlockEntityType.Builder.of(PressurizerBlockEntity::new, Registry.pressurizerBlock).build(null).setRegistryName("pressurizer")
|
||||
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(
|
||||
Registry.pipeFrameEntity = (EntityType<PipeFrameEntity>) EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame").setRegistryName("pipe_frame")
|
||||
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(
|
||||
Registry.pipeContainer = (MenuType<MainPipeContainer>) IForgeMenuType.create((windowId, inv, data) -> new MainPipeContainer(Registry.pipeContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("pipe"),
|
||||
Registry.itemTerminalContainer = (MenuType<ItemTerminalContainer>) IForgeMenuType.create((windowId, inv, data) -> new ItemTerminalContainer(Registry.itemTerminalContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("item_terminal"),
|
||||
Registry.craftingTerminalContainer = (MenuType<CraftingTerminalContainer>) IForgeMenuType.create((windowId, inv, data) -> new CraftingTerminalContainer(Registry.craftingTerminalContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("crafting_terminal"),
|
||||
Registry.pressurizerContainer = (MenuType<PressurizerContainer>) IForgeMenuType.create((windowId, inv, data) -> new PressurizerContainer(Registry.pressurizerContainer, windowId, inv.player, data.readBlockPos())).setRegistryName("pressurizer"),
|
||||
Registry.extractionModuleContainer = Registry.createPipeContainer("extraction_module"),
|
||||
Registry.filterModuleContainer = Registry.createPipeContainer("filter_module"),
|
||||
Registry.retrievalModuleContainer = Registry.createPipeContainer("retrieval_module"),
|
||||
Registry.stackSizeModuleContainer = Registry.createPipeContainer("stack_size_module"),
|
||||
Registry.filterIncreaseModuleContainer = Registry.createPipeContainer("filter_increase_module"),
|
||||
Registry.craftingModuleContainer = Registry.createPipeContainer("crafting_module"),
|
||||
Registry.filterModifierModuleContainer = Registry.createPipeContainer("filter_modifier_module")
|
||||
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")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -217,21 +217,21 @@ public final class Registry {
|
|||
public static final class Client {
|
||||
|
||||
public static void setup(FMLClientSetupEvent event) {
|
||||
ItemBlockRenderTypes.setRenderLayer(Registry.pipeBlock, RenderType.cutout());
|
||||
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new);
|
||||
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new);
|
||||
ItemBlockRenderTypes.setRenderLayer(pipeBlock, RenderType.cutout());
|
||||
BlockEntityRenderers.register(pipeBlockEntity, PipeRenderer::new);
|
||||
EntityRenderers.register(pipeFrameEntity, PipeFrameRenderer::new);
|
||||
|
||||
MenuScreens.register(Registry.pipeContainer, MainPipeGui::new);
|
||||
MenuScreens.register(Registry.itemTerminalContainer, ItemTerminalGui::new);
|
||||
MenuScreens.register(Registry.pressurizerContainer, PressurizerGui::new);
|
||||
MenuScreens.register(Registry.craftingTerminalContainer, CraftingTerminalGui::new);
|
||||
MenuScreens.register(Registry.extractionModuleContainer, ExtractionModuleGui::new);
|
||||
MenuScreens.register(Registry.filterModuleContainer, FilterModuleGui::new);
|
||||
MenuScreens.register(Registry.retrievalModuleContainer, RetrievalModuleGui::new);
|
||||
MenuScreens.register(Registry.stackSizeModuleContainer, StackSizeModuleGui::new);
|
||||
MenuScreens.register(Registry.filterIncreaseModuleContainer, FilterIncreaseModuleGui::new);
|
||||
MenuScreens.register(Registry.craftingModuleContainer, CraftingModuleGui::new);
|
||||
MenuScreens.register(Registry.filterModifierModuleContainer, FilterModifierModuleGui::new);
|
||||
MenuScreens.register(pipeContainer, MainPipeGui::new);
|
||||
MenuScreens.register(itemTerminalContainer, ItemTerminalGui::new);
|
||||
MenuScreens.register(pressurizerContainer, PressurizerGui::new);
|
||||
MenuScreens.register(craftingTerminalContainer, CraftingTerminalGui::new);
|
||||
MenuScreens.register(extractionModuleContainer, ExtractionModuleGui::new);
|
||||
MenuScreens.register(filterModuleContainer, FilterModuleGui::new);
|
||||
MenuScreens.register(retrievalModuleContainer, RetrievalModuleGui::new);
|
||||
MenuScreens.register(stackSizeModuleContainer, StackSizeModuleGui::new);
|
||||
MenuScreens.register(filterIncreaseModuleContainer, FilterIncreaseModuleGui::new);
|
||||
MenuScreens.register(craftingModuleContainer, CraftingModuleGui::new);
|
||||
MenuScreens.register(filterModifierModuleContainer, FilterModifierModuleGui::new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
@Override
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(PipeFrameEntity.AMOUNT, -1);
|
||||
this.entityData.define(AMOUNT, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
if (this.tickCount % 40 != 0)
|
||||
return;
|
||||
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) {
|
||||
var node = network.getNodeFromPipe(attached);
|
||||
if (node != null) {
|
||||
|
@ -61,17 +61,17 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
if (!stack.isEmpty()) {
|
||||
var items = network.getOrderedNetworkItems(node);
|
||||
var amount = items.stream().mapToInt(i -> i.getItemAmount(this.level, stack)).sum();
|
||||
this.entityData.set(PipeFrameEntity.AMOUNT, amount);
|
||||
this.entityData.set(AMOUNT, amount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.entityData.set(PipeFrameEntity.AMOUNT, -1);
|
||||
this.entityData.set(AMOUNT, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
|
@ -85,11 +85,11 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
}
|
||||
|
||||
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() {
|
||||
return this.entityData.get(PipeFrameEntity.AMOUNT);
|
||||
return this.entityData.get(AMOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package de.ellpeck.prettypipes.items;
|
||||
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -19,9 +17,9 @@ public interface IModule {
|
|||
|
||||
void tick(ItemStack module, PipeBlockEntity tile);
|
||||
|
||||
boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler);
|
||||
boolean canNetworkSee(ItemStack module, PipeBlockEntity tile);
|
||||
|
||||
boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination);
|
||||
boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack);
|
||||
|
||||
int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination);
|
||||
|
||||
|
@ -46,6 +44,4 @@ public interface IModule {
|
|||
Integer getCustomNextNode(ItemStack module, PipeBlockEntity tile, List<BlockPos> nodes, int index);
|
||||
|
||||
ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile);
|
||||
|
||||
DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,10 @@ package de.ellpeck.prettypipes.items;
|
|||
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -47,12 +45,12 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -105,9 +103,4 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
public ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.gui.widget.ExtendedButton;
|
||||
|
||||
public class DirectionSelector {
|
||||
|
||||
private Direction direction;
|
||||
private boolean modified;
|
||||
|
||||
private final ItemStack stack;
|
||||
private final PipeBlockEntity pipe;
|
||||
|
||||
public DirectionSelector(ItemStack stack, PipeBlockEntity pipe) {
|
||||
this.stack = stack;
|
||||
this.pipe = pipe;
|
||||
this.load();
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AbstractWidget getButton(int x, int y) {
|
||||
return new ExtendedButton(x, y, 100, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".populate"), button ->
|
||||
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.DIRECTION_SELECTOR)) {
|
||||
@Override
|
||||
public Component getMessage() {
|
||||
var pipe = DirectionSelector.this.pipe;
|
||||
var dir = DirectionSelector.this.getDirection();
|
||||
MutableComponent msg = new TranslatableComponent("dir." + PrettyPipes.ID + "." + (dir != null ? dir.getName() : "none"));
|
||||
if (dir != null) {
|
||||
var blockName = pipe.getItemHandler(dir) != null ? pipe.getLevel().getBlockState(pipe.getBlockPos().relative(dir)).getBlock().getName() : null;
|
||||
if (blockName != null)
|
||||
msg = msg.append(" (").append(blockName).append(")");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void onButtonPacket() {
|
||||
var dir = this.getValidDirection(this.getDirection());
|
||||
if (this.direction != dir) {
|
||||
this.direction = dir;
|
||||
this.modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!this.modified)
|
||||
return;
|
||||
this.modified = false;
|
||||
|
||||
var tag = new CompoundTag();
|
||||
var dir = this.getDirection();
|
||||
if (dir != null)
|
||||
tag.putString("direction", dir.getName());
|
||||
this.stack.getOrCreateTag().put("direction_selector", tag);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (this.stack.hasTag()) {
|
||||
var tag = this.stack.getTag().getCompound("direction_selector");
|
||||
this.direction = Direction.byName(tag.getString("direction"));
|
||||
}
|
||||
}
|
||||
|
||||
public Direction getDirection() {
|
||||
// default to the first direction with a container if ours is invalid or unset
|
||||
if (this.direction == null || !this.isDirectionValid(this.direction))
|
||||
return this.getValidDirection(this.direction);
|
||||
return this.direction;
|
||||
}
|
||||
|
||||
private boolean isDirectionValid(Direction dir) {
|
||||
if (this.pipe.getItemHandler(dir) == null)
|
||||
return false;
|
||||
return this.pipe.streamModules()
|
||||
.filter(p -> p.getLeft() != this.stack)
|
||||
.map(p -> p.getRight().getDirectionSelector(p.getLeft(), this.pipe))
|
||||
// don't use getDirection here because we don't want a stack overflow
|
||||
.noneMatch(p -> p != null && p.direction == dir);
|
||||
}
|
||||
|
||||
private Direction getValidDirection(Direction dir) {
|
||||
if (dir == null)
|
||||
dir = Direction.UP;
|
||||
for (var i = 0; i < 6; i++) {
|
||||
dir = Direction.from3DDataValue(dir.get3DDataValue() + 1);
|
||||
if (this.isDirectionValid(dir))
|
||||
return dir;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface IDirectionContainer {
|
||||
|
||||
DirectionSelector getSelector();
|
||||
|
||||
}
|
||||
}
|
|
@ -48,22 +48,17 @@ public class ItemFilter extends ItemStackHandler {
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public List<AbstractWidget> getButtons(Screen gui, int x, int y, boolean rightAligned) {
|
||||
public List<AbstractWidget> getButtons(Screen gui, int x, int y) {
|
||||
List<AbstractWidget> buttons = new ArrayList<>();
|
||||
if (this.canModifyWhitelist) {
|
||||
var whitelistText = (Supplier<String>) () -> "info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist");
|
||||
buttons.add(new Button(x - 20, y, 20, 20, new TranslatableComponent(whitelistText.get()), button -> {
|
||||
var whitelistText = (Supplier<TranslatableComponent>) () -> new TranslatableComponent("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist"));
|
||||
buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> {
|
||||
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
|
||||
button.setMessage(new TranslatableComponent(whitelistText.get()));
|
||||
}) {
|
||||
@Override
|
||||
public void renderToolTip(PoseStack matrix, int x, int y) {
|
||||
gui.renderTooltip(matrix, new TranslatableComponent(whitelistText.get() + ".description").withStyle(ChatFormatting.GRAY), x, y);
|
||||
}
|
||||
});
|
||||
button.setMessage(whitelistText.get());
|
||||
}));
|
||||
}
|
||||
if (this.canPopulateFromInventories) {
|
||||
buttons.add(new Button(x - 42, y, 20, 20, new TranslatableComponent("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
|
||||
public void renderToolTip(PoseStack matrix, int x, int y) {
|
||||
gui.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y);
|
||||
|
@ -112,7 +107,7 @@ public class ItemFilter extends ItemStackHandler {
|
|||
}
|
||||
|
||||
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
|
||||
for (ItemStackHandler handler : this.pipe.getFilters()) {
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
|
@ -169,7 +164,6 @@ public class ItemFilter extends ItemStackHandler {
|
|||
|
||||
ItemFilter getFilter();
|
||||
|
||||
default void onFilterPopulated() {
|
||||
}
|
||||
default void onFilterPopulated() {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ public enum ItemOrder {
|
|||
}
|
||||
|
||||
public ItemOrder next() {
|
||||
return ItemOrder.values()[(this.ordinal() + 1) % ItemOrder.values().length];
|
||||
return values()[(this.ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
@ -42,7 +41,7 @@ public class ItemTerminalWidget extends AbstractWidget {
|
|||
this.setBlitOffset(100);
|
||||
renderer.blitOffset = 100;
|
||||
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();
|
||||
renderer.renderGuiItem(this.stack, this.x, this.y);
|
||||
var amount = !this.craftable ? this.stack.getCount() : 0;
|
||||
|
|
|
@ -20,30 +20,30 @@ public class PlayerPrefs {
|
|||
public boolean syncJei = true;
|
||||
|
||||
public void save() {
|
||||
var file = PlayerPrefs.getFile();
|
||||
var file = getFile();
|
||||
if (file.exists())
|
||||
file.delete();
|
||||
try (var writer = new FileWriter(file)) {
|
||||
PlayerPrefs.GSON.toJson(this, writer);
|
||||
GSON.toJson(this, writer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerPrefs get() {
|
||||
if (PlayerPrefs.instance == null) {
|
||||
var file = PlayerPrefs.getFile();
|
||||
if (instance == null) {
|
||||
var file = getFile();
|
||||
if (file.exists()) {
|
||||
try (var reader = new FileReader(file)) {
|
||||
PlayerPrefs.instance = PlayerPrefs.GSON.fromJson(reader, PlayerPrefs.class);
|
||||
return PlayerPrefs.instance;
|
||||
instance = GSON.fromJson(reader, PlayerPrefs.class);
|
||||
return instance;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
PlayerPrefs.instance = new PlayerPrefs();
|
||||
instance = new PlayerPrefs();
|
||||
}
|
||||
return PlayerPrefs.instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static File getFile() {
|
||||
|
|
|
@ -102,6 +102,6 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
|||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
this.pipePos = NbtUtils.readBlockPos(nbt.getCompound("pipe_pos"));
|
||||
this.direction = Direction.values()[nbt.getInt("direction")];
|
||||
this.direction = Direction.values()[(nbt.getInt("direction"))];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class PipeItem implements IPipeItem {
|
|||
}
|
||||
|
||||
public PipeItem(ItemStack stack, float speed) {
|
||||
this(PipeItem.TYPE, stack, speed);
|
||||
this(TYPE, stack, speed);
|
||||
}
|
||||
|
||||
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) {
|
||||
this.startInventory = startInventory;
|
||||
this.destInventory = destInventory;
|
||||
this.path = PipeItem.compilePath(path);
|
||||
this.path = compilePath(path);
|
||||
this.currGoalPos = this.getStartPipe();
|
||||
this.currentTile = 0;
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class PipeItem implements IPipeItem {
|
|||
currPipe = next;
|
||||
}
|
||||
} 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) {
|
||||
// we're past the start of the pipe, so move to the center of the next pipe
|
||||
BlockPos nextPos;
|
||||
|
|
|
@ -324,9 +324,11 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
|
|||
if (!this.world.isLoaded(dest))
|
||||
continue;
|
||||
var pipe = this.getPipe(dest);
|
||||
if (!pipe.canNetworkSee())
|
||||
continue;
|
||||
for (var dir : Direction.values()) {
|
||||
var handler = pipe.getItemHandler(dir);
|
||||
if (handler == null || !pipe.canNetworkSee(dir, handler))
|
||||
if (handler == null)
|
||||
continue;
|
||||
// check if this handler already exists (double-connected pipes, double chests etc.)
|
||||
if (info.stream().anyMatch(l -> handler.equals(l.getItemHandler(this.world))))
|
||||
|
|
|
@ -26,8 +26,6 @@ import org.apache.logging.log4j.util.TriConsumer;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
|
||||
|
||||
public class PacketButton {
|
||||
|
||||
private BlockPos pos;
|
||||
|
@ -123,10 +121,6 @@ public class PacketButton {
|
|||
TAG_FILTER((pos, data, player) -> {
|
||||
var container = (FilterModifierModuleContainer) player.containerMenu;
|
||||
FilterModifierModuleItem.setFilterTag(container.moduleStack, container.getTags().get(data[0]));
|
||||
}),
|
||||
DIRECTION_SELECTOR((pos, data, player) -> {
|
||||
if (player.containerMenu instanceof IDirectionContainer filtered)
|
||||
filtered.getSelector().onButtonPacket();
|
||||
});
|
||||
|
||||
public final TriConsumer<BlockPos, int[], Player> action;
|
||||
|
|
|
@ -53,8 +53,8 @@ public class PacketCraftingModuleTransfer {
|
|||
public void run() {
|
||||
Player player = ctx.get().getSender();
|
||||
if (player.containerMenu instanceof CraftingModuleContainer container) {
|
||||
PacketCraftingModuleTransfer.copy(container.input, message.inputs);
|
||||
PacketCraftingModuleTransfer.copy(container.output, message.outputs);
|
||||
copy(container.input, message.inputs);
|
||||
copy(container.output, message.outputs);
|
||||
container.modified = true;
|
||||
container.broadcastChanges();
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class PacketGhostSlot {
|
|||
private final TagKey<Item> tag;
|
||||
|
||||
public Entry(List<ItemStack> stacks) {
|
||||
var tag = Entry.getTagForStacks(stacks);
|
||||
var tag = getTagForStacks(stacks);
|
||||
if (tag != null) {
|
||||
this.stacks = null;
|
||||
this.tag = tag;
|
||||
|
|
|
@ -16,24 +16,24 @@ public final class PacketHandler {
|
|||
private static SimpleChannel network;
|
||||
|
||||
public static void setup() {
|
||||
PacketHandler.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(PrettyPipes.ID, "network"), () -> PacketHandler.VERSION, PacketHandler.VERSION::equals, PacketHandler.VERSION::equals);
|
||||
PacketHandler.network.registerMessage(0, PacketItemEnterPipe.class, PacketItemEnterPipe::toBytes, PacketItemEnterPipe::fromBytes, PacketItemEnterPipe::onMessage);
|
||||
PacketHandler.network.registerMessage(1, PacketButton.class, PacketButton::toBytes, PacketButton::fromBytes, PacketButton::onMessage);
|
||||
PacketHandler.network.registerMessage(2, PacketNetworkItems.class, PacketNetworkItems::toBytes, PacketNetworkItems::fromBytes, PacketNetworkItems::onMessage);
|
||||
PacketHandler.network.registerMessage(3, PacketRequest.class, PacketRequest::toBytes, PacketRequest::fromBytes, PacketRequest::onMessage);
|
||||
PacketHandler.network.registerMessage(4, PacketGhostSlot.class, PacketGhostSlot::toBytes, PacketGhostSlot::fromBytes, PacketGhostSlot::onMessage);
|
||||
PacketHandler.network.registerMessage(5, PacketCraftingModuleTransfer.class, PacketCraftingModuleTransfer::toBytes, PacketCraftingModuleTransfer::fromBytes, PacketCraftingModuleTransfer::onMessage);
|
||||
network = NetworkRegistry.newSimpleChannel(new ResourceLocation(PrettyPipes.ID, "network"), () -> VERSION, VERSION::equals, VERSION::equals);
|
||||
network.registerMessage(0, PacketItemEnterPipe.class, PacketItemEnterPipe::toBytes, PacketItemEnterPipe::fromBytes, PacketItemEnterPipe::onMessage);
|
||||
network.registerMessage(1, PacketButton.class, PacketButton::toBytes, PacketButton::fromBytes, PacketButton::onMessage);
|
||||
network.registerMessage(2, PacketNetworkItems.class, PacketNetworkItems::toBytes, PacketNetworkItems::fromBytes, PacketNetworkItems::onMessage);
|
||||
network.registerMessage(3, PacketRequest.class, PacketRequest::toBytes, PacketRequest::fromBytes, PacketRequest::onMessage);
|
||||
network.registerMessage(4, PacketGhostSlot.class, PacketGhostSlot::toBytes, PacketGhostSlot::fromBytes, PacketGhostSlot::onMessage);
|
||||
network.registerMessage(5, PacketCraftingModuleTransfer.class, PacketCraftingModuleTransfer::toBytes, PacketCraftingModuleTransfer::fromBytes, PacketCraftingModuleTransfer::onMessage);
|
||||
}
|
||||
|
||||
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) {
|
||||
PacketHandler.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message);
|
||||
network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message);
|
||||
}
|
||||
|
||||
public static void sendToServer(Object message) {
|
||||
PacketHandler.network.send(PacketDistributor.SERVER.noArg(), message);
|
||||
network.send(PacketDistributor.SERVER.noArg(), message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface IPipeItem extends INBTSerializable<CompoundTag> {
|
|||
|
||||
static IPipeItem load(CompoundTag nbt) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,26 +50,26 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
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> 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()
|
||||
.put(Direction.UP, Block.box(5, 10, 5, 11, 16, 11))
|
||||
.put(Direction.DOWN, Block.box(5, 0, 5, 11, 6, 11))
|
||||
.put(Direction.NORTH, Block.box(5, 5, 0, 11, 11, 6))
|
||||
.put(Direction.SOUTH, Block.box(5, 5, 10, 11, 11, 16))
|
||||
.put(Direction.EAST, Block.box(10, 5, 5, 16, 11, 11))
|
||||
.put(Direction.WEST, Block.box(0, 5, 5, 6, 11, 11))
|
||||
.put(Direction.UP, box(5, 10, 5, 11, 16, 11))
|
||||
.put(Direction.DOWN, box(5, 0, 5, 11, 6, 11))
|
||||
.put(Direction.NORTH, box(5, 5, 0, 11, 11, 6))
|
||||
.put(Direction.SOUTH, box(5, 5, 10, 11, 11, 16))
|
||||
.put(Direction.EAST, box(10, 5, 5, 16, 11, 11))
|
||||
.put(Direction.WEST, box(0, 5, 5, 6, 11, 11))
|
||||
.build();
|
||||
|
||||
static {
|
||||
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() {
|
||||
super(Block.Properties.of(Material.STONE).strength(2).sound(SoundType.STONE).noOcclusion());
|
||||
|
||||
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);
|
||||
this.registerDefaultState(state);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
var newState = this.createState(worldIn, pos, state);
|
||||
if (newState != state) {
|
||||
worldIn.setBlockAndUpdate(pos, newState);
|
||||
PipeBlock.onStateChanged(worldIn, pos, newState);
|
||||
onStateChanged(worldIn, pos, newState);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,17 +133,17 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
|
||||
@Override
|
||||
public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
PipeBlock.onStateChanged(worldIn, pos, state);
|
||||
onStateChanged(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
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)));
|
||||
|
@ -166,10 +166,10 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
var key = Pair.of(state, cover);
|
||||
var shape = cache.get(key);
|
||||
if (shape == null) {
|
||||
shape = PipeBlock.CENTER_SHAPE;
|
||||
for (var entry : PipeBlock.DIRECTIONS.entrySet()) {
|
||||
shape = CENTER_SHAPE;
|
||||
for (var entry : DIRECTIONS.entrySet()) {
|
||||
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)
|
||||
shape = shapeModifier.apply(shape);
|
||||
|
@ -187,7 +187,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
state = state.setValue(BlockStateProperties.WATERLOGGED, true);
|
||||
|
||||
for (var dir : Direction.values()) {
|
||||
var prop = PipeBlock.DIRECTIONS.get(dir);
|
||||
var prop = DIRECTIONS.get(dir);
|
||||
var type = this.getConnectionType(world, pos, dir, state);
|
||||
// don't reconnect on blocked faces
|
||||
if (type.isConnected() && curr.getValue(prop) == ConnectionType.BLOCKED)
|
||||
|
@ -215,8 +215,8 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
if (blockHandler != null)
|
||||
return ConnectionType.CONNECTED;
|
||||
var offState = world.getBlockState(offset);
|
||||
if (PipeBlock.hasLegsTo(world, offState, offset, direction)) {
|
||||
if (PipeBlock.DIRECTIONS.values().stream().noneMatch(d -> state.getValue(d) == ConnectionType.LEGS))
|
||||
if (hasLegsTo(world, offState, offset, direction)) {
|
||||
if (DIRECTIONS.values().stream().noneMatch(d -> state.getValue(d) == ConnectionType.LEGS))
|
||||
return ConnectionType.LEGS;
|
||||
}
|
||||
return ConnectionType.DISCONNECTED;
|
||||
|
@ -226,7 +226,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
if (state.getBlock() instanceof WallBlock || state.getBlock() instanceof FenceBlock)
|
||||
return direction == Direction.DOWN;
|
||||
if (state.getMaterial() == Material.STONE || state.getMaterial() == Material.METAL)
|
||||
return Block.canSupportCenter(world, pos, direction.getOpposite());
|
||||
return canSupportCenter(world, pos, direction.getOpposite());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
var connections = 0;
|
||||
var force = false;
|
||||
for (var dir : Direction.values()) {
|
||||
var value = newState.getValue(PipeBlock.DIRECTIONS.get(dir));
|
||||
var value = newState.getValue(DIRECTIONS.get(dir));
|
||||
if (!value.isConnected())
|
||||
continue;
|
||||
connections++;
|
||||
|
@ -271,7 +271,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
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) {
|
||||
|
|
|
@ -186,68 +186,65 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
}
|
||||
|
||||
public Pair<BlockPos, ItemStack> getAvailableDestination(ItemStack stack, boolean force, boolean preventOversending) {
|
||||
if (!this.canWork())
|
||||
return null;
|
||||
if (!force && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack)))
|
||||
return null;
|
||||
for (var dir : Direction.values()) {
|
||||
var dest = this.getAvailableDestination(dir, stack, force, preventOversending);
|
||||
if (!dest.isEmpty())
|
||||
return Pair.of(this.worldPosition.relative(dir), dest);
|
||||
var handler = this.getItemHandler(dir);
|
||||
if (handler == null)
|
||||
continue;
|
||||
var remain = ItemHandlerHelper.insertItem(handler, stack, true);
|
||||
// did we insert anything?
|
||||
if (remain.getCount() == stack.getCount())
|
||||
continue;
|
||||
var toInsert = stack.copy();
|
||||
toInsert.shrink(remain.getCount());
|
||||
// limit to the max amount that modules allow us to insert
|
||||
var maxAmount = this.streamModules().mapToInt(m -> m.getRight().getMaxInsertionAmount(m.getLeft(), this, stack, handler)).min().orElse(Integer.MAX_VALUE);
|
||||
if (maxAmount < toInsert.getCount())
|
||||
toInsert.setCount(maxAmount);
|
||||
var offset = this.worldPosition.relative(dir);
|
||||
if (preventOversending || maxAmount < Integer.MAX_VALUE) {
|
||||
var network = PipeNetwork.get(this.level);
|
||||
// these are the items that are currently in the pipes, going to this inventory
|
||||
var onTheWay = network.getItemsOnTheWay(offset, null);
|
||||
if (onTheWay > 0) {
|
||||
if (maxAmount < Integer.MAX_VALUE) {
|
||||
// these are the items on the way, limited to items of the same type as stack
|
||||
var onTheWaySame = network.getItemsOnTheWay(offset, stack);
|
||||
// check if any modules are limiting us
|
||||
if (toInsert.getCount() + onTheWaySame > maxAmount)
|
||||
toInsert.setCount(maxAmount - onTheWaySame);
|
||||
}
|
||||
// totalSpace will be the amount of items that fit into the attached container
|
||||
var totalSpace = 0;
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var copy = stack.copy();
|
||||
var maxStackSize = copy.getMaxStackSize();
|
||||
// if the container can store more than 64 items in this slot, then it's likely
|
||||
// a barrel or similar, meaning that the slot limit matters more than the max stack size
|
||||
var limit = handler.getSlotLimit(i);
|
||||
if (limit > 64)
|
||||
maxStackSize = limit;
|
||||
copy.setCount(maxStackSize);
|
||||
// this is an inaccurate check since it ignores the fact that some slots might
|
||||
// have space for items of other types, but it'll be good enough for us
|
||||
var left = handler.insertItem(i, copy, true);
|
||||
totalSpace += maxStackSize - left.getCount();
|
||||
}
|
||||
// if the items on the way plus the items we're trying to move are too much, reduce
|
||||
if (onTheWay + toInsert.getCount() > totalSpace)
|
||||
toInsert.setCount(totalSpace - onTheWay);
|
||||
}
|
||||
}
|
||||
// we return the item that can actually be inserted, NOT the remainder!
|
||||
if (!toInsert.isEmpty())
|
||||
return Pair.of(offset, toInsert);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getAvailableDestination(Direction direction, ItemStack stack, boolean force, boolean preventOversending) {
|
||||
if (!this.canWork())
|
||||
return ItemStack.EMPTY;
|
||||
var handler = this.getItemHandler(direction);
|
||||
if (handler == null || !force && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack, direction, handler)))
|
||||
return ItemStack.EMPTY;
|
||||
var remain = ItemHandlerHelper.insertItem(handler, stack, true);
|
||||
// did we insert anything?
|
||||
if (remain.getCount() == stack.getCount())
|
||||
return ItemStack.EMPTY;
|
||||
var toInsert = stack.copy();
|
||||
toInsert.shrink(remain.getCount());
|
||||
// limit to the max amount that modules allow us to insert
|
||||
var maxAmount = this.streamModules().mapToInt(m -> m.getRight().getMaxInsertionAmount(m.getLeft(), this, stack, handler)).min().orElse(Integer.MAX_VALUE);
|
||||
if (maxAmount < toInsert.getCount())
|
||||
toInsert.setCount(maxAmount);
|
||||
var offset = this.worldPosition.relative(direction);
|
||||
if (preventOversending || maxAmount < Integer.MAX_VALUE) {
|
||||
var network = PipeNetwork.get(this.level);
|
||||
// these are the items that are currently in the pipes, going to this inventory
|
||||
var onTheWay = network.getItemsOnTheWay(offset, null);
|
||||
if (onTheWay > 0) {
|
||||
if (maxAmount < Integer.MAX_VALUE) {
|
||||
// these are the items on the way, limited to items of the same type as stack
|
||||
var onTheWaySame = network.getItemsOnTheWay(offset, stack);
|
||||
// check if any modules are limiting us
|
||||
if (toInsert.getCount() + onTheWaySame > maxAmount)
|
||||
toInsert.setCount(maxAmount - onTheWaySame);
|
||||
}
|
||||
// totalSpace will be the amount of items that fit into the attached container
|
||||
var totalSpace = 0;
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var copy = stack.copy();
|
||||
var maxStackSize = copy.getMaxStackSize();
|
||||
// if the container can store more than 64 items in this slot, then it's likely
|
||||
// a barrel or similar, meaning that the slot limit matters more than the max stack size
|
||||
var limit = handler.getSlotLimit(i);
|
||||
if (limit > 64)
|
||||
maxStackSize = limit;
|
||||
copy.setCount(maxStackSize);
|
||||
// this is an inaccurate check since it ignores the fact that some slots might
|
||||
// have space for items of other types, but it'll be good enough for us
|
||||
var left = handler.insertItem(i, copy, true);
|
||||
totalSpace += maxStackSize - left.getCount();
|
||||
}
|
||||
// if the items on the way plus the items we're trying to move are too much, reduce
|
||||
if (onTheWay + toInsert.getCount() > totalSpace)
|
||||
toInsert.setCount(totalSpace - onTheWay);
|
||||
}
|
||||
}
|
||||
// we return the item that can actually be inserted, NOT the remainder!
|
||||
return toInsert;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
@ -318,9 +315,13 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean isConnectedInventory(Direction dir) {
|
||||
return this.getItemHandler(dir) != null;
|
||||
}
|
||||
|
||||
public boolean canHaveModules() {
|
||||
for (var dir : Direction.values()) {
|
||||
if (this.getItemHandler(dir) != null)
|
||||
if (this.isConnectedInventory(dir))
|
||||
return true;
|
||||
var connectable = this.getPipeConnectable(dir);
|
||||
if (connectable != null && connectable.allowsModules(this.worldPosition, dir))
|
||||
|
@ -329,8 +330,8 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean canNetworkSee(Direction direction, IItemHandler handler) {
|
||||
return this.streamModules().allMatch(m -> m.getRight().canNetworkSee(m.getLeft(), this, direction, handler));
|
||||
public boolean canNetworkSee() {
|
||||
return this.streamModules().allMatch(m -> m.getRight().canNetworkSee(m.getLeft(), this));
|
||||
}
|
||||
|
||||
public Stream<Pair<ItemStack, IModule>> streamModules() {
|
||||
|
|
|
@ -79,7 +79,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
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);
|
||||
|
||||
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);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
}
|
||||
|
||||
private void drawForeground(PoseStack matrix, int mouseX, int mouseY) {
|
||||
|
|
|
@ -17,7 +17,7 @@ public class CraftingModuleGui extends AbstractPipeGui<CraftingModuleContainer>
|
|||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(matrix, partialTicks, mouseX, mouseY);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,10 @@ import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
|||
import de.ellpeck.prettypipes.terminal.CraftingTerminalBlockEntity;
|
||||
import de.ellpeck.prettypipes.terminal.ItemTerminalBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -56,12 +54,12 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -149,7 +147,7 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
var out = output.getStackInSlot(i);
|
||||
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
|
||||
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)
|
||||
craftable += out.getCount() * availableCrafts;
|
||||
}
|
||||
|
@ -181,7 +179,7 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
continue;
|
||||
var copy = in.copy();
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.extraction;
|
||||
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
|
@ -11,10 +9,9 @@ import net.minecraft.world.inventory.MenuType;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionModuleItem> implements IFilteredContainer, IDirectionContainer {
|
||||
public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionModuleItem> implements IFilteredContainer {
|
||||
|
||||
public ItemFilter filter;
|
||||
public DirectionSelector directionSelector;
|
||||
|
||||
public ExtractionModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
||||
super(type, id, player, pos, moduleIndex);
|
||||
|
@ -23,8 +20,6 @@ public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionM
|
|||
@Override
|
||||
protected void addSlots() {
|
||||
this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
|
||||
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
|
||||
|
||||
for (var slot : this.filter.getSlots((176 - this.module.filterSlots * 18) / 2 + 1, 17 + 32))
|
||||
this.addSlot(slot);
|
||||
}
|
||||
|
@ -33,16 +28,10 @@ public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionM
|
|||
public void removed(Player playerIn) {
|
||||
super.removed(playerIn);
|
||||
this.filter.save();
|
||||
this.directionSelector.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getSelector() {
|
||||
return this.directionSelector;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ public class ExtractionModuleGui extends AbstractPipeGui<ExtractionModuleContain
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
for (var widget : this.menu.filter.getButtons(this, this.leftPos + this.imageWidth - 7, this.topPos + 17 + 32 + 20, true))
|
||||
for (var widget : this.menu.filter.getButtons(this, this.leftPos + 7, this.topPos + 17 + 32 + 20))
|
||||
this.addRenderableWidget(widget);
|
||||
this.addRenderableWidget(this.menu.directionSelector.getButton(this.leftPos + 7, this.topPos + 17 + 32 + 20));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.prettypipes.Registry;
|
|||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
|
@ -13,7 +12,6 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class ExtractionModuleItem extends ModuleItem {
|
||||
|
||||
|
@ -35,36 +33,35 @@ public class ExtractionModuleItem extends ModuleItem {
|
|||
if (!tile.shouldWorkNow(this.speed) || !tile.canWork())
|
||||
return;
|
||||
var filter = this.getItemFilter(module, tile);
|
||||
var dir = this.getDirectionSelector(module, tile).getDirection();
|
||||
if (dir == null)
|
||||
return;
|
||||
var handler = tile.getItemHandler(dir);
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
var network = PipeNetwork.get(tile.getLevel());
|
||||
for (var j = 0; j < handler.getSlots(); j++) {
|
||||
var stack = handler.extractItem(j, this.maxExtraction, true);
|
||||
if (stack.isEmpty())
|
||||
for (var dir : Direction.values()) {
|
||||
var handler = tile.getItemHandler(dir);
|
||||
if (handler == null)
|
||||
continue;
|
||||
if (!filter.isAllowed(stack))
|
||||
continue;
|
||||
var remain = network.routeItem(tile.getBlockPos(), tile.getBlockPos().relative(dir), stack, this.preventOversending);
|
||||
if (remain.getCount() != stack.getCount()) {
|
||||
handler.extractItem(j, stack.getCount() - remain.getCount(), false);
|
||||
return;
|
||||
for (var j = 0; j < handler.getSlots(); j++) {
|
||||
var stack = handler.extractItem(j, this.maxExtraction, true);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
if (!filter.isAllowed(stack))
|
||||
continue;
|
||||
var remain = network.routeItem(tile.getBlockPos(), tile.getBlockPos().relative(dir), stack, this.preventOversending);
|
||||
if (remain.getCount() != stack.getCount()) {
|
||||
handler.extractItem(j, stack.getCount() - remain.getCount(), false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
|
||||
return direction != this.getDirectionSelector(module, tile).getDirection();
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
|
||||
return direction != this.getDirectionSelector(module, tile).getDirection();
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,9 +83,4 @@ public class ExtractionModuleItem extends ModuleItem {
|
|||
public ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile) {
|
||||
return new ItemFilter(this.filterSlots, module, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return new DirectionSelector(module, tile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.insertion;
|
||||
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
|
@ -11,10 +9,9 @@ import net.minecraft.world.inventory.MenuType;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleItem> implements IFilteredContainer, IDirectionContainer {
|
||||
public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleItem> implements IFilteredContainer {
|
||||
|
||||
public ItemFilter filter;
|
||||
public DirectionSelector directionSelector;
|
||||
|
||||
public FilterModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
||||
super(type, id, player, pos, moduleIndex);
|
||||
|
@ -29,8 +26,6 @@ public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleIte
|
|||
@Override
|
||||
protected void addSlots() {
|
||||
this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
|
||||
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
|
||||
|
||||
for (var slot : this.filter.getSlots((176 - Math.min(this.module.filterSlots, 9) * 18) / 2 + 1, 17 + 32))
|
||||
this.addSlot(slot);
|
||||
}
|
||||
|
@ -39,17 +34,10 @@ public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleIte
|
|||
public void removed(Player playerIn) {
|
||||
super.removed(playerIn);
|
||||
this.filter.save();
|
||||
this.directionSelector.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getSelector() {
|
||||
return this.directionSelector;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.insertion;
|
||||
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
@ -14,9 +15,7 @@ public class FilterModuleGui extends AbstractPipeGui<FilterModuleContainer> {
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
var buttonsY = this.topPos + 17 + 32 + 18 * Mth.ceil(this.menu.filter.getSlots() / 9F) + 2;
|
||||
for (var widget : this.menu.filter.getButtons(this, this.leftPos + this.imageWidth - 7, buttonsY, true))
|
||||
for (var widget : this.menu.filter.getButtons(this, this.leftPos + 7, this.topPos + 17 + 32 + 18 * Mth.ceil(this.menu.filter.getSlots() / 9F) + 2))
|
||||
this.addRenderableWidget(widget);
|
||||
this.addRenderableWidget(this.menu.directionSelector.getButton(this.leftPos + 7, buttonsY));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,12 @@ import de.ellpeck.prettypipes.Registry;
|
|||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class FilterModuleItem extends ModuleItem {
|
||||
|
||||
|
@ -26,8 +23,9 @@ public class FilterModuleItem extends ModuleItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
|
||||
return this.getDirectionSelector(module, tile).getDirection() != direction || this.getItemFilter(module, tile).isAllowed(stack);
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) {
|
||||
var filter = this.getItemFilter(module, tile);
|
||||
return filter.isAllowed(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,9 +49,4 @@ public class FilterModuleItem extends ModuleItem {
|
|||
filter.canPopulateFromInventories = this.canPopulateFromInventories;
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return new DirectionSelector(module, tile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class FilterModifierModuleGui extends AbstractPipeGui<FilterModifierModul
|
|||
text = ChatFormatting.BOLD + text;
|
||||
FilterModifierModuleGui.this.font.draw(matrix, text, this.x, this.y, color);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
}
|
||||
|
||||
private boolean onClicked(double mouseX, double mouseY, int button) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class FilterModifierModuleItem extends ModuleItem {
|
|||
|
||||
public ItemEquality getEqualityType(ItemStack stack) {
|
||||
if (this.type == ItemEquality.Type.TAG) {
|
||||
return ItemEquality.tag(FilterModifierModuleItem.getFilterTag(stack));
|
||||
return ItemEquality.tag(getFilterTag(stack));
|
||||
} else {
|
||||
return this.type.getDefaultInstance();
|
||||
}
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.retrieval;
|
||||
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalModuleItem> implements IFilteredContainer, IDirectionContainer {
|
||||
public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalModuleItem> implements IFilteredContainer {
|
||||
|
||||
public ItemFilter filter;
|
||||
public DirectionSelector directionSelector;
|
||||
|
||||
public RetrievalModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
||||
super(type, id, player, pos, moduleIndex);
|
||||
|
@ -23,8 +21,6 @@ public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalMod
|
|||
@Override
|
||||
protected void addSlots() {
|
||||
this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
|
||||
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
|
||||
|
||||
for (var slot : this.filter.getSlots((176 - this.module.filterSlots * 18) / 2 + 1, 17 + 32))
|
||||
this.addSlot(slot);
|
||||
}
|
||||
|
@ -33,16 +29,10 @@ public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalMod
|
|||
public void removed(Player playerIn) {
|
||||
super.removed(playerIn);
|
||||
this.filter.save();
|
||||
this.directionSelector.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getSelector() {
|
||||
return this.directionSelector;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.retrieval;
|
||||
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
|
@ -13,8 +14,7 @@ public class RetrievalModuleGui extends AbstractPipeGui<RetrievalModuleContainer
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
for (var widget : this.menu.filter.getButtons(this, this.leftPos + this.imageWidth - 7, this.topPos + 17 + 32 + 20, true))
|
||||
for (var widget : this.menu.filter.getButtons(this, this.leftPos + 7, this.topPos + 17 + 32 + 20))
|
||||
this.addRenderableWidget(widget);
|
||||
this.addRenderableWidget(this.menu.directionSelector.getButton(this.leftPos + 7, this.topPos + 17 + 32 + 20));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ import de.ellpeck.prettypipes.Registry;
|
|||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class RetrievalModuleItem extends ModuleItem {
|
||||
|
||||
|
@ -34,11 +34,8 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
public void tick(ItemStack module, PipeBlockEntity tile) {
|
||||
if (!tile.shouldWorkNow(this.speed) || !tile.canWork())
|
||||
return;
|
||||
var dir = this.getDirectionSelector(module, tile).getDirection();
|
||||
if (dir == null)
|
||||
return;
|
||||
|
||||
var network = PipeNetwork.get(tile.getLevel());
|
||||
|
||||
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||
// loop through filters to see which items to pull
|
||||
for (var subFilter : tile.getFilters()) {
|
||||
|
@ -48,26 +45,26 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
continue;
|
||||
var copy = filtered.copy();
|
||||
copy.setCount(this.maxExtraction);
|
||||
var dest = tile.getAvailableDestination(dir, copy, true, this.preventOversending);
|
||||
if (dest.isEmpty())
|
||||
var dest = tile.getAvailableDestination(copy, true, this.preventOversending);
|
||||
if (dest == null)
|
||||
continue;
|
||||
var remain = dest.copy();
|
||||
var remain = dest.getRight().copy();
|
||||
// are we already waiting for crafting results? If so, don't request those again
|
||||
remain.shrink(network.getCurrentlyCraftingAmount(tile.getBlockPos(), copy, equalityTypes));
|
||||
if (network.requestItem(tile.getBlockPos(), tile.getBlockPos().relative(dir), remain, equalityTypes).isEmpty())
|
||||
if (network.requestItem(tile.getBlockPos(), dest.getLeft(), remain, equalityTypes).isEmpty())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
|
||||
return direction != this.getDirectionSelector(module, tile).getDirection();
|
||||
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
|
||||
return direction != this.getDirectionSelector(module, tile).getDirection();
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,9 +89,4 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
filter.isWhitelist = true;
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return new DirectionSelector(module, tile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ public class StackSizeModuleItem extends ModuleItem {
|
|||
|
||||
@Override
|
||||
public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) {
|
||||
var max = StackSizeModuleItem.getMaxStackSize(module);
|
||||
if (StackSizeModuleItem.getLimitToMaxStackSize(module))
|
||||
var max = getMaxStackSize(module);
|
||||
if (getLimitToMaxStackSize(module))
|
||||
max = Math.min(max, stack.getMaxStackSize());
|
||||
var amount = 0;
|
||||
for (var i = 0; i < destination.getSlots(); i++) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class PressurizerBlock extends BaseEntityBlock {
|
|||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
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
|
||||
|
|
|
@ -38,7 +38,7 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
|
|||
@Override
|
||||
protected void renderBg(PoseStack matrixStack, float partialTicks, int x, int y) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, PressurizerGui.TEXTURE);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
this.blit(matrixStack, this.leftPos, this.topPos, 0, 0, 176, 137);
|
||||
var energy = (int) (this.menu.tile.getEnergyPercentage() * 124);
|
||||
this.blit(matrixStack, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12);
|
||||
|
|
|
@ -3,7 +3,6 @@ package de.ellpeck.prettypipes.terminal;
|
|||
import de.ellpeck.prettypipes.Registry;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
@ -19,6 +18,6 @@ public class CraftingTerminalBlock extends ItemTerminalBlock {
|
|||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,10 +111,10 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
network.startProfile("terminal_request_crafting");
|
||||
this.updateItems();
|
||||
// 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);
|
||||
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 (lowestAvailable <= 0 && force)
|
||||
lowestAvailable = maxAmount;
|
||||
|
@ -128,7 +128,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
continue;
|
||||
requested = requested.copy();
|
||||
requested.setCount(lowestAvailable);
|
||||
this.requestItemImpl(requested, ItemTerminalBlockEntity.onItemUnavailable(player, force));
|
||||
this.requestItemImpl(requested, onItemUnavailable(player, force));
|
||||
}
|
||||
player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".sending_ingredients", lowestAvailable).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN)), UUID.randomUUID());
|
||||
} else {
|
||||
|
|
|
@ -82,7 +82,7 @@ public class ItemTerminalBlock extends BaseEntityBlock {
|
|||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -163,11 +163,11 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
|||
.filter(s -> ItemEquality.compareItems(s, filter) && s.hasTag() && s.getTag().hashCode() == nbtHash)
|
||||
.findFirst().orElse(filter);
|
||||
}
|
||||
var requested = this.requestItemImpl(stack, ItemTerminalBlockEntity.onItemUnavailable(player, false));
|
||||
var requested = this.requestItemImpl(stack, onItemUnavailable(player, false));
|
||||
if (requested > 0) {
|
||||
player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".sending", requested, stack.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN)), UUID.randomUUID());
|
||||
} else {
|
||||
ItemTerminalBlockEntity.onItemUnavailable(player, false).accept(stack);
|
||||
onItemUnavailable(player, false).accept(stack);
|
||||
}
|
||||
network.endProfile();
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
|||
public int requestItemImpl(ItemStack stack, Consumer<ItemStack> unavailableConsumer) {
|
||||
var item = this.networkItems.get(new EquatableItemStack(stack, ItemEquality.NBT));
|
||||
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());
|
||||
return stack.getCount() - ret.getRight().getCount();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import de.ellpeck.prettypipes.PrettyPipes;
|
|||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
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.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -26,9 +25,9 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
protected void init() {
|
||||
super.init();
|
||||
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?)
|
||||
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));
|
||||
}));
|
||||
this.tick();
|
||||
|
@ -71,7 +70,7 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
|
||||
@Override
|
||||
protected ResourceLocation getTexture() {
|
||||
return CraftingTerminalGui.TEXTURE;
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.client.gui.components.EditBox;
|
|||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
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.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
|
@ -73,7 +72,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
this.updateWidgets();
|
||||
|
||||
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) {
|
||||
this.requestAmount = modifier;
|
||||
} else {
|
||||
|
@ -84,7 +83,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
this.requestAmount = 384;
|
||||
}));
|
||||
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)
|
||||
this.requestAmount = 1;
|
||||
}));
|
||||
|
@ -326,7 +325,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
this.hoveredCrafting = ItemStack.EMPTY;
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
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);
|
||||
|
||||
var x = 0;
|
||||
|
@ -350,7 +349,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
}
|
||||
|
||||
protected ResourceLocation getTexture() {
|
||||
return ItemTerminalGui.TEXTURE;
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -378,9 +377,9 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
}
|
||||
|
||||
public static int requestModifier() {
|
||||
if (Screen.hasControlDown()) {
|
||||
if (hasControlDown()) {
|
||||
return 10;
|
||||
} else if (Screen.hasShiftDown()) {
|
||||
} else if (hasShiftDown()) {
|
||||
return 64;
|
||||
} else {
|
||||
return 1;
|
||||
|
|
|
@ -62,13 +62,11 @@
|
|||
"container.prettypipes.item_terminal": "Item Terminal",
|
||||
"container.prettypipes.crafting_terminal": "Crafting Terminal",
|
||||
"container.prettypipes.pressurizer": "Pipe Pressurizer",
|
||||
"info.prettypipes.whitelist": "\u00A72A",
|
||||
"info.prettypipes.blacklist": "\u00A74D",
|
||||
"info.prettypipes.whitelist.description": "Items in filter slots are allowed",
|
||||
"info.prettypipes.blacklist.description": "Items in filter slots are disallowed",
|
||||
"info.prettypipes.whitelist": "Allowed",
|
||||
"info.prettypipes.blacklist": "Disallowed",
|
||||
"info.prettypipes.shift": "Hold Shift for info",
|
||||
"info.prettypipes.populate": "P",
|
||||
"info.prettypipes.populate.description": "Populate filter slots with items from adjacent inventories",
|
||||
"info.prettypipes.populate": "Populate",
|
||||
"info.prettypipes.populate.description": "Filters items from adjacent inventories",
|
||||
"info.prettypipes.max_stack_size": "Maximum item amount",
|
||||
"info.prettypipes.limit_to_max_on": "Limit to one stack",
|
||||
"info.prettypipes.limit_to_max_off": "Don't limit to one stack",
|
||||
|
@ -90,12 +88,5 @@
|
|||
"info.prettypipes.cancel_all": "Cancel",
|
||||
"info.prettypipes.cancel_all.desc": "Stops waiting for current crafting outputs\nDoesn't remove inputs from blocks",
|
||||
"info.prettypipes.no_pipe_connected": "The terminal needs to be connected to a pipe network",
|
||||
"info.prettypipes.too_many_pipes_connected": "The terminal can only be connected to a single pipe at a time",
|
||||
"dir.prettypipes.up": "Up",
|
||||
"dir.prettypipes.down": "Down",
|
||||
"dir.prettypipes.north": "North",
|
||||
"dir.prettypipes.east": "East",
|
||||
"dir.prettypipes.south": "South",
|
||||
"dir.prettypipes.west": "West",
|
||||
"dir.prettypipes.none": "No Side Valid"
|
||||
"info.prettypipes.too_many_pipes_connected": "The terminal can only be connected to a single pipe at a time"
|
||||
}
|
Loading…
Reference in a new issue