everybody do the yoinky splinky

This commit is contained in:
Boblet 2025-04-07 16:53:08 +02:00
parent 097907820b
commit fb19e4d93f
12 changed files with 152 additions and 15 deletions

View File

@ -7,12 +7,14 @@ import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.network.TileEntityPneumoTube;
import com.hbm.util.Compat;
import api.hbm.block.IToolable;
import api.hbm.fluidmk2.IFluidConnectorBlockMK2;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
@ -35,6 +37,7 @@ public class PneumoTube extends BlockContainer implements IToolable, IFluidConne
@SideOnly(Side.CLIENT) public IIcon iconIn;
@SideOnly(Side.CLIENT) public IIcon iconOut;
@SideOnly(Side.CLIENT) public IIcon iconConnector;
@SideOnly(Side.CLIENT) public IIcon iconStraight;
@SideOnly(Side.CLIENT) public IIcon activeIcon;
public boolean[] renderSides = new boolean[] {true, true, true, true, true, true};
@ -62,6 +65,7 @@ public class PneumoTube extends BlockContainer implements IToolable, IFluidConne
iconIn = reg.registerIcon(RefStrings.MODID + ":pneumatic_tube_in");
iconOut = reg.registerIcon(RefStrings.MODID + ":pneumatic_tube_out");
iconConnector = reg.registerIcon(RefStrings.MODID + ":pneumatic_tube_connector");
iconStraight = reg.registerIcon(RefStrings.MODID + ":pneumatic_tube_straight");
this.activeIcon = this.baseIcon = this.blockIcon;
}
@ -82,6 +86,24 @@ public class PneumoTube extends BlockContainer implements IToolable, IFluidConne
for(int i = 0; i < 6; i++) renderSides[i] = true;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(player.getHeldItem() != null && ToolType.getType(player.getHeldItem()) == ToolType.SCREWDRIVER) return false;
if(!player.isSneaking()) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityPneumoTube) {
TileEntityPneumoTube tube = (TileEntityPneumoTube) tile;
if(tube.isCompressor()) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
}
}
return false;
} else {
return false;
}
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if(tool != ToolType.SCREWDRIVER) return false;
@ -92,12 +114,12 @@ public class PneumoTube extends BlockContainer implements IToolable, IFluidConne
ForgeDirection rot = player.isSneaking() ? tube.ejectionDir : tube.insertionDir;
ForgeDirection oth = player.isSneaking() ? tube.insertionDir : tube.ejectionDir;
for(int i = 0; i < 6; i++) {
for(int i = 0; i < 7; i++) {
rot = ForgeDirection.getOrientation((rot.ordinal() + 1) % 7);
if(rot == ForgeDirection.UNKNOWN) break; //unknown is always valid, simply disables this part
if(rot == oth) continue; //skip if both positions collide
TileEntity tile = Compat.getTileStandard(world, x + rot.offsetX, y + rot.offsetY, z + rot.offsetZ);
if(tile instanceof IInventory) break; //valid if connected to an IInventory
if(tile instanceof IInventory && !(tile instanceof TileEntityPneumoTube)) break; //valid if connected to an IInventory
}
if(player.isSneaking()) tube.ejectionDir = rot; else tube.insertionDir = rot;
@ -185,12 +207,12 @@ public class PneumoTube extends BlockContainer implements IToolable, IFluidConne
public boolean canConnectToAir(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
TileEntityPneumoTube tube = (TileEntityPneumoTube) world.getTileEntity(x, y, z);
if(tube != null && tube.insertionDir == ForgeDirection.UNKNOWN) return false;
return Library.canConnectFluid(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir, Fluids.AIR);
if(tube != null && !tube.isCompressor()) return false;
return Library.canConnectFluid(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir, Fluids.AIR) && !(world.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) instanceof TileEntityPneumoTube);
}
@Override
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
TileEntityPneumoTube tube = (TileEntityPneumoTube) world.getTileEntity(x, y, z);
return tube != null && tube.insertionDir != ForgeDirection.UNKNOWN;
return tube != null && tube.isCompressor();
}
}

View File

@ -1,6 +1,7 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotPattern;
import com.hbm.inventory.SlotUpgrade;
import com.hbm.tileentity.network.TileEntityPneumoTube;
import net.minecraft.entity.player.EntityPlayer;
@ -22,6 +23,10 @@ public class ContainerPneumoTube extends ContainerBase {
}
}
//upgrades
this.addSlotToContainer(new SlotUpgrade(tube, 15, 152, 23));
this.addSlotToContainer(new SlotUpgrade(tube, 16, 152, 47));
playerInv(invPlayer, 8, 103, 161);
}

View File

@ -0,0 +1,67 @@
package com.hbm.inventory.gui;
import java.util.Arrays;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerPneumoTube;
import com.hbm.lib.RefStrings;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.render.util.GaugeUtil;
import com.hbm.tileentity.network.TileEntityPneumoTube;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GUIPneumoTube extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_pneumatic_pipe.png");
public TileEntityPneumoTube tube;
public GUIPneumoTube(InventoryPlayer invPlayer, TileEntityPneumoTube tedf) {
super(new ContainerPneumoTube(invPlayer, tedf));
this.tube = tedf;
this.xSize = 176;
this.ySize = 185;
}
@Override
public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, interp);
tube.compair.renderTankInfo(this, x, y, guiLeft + 7, guiTop + 16, 18, 18);
if(this.mc.thePlayer.inventory.getItemStack() == null) {
for(int i = 0; i < 15; ++i) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && tube.pattern.modes[i] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(tube.pattern.modes[i]) }), x, y - 30);
}
}
}
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.tube.hasCustomInventoryName() ? this.tube.getInventoryName() : I18n.format(this.tube.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
drawTexturedModalRect(guiLeft + 6 + 4 * (tube.compair.getPressure() - 1), guiTop + 36, 179, 18, 4, 8);
GaugeUtil.drawSmoothGauge(guiLeft + 16, guiTop + 25, this.zLevel, (double) tube.compair.getFill() / (double) tube.compair.getMaxFill(), 5, 2, 1, 0xCA6C43, 0xAB4223);
}
}

View File

@ -31,15 +31,20 @@ public class RenderPneumoTube implements ISimpleBlockRenderingHandler {
renderer.setRenderBounds(lower, lower, 0, upper, upper, 1);
renderer.uvRotateTop = 2;
renderer.uvRotateBottom = 1;
tessellator.startDrawingQuads();
tessellator.setNormal(0F, 1F, 0F); renderer.renderFaceYPos(block, 0, 0, 0, duct.getIcon(0, 0));
tessellator.setNormal(0F, -1F, 0F); renderer.renderFaceYNeg(block, 0, 0, 0, duct.getIcon(0, 0));
tessellator.setNormal(1F, 0F, 0F); renderer.renderFaceXPos(block, 0, 0, 0, duct.getIcon(0, 0));
tessellator.setNormal(-1F, 0F, 0F); renderer.renderFaceXNeg(block, 0, 0, 0, duct.getIcon(0, 0));
tessellator.setNormal(0F, 1F, 0F); renderer.renderFaceYPos(block, 0, 0, 0, duct.iconStraight);
tessellator.setNormal(0F, -1F, 0F); renderer.renderFaceYNeg(block, 0, 0, 0, duct.iconStraight);
tessellator.setNormal(1F, 0F, 0F); renderer.renderFaceXPos(block, 0, 0, 0, duct.iconStraight);
tessellator.setNormal(-1F, 0F, 0F); renderer.renderFaceXNeg(block, 0, 0, 0, duct.iconStraight);
tessellator.setNormal(0F, 0F, 1F); renderer.renderFaceZPos(block, 0, 0, 0, duct.iconConnector);
tessellator.setNormal(0F, 0F, -1F); renderer.renderFaceZNeg(block, 0, 0, 0, duct.iconConnector);
tessellator.draw();
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
}
@Override
@ -70,6 +75,7 @@ public class RenderPneumoTube implements ISimpleBlockRenderingHandler {
renderer.setRenderBounds(0.0D, lower, lower, 1.0D, upper, upper);
duct.renderSides[4] = false;
duct.renderSides[5] = false;
duct.activeIcon = duct.iconStraight;
renderer.renderStandardBlock(block, x, y, z);
duct.resetRenderSides();
@ -78,16 +84,30 @@ public class RenderPneumoTube implements ISimpleBlockRenderingHandler {
renderer.setRenderBounds(lower, lower, 0.0D, upper, upper, 1.0D);
duct.renderSides[2] = false;
duct.renderSides[3] = false;
duct.activeIcon = duct.iconStraight;
renderer.uvRotateTop = 2;
renderer.uvRotateBottom = 1;
renderer.renderStandardBlock(block, x, y, z);
duct.resetRenderSides();
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
//Straight along Y
} else if(mask == 0b001100) {
renderer.setRenderBounds(lower, 0.0D, lower, upper, 1.0D, upper);
duct.renderSides[0] = false;
duct.renderSides[1] = false;
duct.activeIcon = duct.iconStraight;
renderer.uvRotateNorth = 2;
renderer.uvRotateSouth = 2;
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 2;
renderer.renderStandardBlock(block, x, y, z);
duct.resetRenderSides();
renderer.uvRotateNorth = 0;
renderer.uvRotateSouth = 0;
renderer.uvRotateEast = 0;
renderer.uvRotateWest = 0;
//Any
} else {
renderer.setRenderBounds(lower, lower, lower, upper, upper, upper);
@ -115,6 +135,8 @@ public class RenderPneumoTube implements ISimpleBlockRenderingHandler {
}
}
duct.activeIcon = duct.baseIcon;
return true;
}

View File

@ -61,6 +61,10 @@ public class GaugeUtil {
}
public static void drawSmoothGauge(int x, int y, double z, double progress, double tipLength, double backLength, double backSide, int color) {
drawSmoothGauge(x, y, z, progress, tipLength, backLength, backSide, color, 0x000000);
}
public static void drawSmoothGauge(int x, int y, double z, double progress, double tipLength, double backLength, double backSide, int color, int colorOuter) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
progress = MathHelper.clamp_double(progress, 0, 1);
@ -76,7 +80,7 @@ public class GaugeUtil {
Tessellator tess = Tessellator.instance;
tess.startDrawing(GL11.GL_TRIANGLES);
tess.setColorOpaque_F(0F, 0F, 0F);
tess.setColorOpaque_I(colorOuter);
double mult = 1.5;
tess.addVertex(x + tip.xCoord * mult, y + tip.yCoord * mult, z);
tess.addVertex(x + left.xCoord * mult, y + left.yCoord * mult, z);

View File

@ -3,11 +3,13 @@ package com.hbm.tileentity.network;
import com.hbm.inventory.container.ContainerPneumoTube;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIPneumoTube;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.EnumUtil;
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
@ -21,7 +23,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIProvider {
public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIProvider, IFluidStandardReceiverMK2 {
public ModulePatternMatcher pattern = new ModulePatternMatcher(15);
public ForgeDirection insertionDir = ForgeDirection.UNKNOWN;
@ -30,7 +32,7 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
public FluidTank compair;
public TileEntityPneumoTube() {
super(15);
super(17);
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
}
@ -44,10 +46,22 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
if(!worldObj.isRemote) {
if(this.isCompressor()) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(dir != this.insertionDir && dir != this.ejectionDir) {
this.trySubscribe(compair.getTankType(), worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
}
}
}
this.networkPackNT(15);
}
}
public boolean isCompressor() {
return this.insertionDir != ForgeDirection.UNKNOWN;
}
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
@ -112,6 +126,9 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
@Override
@SideOnly(Side.CLIENT)
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
return new GUIPneumoTube(player.inventory, this);
}
@Override public FluidTank[] getAllTanks() { return new FluidTank[] {compair}; }
@Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {compair}; }
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B