fixed pouring, rendering for foundry outlet

This commit is contained in:
Bob 2022-09-27 23:22:27 +02:00
parent 462be270d9
commit 35c9833e69
14 changed files with 221 additions and 14 deletions

View File

@ -97,22 +97,22 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
@Override
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) {
return ((TileEntityFoundryChannel) world.getTileEntity(x, y, z)).canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack);
return ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack);
}
@Override
public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) {
return ((TileEntityFoundryChannel) world.getTileEntity(x, y, z)).pour(world, x, y, z, dX, dY, dZ, side, stack);
return ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).pour(world, x, y, z, dX, dY, dZ, side, stack);
}
@Override
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
return ((TileEntityFoundryChannel) world.getTileEntity(x, y, z)).canAcceptPartialFlow(world, x, y, z, side, stack);
return ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).canAcceptPartialFlow(world, x, y, z, side, stack);
}
@Override
public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
return ((TileEntityFoundryChannel) world.getTileEntity(x, y, z)).flow(world, x, y, z, side, stack);
return ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).flow(world, x, y, z, side, stack);
}
public boolean canConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
@ -122,7 +122,7 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
Block b = world.getBlock(x + dir.offsetX, y, z + dir.offsetZ);
return b == ModBlocks.foundry_channel || b == ModBlocks.foundry_mold;
return b == ModBlocks.foundry_channel || b == ModBlocks.foundry_mold || b == ModBlocks.foundry_outlet;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();

View File

@ -11,8 +11,11 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -23,6 +26,7 @@ public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor {
@SideOnly(Side.CLIENT) public IIcon iconSide;
@SideOnly(Side.CLIENT) public IIcon iconBottom;
@SideOnly(Side.CLIENT) public IIcon iconInner;
@SideOnly(Side.CLIENT) public IIcon iconFront;
public FoundryOutlet() {
super(Material.rock);
@ -32,16 +36,27 @@ public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor {
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":foundry_channel_top");
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":foundry_channel_side");
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":foundry_channel_bottom");
this.iconInner = iconRegister.registerIcon(RefStrings.MODID + ":foundry_channel_inner");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":foundry_outlet_top");
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":foundry_outlet_side");
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":foundry_outlet_bottom");
this.iconInner = iconRegister.registerIcon(RefStrings.MODID + ":foundry_outlet_inner");
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":foundry_outlet_front");
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {

View File

@ -955,6 +955,7 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.foundry_basin), new Object[] { "B B", "B B", "BSB", 'B', ModItems.ingot_firebrick, 'S', Blocks.stone_slab });
addRecipeAuto(new ItemStack(ModBlocks.foundry_mold), new Object[] { "B B", "BSB", 'B', ModItems.ingot_firebrick, 'S', Blocks.stone_slab });
addRecipeAuto(new ItemStack(ModBlocks.foundry_channel, 4), new Object[] { "B B", " S ", 'B', ModItems.ingot_firebrick, 'S', Blocks.stone_slab });
addShapelessAuto(new ItemStack(ModBlocks.foundry_outlet), new Object[] { ModBlocks.foundry_channel, STEEL.plate() });
addRecipeAuto(new ItemStack(ModItems.mold_base), new Object[] { " B ", "BIB", " B ", 'B', ModItems.ingot_firebrick, 'I', IRON.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.brick_fire), new Object[] { "BB", "BB", 'B', ModItems.ingot_firebrick });
addShapelessAuto(new ItemStack(ModItems.ingot_firebrick, 4), new Object[] { ModBlocks.brick_fire });

View File

@ -0,0 +1,15 @@
package com.hbm.render.block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
public class RenderBlocksFixed extends RenderBlocks {
public RenderBlocksFixed() {
super();
}
public RenderBlocksFixed(IBlockAccess world) {
super(world);
}
}

View File

@ -1,21 +1,163 @@
package com.hbm.render.block;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.machine.FoundryChannel;
import com.hbm.blocks.machine.FoundryOutlet;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
public class RenderOutlet implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
double bot = 0.0D;
double top = 0.5D;
double x = 0;
double y = 0;
double z = 0;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
FoundryOutlet outlet = (FoundryOutlet) block;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
renderer.setRenderBounds(0.3125D, bot, 0D, 0.6875D, top, 0.375D);
tessellator.setNormal(0F, 1F, 0F);
renderer.renderFaceYPos(block, x, y, z, outlet.iconTop);
renderer.renderFaceYPos(block, x, y - 0.375D, z, outlet.iconBottom);
tessellator.setNormal(0F, -1F, 0F);
renderer.renderFaceYNeg(block, x, y, z, outlet.iconBottom);
tessellator.setNormal(1F, 0F, 0F);
renderer.field_152631_f = true;
renderer.renderFaceXPos(block, x, y, z, outlet.iconSide);
renderer.renderFaceXPos(block, x - 0.3125D, y, z, outlet.iconInner);
renderer.field_152631_f = false;
tessellator.setNormal(-1F, 0F, 0F);
renderer.renderFaceXNeg(block, x, y, z, outlet.iconSide);
renderer.renderFaceXNeg(block, x + 0.3125D, y, z, outlet.iconInner);
tessellator.setNormal(0F, 0F, 1F);
renderer.renderFaceZPos(block, x, y, z, outlet.iconFront);
tessellator.draw();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
int colorMult = block.colorMultiplier(world, x, y, z);
float r = (float) (colorMult >> 16 & 255) / 255.0F;
float g = (float) (colorMult >> 8 & 255) / 255.0F;
float b = (float) (colorMult & 255) / 255.0F;
float mulBottom = 0.5F;
float mulTop = 1.0F;
float mulZ = 0.8F;
float mulX = 0.6F;
double bot = 0.0D;
double top = 0.5D;
if(EntityRenderer.anaglyphEnable) {
float aR = (r * 30.0F + g * 59.0F + b * 11.0F) / 100.0F;
float aG = (r * 30.0F + g * 70.0F) / 100.0F;
float aB = (r * 30.0F + b * 70.0F) / 100.0F;
r = aR;
g = aG;
b = aB;
}
FoundryOutlet outlet = (FoundryOutlet) block;
int meta = world.getBlockMetadata(x, y, z);
int brightness = block.getMixedBrightnessForBlock(world, x, y, z);
tessellator.setBrightness(brightness);
if(meta == 4) {
renderer.setRenderBounds(0.625D, bot, 0.3125D, 1D, top, 0.6875D);
tessellator.setColorOpaque_F(r * mulBottom, g * mulBottom, b * mulBottom);
renderer.renderFaceYNeg(block, x, y, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulTop, g * mulTop, b * mulTop);
renderer.renderFaceYPos(block, x, y, z, outlet.iconTop);
renderer.renderFaceYPos(block, x, y - 0.375D, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulZ, g * mulZ, b * mulZ);
renderer.renderFaceZPos(block, x, y, z, outlet.iconSide);
renderer.renderFaceZPos(block, x, y, z - 0.3125D, outlet.iconInner);
renderer.field_152631_f = true;
renderer.renderFaceZNeg(block, x, y, z, outlet.iconSide);
renderer.renderFaceZNeg(block, x, y, z + 0.3125D, outlet.iconInner);
renderer.field_152631_f = false;
tessellator.setColorOpaque_F(r * mulX, g * mulX, b * mulX);
renderer.renderFaceXNeg(block, x, y, z, outlet.iconFront);
}
if(meta == 5) {
renderer.setRenderBounds(0D, bot, 0.3125D, 0.375D, top, 0.6875D);
tessellator.setColorOpaque_F(r * mulBottom, g * mulBottom, b * mulBottom);
renderer.renderFaceYNeg(block, x, y, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulTop, g * mulTop, b * mulTop);
renderer.renderFaceYPos(block, x, y, z, outlet.iconTop);
renderer.renderFaceYPos(block, x, y - 0.375D, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulZ, g * mulZ, b * mulZ);
renderer.renderFaceZPos(block, x, y, z, outlet.iconSide);
renderer.renderFaceZPos(block, x, y, z - 0.3125D, outlet.iconInner);
renderer.field_152631_f = true;
renderer.renderFaceZNeg(block, x, y, z, outlet.iconSide);
renderer.renderFaceZNeg(block, x, y, z + 0.3125D, outlet.iconInner);
renderer.field_152631_f = false;
tessellator.setColorOpaque_F(r * mulX, g * mulX, b * mulX);
renderer.renderFaceXPos(block, x, y, z, outlet.iconFront);
}
if(meta == 2) {
renderer.setRenderBounds(0.3125D, bot, 0.625D, 0.6875D, top, 1D);
tessellator.setColorOpaque_F(r * mulBottom, g * mulBottom, b * mulBottom);
renderer.renderFaceYNeg(block, x, y, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulTop, g * mulTop, b * mulTop);
renderer.renderFaceYPos(block, x, y, z, outlet.iconTop);
renderer.renderFaceYPos(block, x, y - 0.375D, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulX, g * mulX, b * mulX);
renderer.field_152631_f = true;
renderer.renderFaceXPos(block, x, y, z, outlet.iconSide);
renderer.renderFaceXPos(block, x - 0.3125D, y, z, outlet.iconInner);
renderer.field_152631_f = false;
renderer.renderFaceXNeg(block, x, y, z, outlet.iconSide);
renderer.renderFaceXNeg(block, x + 0.3125D, y, z, outlet.iconInner);
tessellator.setColorOpaque_F(r * mulZ, g * mulZ, b * mulZ);
renderer.renderFaceZNeg(block, x, y, z, outlet.iconFront);
}
if(meta == 3) {
renderer.setRenderBounds(0.3125D, bot, 0D, 0.6875D, top, 0.375D);
tessellator.setColorOpaque_F(r * mulBottom, g * mulBottom, b * mulBottom);
renderer.renderFaceYNeg(block, x, y, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulTop, g * mulTop, b * mulTop);
renderer.renderFaceYPos(block, x, y, z, outlet.iconTop);
renderer.renderFaceYPos(block, x, y - 0.375D, z, outlet.iconBottom);
tessellator.setColorOpaque_F(r * mulX, g * mulX, b * mulX);
renderer.field_152631_f = true;
renderer.renderFaceXPos(block, x, y, z, outlet.iconSide);
renderer.renderFaceXPos(block, x - 0.3125D, y, z, outlet.iconInner);
renderer.field_152631_f = false;
renderer.renderFaceXNeg(block, x, y, z, outlet.iconSide);
renderer.renderFaceXNeg(block, x + 0.3125D, y, z, outlet.iconInner);
tessellator.setColorOpaque_F(r * mulZ, g * mulZ, b * mulZ);
renderer.renderFaceZPos(block, x, y, z, outlet.iconFront);
}
return true;
}

View File

@ -255,6 +255,7 @@ public class TileMappings {
put(TileEntityFoundryMold.class, "tileentity_foundry_mold");
put(TileEntityFoundryBasin.class, "tileentity_foundry_basin");
put(TileEntityFoundryChannel.class, "tileentity_foundry_channel");
put(TileEntityFoundryOutlet.class, "tileentity_foundry_outlet");
put(TileEntityMachineAutocrafter.class, "tileentity_autocrafter");
put(TileEntityDiFurnaceRTG.class, "tileentity_rtg_difurnace");

View File

@ -15,6 +15,8 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFoundryChannel extends TileEntityFoundryBase {
public int nextUpdate;
@Override
public void updateEntity() {
@ -24,7 +26,11 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase {
this.amount = 0;
}
if(worldObj.rand.nextInt(10) == 0 && this.amount > 0 && this.type != null) {
nextUpdate--;
if(nextUpdate <= 0 && this.amount > 0 && this.type != null) {
nextUpdate = worldObj.rand.nextInt(6) + 10;
List<Integer> ints = new ArrayList() {{ add(2); add(3); add(4); add(5); }};
Collections.shuffle(ints);

View File

@ -1,8 +1,11 @@
package com.hbm.tileentity.machine;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.util.CrucibleUtil;
import api.hbm.block.ICrucibleAcceptor;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -10,15 +13,36 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
@Override public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { return false; }
@Override public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { return stack; }
@Override
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
return this.standardCheck(world, x, y, z, side, stack);
Vec3 start = Vec3.createVectorHelper(x + 0.5, y - 0.125, z + 0.5);
Vec3 end = Vec3.createVectorHelper(x + 0.5, y + 0.125 - 4, z + 0.5);
MovingObjectPosition[] mop = new MovingObjectPosition[1];
ICrucibleAcceptor acc = CrucibleUtil.getPouringTarget(world, start, end, mop);
if(acc == null) {
return false;
}
return acc.canAcceptPartialPour(world, mop[0].blockX, mop[0].blockY, mop[0].blockZ, mop[0].hitVec.xCoord, mop[0].hitVec.yCoord, mop[0].hitVec.zCoord, ForgeDirection.UP, stack);
}
@Override
public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
return standardAdd(world, x, y, z, side, stack);
Vec3 start = Vec3.createVectorHelper(x + 0.5, y - 0.125, z + 0.5);
Vec3 end = Vec3.createVectorHelper(x + 0.5, y + 0.125 - 4, z + 0.5);
MovingObjectPosition[] mop = new MovingObjectPosition[1];
ICrucibleAcceptor acc = CrucibleUtil.getPouringTarget(world, start, end, mop);
if(acc == null)
return stack;
return acc.pour(world, mop[0].blockX, mop[0].blockY, mop[0].blockZ, mop[0].hitVec.xCoord, mop[0].hitVec.yCoord, mop[0].hitVec.zCoord, ForgeDirection.UP, stack);
}
@Override

View File

@ -66,9 +66,12 @@ public class CrucibleUtil {
for(MaterialStack stack : stacks) {
MaterialStack left = tryPourStack(world, acc, mop, stack, impactPosHolder);
int amountToPour = Math.min(stack.amount, quanta);
MaterialStack toPour = new MaterialStack(stack.material, amountToPour);
MaterialStack left = tryPourStack(world, acc, mop, toPour, impactPosHolder);
if(left != null) {
stack.amount -= (amountToPour - left.amount);
return new MaterialStack(stack.material, stack.amount - left.amount);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B