mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
compiles
This commit is contained in:
parent
3d3b1465c5
commit
05b815ac97
34 changed files with 193 additions and 226 deletions
|
@ -48,8 +48,6 @@ import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalGui;
|
|||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -57,9 +55,7 @@ import net.minecraft.world.entity.EntityType;
|
|||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
@ -80,12 +76,13 @@ import java.util.function.BiFunction;
|
|||
@Mod.EventBusSubscriber(bus = Bus.MOD)
|
||||
public final class Registry {
|
||||
|
||||
public static final CreativeModeTab TAB = new CreativeModeTab(PrettyPipes.ID) {
|
||||
// TODO creative tab bleh
|
||||
/* public static final CreativeModeTab TAB = new CreativeModeTab(PrettyPipes.ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(Registry.wrenchItem);
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
||||
public static Capability<PipeNetwork> pipeNetworkCapability = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
|
@ -132,7 +129,7 @@ public final class Registry {
|
|||
|
||||
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, "blank_module"), new Item(new Item.Properties()));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameItem = new PipeFrameItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "stack_size_module"), new StackSizeModuleItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "redstone_module"), new RedstoneModuleItem());
|
||||
|
@ -157,7 +154,7 @@ public final class Registry {
|
|||
|
||||
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))));
|
||||
.forEach(b -> h.register(b.getKey().location(), new BlockItem(b.getValue(), new Item.Properties())));
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, h -> {
|
||||
|
@ -188,7 +185,7 @@ public final class Registry {
|
|||
|
||||
private static <T extends AbstractPipeContainer<?>> MenuType<T> registerPipeContainer(RegisterEvent.RegisterHelper<MenuType<?>> helper, String name) {
|
||||
var type = (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 moduleStack = tile.modules.getStackInSlot(moduleIndex);
|
||||
return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex);
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class Utility {
|
|||
|
||||
public static Direction getDirectionFromOffset(BlockPos pos, BlockPos other) {
|
||||
var diff = pos.subtract(other);
|
||||
return Direction.fromNormal(diff.getX(), diff.getY(), diff.getZ());
|
||||
return Direction.fromDelta(diff.getX(), diff.getY(), diff.getZ());
|
||||
}
|
||||
|
||||
public static void addTooltip(String name, List<Component> tooltip) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<C
|
|||
List<PacketGhostSlot.Entry> stacks = new ArrayList<>();
|
||||
var ingredients = slots.getSlotViews(RecipeIngredientRole.INPUT);
|
||||
for (var entry : ingredients)
|
||||
stacks.add(new PacketGhostSlot.Entry(entry.getIngredients(VanillaTypes.ITEM_STACK).collect(Collectors.toList())));
|
||||
stacks.add(new PacketGhostSlot.Entry(player.level(), entry.getIngredients(VanillaTypes.ITEM_STACK).collect(Collectors.toList())));
|
||||
PacketHandler.sendToServer(new PacketGhostSlot(container.getTile().getBlockPos(), stacks));
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -73,12 +73,12 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
var screen = event.getScreen();
|
||||
if (!(screen instanceof ItemTerminalGui terminal))
|
||||
return;
|
||||
terminal.addRenderableWidget(this.jeiSyncButton = new Button(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20, Component.literal(""), button -> {
|
||||
terminal.addRenderableWidget(this.jeiSyncButton = Button.builder(Component.literal(""), button -> {
|
||||
var preferences = PlayerPrefs.get();
|
||||
preferences.syncJei = !preferences.syncJei;
|
||||
preferences.save();
|
||||
terminal.updateWidgets();
|
||||
}));
|
||||
}).bounds(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20).build());
|
||||
if (PlayerPrefs.get().syncJei)
|
||||
terminal.search.setValue(this.runtime.getIngredientFilter().getFilterText());
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
var sync = PlayerPrefs.get().syncJei;
|
||||
if (event instanceof ScreenEvent.Render.Post) {
|
||||
if (this.jeiSyncButton.isHoveredOrFocused())
|
||||
terminal.renderTooltip(event.getPoseStack(), Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||
event.getGuiGraphics().renderTooltip(terminal.getMinecraft().font, Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||
} else if (event instanceof ScreenEvent.Render.Pre) {
|
||||
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
|||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.DamageTypeTags;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
|
@ -48,19 +49,19 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.level.isClientSide)
|
||||
if (this.level().isClientSide)
|
||||
return;
|
||||
if (this.tickCount % 40 != 0)
|
||||
return;
|
||||
var network = PipeNetwork.get(this.level);
|
||||
var attached = PipeFrameEntity.getAttachedPipe(this.level, this.pos, this.direction);
|
||||
var network = PipeNetwork.get(this.level());
|
||||
var attached = PipeFrameEntity.getAttachedPipe(this.level(), this.pos, this.direction);
|
||||
if (attached != null) {
|
||||
var node = network.getNodeFromPipe(attached);
|
||||
if (node != null) {
|
||||
var stack = this.getItem();
|
||||
if (!stack.isEmpty()) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return super.survives() && PipeFrameEntity.canPlace(this.level, this.pos, this.direction);
|
||||
return super.survives() && PipeFrameEntity.canPlace(this.level(), this.pos, this.direction);
|
||||
}
|
||||
|
||||
private static BlockPos getAttachedPipe(Level world, BlockPos pos, Direction direction) {
|
||||
|
@ -96,8 +97,8 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(source)) {
|
||||
return false;
|
||||
} else if (!source.isExplosion() && !this.getItem().isEmpty()) {
|
||||
if (!this.level.isClientSide) {
|
||||
} else if (!source.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) {
|
||||
if (!this.level().isClientSide) {
|
||||
this.dropItemOrSelf(source.getDirectEntity(), false);
|
||||
this.playSound(SoundEvents.ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F);
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
}
|
||||
|
||||
private void dropItemOrSelf(@Nullable Entity entityIn, boolean b) {
|
||||
if (!this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
if (!this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
if (entityIn == null)
|
||||
this.getItem().setEntityRepresentation(null);
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package de.ellpeck.prettypipes.entities;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
|
@ -20,17 +21,17 @@ public class PipeFrameRenderer extends ItemFrameRenderer<PipeFrameEntity> {
|
|||
var vec3d = this.getRenderOffset(entityIn, partialTicks);
|
||||
matrixStackIn.translate(-vec3d.x, -vec3d.y, -vec3d.z);
|
||||
matrixStackIn.translate(direction.getStepX() * 0.46875, direction.getStepY() * 0.46875, direction.getStepZ() * 0.46875);
|
||||
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(entityIn.getXRot()));
|
||||
matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(180.0F - entityIn.getYRot()));
|
||||
matrixStackIn.mulPose(Axis.XP.rotationDegrees(entityIn.getXRot()));
|
||||
matrixStackIn.mulPose(Axis.YP.rotationDegrees(180.0F - entityIn.getYRot()));
|
||||
|
||||
var font = this.getFont();
|
||||
var amount = entityIn.getAmount();
|
||||
var ammountStrg = amount < 0 ? "?" : String.valueOf(amount);
|
||||
var x = 0.5F - font.width(ammountStrg) / 2F;
|
||||
var amountStrg = amount < 0 ? "?" : String.valueOf(amount);
|
||||
var x = 0.5F - font.width(amountStrg) / 2F;
|
||||
var matrix4f = matrixStackIn.last().pose();
|
||||
matrixStackIn.translate(0, 0.285F, 0.415F);
|
||||
matrixStackIn.scale(-0.02F, -0.02F, 0.02F);
|
||||
font.drawInBatch(ammountStrg, x, 0, 0xFFFFFF, true, matrix4f, bufferIn, false, 0, packedLightIn);
|
||||
font.drawInBatch(amountStrg, x, 0, 0xFFFFFF, true, matrix4f, bufferIn, Font.DisplayMode.NORMAL, 0, packedLightIn);
|
||||
|
||||
matrixStackIn.popPose();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
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;
|
||||
|
@ -30,7 +29,7 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
private final String name;
|
||||
|
||||
public ModuleItem(String name) {
|
||||
super(new Properties().tab(Registry.TAB).stacksTo(16));
|
||||
super(new Properties().stacksTo(16));
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
public class PipeFrameItem extends Item {
|
||||
|
||||
public PipeFrameItem() {
|
||||
super(new Properties().tab(Registry.TAB));
|
||||
super(new Properties());
|
||||
}
|
||||
|
||||
// HangingEntityItem copypasta mostly, since it hardcodes the entities bleh
|
||||
|
@ -60,7 +60,7 @@ public class PipeFrameItem extends Item {
|
|||
}
|
||||
|
||||
protected boolean canPlace(Player playerIn, Direction directionIn, ItemStack itemStackIn, BlockPos posIn) {
|
||||
return !directionIn.getAxis().isVertical() && playerIn.mayUseItemAt(posIn, directionIn, itemStackIn) && PipeFrameEntity.canPlace(playerIn.level, posIn, directionIn);
|
||||
return !directionIn.getAxis().isVertical() && playerIn.mayUseItemAt(posIn, directionIn, itemStackIn) && PipeFrameEntity.canPlace(playerIn.level(), posIn, directionIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.prettypipes.items;
|
||||
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||
|
@ -27,7 +26,7 @@ import java.util.List;
|
|||
public class WrenchItem extends Item {
|
||||
|
||||
public WrenchItem() {
|
||||
super(new Item.Properties().stacksTo(1).tab(Registry.TAB));
|
||||
super(new Item.Properties().stacksTo(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class Events {
|
|||
var dump = PipeNetwork.get(source.getLevel()).toString();
|
||||
try {
|
||||
Files.writeString(file, dump, StandardCharsets.UTF_8);
|
||||
source.sendSuccess(Component.literal("Wrote network dump to file " + file.toAbsolutePath()), true);
|
||||
source.sendSuccess(() -> Component.literal("Wrote network dump to file " + file.toAbsolutePath()), true);
|
||||
} catch (IOException e) {
|
||||
source.sendFailure(Component.literal("Failed to write network dump to file " + file.toAbsolutePath()));
|
||||
return -1;
|
||||
|
@ -43,13 +43,13 @@ public final class Events {
|
|||
.then(Commands.literal("uncache").executes(c -> {
|
||||
var source = c.getSource();
|
||||
PipeNetwork.get(source.getLevel()).clearCaches();
|
||||
source.sendSuccess(Component.literal("Cleared all pipe caches in the world"), true);
|
||||
source.sendSuccess(() -> Component.literal("Cleared all pipe caches in the world"), true);
|
||||
return 0;
|
||||
}))
|
||||
.then(Commands.literal("unlock").executes(c -> {
|
||||
var source = c.getSource();
|
||||
PipeNetwork.get(source.getLevel()).unlock();
|
||||
source.sendSuccess(Component.literal("Resolved all network locks in the world"), true);
|
||||
source.sendSuccess(() -> Component.literal("Resolved all network locks in the world"), true);
|
||||
return 0;
|
||||
})));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import java.util.function.Supplier;
|
|||
public class ItemEquality {
|
||||
|
||||
public static final ItemEquality DAMAGE = new ItemEquality((stack, filter) -> stack.getDamageValue() == filter.getDamageValue(), false, Type.DAMAGE);
|
||||
public static final ItemEquality NBT = new ItemEquality(ItemStack::tagMatches, false, Type.NBT);
|
||||
// TODO see if this tagMatches replacement is good enough?
|
||||
public static final ItemEquality NBT = new ItemEquality(ItemStack::areShareTagsEqual, false, Type.NBT);
|
||||
public static final ItemEquality MOD = new ItemEquality((stack, filter) -> stack.getItem().getCreatorModId(stack).equals(filter.getItem().getCreatorModId(filter)), true, Type.MOD);
|
||||
|
||||
public final Type type;
|
||||
|
@ -28,7 +29,7 @@ public class ItemEquality {
|
|||
}
|
||||
|
||||
public static boolean compareItems(ItemStack stack, ItemStack filter, ItemEquality... types) {
|
||||
var equal = ItemStack.isSameIgnoreDurability(stack, filter);
|
||||
var equal = ItemStack.isSameItem(stack, filter);
|
||||
if (types.length <= 0)
|
||||
return equal;
|
||||
for (var type : types) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
|
@ -8,6 +7,7 @@ import de.ellpeck.prettypipes.pipe.modules.modifier.FilterModifierModuleItem;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -52,23 +52,13 @@ public class ItemFilter extends ItemStackHandler {
|
|||
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, Component.translatable(whitelistText.get()), button -> {
|
||||
buttons.add(Button.builder(Component.translatable(whitelistText.get()), button -> {
|
||||
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
|
||||
button.setMessage(Component.translatable(whitelistText.get()));
|
||||
}) {
|
||||
@Override
|
||||
public void renderToolTip(PoseStack matrix, int x, int y) {
|
||||
gui.renderTooltip(matrix, Component.translatable(whitelistText.get() + ".description").withStyle(ChatFormatting.GRAY), x, y);
|
||||
}
|
||||
});
|
||||
}).bounds(x - 20, y, 20, 20).tooltip(Tooltip.create(Component.translatable(whitelistText.get() + ".description").withStyle(ChatFormatting.GRAY))).build());
|
||||
}
|
||||
if (this.canPopulateFromInventories) {
|
||||
buttons.add(new Button(x - 42, y, 20, 20, Component.translatable("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, Component.translatable("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y);
|
||||
}
|
||||
});
|
||||
buttons.add(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)).bounds(x - 42, y, 20, 20).tooltip(Tooltip.create(Component.translatable("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY))).build());
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
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.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -37,46 +37,44 @@ public class ItemTerminalWidget extends AbstractWidget {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
protected void renderWidget(GuiGraphics graphics, int p_268034_, int p_268009_, float p_268085_) {
|
||||
var mc = this.screen.getMinecraft();
|
||||
var renderer = mc.getItemRenderer();
|
||||
this.setBlitOffset(100);
|
||||
renderer.blitOffset = 100;
|
||||
// TODO test this new blit offset replacement?
|
||||
graphics.pose().translate(0, 0, 100);
|
||||
if (this.selected)
|
||||
GuiComponent.fill(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433);
|
||||
graphics.fill(this.getX(), this.getY(), this.getX() + 16, this.getY() + 16, -2130706433);
|
||||
RenderSystem.enableDepthTest();
|
||||
renderer.renderGuiItem(this.stack, this.x, this.y);
|
||||
graphics.renderItem(this.stack, this.getX(), this.getY());
|
||||
var amount = !this.craftable ? this.stack.getCount() : 0;
|
||||
var amountStrg = this.stack.getCount() >= 1000 ? amount / 1000 + "k" : String.valueOf(amount);
|
||||
renderer.renderGuiItemDecorations(mc.font, this.stack, this.x, this.y, amountStrg);
|
||||
renderer.blitOffset = 0;
|
||||
this.setBlitOffset(0);
|
||||
graphics.renderItemDecorations(mc.font, this.stack, this.getX(), this.getY(), amountStrg);
|
||||
graphics.pose().translate(0, 0, -100);
|
||||
|
||||
if (this.isHoveredOrFocused()) {
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.colorMask(true, true, true, false);
|
||||
this.fillGradient(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433, -2130706433);
|
||||
graphics.fillGradient(this.getX(), this.getY(), this.getX() + 16, this.getY() + 16, -2130706433, -2130706433);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderToolTip(PoseStack matrix, int mouseX, int mouseY) {
|
||||
public void renderToolTip(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
if (this.visible && this.isHoveredOrFocused()) {
|
||||
var tooltip = this.screen.getTooltipFromItem(this.stack);
|
||||
var tooltip = Screen.getTooltipFromItem(this.screen.getMinecraft(), this.stack);
|
||||
if (this.stack.getCount() >= 1000) {
|
||||
var comp = tooltip.get(0);
|
||||
if (comp instanceof MutableComponent m) {
|
||||
if (comp instanceof MutableComponent m)
|
||||
tooltip.set(0, m.append(Component.literal(" (" + this.stack.getCount() + ')').withStyle(ChatFormatting.BOLD)));
|
||||
}
|
||||
}
|
||||
this.screen.renderTooltip(matrix, tooltip, Optional.empty(), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.screen.getMinecraft().font, tooltip, Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNarration(NarrationElementOutput output) {
|
||||
public void updateWidgetNarration(NarrationElementOutput output) {
|
||||
this.defaultButtonNarrationText(output);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.prettypipes.pipe.IPipeItem;
|
|||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -18,6 +17,7 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -104,7 +104,7 @@ public class PipeItem implements IPipeItem {
|
|||
var currSpeed = Math.min(0.25F, motionLeft);
|
||||
motionLeft -= currSpeed;
|
||||
|
||||
var myPos = new BlockPos(this.x, this.y, this.z);
|
||||
var myPos = BlockPos.containing(this.x, this.y, this.z);
|
||||
if (!myPos.equals(currPipe.getBlockPos()) && (currPipe.getBlockPos().equals(this.getDestPipe()) || !myPos.equals(this.startInventory))) {
|
||||
// we're done with the current pipe, so switch to the next one
|
||||
currPipe.getItems().remove(this);
|
||||
|
@ -196,7 +196,7 @@ public class PipeItem implements IPipeItem {
|
|||
@Override
|
||||
public void drop(Level world, ItemStack stack) {
|
||||
var item = new ItemEntity(world, this.x, this.y, this.z, stack.copy());
|
||||
item.level.addFreshEntity(item);
|
||||
item.level().addFreshEntity(item);
|
||||
}
|
||||
|
||||
protected ItemStack store(PipeBlockEntity currPipe) {
|
||||
|
@ -312,7 +312,7 @@ public class PipeItem implements IPipeItem {
|
|||
(random.nextFloat() * 2.0F - 1.0F) * 0.25F * 0.5F,
|
||||
(random.nextFloat() * 2.0F - 1.0F) * 0.25F * 0.5F);
|
||||
}
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(this.stack, ItemTransforms.TransformType.GROUND, light, overlay, matrixStack, source, 0);
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(this.stack, ItemDisplayContext.GROUND, light, overlay, matrixStack, source, tile.getLevel(), 0);
|
||||
matrixStack.popPose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PacketButton {
|
|||
|
||||
public enum ButtonResult {
|
||||
PIPE_TAB((pos, data, player) -> {
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level, pos);
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level(), pos);
|
||||
if (data[0] < 0) {
|
||||
NetworkHooks.openScreen((ServerPlayer) player, tile, pos);
|
||||
} else {
|
||||
|
@ -113,11 +113,11 @@ public class PacketButton {
|
|||
StackSizeModuleItem.setMaxStackSize(container.moduleStack, data[0]);
|
||||
}),
|
||||
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level, pos);
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level(), pos);
|
||||
tile.requestCraftingItems(player, data[0], data[1] > 0);
|
||||
}),
|
||||
CANCEL_CRAFTING((pos, data, player) -> {
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, pos);
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), pos);
|
||||
tile.cancelCrafting();
|
||||
}),
|
||||
TAG_FILTER((pos, data, player) -> {
|
||||
|
|
|
@ -6,7 +6,7 @@ import de.ellpeck.prettypipes.Utility;
|
|||
import de.ellpeck.prettypipes.terminal.CraftingTerminalBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -14,6 +14,7 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -55,7 +56,7 @@ public class PacketGhostSlot {
|
|||
@SuppressWarnings("Convert2Lambda")
|
||||
public static void onMessage(PacketGhostSlot message, Supplier<NetworkEvent.Context> ctx) {
|
||||
var doIt = (Consumer<Player>) p -> {
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, p.level, message.pos);
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, p.level(), message.pos);
|
||||
if (tile != null)
|
||||
tile.setGhostItems(message.stacks);
|
||||
};
|
||||
|
@ -88,8 +89,8 @@ public class PacketGhostSlot {
|
|||
private final List<ItemStack> stacks;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
public Entry(List<ItemStack> stacks) {
|
||||
var tag = Entry.getTagForStacks(stacks);
|
||||
public Entry(Level level, List<ItemStack> stacks) {
|
||||
var tag = Entry.getTagForStacks(level, stacks);
|
||||
if (tag != null) {
|
||||
this.stacks = null;
|
||||
this.tag = tag;
|
||||
|
@ -107,14 +108,14 @@ public class PacketGhostSlot {
|
|||
this.stacks.add(buf.readItem());
|
||||
} else {
|
||||
this.stacks = null;
|
||||
this.tag = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(buf.readUtf()));
|
||||
this.tag = TagKey.create(Registries.ITEM, new ResourceLocation(buf.readUtf()));
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getStacks() {
|
||||
public List<ItemStack> getStacks(Level level) {
|
||||
if (this.stacks != null)
|
||||
return this.stacks;
|
||||
return Streams.stream(Registry.ITEM.getTagOrEmpty(this.tag).iterator())
|
||||
return Streams.stream(level.registryAccess().registry(Registries.ITEM).get().getTagOrEmpty(this.tag).iterator())
|
||||
.filter(h -> h.value() != null & h.value() != Items.AIR)
|
||||
.map(h -> new ItemStack(h.value())).collect(Collectors.toList());
|
||||
}
|
||||
|
@ -132,8 +133,8 @@ public class PacketGhostSlot {
|
|||
return buf;
|
||||
}
|
||||
|
||||
private static TagKey<Item> getTagForStacks(List<ItemStack> stacks) {
|
||||
return Registry.ITEM.getTags().filter(e -> {
|
||||
private static TagKey<Item> getTagForStacks(Level level, List<ItemStack> stacks) {
|
||||
return level.registryAccess().registry(Registries.ITEM).get().getTags().filter(e -> {
|
||||
var tag = e.getSecond();
|
||||
if (tag.size() != stacks.size())
|
||||
return false;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PacketRequest {
|
|||
@Override
|
||||
public void run() {
|
||||
Player player = ctx.get().getSender();
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, message.pos);
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), message.pos);
|
||||
message.stack.setCount(message.amount);
|
||||
tile.requestItem(player, message.stack, message.nbtHash);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.BooleanOp;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -66,7 +65,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
}
|
||||
|
||||
public PipeBlock() {
|
||||
super(Block.Properties.of(Material.STONE).strength(2).sound(SoundType.STONE).noOcclusion());
|
||||
super(Block.Properties.of().strength(2).sound(SoundType.STONE).noOcclusion());
|
||||
|
||||
var state = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false);
|
||||
for (var prop : PipeBlock.DIRECTIONS.values())
|
||||
|
@ -225,8 +224,9 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
protected static boolean hasLegsTo(Level world, BlockState state, BlockPos pos, Direction direction) {
|
||||
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());
|
||||
// TODO figure out new condition for legs now that materials are gone
|
||||
/* if (state.getMaterial() == Material.STONE || state.getMaterial() == Material.METAL)
|
||||
return Block.canSupportCenter(world, pos, direction.getOpposite());*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
|||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
@ -116,7 +117,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
public void load(CompoundTag compound) {
|
||||
this.modules.deserializeNBT(compound.getCompound("modules"));
|
||||
this.moduleDropCheck = compound.getInt("module_drop_check");
|
||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(compound.getCompound("cover")) : null;
|
||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), compound.getCompound("cover")) : null;
|
||||
this.craftIngredientRequests.clear();
|
||||
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), NetworkLock::new));
|
||||
this.craftResultRequests.clear();
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends AbstractC
|
|||
|
||||
public AbstractPipeContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
||||
super(type, id);
|
||||
this.tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level, pos);
|
||||
this.tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level(), pos);
|
||||
this.moduleStack = moduleIndex < 0 ? null : this.tile.modules.getStackInSlot(moduleIndex);
|
||||
this.module = moduleIndex < 0 ? null : (T) this.moduleStack.getItem();
|
||||
this.moduleIndex = moduleIndex;
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package de.ellpeck.prettypipes.pipe.containers;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -56,39 +53,38 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
for (var widget : this.renderables) {
|
||||
if (widget instanceof AbstractWidget abstractWidget) {
|
||||
// TDOO render widget tooltips?
|
||||
/* if (widget instanceof AbstractWidget abstractWidget) {
|
||||
if (abstractWidget.isHoveredOrFocused())
|
||||
abstractWidget.renderToolTip(matrix, mouseX, mouseY);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
this.renderTooltip(matrix, mouseX, mouseY);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
this.font.draw(matrix, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752);
|
||||
this.font.draw(matrix, this.title.getString(), 8, 6 + 32, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752);
|
||||
graphics.drawString(this.font, this.title.getString(), 8, 6 + 32, 4210752);
|
||||
for (var tab : this.tabs)
|
||||
tab.drawForeground(matrix, mouseX, mouseY);
|
||||
tab.drawForeground(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
this.blit(matrix, this.leftPos, this.topPos + 32, 0, 0, 176, 171);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos, this.topPos + 32, 0, 0, 176, 171);
|
||||
|
||||
for (var tab : this.tabs)
|
||||
tab.draw(matrix);
|
||||
tab.draw(graphics);
|
||||
|
||||
// draw the slots since we're using a blank ui
|
||||
for (var slot : this.menu.slots) {
|
||||
if (slot instanceof SlotItemHandler)
|
||||
this.blit(matrix, this.leftPos + slot.x - 1, this.topPos + slot.y - 1, 176, 62, 18, 18);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + slot.x - 1, this.topPos + slot.y - 1, 176, 62, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +124,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
this.y = AbstractPipeGui.this.topPos;
|
||||
}
|
||||
|
||||
private void draw(PoseStack matrix) {
|
||||
private void draw(GuiGraphics graphics) {
|
||||
var y = 2;
|
||||
var v = 0;
|
||||
var height = 30;
|
||||
|
@ -139,17 +135,14 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
height = 32;
|
||||
itemOffset = 7;
|
||||
}
|
||||
AbstractPipeGui.this.blit(matrix, this.x, this.y + y, 176, v, 28, height);
|
||||
|
||||
AbstractPipeGui.this.itemRenderer.renderGuiItem(this.moduleStack, this.x + 6, this.y + itemOffset);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.x, this.y + y, 176, v, 28, height);
|
||||
graphics.renderItem(this.moduleStack, this.x + 6, this.y + itemOffset);
|
||||
}
|
||||
|
||||
private void drawForeground(PoseStack matrix, int mouseX, int mouseY) {
|
||||
private void drawForeground(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
if (mouseX < this.x || mouseY < this.y || mouseX >= this.x + 28 || mouseY >= this.y + 32)
|
||||
return;
|
||||
AbstractPipeGui.this.renderTooltip(matrix, this.moduleStack.getHoverName(), mouseX - AbstractPipeGui.this.leftPos, mouseY - AbstractPipeGui.this.topPos);
|
||||
graphics.renderTooltip(AbstractPipeGui.this.font, this.moduleStack.getHoverName(), mouseX - AbstractPipeGui.this.leftPos, mouseY - AbstractPipeGui.this.topPos);
|
||||
}
|
||||
|
||||
private boolean onClicked(double mouseX, double mouseY, int button) {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.craft;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
|
@ -14,10 +12,8 @@ public class CraftingModuleGui extends AbstractPipeGui<CraftingModuleContainer>
|
|||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
this.blit(matrix, this.leftPos + 176 / 2 - 16 / 2, this.topPos + 32 + 18 * 2, 176, 80, 16, 16);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 176 / 2 - 16 / 2, this.topPos + 32 + 18 * 2, 176, 80, 16, 16);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.modifier;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -28,18 +28,18 @@ public class FilterModifierModuleGui extends AbstractPipeGui<FilterModifierModul
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(matrix, partialTicks, mouseX, mouseY);
|
||||
this.blit(matrix, this.leftPos + 7, this.topPos + 32 + 15, 0, 196, 162, 60);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 7, this.topPos + 32 + 15, 0, 196, 162, 60);
|
||||
|
||||
for (var tag : this.tagButtons)
|
||||
tag.draw(matrix, mouseX, mouseY);
|
||||
tag.draw(graphics, mouseX, mouseY);
|
||||
|
||||
if (this.tags.size() >= 6) {
|
||||
var percentage = this.scrollOffset / (float) (this.tags.size() - 5);
|
||||
this.blit(matrix, this.leftPos + 156, this.topPos + 32 + 16 + (int) (percentage * (58 - 15)), 232, 241, 12, 15);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 156, this.topPos + 32 + 16 + (int) (percentage * (58 - 15)), 232, 241, 12, 15);
|
||||
} else {
|
||||
this.blit(matrix, this.leftPos + 156, this.topPos + 32 + 16, 244, 241, 12, 15);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 156, this.topPos + 32 + 16, 244, 241, 12, 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,14 +117,14 @@ public class FilterModifierModuleGui extends AbstractPipeGui<FilterModifierModul
|
|||
this.y = y;
|
||||
}
|
||||
|
||||
private void draw(PoseStack matrix, double mouseX, double mouseY) {
|
||||
private void draw(GuiGraphics graphics, double mouseX, double mouseY) {
|
||||
var color = 4210752;
|
||||
var text = this.tag.toString();
|
||||
if (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 140 && mouseY < this.y + 12)
|
||||
color = 0xFFFFFF;
|
||||
if (this.tag.equals(FilterModifierModuleItem.getFilterTag(FilterModifierModuleGui.this.menu.moduleStack)))
|
||||
text = ChatFormatting.BOLD + text;
|
||||
FilterModifierModuleGui.this.font.draw(matrix, text, this.x, this.y, color);
|
||||
graphics.drawString(FilterModifierModuleGui.this.font, text, this.x, this.y, color);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.stacksize;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton.ButtonResult;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
|
@ -43,16 +43,16 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
|||
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"));
|
||||
this.addRenderableWidget(new Button(this.leftPos + 7, this.topPos + 17 + 32 + 10 + 22, 120, 20, buttonText.get(), b -> {
|
||||
this.addRenderableWidget(Button.builder(buttonText.get(), b -> {
|
||||
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON);
|
||||
b.setMessage(buttonText.get());
|
||||
}));
|
||||
}).bounds(this.leftPos + 7, this.topPos + 17 + 32 + 10 + 22, 120, 20).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
super.renderLabels(matrix, mouseX, mouseY);
|
||||
this.font.draw(matrix, I18n.get("info." + PrettyPipes.ID + ".max_stack_size") + ":", 7, 17 + 32, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
super.renderLabels(graphics, mouseX, mouseY);
|
||||
graphics.drawString(this.font, I18n.get("info." + PrettyPipes.ID + ".max_stack_size") + ":", 7, 17 + 32, 4210752);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -31,7 +30,7 @@ import java.util.List;
|
|||
public class PressurizerBlock extends BaseEntityBlock {
|
||||
|
||||
public PressurizerBlock() {
|
||||
super(BlockBehaviour.Properties.of(Material.STONE).strength(3).sound(SoundType.STONE));
|
||||
super(BlockBehaviour.Properties.of().strength(3).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class PressurizerContainer extends AbstractContainerMenu {
|
|||
|
||||
public PressurizerContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos) {
|
||||
super(type, id);
|
||||
this.tile = Utility.getBlockEntity(PressurizerBlockEntity.class, player.level, pos);
|
||||
this.tile = Utility.getBlockEntity(PressurizerBlockEntity.class, player.level(), pos);
|
||||
|
||||
for (var l = 0; l < 3; ++l)
|
||||
for (var j1 = 0; j1 < 9; ++j1)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package de.ellpeck.prettypipes.pressurizer;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
@ -20,26 +18,24 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(matrix, mouseX, mouseY);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
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);
|
||||
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + ".energy", this.menu.tile.getEnergy(), this.menu.tile.getMaxEnergy()), mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
this.font.draw(matrix, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752);
|
||||
this.font.draw(matrix, this.title.getString(), 8, 6, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752);
|
||||
graphics.drawString(this.font, this.title.getString(), 8, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrixStack, float partialTicks, int x, int y) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, PressurizerGui.TEXTURE);
|
||||
this.blit(matrixStack, this.leftPos, this.topPos, 0, 0, 176, 137);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int x, int y) {
|
||||
graphics.blit(PressurizerGui.TEXTURE, 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);
|
||||
graphics.blit(PressurizerGui.TEXTURE, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
public void setGhostItems(List<PacketGhostSlot.Entry> stacks) {
|
||||
this.updateItems();
|
||||
for (var i = 0; i < this.ghostItems.getSlots(); i++) {
|
||||
var items = stacks.get(i).getStacks();
|
||||
var items = stacks.get(i).getStacks(this.level);
|
||||
if (items.isEmpty()) {
|
||||
this.ghostItems.setStackInSlot(i, ItemStack.EMPTY);
|
||||
continue;
|
||||
|
@ -97,7 +97,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
if (!this.level.isClientSide) {
|
||||
List<PacketGhostSlot.Entry> clients = new ArrayList<>();
|
||||
for (var i = 0; i < this.ghostItems.getSlots(); i++)
|
||||
clients.add(new PacketGhostSlot.Entry(Collections.singletonList(this.ghostItems.getStackInSlot(i))));
|
||||
clients.add(new PacketGhostSlot.Entry(this.level, Collections.singletonList(this.ghostItems.getStackInSlot(i))));
|
||||
PacketHandler.sendToAllLoaded(this.level, this.getBlockPos(), new PacketGhostSlot(this.getBlockPos(), clients));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -31,7 +30,7 @@ import java.util.List;
|
|||
public class ItemTerminalBlock extends BaseEntityBlock {
|
||||
|
||||
public ItemTerminalBlock() {
|
||||
super(Properties.of(Material.STONE).strength(3).sound(SoundType.STONE));
|
||||
super(Properties.of().strength(3).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,11 +46,11 @@ public class CraftingTerminalContainer extends ItemTerminalContainer {
|
|||
@Override
|
||||
public void slotsChanged(Container inventoryIn) {
|
||||
super.slotsChanged(inventoryIn);
|
||||
if (!this.player.level.isClientSide) {
|
||||
if (!this.player.level().isClientSide) {
|
||||
var ret = ItemStack.EMPTY;
|
||||
var optional = this.player.level.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftInventory, this.player.level);
|
||||
var optional = this.player.level().getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftInventory, this.player.level());
|
||||
if (optional.isPresent())
|
||||
ret = optional.get().assemble(this.craftInventory);
|
||||
ret = optional.get().assemble(this.craftInventory, this.player.level().registryAccess());
|
||||
this.craftResult.setItem(0, ret);
|
||||
((ServerPlayer) this.player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, 0, 0, ret));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -24,12 +24,12 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
@Override
|
||||
protected void 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(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
var amount = ItemTerminalGui.requestModifier();
|
||||
// also allow holding backspace instead of alt for people whose alt key is inaccessible (linux?)
|
||||
var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;
|
||||
PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force));
|
||||
}));
|
||||
}).bounds(this.leftPos + 8, this.topPos + 100, 50, 20).build());
|
||||
this.tick();
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,10 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
super.renderLabels(matrix, mouseX, mouseY);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
super.renderLabels(graphics, mouseX, mouseY);
|
||||
|
||||
var container = this.getCraftingContainer();
|
||||
var tile = container.getTile();
|
||||
|
@ -63,8 +64,8 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
var slot = container.slots.stream().filter(s -> s.container == container.craftInventory && s.getSlotIndex() == finalI).findFirst().orElse(null);
|
||||
if (slot == null)
|
||||
continue;
|
||||
this.minecraft.getItemRenderer().renderGuiItem(ghost, slot.x, slot.y);
|
||||
this.minecraft.getItemRenderer().renderGuiItemDecorations(this.font, ghost, slot.x, slot.y, "0");
|
||||
graphics.renderItem(ghost, slot.x, slot.y);
|
||||
graphics.renderItemDecorations(this.font, ghost, slot.x, slot.y, "0");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ItemTerminalContainer extends AbstractContainerMenu {
|
|||
|
||||
public ItemTerminalContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos) {
|
||||
super(type, id);
|
||||
this.tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, pos);
|
||||
this.tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), pos);
|
||||
|
||||
this.addOwnSlots(player);
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.misc.ItemTerminalWidget;
|
||||
import de.ellpeck.prettypipes.misc.PlayerPrefs;
|
||||
|
@ -10,14 +8,14 @@ import de.ellpeck.prettypipes.packets.PacketButton;
|
|||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import de.ellpeck.prettypipes.packets.PacketRequest;
|
||||
import joptsimple.internal.Strings;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
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;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -70,7 +68,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
if (this.items != null)
|
||||
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(Button.builder(Component.literal("+"), button -> {
|
||||
var modifier = ItemTerminalGui.requestModifier();
|
||||
if (modifier > 1 && this.requestAmount == 1) {
|
||||
this.requestAmount = modifier;
|
||||
|
@ -80,14 +78,14 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
// 384 items is 6 stacks, which is what fits into the terminal slots
|
||||
if (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 -> {
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12).build());
|
||||
this.minusButton = this.addRenderableWidget(Button.builder(Component.literal("-"), button -> {
|
||||
this.requestAmount -= ItemTerminalGui.requestModifier();
|
||||
if (this.requestAmount < 1)
|
||||
this.requestAmount = 1;
|
||||
}));
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12).build());
|
||||
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(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
var widget = this.streamWidgets().filter(w -> w.selected).findFirst();
|
||||
if (!widget.isPresent())
|
||||
return;
|
||||
|
@ -95,26 +93,25 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
stack.setCount(1);
|
||||
PacketHandler.sendToServer(new PacketRequest(this.menu.tile.getBlockPos(), stack, this.requestAmount));
|
||||
this.requestAmount = 1;
|
||||
}));
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20).build());
|
||||
this.requestButton.active = false;
|
||||
this.orderButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos, 20, 20, Component.literal(""), button -> {
|
||||
this.orderButton = this.addRenderableWidget(Button.builder(Component.literal(""), button -> {
|
||||
if (this.sortedItems == null)
|
||||
return;
|
||||
var prefs = PlayerPrefs.get();
|
||||
prefs.terminalItemOrder = prefs.terminalItemOrder.next();
|
||||
prefs.save();
|
||||
this.updateWidgets();
|
||||
}));
|
||||
this.ascendingButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos + 22, 20, 20, Component.literal(""), button -> {
|
||||
}).bounds(this.leftPos - 22, this.topPos, 20, 20).build());
|
||||
this.ascendingButton = this.addRenderableWidget(Button.builder(Component.literal(""), button -> {
|
||||
if (this.sortedItems == null)
|
||||
return;
|
||||
var prefs = PlayerPrefs.get();
|
||||
prefs.terminalAscending = !prefs.terminalAscending;
|
||||
prefs.save();
|
||||
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 -> {
|
||||
}));
|
||||
}).bounds(this.leftPos - 22, this.topPos + 22, 20, 20).build());
|
||||
this.cancelCraftingButton = this.addRenderableWidget(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".cancel_all"), b -> {}).bounds(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20).build());
|
||||
this.cancelCraftingButton.visible = false;
|
||||
for (var y = 0; y < 4; y++) {
|
||||
for (var x = 0; x < 9; x++)
|
||||
|
@ -148,9 +145,9 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
if (button == 0 && mouseX >= this.leftPos + this.getXOffset() + 172 && this.topPos + mouseY >= 18 && mouseX < this.leftPos + this.getXOffset() + 172 + 12 && mouseY < this.topPos + 18 + 70) {
|
||||
this.isScrolling = true;
|
||||
return true;
|
||||
} else if (button == 1 && mouseX >= this.search.x && mouseX <= this.search.x + this.search.getWidth() && mouseY >= this.search.y && mouseY <= this.search.y + 8) {
|
||||
} else if (button == 1 && mouseX >= this.search.getX() && mouseX <= this.search.getX() + this.search.getWidth() && mouseY >= this.search.getY() && mouseY <= this.search.getY() + 8) {
|
||||
this.search.setValue("");
|
||||
this.search.setFocus(true);
|
||||
this.search.setFocused(true);
|
||||
this.setFocused(this.search);
|
||||
return true;
|
||||
}
|
||||
|
@ -268,72 +265,70 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
for (var widget : this.renderables) {
|
||||
if (widget instanceof ItemTerminalWidget terminal)
|
||||
terminal.renderToolTip(matrix, mouseX, mouseY);
|
||||
terminal.renderToolTip(graphics, mouseX, mouseY);
|
||||
}
|
||||
if (this.sortedItems != null) {
|
||||
var prefs = PlayerPrefs.get();
|
||||
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);
|
||||
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
|
||||
if (this.ascendingButton.isHoveredOrFocused())
|
||||
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||
}
|
||||
if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) {
|
||||
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);
|
||||
graphics.renderTooltip(this.font, Arrays.stream(tooltip).map(Component::literal).collect(Collectors.toList()), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
if (!this.hoveredCrafting.isEmpty())
|
||||
this.renderTooltip(matrix, this.hoveredCrafting, mouseX, mouseY);
|
||||
this.renderTooltip(matrix, mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, this.hoveredCrafting, mouseX, mouseY);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
this.font.draw(matrix, this.playerInventoryTitle.getString(), 8 + this.getXOffset(), this.imageHeight - 96 + 2, 4210752);
|
||||
this.font.draw(matrix, this.title.getString(), 8, 6, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8 + this.getXOffset(), this.imageHeight - 96 + 2, 4210752);
|
||||
graphics.drawString(this.font, this.title.getString(), 8, 6, 4210752);
|
||||
|
||||
var amount = String.valueOf(this.requestAmount);
|
||||
this.font.draw(matrix, amount, (176 + 15 - this.font.width(amount)) / 2F - 7 + this.getXOffset(), 106, 4210752);
|
||||
graphics.drawString(this.font, amount, (176 + 15 - this.font.width(amount)) / 2 - 7 + this.getXOffset(), 106, 4210752);
|
||||
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
this.font.draw(matrix, I18n.get("info." + PrettyPipes.ID + ".crafting"), this.imageWidth + 4, 4 + 6, 4210752);
|
||||
graphics.drawString(this.font, I18n.get("info." + PrettyPipes.ID + ".crafting"), this.imageWidth + 4, 4 + 6, 4210752);
|
||||
if (this.currentlyCrafting.size() > 6)
|
||||
this.font.draw(matrix, ". . .", this.imageWidth + 24, 4 + 51, 4210752);
|
||||
graphics.drawString(this.font, ". . .", this.imageWidth + 24, 4 + 51, 4210752);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, this.getTexture());
|
||||
this.blit(matrix, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
graphics.blit(this.getTexture(), this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
|
||||
if (this.sortedItems != null && this.sortedItems.size() >= 9 * 4) {
|
||||
var percentage = this.scrollOffset / (float) (this.sortedItems.size() / 9 - 3);
|
||||
this.blit(matrix, this.leftPos + this.getXOffset() + 172, this.topPos + 18 + (int) (percentage * (70 - 15)), 232, 241, 12, 15);
|
||||
graphics.blit(this.getTexture(), this.leftPos + this.getXOffset() + 172, this.topPos + 18 + (int) (percentage * (70 - 15)), 232, 241, 12, 15);
|
||||
} else {
|
||||
this.blit(matrix, this.leftPos + this.getXOffset() + 172, this.topPos + 18, 244, 241, 12, 15);
|
||||
graphics.blit(this.getTexture(), this.leftPos + this.getXOffset() + 172, this.topPos + 18, 244, 241, 12, 15);
|
||||
}
|
||||
|
||||
// draw the items that are currently crafting
|
||||
this.hoveredCrafting = ItemStack.EMPTY;
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, ItemTerminalGui.TEXTURE);
|
||||
this.blit(matrix, this.leftPos + this.imageWidth, this.topPos + 4, 191, 0, 65, 89);
|
||||
graphics.blit(ItemTerminalGui.TEXTURE, this.leftPos + this.imageWidth, this.topPos + 4, 191, 0, 65, 89);
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
for (var stack : this.currentlyCrafting) {
|
||||
var itemX = this.leftPos + this.imageWidth + 4 + x * 18;
|
||||
var itemY = this.topPos + 4 + 16 + y * 18;
|
||||
this.itemRenderer.renderGuiItem(stack, itemX, itemY);
|
||||
this.itemRenderer.renderGuiItemDecorations(this.font, stack, itemX, itemY, String.valueOf(stack.getCount()));
|
||||
graphics.renderItem(stack, itemX, itemY);
|
||||
graphics.renderItemDecorations(this.font, stack, itemX, itemY, String.valueOf(stack.getCount()));
|
||||
if (mouseX >= itemX && mouseY >= itemY && mouseX < itemX + 16 && mouseY < itemY + 18)
|
||||
this.hoveredCrafting = stack;
|
||||
x++;
|
||||
|
@ -364,7 +359,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T extends GuiEventListener & Widget & NarratableEntry> T addRenderableWidget(T p_169406_) {
|
||||
public <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) {
|
||||
// overriding to public for JEIPrettyPipesPlugin
|
||||
return super.addRenderableWidget(p_169406_);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import net.minecraft.world.entity.player.StackedContents;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.inventory.TransientCraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class WrappedCraftingInventory extends CraftingContainer {
|
||||
public class WrappedCraftingInventory extends TransientCraftingContainer {
|
||||
|
||||
private final ItemStackHandler items;
|
||||
private final CraftingTerminalContainer eventHandler;
|
||||
|
|
Loading…
Reference in a new issue