mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-22 23:39:22 +01:00
part 1?
This commit is contained in:
parent
36f74ee44d
commit
85d080cb3a
20 changed files with 134 additions and 123 deletions
|
@ -23,7 +23,7 @@ if (System.getenv('BUILD_NUMBER') != null) {
|
|||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20200128-1.15.1'
|
||||
mappings channel: 'snapshot', version: '20200723-1.16.1'
|
||||
|
||||
runs {
|
||||
client {
|
||||
|
@ -95,11 +95,11 @@ configurations {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.15.2-31.1.19'
|
||||
minecraft 'net.minecraftforge:forge:1.16.3-34.0.9'
|
||||
embed "org.jgrapht:jgrapht-core:1.4.0"
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2")
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25")
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
|
|
|
@ -197,7 +197,7 @@ public final class Registry {
|
|||
|
||||
public static final class Client {
|
||||
public static void setup(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(pipeBlock, RenderType.cutout());
|
||||
RenderTypeLookup.setRenderLayer(pipeBlock, RenderType.getCutout());
|
||||
ClientRegistry.bindTileEntityRenderer(pipeTileEntity, PipeRenderer::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(pipeFrameEntity, PipeFrameRenderer::new);
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@ public final class Utility {
|
|||
if (Screen.hasShiftDown()) {
|
||||
String[] content = I18n.format("info." + PrettyPipes.ID + "." + name).split("\n");
|
||||
for (String s : content)
|
||||
tooltip.add(new StringTextComponent(s).setStyle(new Style().setColor(TextFormatting.GRAY)));
|
||||
tooltip.add(new StringTextComponent(s).setStyle(Style.EMPTY.setFormatting(TextFormatting.GRAY)));
|
||||
} else {
|
||||
tooltip.add(new TranslationTextComponent("info." + PrettyPipes.ID + ".shift").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)));
|
||||
tooltip.add(new TranslationTextComponent("info." + PrettyPipes.ID + ".shift").setStyle(Style.EMPTY.setFormatting(TextFormatting.DARK_GRAY)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ import net.minecraft.client.gui.screen.Screen;
|
|||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
|
@ -59,7 +61,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
if (!(screen instanceof ItemTerminalGui))
|
||||
return;
|
||||
ItemTerminalGui terminal = (ItemTerminalGui) screen;
|
||||
event.addWidget(this.jeiSyncButton = new Button(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20, "", button -> {
|
||||
event.addWidget(this.jeiSyncButton = new Button(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20, new StringTextComponent(""), button -> {
|
||||
PlayerPrefs prefs = PlayerPrefs.get();
|
||||
prefs.syncJei = !prefs.syncJei;
|
||||
prefs.save();
|
||||
|
@ -78,9 +80,9 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
boolean sync = PlayerPrefs.get().syncJei;
|
||||
if (event instanceof DrawScreenEvent.Post) {
|
||||
if (this.jeiSyncButton.isHovered())
|
||||
terminal.renderTooltip(I18n.format("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||
terminal.renderTooltip(event.getMatrixStack(), new TranslationTextComponent("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||
} else if (event instanceof DrawScreenEvent.Pre) {
|
||||
this.jeiSyncButton.setMessage((sync ? TextFormatting.GREEN : TextFormatting.RED) + "J");
|
||||
this.jeiSyncButton.setMessage(new StringTextComponent((sync ? TextFormatting.GREEN : TextFormatting.RED) + "J"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,7 @@ import net.minecraft.network.PacketBuffer;
|
|||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.GameRules;
|
||||
|
@ -125,14 +122,14 @@ public class PipeFrameEntity extends ItemFrameEntity implements IEntityAdditiona
|
|||
private void dropItemOrSelf(@Nullable Entity entityIn, boolean b) {
|
||||
if (!this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
||||
if (entityIn == null)
|
||||
this.getDisplayedItem().setItemFrame(null);
|
||||
this.getDisplayedItem().setAttachedEntity(null);
|
||||
} else {
|
||||
ItemStack itemstack = this.getDisplayedItem();
|
||||
this.setDisplayedItem(ItemStack.EMPTY);
|
||||
if (entityIn instanceof PlayerEntity) {
|
||||
PlayerEntity playerentity = (PlayerEntity) entityIn;
|
||||
if (playerentity.abilities.isCreativeMode) {
|
||||
itemstack.setItemFrame(null);
|
||||
itemstack.setAttachedEntity(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +139,7 @@ public class PipeFrameEntity extends ItemFrameEntity implements IEntityAdditiona
|
|||
|
||||
if (!itemstack.isEmpty()) {
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.setItemFrame(null);
|
||||
itemstack.setAttachedEntity(null);
|
||||
this.entityDropItem(itemstack);
|
||||
}
|
||||
|
||||
|
@ -150,10 +147,10 @@ public class PipeFrameEntity extends ItemFrameEntity implements IEntityAdditiona
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean processInitialInteract(PlayerEntity player, Hand hand) {
|
||||
public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) {
|
||||
if (this.getDisplayedItem().isEmpty())
|
||||
return super.processInitialInteract(player, hand);
|
||||
return false;
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,14 +4,13 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
||||
public class PipeFrameRenderer extends ItemFrameRenderer {
|
||||
public PipeFrameRenderer(EntityRendererManager renderManagerIn) {
|
||||
|
@ -23,7 +22,7 @@ public class PipeFrameRenderer extends ItemFrameRenderer {
|
|||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
|
||||
matrixStackIn.push();
|
||||
Direction direction = entityIn.getHorizontalFacing();
|
||||
Vec3d vec3d = this.getRenderOffset(entityIn, partialTicks);
|
||||
Vector3d vec3d = this.getRenderOffset(entityIn, partialTicks);
|
||||
matrixStackIn.translate(-vec3d.getX(), -vec3d.getY(), -vec3d.getZ());
|
||||
matrixStackIn.translate(direction.getXOffset() * 0.46875, direction.getYOffset() * 0.46875, direction.getZOffset() * 0.46875);
|
||||
matrixStackIn.rotate(Vector3f.XP.rotationDegrees(entityIn.rotationPitch));
|
||||
|
@ -33,7 +32,7 @@ public class PipeFrameRenderer extends ItemFrameRenderer {
|
|||
int amount = ((PipeFrameEntity) entityIn).getAmount();
|
||||
String ammountStrg = amount < 0 ? "?" : String.valueOf(amount);
|
||||
float x = 0.5F - font.getStringWidth(ammountStrg) / 2F;
|
||||
Matrix4f matrix4f = matrixStackIn.getLast().getPositionMatrix();
|
||||
Matrix4f matrix4f = matrixStackIn.getLast().getMatrix();
|
||||
matrixStackIn.translate(0, 0.285F, 0.415F);
|
||||
matrixStackIn.scale(-0.02F, -0.02F, 0.02F);
|
||||
font.renderString(ammountStrg, x, 0, 0xFFFFFF, true, matrix4f, bufferIn, false, 0, packedLightIn);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class WrenchItem extends Item {
|
|||
if (!(state.getBlock() instanceof PipeBlock))
|
||||
return ActionResultType.PASS;
|
||||
|
||||
if (context.getPlayer().isShiftKeyDown()) {
|
||||
if (context.getPlayer().isSneaking()) {
|
||||
if (!world.isRemote) {
|
||||
Block.spawnDrops(state, world, pos, world.getTileEntity(pos), null, ItemStack.EMPTY);
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_REMOVE_ITEM, SoundCategory.PLAYERS, 1, 1);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||
|
@ -13,6 +14,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
@ -54,17 +56,17 @@ public class ItemFilter extends ItemStackHandler {
|
|||
public List<Widget> getButtons(Screen gui, int x, int y) {
|
||||
List<Widget> buttons = new ArrayList<>();
|
||||
if (this.canModifyWhitelist) {
|
||||
Supplier<String> whitelistText = () -> I18n.format("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist"));
|
||||
Supplier<TranslationTextComponent> whitelistText = () -> new TranslationTextComponent("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist"));
|
||||
buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> {
|
||||
PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
|
||||
button.setMessage(whitelistText.get());
|
||||
}));
|
||||
}
|
||||
if (this.canPopulateFromInventories) {
|
||||
buttons.add(new Button(x + 72, y, 70, 20, I18n.format("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
|
||||
buttons.add(new Button(x + 72, y, 70, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
|
||||
@Override
|
||||
public void renderToolTip(int x, int y) {
|
||||
gui.renderTooltip(TextFormatting.GRAY + I18n.format("info." + PrettyPipes.ID + ".populate.description"), x, y);
|
||||
public void renderToolTip(MatrixStack matrix, int x, int y) {
|
||||
gui.renderTooltip(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + ".populate.description").mergeStyle(TextFormatting.GRAY), x, y);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Comparator;
|
|||
|
||||
public enum ItemOrder {
|
||||
AMOUNT(Comparator.comparingInt(ItemStack::getCount)),
|
||||
NAME(Comparator.comparing(s -> s.getDisplayName().getFormattedText())),
|
||||
NAME(Comparator.comparing(s -> s.getDisplayName().getString())),
|
||||
MOD(Comparator.comparing(s -> s.getItem().getRegistryName().getNamespace()));
|
||||
|
||||
public final Comparator<ItemStack> comparator;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||
|
@ -10,6 +11,9 @@ import net.minecraft.client.gui.widget.Widget;
|
|||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
@ -25,7 +29,7 @@ public class ItemTerminalWidget extends Widget {
|
|||
public ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
public ItemTerminalWidget(int xIn, int yIn, int gridX, int gridY, ItemTerminalGui screen) {
|
||||
super(xIn, yIn, 16, 16, "");
|
||||
super(xIn, yIn, 16, 16, new StringTextComponent(""));
|
||||
this.gridX = gridX;
|
||||
this.gridY = gridY;
|
||||
this.screen = screen;
|
||||
|
@ -39,18 +43,19 @@ public class ItemTerminalWidget extends Widget {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partialTicks) {
|
||||
public void renderButton(MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
Minecraft mc = this.screen.getMinecraft();
|
||||
ItemRenderer renderer = mc.getItemRenderer();
|
||||
this.setBlitOffset(100);
|
||||
renderer.zLevel = 100;
|
||||
if (this.selected)
|
||||
fill(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.renderItemAndEffectIntoGUI(mc.player, this.stack, this.x, this.y);
|
||||
int amount = this.stack.getCount();
|
||||
String amountStrg = this.stack.getCount() >= 1000 ? amount / 1000 + "k" : String.valueOf(amount);
|
||||
FontRenderer font = mc.getFontResourceManager().getFontRenderer(FONT);
|
||||
// TODO figure out how to get the unicode font renderer for the terminal
|
||||
FontRenderer font = mc.fontRenderer;//mc.getFontResourceManager().getFontRenderer(FONT);
|
||||
renderer.renderItemOverlayIntoGUI(font, this.stack, this.x, this.y, amountStrg);
|
||||
renderer.zLevel = 0;
|
||||
this.setBlitOffset(0);
|
||||
|
@ -58,23 +63,24 @@ public class ItemTerminalWidget extends Widget {
|
|||
if (this.isHovered()) {
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.colorMask(true, true, true, false);
|
||||
this.fillGradient(this.x, this.y, this.x + 16, this.y + 16, -2130706433, -2130706433);
|
||||
this.fillGradient(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433, -2130706433);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderToolTip(int mouseX, int mouseY) {
|
||||
public void renderToolTip(MatrixStack matrix, int mouseX, int mouseY) {
|
||||
if (this.visible && this.isHovered()) {
|
||||
FontRenderer font = this.stack.getItem().getFontRenderer(this.stack);
|
||||
if (font == null)
|
||||
font = this.screen.getMinecraft().fontRenderer;
|
||||
GuiUtils.preItemToolTip(this.stack);
|
||||
List<String> tooltip = this.screen.getTooltipFromItem(this.stack);
|
||||
if (this.stack.getCount() >= 1000)
|
||||
tooltip.set(0, tooltip.get(0) + TextFormatting.BOLD + " (" + this.stack.getCount() + ')');
|
||||
this.screen.renderTooltip(tooltip, mouseX, mouseY, font);
|
||||
List<ITextComponent> tooltip = this.screen.getTooltipFromItem(this.stack);
|
||||
if (this.stack.getCount() >= 1000) {
|
||||
ITextComponent comp = tooltip.get(0);
|
||||
if (comp instanceof TextComponent) {
|
||||
tooltip.set(0, ((TextComponent) comp).append(new StringTextComponent(" (" + this.stack.getCount() + ')').mergeStyle(TextFormatting.BOLD)));
|
||||
}
|
||||
}
|
||||
this.screen.func_243308_b(matrix, tooltip, mouseX, mouseY);
|
||||
GuiUtils.postItemToolTip();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.ILiquidContainer;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
|
@ -16,7 +16,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -107,7 +107,7 @@ public class PipeItem implements INBTSerializable<CompoundNBT>, ILiquidContainer
|
|||
next.getItems().add(this);
|
||||
}
|
||||
} else {
|
||||
double dist = new Vec3d(this.currGoalPos).squareDistanceTo(this.x - 0.5F, this.y - 0.5F, this.z - 0.5F);
|
||||
double dist = Vector3d.copy(this.currGoalPos).squareDistanceTo(this.x - 0.5F, this.y - 0.5F, this.z - 0.5F);
|
||||
if (dist < this.speed * this.speed) {
|
||||
// we're past the start of the pipe, so move to the center of the next pipe
|
||||
BlockPos nextPos;
|
||||
|
@ -127,8 +127,8 @@ public class PipeItem implements INBTSerializable<CompoundNBT>, ILiquidContainer
|
|||
float tolerance = 0.001F;
|
||||
if (dist >= tolerance * tolerance) {
|
||||
// when going around corners, we want to move right up to the corner
|
||||
Vec3d motion = new Vec3d(this.x - this.lastX, this.y - this.lastY, this.z - this.lastZ);
|
||||
Vec3d diff = new Vec3d(nextPos.getX() + 0.5F - this.x, nextPos.getY() + 0.5F - this.y, nextPos.getZ() + 0.5F - this.z);
|
||||
Vector3d motion = new Vector3d(this.x - this.lastX, this.y - this.lastY, this.z - this.lastZ);
|
||||
Vector3d diff = new Vector3d(nextPos.getX() + 0.5F - this.x, nextPos.getY() + 0.5F - this.y, nextPos.getZ() + 0.5F - this.z);
|
||||
if (motion.crossProduct(diff).length() >= tolerance) {
|
||||
currSpeed = (float) Math.sqrt(dist);
|
||||
} else {
|
||||
|
@ -146,7 +146,7 @@ public class PipeItem implements INBTSerializable<CompoundNBT>, ILiquidContainer
|
|||
this.lastY = this.y;
|
||||
this.lastZ = this.z;
|
||||
|
||||
Vec3d dist = new Vec3d(this.currGoalPos.getX() + 0.5F - this.x, this.currGoalPos.getY() + 0.5F - this.y, this.currGoalPos.getZ() + 0.5F - this.z);
|
||||
Vector3d dist = new Vector3d(this.currGoalPos.getX() + 0.5F - this.x, this.currGoalPos.getY() + 0.5F - this.y, this.currGoalPos.getZ() + 0.5F - this.z);
|
||||
dist = dist.normalize();
|
||||
this.x += dist.x * currSpeed;
|
||||
this.y += dist.y * currSpeed;
|
||||
|
@ -292,7 +292,7 @@ public class PipeItem implements INBTSerializable<CompoundNBT>, ILiquidContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, IFluidState fluidStateIn) {
|
||||
public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public enum ConnectionType implements IStringSerializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
|
@ -55,7 +55,7 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
|
||||
static {
|
||||
for (Direction dir : Direction.values())
|
||||
DIRECTIONS.put(dir, EnumProperty.create(dir.getName(), ConnectionType.class));
|
||||
DIRECTIONS.put(dir, EnumProperty.create(dir.getName2(), ConnectionType.class));
|
||||
}
|
||||
|
||||
public PipeBlock() {
|
||||
|
@ -98,7 +98,7 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IFluidState getFluidState(BlockState state) {
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
|
@ -129,11 +129,6 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
onStateChanged(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
VoxelShape shape = SHAPE_CACHE.get(state);
|
||||
|
@ -151,7 +146,7 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
|
||||
private BlockState createState(World world, BlockPos pos, BlockState curr) {
|
||||
BlockState state = this.getDefaultState();
|
||||
IFluidState fluid = world.getFluidState(pos);
|
||||
FluidState fluid = world.getFluidState(pos);
|
||||
if (fluid.isTagged(FluidTags.WATER) && fluid.getLevel() == 8)
|
||||
state = state.with(BlockStateProperties.WATERLOGGED, true);
|
||||
|
||||
|
@ -191,7 +186,7 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
if (state.getBlock() instanceof WallBlock || state.getBlock() instanceof FenceBlock)
|
||||
return direction == Direction.DOWN;
|
||||
if (state.getMaterial() == Material.ROCK || state.getMaterial() == Material.IRON)
|
||||
return hasSolidSide(state, world, pos, direction.getOpposite());
|
||||
return hasEnoughSolidSide(world, pos, direction.getOpposite());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT compound) {
|
||||
public void read(BlockState state, CompoundNBT compound) {
|
||||
this.modules.deserializeNBT(compound.getCompound("modules"));
|
||||
super.read(compound);
|
||||
super.read(state, compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,8 +89,8 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag(CompoundNBT nbt) {
|
||||
this.read(nbt);
|
||||
public void handleUpdateTag(BlockState state, CompoundNBT nbt) {
|
||||
this.read(state, nbt);
|
||||
List<PipeItem> items = this.getItems();
|
||||
items.clear();
|
||||
items.addAll(Utility.deserializeAll(nbt.getList("items", NBT.TAG_COMPOUND), PipeItem::new));
|
||||
|
@ -217,7 +217,7 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
if (tile instanceof ChestTileEntity) {
|
||||
BlockState state = this.world.getBlockState(tile.getPos());
|
||||
if (state.getBlock() instanceof ChestBlock)
|
||||
return new InvWrapper(ChestBlock.func_226916_a_((ChestBlock) state.getBlock(), state, this.world, tile.getPos(), true));
|
||||
return new InvWrapper(ChestBlock.getChestInventory((ChestBlock) state.getBlock(), state, this.world, tile.getPos(), true));
|
||||
}
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite()).orElse(null);
|
||||
if (handler != null)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.pipe.containers;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
|
@ -53,37 +54,37 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground();
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
public void render(MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
for (Widget widget : this.buttons) {
|
||||
if (widget.isHovered())
|
||||
widget.renderToolTip(mouseX, mouseY);
|
||||
widget.renderToolTip(matrix, mouseX, mouseY);
|
||||
}
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
this.func_230459_a_(matrix, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
this.font.drawString(this.title.getFormattedText(), 8, 6 + 32, 4210752);
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack matrix, int mouseX, int mouseY) {
|
||||
this.font.drawString(matrix, this.playerInventory.getDisplayName().getString(), 8, this.ySize - 96 + 2, 4210752);
|
||||
this.font.drawString(matrix, this.title.getString(), 8, 6 + 32, 4210752);
|
||||
for (Tab tab : this.tabs)
|
||||
tab.drawForeground(mouseX, mouseY);
|
||||
tab.drawForeground(matrix, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
this.getMinecraft().getTextureManager().bindTexture(TEXTURE);
|
||||
this.blit(this.guiLeft, this.guiTop + 32, 0, 0, 176, 171);
|
||||
this.blit(matrix, this.guiLeft, this.guiTop + 32, 0, 0, 176, 171);
|
||||
|
||||
for (Tab tab : this.tabs)
|
||||
tab.draw();
|
||||
tab.draw(matrix);
|
||||
|
||||
// draw the slots since we're using a blank ui
|
||||
for (Slot slot : this.container.inventorySlots) {
|
||||
if (slot.inventory == this.playerInventory)
|
||||
continue;
|
||||
this.blit(this.guiLeft + slot.xPos - 1, this.guiTop + slot.yPos - 1, 176, 62, 18, 18);
|
||||
this.blit(matrix, this.guiLeft + slot.xPos - 1, this.guiTop + slot.yPos - 1, 176, 62, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +125,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
this.y = AbstractPipeGui.this.guiTop;
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
private void draw(MatrixStack matrix) {
|
||||
int y = 2;
|
||||
int v = 0;
|
||||
int height = 30;
|
||||
|
@ -135,16 +136,16 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
height = 32;
|
||||
itemOffset = 7;
|
||||
}
|
||||
AbstractPipeGui.this.blit(this.x, this.y + y, 176, v, 28, height);
|
||||
AbstractPipeGui.this.blit(matrix, this.x, this.y + y, 176, v, 28, height);
|
||||
|
||||
AbstractPipeGui.this.itemRenderer.renderItemIntoGUI(this.moduleStack, this.x + 6, this.y + itemOffset);
|
||||
AbstractPipeGui.this.getMinecraft().getTextureManager().bindTexture(TEXTURE);
|
||||
}
|
||||
|
||||
private void drawForeground(int mouseX, int mouseY) {
|
||||
private void drawForeground(MatrixStack matrix, int mouseX, int mouseY) {
|
||||
if (mouseX < this.x || mouseY < this.y || mouseX >= this.x + 28 || mouseY >= this.y + 32)
|
||||
return;
|
||||
AbstractPipeGui.this.renderTooltip(this.moduleStack.getDisplayName().getFormattedText(), mouseX - AbstractPipeGui.this.guiLeft, mouseY - AbstractPipeGui.this.guiTop);
|
||||
AbstractPipeGui.this.renderTooltip(matrix, this.moduleStack.getDisplayName(), mouseX - AbstractPipeGui.this.guiLeft, mouseY - AbstractPipeGui.this.guiTop);
|
||||
}
|
||||
|
||||
private boolean onClicked(double mouseX, double mouseY, int button) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.stacksize;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton.ButtonResult;
|
||||
|
@ -9,6 +10,7 @@ import net.minecraft.client.gui.widget.button.Button;
|
|||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -20,7 +22,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
TextFieldWidget textField = this.addButton(new TextFieldWidget(this.font, this.guiLeft + 7, this.guiTop + 17 + 32 + 10, 40, 20, "info." + PrettyPipes.ID + ".max_stack_size") {
|
||||
TextFieldWidget textField = this.addButton(new TextFieldWidget(this.font, this.guiLeft + 7, this.guiTop + 17 + 32 + 10, 40, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".max_stack_size")) {
|
||||
@Override
|
||||
public void writeText(String textToWrite) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
|
@ -39,7 +41,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
|||
int amount = Integer.parseInt(s);
|
||||
PacketButton.sendAndExecute(this.container.tile.getPos(), ButtonResult.STACK_SIZE_AMOUNT, amount);
|
||||
});
|
||||
Supplier<String> buttonText = () -> I18n.format("info." + PrettyPipes.ID + ".limit_to_max_" + (StackSizeModuleItem.getLimitToMaxStackSize(this.container.moduleStack) ? "on" : "off"));
|
||||
Supplier<TranslationTextComponent> buttonText = () -> new TranslationTextComponent("info." + PrettyPipes.ID + ".limit_to_max_" + (StackSizeModuleItem.getLimitToMaxStackSize(this.container.moduleStack) ? "on" : "off"));
|
||||
this.addButton(new Button(this.guiLeft + 7, this.guiTop + 17 + 32 + 10 + 22, 120, 20, buttonText.get(), b -> {
|
||||
PacketButton.sendAndExecute(this.container.tile.getPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON);
|
||||
b.setMessage(buttonText.get());
|
||||
|
@ -47,9 +49,9 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
this.font.drawString(I18n.format("info." + PrettyPipes.ID + ".max_stack_size") + ":", 7, 17 + 32, 4210752);
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack matrix, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(matrix, mouseX, mouseY);
|
||||
this.font.drawString(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + ".max_stack_size") + ":", 7, 17 + 32, 4210752);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.prettypipes.packets.PacketGhostSlot;
|
|||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalContainer;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
|
@ -133,7 +134,7 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
|||
lowestAvailable = 0;
|
||||
}
|
||||
if (available <= 0)
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".not_found", stack.stack.getDisplayName()).setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".not_found", stack.stack.getDisplayName()).setStyle(Style.EMPTY.setFormatting(TextFormatting.RED)), UUID.randomUUID());
|
||||
}
|
||||
if (lowestAvailable > 0) {
|
||||
// if we're only crafting one item, pretend we only have enough for one
|
||||
|
@ -147,7 +148,7 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
|||
requested.setCount(lowestAvailable);
|
||||
this.requestItemImpl(requested);
|
||||
}
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".sending_ingredients", lowestAvailable).setStyle(new Style().setColor(TextFormatting.GREEN)));
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".sending_ingredients", lowestAvailable).setStyle(Style.EMPTY.setFormatting(TextFormatting.GREEN)), UUID.randomUUID());
|
||||
}
|
||||
network.endProfile();
|
||||
}
|
||||
|
@ -159,9 +160,9 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT compound) {
|
||||
public void read(BlockState state, CompoundNBT compound) {
|
||||
this.craftItems.deserializeNBT(compound.getCompound("craft_items"));
|
||||
super.read(compound);
|
||||
super.read(state, compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import de.ellpeck.prettypipes.packets.PacketHandler;
|
|||
import de.ellpeck.prettypipes.packets.PacketNetworkItems;
|
||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
|
@ -138,9 +139,9 @@ public class ItemTerminalTileEntity extends TileEntity implements INamedContaine
|
|||
this.updateItems();
|
||||
int requested = this.requestItemImpl(stack);
|
||||
if (requested > 0) {
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".sending", requested, stack.getDisplayName()).setStyle(new Style().setColor(TextFormatting.GREEN)));
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".sending", requested, stack.getDisplayName()).setStyle(Style.EMPTY.setFormatting(TextFormatting.GREEN)), UUID.randomUUID());
|
||||
} else {
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".not_found", stack.getDisplayName()).setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".not_found", stack.getDisplayName()).setStyle(Style.EMPTY.setFormatting(TextFormatting.RED)), UUID.randomUUID());
|
||||
}
|
||||
network.endProfile();
|
||||
}
|
||||
|
@ -209,11 +210,11 @@ public class ItemTerminalTileEntity extends TileEntity implements INamedContaine
|
|||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT compound) {
|
||||
public void read(BlockState state, CompoundNBT compound) {
|
||||
this.items.deserializeNBT(compound.getCompound("items"));
|
||||
this.pendingRequests.clear();
|
||||
this.pendingRequests.addAll(Utility.deserializeAll(compound.getList("requests", NBT.TAG_COMPOUND), NetworkLock::new));
|
||||
super.read(compound);
|
||||
super.read(state, compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
|
@ -15,6 +16,7 @@ import net.minecraft.inventory.container.Slot;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public class CraftingTerminalGui extends ItemTerminalGui {
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/crafting_terminal.png");
|
||||
|
@ -28,7 +30,7 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
this.requestButton = this.addButton(new Button(this.guiLeft + 8, this.guiTop + 100, 50, 20, I18n.format("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
this.requestButton = this.addButton(new Button(this.guiLeft + 8, this.guiTop + 100, 50, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
int all = hasShiftDown() ? 1 : 0;
|
||||
PacketHandler.sendToServer(new PacketButton(this.container.tile.getPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, all));
|
||||
}));
|
||||
|
@ -50,8 +52,8 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack matrix, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(matrix, mouseX, mouseY);
|
||||
|
||||
CraftingTerminalContainer container = this.getCraftingContainer();
|
||||
CraftingTerminalTileEntity tile = container.getTile();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.misc.ItemOrder;
|
||||
import de.ellpeck.prettypipes.misc.ItemTerminalWidget;
|
||||
|
@ -19,6 +20,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -47,7 +50,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
this.plusButton = this.addButton(new Button(this.guiLeft + this.getXOffset() + 95 - 7 + 12, this.guiTop + 103, 12, 12, "+", button -> {
|
||||
this.plusButton = this.addButton(new Button(this.guiLeft + this.getXOffset() + 95 - 7 + 12, this.guiTop + 103, 12, 12, new StringTextComponent("+"), button -> {
|
||||
int modifier = requestModifier();
|
||||
if (modifier > 1 && this.requestAmount == 1) {
|
||||
this.requestAmount = modifier;
|
||||
|
@ -57,13 +60,13 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
if (this.requestAmount > 384)
|
||||
this.requestAmount = 384;
|
||||
}));
|
||||
this.minusButton = this.addButton(new Button(this.guiLeft + this.getXOffset() + 95 - 7 - 24, this.guiTop + 103, 12, 12, "-", button -> {
|
||||
this.minusButton = this.addButton(new Button(this.guiLeft + this.getXOffset() + 95 - 7 - 24, this.guiTop + 103, 12, 12, new StringTextComponent("-"), button -> {
|
||||
this.requestAmount -= requestModifier();
|
||||
if (this.requestAmount < 1)
|
||||
this.requestAmount = 1;
|
||||
}));
|
||||
this.minusButton.active = false;
|
||||
this.requestButton = this.addButton(new Button(this.guiLeft + this.getXOffset() + 95 - 7 - 25, this.guiTop + 115, 50, 20, I18n.format("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
this.requestButton = this.addButton(new Button(this.guiLeft + this.getXOffset() + 95 - 7 - 25, this.guiTop + 115, 50, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
Optional<ItemTerminalWidget> widget = this.streamWidgets().filter(w -> w.selected).findFirst();
|
||||
if (!widget.isPresent())
|
||||
return;
|
||||
|
@ -73,7 +76,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
this.requestAmount = 1;
|
||||
}));
|
||||
this.requestButton.active = false;
|
||||
this.orderButton = this.addButton(new Button(this.guiLeft - 22, this.guiTop, 20, 20, "", button -> {
|
||||
this.orderButton = this.addButton(new Button(this.guiLeft - 22, this.guiTop, 20, 20, new StringTextComponent(""), button -> {
|
||||
if (this.sortedItems == null)
|
||||
return;
|
||||
PlayerPrefs prefs = PlayerPrefs.get();
|
||||
|
@ -81,7 +84,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
prefs.save();
|
||||
this.updateWidgets();
|
||||
}));
|
||||
this.ascendingButton = this.addButton(new Button(this.guiLeft - 22, this.guiTop + 22, 20, 20, "", button -> {
|
||||
this.ascendingButton = this.addButton(new Button(this.guiLeft - 22, this.guiTop + 22, 20, 20, new StringTextComponent(""), button -> {
|
||||
if (this.sortedItems == null)
|
||||
return;
|
||||
PlayerPrefs prefs = PlayerPrefs.get();
|
||||
|
@ -93,7 +96,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
for (int x = 0; x < 9; x++)
|
||||
this.addButton(new ItemTerminalWidget(this.guiLeft + this.getXOffset() + 8 + x * 18, this.guiTop + 18 + y * 18, x, y, this));
|
||||
}
|
||||
this.search = this.addButton(new TextFieldWidget(this.font, this.guiLeft + this.getXOffset() + 97, this.guiTop + 6, 86, 8, ""));
|
||||
this.search = this.addButton(new TextFieldWidget(this.font, this.guiLeft + this.getXOffset() + 97, this.guiTop + 6, 86, 8, new StringTextComponent("")));
|
||||
this.search.setEnableBackgroundDrawing(false);
|
||||
this.lastSearchText = "";
|
||||
if (this.items != null)
|
||||
|
@ -139,8 +142,8 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
|
||||
public void updateWidgets() {
|
||||
PlayerPrefs prefs = PlayerPrefs.get();
|
||||
this.ascendingButton.setMessage(prefs.terminalAscending ? "^" : "v");
|
||||
this.orderButton.setMessage(prefs.terminalItemOrder.name().substring(0, 1));
|
||||
this.ascendingButton.setMessage(new StringTextComponent(prefs.terminalAscending ? "^" : "v"));
|
||||
this.orderButton.setMessage(new StringTextComponent(prefs.terminalItemOrder.name().substring(0, 1)));
|
||||
|
||||
Comparator<ItemStack> comparator = prefs.terminalItemOrder.comparator;
|
||||
if (!prefs.terminalAscending)
|
||||
|
@ -183,42 +186,42 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground();
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
public void render(MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
for (Widget widget : this.buttons) {
|
||||
if (widget instanceof ItemTerminalWidget)
|
||||
widget.renderToolTip(mouseX, mouseY);
|
||||
widget.renderToolTip(matrix, mouseX, mouseY);
|
||||
}
|
||||
if (this.sortedItems != null) {
|
||||
PlayerPrefs prefs = PlayerPrefs.get();
|
||||
if (this.orderButton.isHovered())
|
||||
this.renderTooltip(I18n.format("info." + PrettyPipes.ID + ".order", I18n.format("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
|
||||
this.renderTooltip(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + ".order", I18n.format("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
|
||||
if (this.ascendingButton.isHovered())
|
||||
this.renderTooltip(I18n.format("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||
this.renderTooltip(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||
}
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
this.func_230459_a_(matrix, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8 + this.getXOffset(), this.ySize - 96 + 2, 4210752);
|
||||
this.font.drawString(this.title.getFormattedText(), 8, 6, 4210752);
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack matrix, int mouseX, int mouseY) {
|
||||
this.font.drawString(matrix, this.playerInventory.getDisplayName().getString(), 8 + this.getXOffset(), this.ySize - 96 + 2, 4210752);
|
||||
this.font.drawString(matrix, this.title.getString(), 8, 6, 4210752);
|
||||
|
||||
String amount = String.valueOf(this.requestAmount);
|
||||
this.font.drawString(amount, (176 + 15 - this.font.getStringWidth(amount)) / 2F - 7 + this.getXOffset(), 106, 4210752);
|
||||
this.font.drawString(matrix, amount, (176 + 15 - this.font.getStringWidth(amount)) / 2F - 7 + this.getXOffset(), 106, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
this.getMinecraft().getTextureManager().bindTexture(this.getTexture());
|
||||
this.blit(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||
this.blit(matrix, this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (this.sortedItems != null && this.sortedItems.size() >= 9 * 4) {
|
||||
float percentage = this.scrollOffset / (float) (this.sortedItems.size() / 9 - 3);
|
||||
this.blit(this.guiLeft + this.getXOffset() + 172, this.guiTop + 18 + (int) (percentage * (70 - 15)), 232, 241, 12, 15);
|
||||
this.blit(matrix, this.guiLeft + this.getXOffset() + 172, this.guiTop + 18 + (int) (percentage * (70 - 15)), 232, 241, 12, 15);
|
||||
} else {
|
||||
this.blit(this.guiLeft + this.getXOffset() + 172, this.guiTop + 18, 244, 241, 12, 15);
|
||||
this.blit(matrix, this.guiLeft + this.getXOffset() + 172, this.guiTop + 18, 244, 241, 12, 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue