caster is finished, woo!

This commit is contained in:
70000hp 2023-12-31 15:56:09 -05:00
parent b6f1d422e8
commit 9340287403
8 changed files with 760 additions and 921 deletions

View File

@ -32,16 +32,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay { public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay, IToolable {
public MachineStrandCaster() { public MachineStrandCaster() {
super(Material.iron); super(Material.iron);
} }
//reminder, if the machine is a solid brick, get dimensions will already handle it without the need to use fillSapce //reminder, if the machine is a solid brick, get dimensions will already handle it without the need to use fillSapce
//the order is up, down, forward, backward, left, right //the order is up, down, forward, backward, left, right
//x is for left(-)/right(+), z is for forward(+)/backward(-), y you already know //x is for left(-)/right(+), z is for forward(+)/backward(-), y you already know
@Override @Override
public int[] getDimensions() {return new int[]{0, 0, 6, 0, 1, 0};} public int[] getDimensions() {
return new int[]{0, 0, 6, 0, 1, 0};
}
@Override @Override
public int getOffset() { public int getOffset() {
@ -194,6 +197,7 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
} }
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xFF4000, 0x401000, text); ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xFF4000, 0x401000, text);
} }
@Override @Override
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) { protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
x += dir.offsetX * o; x += dir.offsetX * o;
@ -202,5 +206,31 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
if (!MultiblockHandlerXR.checkSpace(world, x, y, z, getDimensions(), x, y, z, dir)) return false; if (!MultiblockHandlerXR.checkSpace(world, x, y, z, getDimensions(), x, y, z, dir)) return false;
return MultiblockHandlerXR.checkSpace(world, x, y, z, new int[]{2, 0, 1, 0, 1, 0}, x, y, z, dir); return MultiblockHandlerXR.checkSpace(world, x, y, z, new int[]{2, 0, 1, 0, 1, 0}, x, y, z, dir);
} }
@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;
TileEntityFoundryCastingBase cast = (TileEntityFoundryCastingBase) world.getTileEntity(x, y, z);
if (cast.slots[0] == null)
return false;
if (!player.inventory.addItemStackToInventory(cast.slots[0].copy())) {
EntityItem item = new EntityItem(world, x + 0.5, y + this.maxY, z + 0.5, cast.slots[0].copy());
world.spawnEntityInWorld(item);
} else {
player.inventoryContainer.detectAndSendChanges();
}
cast.markDirty();
world.markBlockForUpdate(x, y, z);
cast.slots[0] = null;
cast.markDirty();
return true;
}
} }

View File

@ -61,7 +61,7 @@ public class GUIMachineStrandCaster extends GuiInfoContainer {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
int targetHeight = (caster.amount) * 79 / caster.getCapacity(); int targetHeight = Math.min((caster.amount) * 79 / caster.getCapacity(), 92);
int hex = caster.type.moltenColor; int hex = caster.type.moltenColor;
//hex = 0xC18336; //hex = 0xC18336;
@ -83,18 +83,16 @@ public class GUIMachineStrandCaster extends GuiInfoContainer {
} }
protected void drawStackInfo(int mouseX, int mouseY, int x, int y) { protected void drawStackInfo(int mouseX, int mouseY, int x, int y) {
List<String> list = new ArrayList(); List<String> list = new ArrayList();
if (caster.type == null) list.add(EnumChatFormatting.RED + "Empty"); if (caster.type == null) list.add(EnumChatFormatting.RED + "Empty");
else list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(caster.type.getUnlocalizedName()) + ": " + Mats.formatAmount(caster.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))); else
list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(caster.type.getUnlocalizedName()) + ": " + Mats.formatAmount(caster.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 36, 81, mouseX, mouseY, list); this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 36, 81, mouseX, mouseY, list);
} }
} }

View File

@ -445,6 +445,15 @@ public class AssemblerRecipes {
new ComparableStack(ModItems.wire_red_copper, 24), new ComparableStack(ModItems.wire_red_copper, 24),
new ComparableStack(ModItems.circuit_copper, 1) new ComparableStack(ModItems.circuit_copper, 1)
}, 300); }, 300);
makeRecipe(new ComparableStack(ModBlocks.machine_strand_caster, 1), new AStack[] {
new ComparableStack(ModItems.ingot_firebrick, 12),
new OreDictStack(STEEL.plateCast(), 6),
new OreDictStack(CU.plateWelded(), 2),
new ComparableStack(ModItems.tank_steel, 2),
new OreDictStack(ANY_CONCRETE.any(), 8)
}, 100);
makeRecipe(new ComparableStack(ModItems.piston_set, 1, EnumPistonType.STEEL.ordinal()), new AStack[] { makeRecipe(new ComparableStack(ModItems.piston_set, 1, EnumPistonType.STEEL.ordinal()), new AStack[] {
new OreDictStack(STEEL.plate(), 16), new OreDictStack(STEEL.plate(), 16),
new OreDictStack(CU.plate(), 4), new OreDictStack(CU.plate(), 4),

View File

@ -2,18 +2,34 @@ package com.hbm.render.tileentity;
import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager; import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase; import com.hbm.render.item.ItemRenderBase;
import com.hbm.tileentity.machine.TileEntityMachineStrandCaster;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.nio.DoubleBuffer;
public class RenderStrandCaster extends TileEntitySpecialRenderer implements IItemRendererProvider { public class RenderStrandCaster extends TileEntitySpecialRenderer implements IItemRendererProvider {
public static final ResourceLocation lava = new ResourceLocation(RefStrings.MODID, "textures/models/machines/lava_gray.png");
private static DoubleBuffer buf = null;
@Override @Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float interp) { public void renderTileEntityAt(TileEntity te, double x, double y, double z, float interp) {
TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) te;
if(buf == null){
buf = GLAllocation.createDirectByteBuffer(8*4).asDoubleBuffer();
}
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5); GL11.glTranslated(x + 0.5, y, z + 0.5);
@ -31,7 +47,53 @@ public class RenderStrandCaster extends TileEntitySpecialRenderer implements IIt
GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.strand_caster_tex); bindTexture(ResourceManager.strand_caster_tex);
ResourceManager.strand_caster.renderAll(); ResourceManager.strand_caster.renderPart("caster");
if (caster.amount != 0 && caster.getInstalledMold() != null) {
double level = ((double) caster.amount / (double) caster.getCapacity()) * 0.675D;
double offset = ((double) caster.amount / (double) caster.getInstalledMold().getCost()) * 0.375D;
int color = caster.type.moltenColor;
int r = color >> 16 & 0xFF;
int g = color >> 8 & 0xFF;
int b = color & 0xFF;
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
GL11.glColor3f( r/ 255F, g/ 255F, b/ 255F);
GL11.glEnable(GL11.GL_CLIP_PLANE0);
buf.put(new double[] { 0, 0, -1, 0.5} );
buf.rewind();
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, buf);
GL11.glTranslated(0,0,-offset + 3.4);
ResourceManager.strand_caster.renderPart("plate");
GL11.glDisable(GL11.GL_CLIP_PLANE0);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
Tessellator tess = Tessellator.instance;
tess.setNormal(0F, 1F, 0F);
tess.setColorOpaque_F(r / 255F, g / 255F, b / 255F);
bindTexture(lava);
tess.startDrawingQuads();
tess.addVertexWithUV(-0.9, 2.3 + level, -0.999, 0, 0);
tess.addVertexWithUV(-0.9, 2.3 + level, 0.999, 0, 1);
tess.addVertexWithUV(0.9, 2.3 + level, 0.999, 1, 1);
tess.addVertexWithUV(0.9, 2.3 + level, -0.999, 1, 0);
tess.draw();
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopAttrib();
}
GL11.glShadeModel(GL11.GL_FLAT); GL11.glShadeModel(GL11.GL_FLAT);
@ -48,11 +110,11 @@ public class RenderStrandCaster extends TileEntitySpecialRenderer implements IIt
public IItemRenderer getRenderer() { public IItemRenderer getRenderer() {
return new ItemRenderBase( ) { return new ItemRenderBase( ) {
public void renderInventory() { public void renderInventory() {
GL11.glTranslated(1, 1, 0); GL11.glTranslated(2, 0, 2);
GL11.glScaled(2.5, 2.5, 2.5); GL11.glScaled( 2, 2, 2);
} }
public void renderCommon() { public void renderCommon() {
GL11.glScaled(0.5, 0.5, 0.5); GL11.glScaled(1, 1, 1);
GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.strand_caster_tex); ResourceManager.strand_caster.renderAll(); bindTexture(ResourceManager.strand_caster_tex); ResourceManager.strand_caster.renderAll();
GL11.glShadeModel(GL11.GL_FLAT); GL11.glShadeModel(GL11.GL_FLAT);

View File

@ -158,7 +158,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
Vec3 impact = Vec3.createVectorHelper(0, 0, 0); Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, this.wasteStack, MaterialShapes.NUGGET.q(2), impact); MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, this.wasteStack, MaterialShapes.NUGGET.q(3), impact);
if(didPour != null) { if(didPour != null) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
@ -198,7 +198,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
} }
Vec3 impact = Vec3.createVectorHelper(0, 0, 0); Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, toCast, MaterialShapes.NUGGET.q(2), impact); MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, toCast, MaterialShapes.NUGGET.q(3), impact);
if(didPour != null) { if(didPour != null) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();

View File

@ -36,10 +36,12 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
public FluidTank water; public FluidTank water;
public FluidTank steam; public FluidTank steam;
@Override @Override
public String getName() { public String getName() {
return "container.machineStrandCaster"; return "container.machineStrandCaster";
} }
@Override @Override
public String getInventoryName() { public String getInventoryName() {
return getName(); return getName();
@ -123,15 +125,15 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
ItemMold.Mold mold = this.getInstalledMold(); ItemMold.Mold mold = this.getInstalledMold();
if (type != null && mold != null && this.amount >= mold.getCost() * 9 && mold.getOutput(type) != null) { if (type != null && mold != null && this.amount >= mold.getCost() * 9 && mold.getOutput(type) != null) {
for (int i = 1; i < 7; i++) { for (int i = 1; i < 7; i++) {
if (slots[i] == null || slots[i].isItemEqual(mold.getOutput(type)) && slots[i].stackSize + mold.getOutput(type).stackSize <= mold.getOutput(type).getMaxStackSize()) if (slots[i] == null || slots[i].isItemEqual(mold.getOutput(type)) && slots[i].stackSize + mold.getOutput(type).stackSize <= mold.getOutput(type).getMaxStackSize())
return water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();; return water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();
} }
} }
return false; return false;
} }
public DirPos[] getFluidConPos() { public DirPos[] getFluidConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
@ -157,6 +159,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
new int[]{xCoord, yCoord + 2, zCoord}, new int[]{xCoord, yCoord + 2, zCoord},
}; };
} }
@Override @Override
public ItemMold.Mold getInstalledMold() { public ItemMold.Mold getInstalledMold() {
if (slots[0] == null) return null; if (slots[0] == null) return null;
@ -167,6 +170,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
return null; return null;
} }
@Override @Override
public int getMoldSize() { public int getMoldSize() {
return getInstalledMold().size; return getInstalledMold().size;
@ -190,11 +194,13 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
if (this.type != null && this.type != stack.material) return false; if (this.type != null && this.type != stack.material) return false;
return !(this.amount >= this.getCapacity() || getInstalledMold() == null); return !(this.amount >= this.getCapacity() || getInstalledMold() == null);
} }
@Override @Override
public int getCapacity() { public int getCapacity() {
ItemMold.Mold mold = this.getInstalledMold(); ItemMold.Mold mold = this.getInstalledMold();
return mold == null ? 50000 : mold.getCost() * 50; return mold == null ? 50000 : mold.getCost() * 10;
} }
private int getWaterRequired() { private int getWaterRequired() {
return getInstalledMold() != null ? 5 * getInstalledMold().getCost() : 50; return getInstalledMold() != null ? 5 * getInstalledMold().getCost() : 50;
} }
@ -235,16 +241,17 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
} }
public void networkPack(NBTTagCompound nbt, int range) { public void networkPack(NBTTagCompound nbt, int range) {
if (!worldObj.isRemote) if (!worldObj.isRemote)
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range)); PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
} }
@Override @Override
public void networkUnpack(NBTTagCompound nbt) { public void networkUnpack(NBTTagCompound nbt) {
water.readFromNBT(nbt, "w"); water.readFromNBT(nbt, "w");
steam.readFromNBT(nbt, "s"); steam.readFromNBT(nbt, "s");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
@ -258,6 +265,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
water.readFromNBT(nbt, "w"); water.readFromNBT(nbt, "w");
steam.readFromNBT(nbt, "s"); steam.readFromNBT(nbt, "s");
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack) { public boolean isItemValidForSlot(int i, ItemStack stack) {
@ -282,6 +290,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
public void markChanged() { public void markChanged() {
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
} }
@Override @Override
public boolean isUseableByPlayer(EntityPlayer player) { public boolean isUseableByPlayer(EntityPlayer player) {
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
@ -301,6 +310,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
public boolean canExtractItem(int slot, ItemStack itemStack, int side) { public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
return !this.isItemValidForSlot(slot, itemStack); return !this.isItemValidForSlot(slot, itemStack);
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
@ -311,15 +321,13 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
xCoord - 1, xCoord - 1,
yCoord, yCoord,
zCoord - 1, zCoord - 1,
xCoord + 2, xCoord + 6,
yCoord + 3, yCoord + 3,
zCoord + 7 zCoord + 6
); );
} }
return bb; return bb;
} }
} }

File diff suppressed because it is too large Load Diff