diff --git a/src/main/java/api/hbm/block/ICrucibleAcceptor.java b/src/main/java/api/hbm/block/ICrucibleAcceptor.java index 0f140f941..b94433534 100644 --- a/src/main/java/api/hbm/block/ICrucibleAcceptor.java +++ b/src/main/java/api/hbm/block/ICrucibleAcceptor.java @@ -1,7 +1,13 @@ package api.hbm.block; -import com.hbm.inventory.material.Mats.MaterialStack; +import java.util.List; +import com.hbm.inventory.material.Mats.MaterialStack; +import com.hbm.inventory.material.NTMMaterial.SmeltingBehavior; + +import net.minecraft.block.Block; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -22,4 +28,80 @@ public interface ICrucibleAcceptor { //public boolean canAcceptFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack); public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack); public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack); + + /** + * Standard pouring, casting a hitscan straight down at the given coordinates with the given range. Returns the materialStack that has been removed. + * The method doesn't make copies of the MaterialStacks in the list, so the materials being subtracted or outright removed will apply to the original list. + */ + public static MaterialStack tryPour(World world, double x, double y, double z, double range, boolean safe, List stacks, int quanta, Vec3 impactPos) { + + if(stacks.isEmpty()) return null; + + Vec3 start = Vec3.createVectorHelper(x, y, z); + Vec3 end = Vec3.createVectorHelper(x, y - range, z); + + MovingObjectPosition mop = world.func_147447_a(start, end, true, true, true); + + //if the pour misses + if(mop == null || mop.typeOfHit != mop.typeOfHit.BLOCK) { + return spill(mop, safe, stacks, quanta, impactPos); + } + + Block b = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); + + if(!(b instanceof ICrucibleAcceptor)) { + return spill(mop, safe, stacks, quanta, impactPos); + } + + ICrucibleAcceptor acc = (ICrucibleAcceptor) b; + Vec3 hit = mop.hitVec; + MaterialStack pouredStack = null; + + for(MaterialStack stack : stacks) { + + 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(left == null) { + left = new MaterialStack(stack.material, 0); + } + + pouredStack = new MaterialStack(stack.material, stack.amount - left.amount); + stack.amount -= pouredStack.amount; + impactPos.xCoord = hit.xCoord; + impactPos.yCoord = hit.yCoord; + impactPos.zCoord = hit.zCoord; + + break; + } + } + + return pouredStack; + } + + public static MaterialStack spill(MovingObjectPosition mop, boolean safe, List stacks, int quanta, Vec3 impactPos) { + + //do nothing if safe mode is on + if(safe) { + return null; + } + + //simply use the first available material + MaterialStack top = stacks.get(0); + MaterialStack toWaste = new MaterialStack(top.material, Math.min(top.amount, quanta)); + top.amount -= toWaste.amount; + //remove all stacks with no content + stacks.removeIf(o -> o.amount <= 0); + + //if there is a vec3 reference, set the impact coordinates + if(impactPos != null && mop != null) { + impactPos.xCoord = mop.hitVec.xCoord; + impactPos.yCoord = mop.hitVec.yCoord; + impactPos.zCoord = mop.hitVec.zCoord; + } + + return toWaste; + } } diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 9c1a06c9e..321f3e122 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -642,6 +642,7 @@ public class ModBlocks { public static Block foundry_mold; public static Block foundry_basin; public static Block foundry_channel; + public static Block foundry_outlet; public static Block machine_difurnace_off; public static Block machine_difurnace_on; @@ -1824,9 +1825,10 @@ public class ModBlocks { machine_sawmill = new MachineSawmill().setBlockName("machine_sawmill").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_crucible = new MachineCrucible().setBlockName("machine_crucible").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_crucible"); - foundry_mold = new FoundryMold().setBlockName("foundry_mold").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":foundry_mold"); - foundry_basin = new FoundryBasin().setBlockName("foundry_basin").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":foundry_basin"); - foundry_channel = new FoundryChannel().setBlockName("foundry_channel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":foundry_channel"); + foundry_mold = new FoundryMold().setBlockName("foundry_mold").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire"); + foundry_basin = new FoundryBasin().setBlockName("foundry_basin").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire"); + foundry_channel = new FoundryChannel().setBlockName("foundry_channel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire"); + foundry_outlet = new FoundryOutlet().setBlockName("foundry_outlet").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire"); machine_difurnace_off = new MachineDiFurnace(false).setBlockName("machine_difurnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); machine_difurnace_on = new MachineDiFurnace(true).setBlockName("machine_difurnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F); @@ -3022,6 +3024,7 @@ public class ModBlocks { register(foundry_mold); register(foundry_basin); register(foundry_channel); + register(foundry_outlet); GameRegistry.registerBlock(machine_difurnace_off, machine_difurnace_off.getUnlocalizedName()); GameRegistry.registerBlock(machine_difurnace_on, machine_difurnace_on.getUnlocalizedName()); GameRegistry.registerBlock(machine_difurnace_rtg_off, machine_difurnace_rtg_off.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/machine/FoundryOutlet.java b/src/main/java/com/hbm/blocks/machine/FoundryOutlet.java new file mode 100644 index 000000000..82b0698cf --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/FoundryOutlet.java @@ -0,0 +1,80 @@ +package com.hbm.blocks.machine; + +import com.hbm.inventory.material.Mats.MaterialStack; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityFoundryOutlet; + +import api.hbm.block.ICrucibleAcceptor; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +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.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor { + + @SideOnly(Side.CLIENT) public IIcon iconTop; + @SideOnly(Side.CLIENT) public IIcon iconSide; + @SideOnly(Side.CLIENT) public IIcon iconBottom; + @SideOnly(Side.CLIENT) public IIcon iconInner; + + public FoundryOutlet() { + super(Material.rock); + } + + @Override + @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"); + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityFoundryOutlet(); + } + + @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 ((TileEntityFoundryOutlet) 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 ((TileEntityFoundryOutlet) world.getTileEntity(x, y, z)).flow(world, x, y, z, side, stack); + } + + public static int renderID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public int getRenderType() { + return renderID; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } +} diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index a1c9af8ae..c5038b221 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -3604,8 +3604,8 @@ public class ModItems { coin_maskman = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("coin_maskman").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coin_maskman"); coin_worm = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("coin_worm").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coin_worm"); coin_ufo = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("coin_ufo").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coin_ufo"); - coin_siege = new ItemSiegeCoin().setUnlocalizedName("coin_siege").setCreativeTab(MainRegistry.consumableTab); - source = new ItemCustomLore().setRarity(EnumRarity.epic).setUnlocalizedName("source").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":source"); + coin_siege = new ItemSiegeCoin().setUnlocalizedName("coin_siege").setCreativeTab(null); + source = new ItemCustomLore().setRarity(EnumRarity.epic).setUnlocalizedName("source").setCreativeTab(null).setTextureName(RefStrings.MODID + ":source"); recycled_ground = new Item().setUnlocalizedName("recycled_ground").setCreativeTab(null).setTextureName(RefStrings.MODID + ":recycled_ground"); recycled_rock = new Item().setUnlocalizedName("recycled_rock").setCreativeTab(null).setTextureName(RefStrings.MODID + ":recycled_rock"); diff --git a/src/main/java/com/hbm/lib/Library.java b/src/main/java/com/hbm/lib/Library.java index a4cd31470..78c66c4ec 100644 --- a/src/main/java/com/hbm/lib/Library.java +++ b/src/main/java/com/hbm/lib/Library.java @@ -300,12 +300,12 @@ public class Library { return player.worldObj.func_147447_a(vec3, vec32, false, false, true); } - public static MovingObjectPosition rayTrace(EntityPlayer player, double length, float interpolation, boolean liquids, boolean entity, boolean allowZeroLength) { + public static MovingObjectPosition rayTrace(EntityPlayer player, double length, float interpolation, boolean allowLiquids, boolean disallowNonCollidingBlocks, boolean mopOnMiss) { Vec3 vec3 = getPosition(interpolation, player); vec3.yCoord += player.eyeHeight; Vec3 vec31 = player.getLook(interpolation); Vec3 vec32 = vec3.addVector(vec31.xCoord * length, vec31.yCoord * length, vec31.zCoord * length); - return player.worldObj.func_147447_a(vec3, vec32, liquids, entity, allowZeroLength); + return player.worldObj.func_147447_a(vec3, vec32, allowLiquids, disallowNonCollidingBlocks, mopOnMiss); } public static Vec3 getPosition(float interpolation, EntityPlayer player) { diff --git a/src/main/java/com/hbm/main/NEIConfig.java b/src/main/java/com/hbm/main/NEIConfig.java index 0b79f4212..44e9aed37 100644 --- a/src/main/java/com/hbm/main/NEIConfig.java +++ b/src/main/java/com/hbm/main/NEIConfig.java @@ -15,7 +15,6 @@ import codechicken.nei.api.IConfigureNEI; import codechicken.nei.api.IHighlightHandler; import codechicken.nei.api.ItemInfo.Layout; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; @@ -102,8 +101,11 @@ public class NEIConfig implements IConfigureNEI { API.hideItem(new ItemStack(ModBlocks.statue_elb_f)); API.hideItem(new ItemStack(ModBlocks.cheater_virus)); API.hideItem(new ItemStack(ModBlocks.cheater_virus_seed)); + API.hideItem(new ItemStack(ModBlocks.transission_hatch)); API.hideItem(new ItemStack(ModItems.euphemium_kit)); API.hideItem(new ItemStack(ModItems.bobmazon_hidden)); + API.hideItem(new ItemStack(ModItems.coin_siege)); + API.hideItem(new ItemStack(ModItems.source)); if(MainRegistry.polaroidID != 11) { API.hideItem(new ItemStack(ModItems.book_secret)); API.hideItem(new ItemStack(ModItems.book_of_)); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java b/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java index febaef81e..13e77a1da 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java @@ -24,12 +24,12 @@ import net.minecraft.block.Block; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -95,43 +95,39 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro this.progress = 0; } - /* TEMP */ if(!this.wasteStack.isEmpty()) { 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); + } + + if(!this.recipeStack.isEmpty()) { - outer: - for(MaterialStack stack : this.wasteStack) { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + List toCast = new ArrayList(); + + CrucibleRecipe recipe = this.getLoadedRecipe(); + //if no recipe is loaded, everything from the recipe stack will be drainable + if(recipe == null) { + toCast.addAll(this.recipeStack); + } else { - for(int i = 0; i < 4; i++) { - int x = xCoord + dir.offsetX * 2; - int z = zCoord + dir.offsetZ * 2; - int y = yCoord - i - 1; - Block b = worldObj.getBlock(x, y, z); - if(b.isAir(worldObj, x, y, z)) continue; - - if(b instanceof ICrucibleAcceptor) { - - ICrucibleAcceptor acc = (ICrucibleAcceptor) b; - int pourAmount = Math.min(MaterialShapes.NUGGET.q(1), stack.amount); - MaterialStack toPour = new MaterialStack(stack.material, pourAmount); - - if(acc.canAcceptPartialPour(worldObj, x, y, z, 0.5, 1, 0.5, ForgeDirection.UP, toPour)) { - int prev = pourAmount; - MaterialStack left = acc.pour(worldObj, x, y, z, 0.5, 1, 0.5, ForgeDirection.UP, toPour); - - int diff = prev - (left != null ? left.amount : 0); - stack.amount -= diff; - - break outer; + for(MaterialStack stack : this.recipeStack) { + for(MaterialStack output : recipe.output) { + if(stack.material == output.material) { + toCast.add(stack); + break; } - } else { - break; } } } + + 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); } - + + this.recipeStack.removeIf(o -> o.amount <= 0); this.wasteStack.removeIf(x -> x.amount <= 0); NBTTagCompound data = new NBTTagCompound(); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBase.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBase.java index 20838c62e..6e5743fdc 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBase.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBase.java @@ -2,6 +2,7 @@ package com.hbm.tileentity.machine; import com.hbm.inventory.material.Mats; import com.hbm.inventory.material.NTMMaterial; +import com.hbm.inventory.material.Mats.MaterialStack; import api.hbm.block.ICrucibleAcceptor; import net.minecraft.nbt.NBTTagCompound; @@ -9,6 +10,8 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; /** * Base class for all foundry channel type blocks - channels, casts, basins, tanks, etc. @@ -80,4 +83,65 @@ public abstract class TileEntityFoundryBase extends TileEntity implements ICruci } public abstract int getCapacity(); + + /** + * Standard check for testing if this material stack can be added to the casting block. Checks:
+ * - type matching
+ * - amount being at max
+ */ + public boolean standardCheck(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { + if(this.type != null && this.type != stack.material) return false; //reject if there's already a different material + if(this.amount >= this.getCapacity()) return false; //reject if the buffer is already full + return true; + } + + /** + * Standardized adding of material via pouring or flowing. Does:
+ * - sets material to match the input + * - adds the amount, not exceeding the maximum + * - returns the amount that cannot be added + */ + public MaterialStack standardAdd(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { + + if(this.type == null) { + this.type = stack.material; + } + + if(stack.amount + this.amount <= this.getCapacity()) { + this.amount += stack.amount; + return null; + } + + int required = this.getCapacity() - this.amount; + this.amount = this.getCapacity(); + + stack.amount -= required; + + return stack; + } + + /** Standard check with no additional limitations added */ + @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); + } + + /** Standard flow, no special handling required */ + @Override + public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { + return standardAdd(world, x, y, z, side, stack); + } + + /** Standard check, but with the additional limitation that the only valid source direction is UP */ + @Override + public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { + if(side != ForgeDirection.UP) return false; + return this.standardCheck(world, x, y, z, side, stack); + } + + /** Standard flow, no special handling required */ + @Override + public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { + return standardAdd(world, x, y, z, side, stack); + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java index 48183a52f..18a513e19 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java @@ -76,31 +76,6 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase Mold mold = this.getInstalledMold(); return mold == null ? 0 : mold.getCost(); } - - /** Standard check with no additional limitations added */ - @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); - } - - /** Standard flow, no special handling required */ - @Override - public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { - return standardAdd(world, x, y, z, side, stack); - } - - /** Standard check, but with the additional limitation that the only valid source direction is UP */ - @Override - public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { - if(side != ForgeDirection.UP) return false; - return this.standardCheck(world, x, y, z, side, stack); - } - - /** Standard flow, no special handling required */ - @Override - public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { - return standardAdd(world, x, y, z, side, stack); - } /** * Standard check for testing if this material stack can be added to the casting block. Checks:
@@ -110,8 +85,7 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase * - whether the mold can accept this type */ public boolean standardCheck(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { - if(this.type != null && this.type != stack.material) return false; //reject if there's already a different material - if(this.amount >= this.getCapacity()) return false; //reject if the buffer is already full + if(!super.standardCheck(world, x, y, z, side, stack)) return false; //reject if base conditions are not met if(this.slots[1] != null) return false; //reject if a freshly casted item is still present Mold mold = this.getInstalledMold(); if(mold == null) return false; @@ -127,44 +101,9 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase return false; //no OD match -> no pouring } - /** - * Standardized adding of material via pouring or flowing. Does:
- * - sets material to match the input - * - adds the amount, not exceeding the maximum - * - returns the amount that cannot be added - */ - public MaterialStack standardAdd(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { - - if(this.type == null) { - this.type = stack.material; - } - - if(stack.amount + this.amount <= this.getCapacity()) { - this.amount += stack.amount; - return null; - } - - int required = this.getCapacity() - this.amount; - this.amount = this.getCapacity(); - - stack.amount -= required; - - return stack; - } - /** Returns an integer determining the mold size, 0 for small molds and 1 for the basin */ public abstract int getMoldSize(); - @Override - public int getSizeInventory() { - return slots.length; - } - - @Override - public ItemStack getStackInSlot(int i) { - return slots[i]; - } - @Override public ItemStack getStackInSlotOnClosing(int i) { if(slots[i] != null) { @@ -203,13 +142,18 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase } @Override - public String getInventoryName() { - return "ntmFoundry"; + public int getSizeInventory() { + return slots.length; } @Override - public boolean hasCustomInventoryName() { - return false; + public ItemStack getStackInSlot(int i) { + return slots[i]; + } + + @Override + public String getInventoryName() { + return "ntmFoundry"; } @Override @@ -217,15 +161,9 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase return 64; } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return false; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack stack) { - return false; - } + @Override public boolean hasCustomInventoryName() { return false; } + @Override public boolean isUseableByPlayer(EntityPlayer player) { return false; } + @Override public boolean isItemValidForSlot(int i, ItemStack stack) { return false; } @Override public void openInventory() { } @Override public void closeInventory() { } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java index a9d73912b..87af1488f 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java @@ -11,7 +11,6 @@ import com.hbm.inventory.material.Mats.MaterialStack; import api.hbm.block.ICrucibleAcceptor; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityFoundryChannel extends TileEntityFoundryBase { @@ -86,66 +85,6 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase { super.updateEntity(); } - @Override - public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { - - if(side != ForgeDirection.UP) return false; //reject from any direction other than the top - if(this.type != null && this.type != stack.material) return false; //reject if there's already a different material - if(this.amount >= this.getCapacity()) return false; //reject if the buffer is already full - - return true; //pour - } - - @Override - public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { - - if(this.type == null) { - this.type = stack.material; - } - - if(stack.amount + this.amount <= this.getCapacity()) { - this.amount += stack.amount; - return null; - } - - int required = this.getCapacity() - this.amount; - this.amount = this.getCapacity(); - - stack.amount -= required; - - return stack; - } - - @Override - public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { - - if(side == ForgeDirection.UP || side == ForgeDirection.DOWN) return false; - if(this.type != null && this.type != stack.material) return false; - if(this.amount >= this.getCapacity()) return false; - - return true; //pour - } - - @Override - public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { - - if(this.type == null) { - this.type = stack.material; - } - - if(stack.amount + this.amount <= this.getCapacity()) { - this.amount += stack.amount; - return null; - } - - int required = this.getCapacity() - this.amount; - this.amount = this.getCapacity(); - - stack.amount -= required; - - return stack; - } - @Override public int getCapacity() { return MaterialShapes.INGOT.q(1); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java new file mode 100644 index 000000000..8b029c69f --- /dev/null +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java @@ -0,0 +1,17 @@ +package com.hbm.tileentity.machine; + +import com.hbm.inventory.material.Mats.MaterialStack; + +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +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 int getCapacity() { + return 0; + } +} diff --git a/src/main/resources/assets/hbm/textures/blocks/foundry_basin.png b/src/main/resources/assets/hbm/textures/blocks/brick_fire.png similarity index 100% rename from src/main/resources/assets/hbm/textures/blocks/foundry_basin.png rename to src/main/resources/assets/hbm/textures/blocks/brick_fire.png diff --git a/src/main/resources/assets/hbm/textures/blocks/brick_light_alt.png b/src/main/resources/assets/hbm/textures/blocks/brick_light_alt.png new file mode 100644 index 000000000..5d0621853 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/brick_light_alt.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/foundry_channel.png b/src/main/resources/assets/hbm/textures/blocks/foundry_channel.png deleted file mode 100644 index f3b5094cc..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/foundry_channel.png and /dev/null differ diff --git a/src/main/resources/assets/hbm/textures/blocks/foundry_mold.png b/src/main/resources/assets/hbm/textures/blocks/foundry_mold.png deleted file mode 100644 index f3b5094cc..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/foundry_mold.png and /dev/null differ