mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fixed pouring, proper item rendering in molds
This commit is contained in:
parent
52fc3868ff
commit
50826c13f6
@ -59,11 +59,12 @@ public interface ICrucibleAcceptor {
|
||||
|
||||
for(MaterialStack stack : stacks) {
|
||||
|
||||
if(stack.material.smeltable != SmeltingBehavior.SMELTABLE)
|
||||
if(stack.material.smeltable != SmeltingBehavior.SMELTABLE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(acc.canAcceptPartialPour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit).getOpposite(), stack)) {
|
||||
MaterialStack left = acc.pour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit).getOpposite(), stack);
|
||||
if(acc.canAcceptPartialPour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit), stack)) {
|
||||
MaterialStack left = acc.pour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit), stack);
|
||||
if(left == null) {
|
||||
left = new MaterialStack(stack.material, 0);
|
||||
}
|
||||
|
||||
@ -85,6 +85,7 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc
|
||||
|
||||
cast.slots[1] = null;
|
||||
cast.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -96,8 +97,9 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc
|
||||
cast.slots[0] = player.getHeldItem().copy();
|
||||
cast.slots[0].stackSize = 1;
|
||||
player.getHeldItem().stackSize--;
|
||||
cast.markDirty();
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F);
|
||||
cast.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -123,6 +125,9 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
cast.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
cast.slots[0] = null;
|
||||
cast.markDirty();
|
||||
|
||||
@ -135,7 +140,7 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc
|
||||
List<String> text = new ArrayList();
|
||||
|
||||
if(cast.slots[0] == null) {
|
||||
text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noMold"));
|
||||
text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast"));
|
||||
} else if(cast.slots[0].getItem() == ModItems.mold){
|
||||
Mold mold = ((ItemMold) cast.slots[0].getItem()).getMold(cast.slots[0]);
|
||||
text.add(EnumChatFormatting.BLUE + I18nUtil.resolveKey("shape." + mold.shape.name().toLowerCase()) + " x" + mold.amount);
|
||||
|
||||
@ -7,69 +7,129 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.IRenderFoundry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
public class RenderFoundry extends TileEntitySpecialRenderer {
|
||||
|
||||
public static final ResourceLocation lava = new ResourceLocation(RefStrings.MODID, "textures/models/machines/lava_gray.png");
|
||||
|
||||
private void drawItem(ItemStack stack, double height) {
|
||||
GL11.glPushMatrix();
|
||||
RenderItem render = new RenderItem();
|
||||
GL11.glTranslated(0.125D, height, 0.125D);
|
||||
|
||||
double scale = 0.0625D * 12D / 16D;
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
if(!ForgeHooksClient.renderInventoryItem(RenderBlocks.getInstance(), Minecraft.getMinecraft().getTextureManager(), stack, true, 0.0F, 1.0F, 0.0F)) {
|
||||
render.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
private void drawBlock(ItemStack stack, IRenderFoundry foundry) {
|
||||
Tessellator tess = Tessellator.instance;
|
||||
Block b = ((ItemBlock)stack.getItem()).field_150939_a;
|
||||
IIcon icon = b.getIcon(1, stack.getItemDamage());
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0F, 1F, 0F);
|
||||
tess.setColorRGBA_F(1F, 1F, 1F, 0.3F);
|
||||
double h = foundry.outHeight();
|
||||
tess.addVertexWithUV(foundry.minX(), h, foundry.minZ(), icon.getMinU(), icon.getMaxV());
|
||||
tess.addVertexWithUV(foundry.minX(), h, foundry.maxZ(), icon.getMaxU(), icon.getMaxV());
|
||||
tess.addVertexWithUV(foundry.maxX(), h, foundry.maxZ(), icon.getMaxU(), icon.getMinV());
|
||||
tess.addVertexWithUV(foundry.maxX(), h, foundry.minZ(), icon.getMinU(), icon.getMinV());
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
|
||||
IRenderFoundry foundry = (IRenderFoundry) tile;
|
||||
|
||||
if(!foundry.shouldRender()) return;
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
Tessellator tess = Tessellator.instance;
|
||||
this.bindTexture(lava);
|
||||
|
||||
int hex = foundry.getMat().moltenColor;
|
||||
Color color = new Color(hex);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0F, 1F, 0F);
|
||||
tess.setColorRGBA_F(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1F);
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX());
|
||||
tess.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0F, 1F, 0F);
|
||||
tess.setColorRGBA_F(1F, 1F, 1F, 0.3F);
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX());
|
||||
tess.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
|
||||
if(foundry instanceof IInventory) {
|
||||
IInventory inv = (IInventory) foundry;
|
||||
ItemStack mold = inv.getStackInSlot(0);
|
||||
|
||||
if(mold != null) {
|
||||
drawItem(mold, foundry.moldHeight());
|
||||
}
|
||||
ItemStack out = inv.getStackInSlot(1);
|
||||
|
||||
if(out != null) {
|
||||
if(out.getItem() instanceof ItemBlock) {
|
||||
drawBlock(out, foundry);
|
||||
} else {
|
||||
drawItem(out, foundry.outHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(foundry.shouldRender()) {
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
this.bindTexture(lava);
|
||||
|
||||
int hex = foundry.getMat().moltenColor;
|
||||
Color color = new Color(hex);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0F, 1F, 0F);
|
||||
tess.setColorRGBA_F(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1F);
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX());
|
||||
tess.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0F, 1F, 0F);
|
||||
tess.setColorRGBA_F(1F, 1F, 1F, 0.3F);
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX());
|
||||
tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX());
|
||||
tess.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@ -16,4 +16,6 @@ public interface IRenderFoundry {
|
||||
public double maxX();
|
||||
public double minZ();
|
||||
public double maxZ();
|
||||
public double moldHeight();
|
||||
public double outHeight();
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
|
||||
Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
|
||||
ICrucibleAcceptor.tryPour(worldObj, xCoord + 0.5D + dir.offsetX * 1.75D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.75D, 6, true, this.wasteStack, MaterialShapes.NUGGET.q(1), impact);
|
||||
ICrucibleAcceptor.tryPour(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(1), impact);
|
||||
}
|
||||
|
||||
if(!this.recipeStack.isEmpty()) {
|
||||
@ -123,7 +123,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
|
||||
}
|
||||
|
||||
Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
|
||||
ICrucibleAcceptor.tryPour(worldObj, xCoord + 0.5D + dir.offsetX * 1.75D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.75D, 6, true, toCast, MaterialShapes.NUGGET.q(1), impact);
|
||||
ICrucibleAcceptor.tryPour(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, toCast, MaterialShapes.NUGGET.q(1), impact);
|
||||
}
|
||||
|
||||
this.recipeStack.removeIf(o -> o.amount <= 0);
|
||||
|
||||
@ -41,4 +41,6 @@ public class TileEntityFoundryBasin extends TileEntityFoundryCastingBase impleme
|
||||
@Override public double maxX() { return 0.875D; }
|
||||
@Override public double minZ() { return 0.125D; }
|
||||
@Override public double maxZ() { return 0.875D; }
|
||||
@Override public double moldHeight() { return 0.13D; }
|
||||
@Override public double outHeight() { return 0.875D; }
|
||||
}
|
||||
|
||||
@ -31,6 +31,15 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase
|
||||
super.updateEntity();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(this.amount > this.getCapacity()) {
|
||||
this.amount = this.getCapacity();
|
||||
}
|
||||
|
||||
if(this.amount == 0) {
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
Mold mold = this.getInstalledMold();
|
||||
|
||||
if(mold != null && this.amount == this.getCapacity() && slots[1] == null) {
|
||||
@ -123,10 +132,12 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase
|
||||
if(itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
if(slots[slot] != null) {
|
||||
if(slots[slot].stackSize <= amount) {
|
||||
ItemStack itemStack = slots[slot];
|
||||
|
||||
@ -33,4 +33,6 @@ public class TileEntityFoundryMold extends TileEntityFoundryCastingBase implemen
|
||||
@Override public double maxX() { return 0.875D; }
|
||||
@Override public double minZ() { return 0.125D; }
|
||||
@Override public double maxZ() { return 0.875D; }
|
||||
@Override public double moldHeight() { return 0.13D; }
|
||||
@Override public double outHeight() { return 0.25D; }
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user