foundry basin, updated crucible block API

This commit is contained in:
Boblet 2022-09-22 16:54:37 +02:00
parent 4479b8bcb9
commit 90299bd1ba
6 changed files with 133 additions and 9 deletions

View File

@ -11,15 +11,15 @@ public interface ICrucibleAcceptor {
* Pouring: The metal leaves the channel/crucible and usually (but not always) falls down. The additional double coords give a more precise impact location.
* Also useful for entities like large crucibles since they are filled from the top.
*/
public boolean canAcceptPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
public MaterialStack canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
public void pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
//public boolean canAcceptPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
/*
* Flowing: The "safe" transfer of metal using a channel or other means, usually from block to block and usually horizontally (but not necessarily).
* May also be used for entities like minecarts that could be loaded from the side.
*/
public boolean canAcceptFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack);
public MaterialStack canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack);
public void flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack);
//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);
}

View File

@ -639,6 +639,8 @@ public class ModBlocks {
public static Block machine_sawmill;
public static Block machine_crucible;
public static Block foundry_basin;
public static Block machine_difurnace_off;
public static Block machine_difurnace_on;
public static Block machine_difurnace_rtg_off;
@ -1820,6 +1822,8 @@ 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_basin = new FoundryBasin().setBlockName("foundry_basin").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":foundry_basin");
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);
machine_difurnace_rtg_off = new MachineDiFurnaceRTG(false).setBlockName("machine_difurnace_rtg_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);

View File

@ -0,0 +1,54 @@
package com.hbm.blocks.machine;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.tileentity.machine.TileEntityFoundryBasin;
import api.hbm.block.ICrucibleAcceptor;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class FoundryBasin extends BlockContainer implements ICrucibleAcceptor {
public FoundryBasin() {
super(Material.rock);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityFoundryBasin();
}
@Override
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) {
return ((TileEntityFoundryBasin) 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 ((TileEntityFoundryBasin) 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 false; }
@Override public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { return 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;
}
}

View File

@ -1336,7 +1336,7 @@ public class ModEventHandler {
private static final String hash = "41eb77f138ce350932e33b6b26b233df9aad0c0c80c6a49cb9a54ddd8fae3f83";
@SubscribeEvent
//@SubscribeEvent
public void onClickSign(PlayerInteractEvent event) {
int x = event.x;

View File

@ -3,6 +3,7 @@ package com.hbm.tileentity.machine;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.NTMMaterial;
import api.hbm.block.ICrucibleAcceptor;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
@ -15,7 +16,7 @@ import net.minecraft.tileentity.TileEntity;
* @author hbm
*
*/
public abstract class TileEntityFoundryBase extends TileEntity {
public abstract class TileEntityFoundryBase extends TileEntity implements ICrucibleAcceptor {
public NTMMaterial type;
protected NTMMaterial lastType;
@ -27,13 +28,18 @@ public abstract class TileEntityFoundryBase extends TileEntity {
if(worldObj.isRemote) {
if(this.lastType != this.type || this.lastAmount != this.amount) {
if(shouldClientReRender() && this.lastType != this.type || this.lastAmount != this.amount) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
this.lastType = this.type;
this.lastAmount = this.amount;
}
}
}
/** Recommended FALSE for things that update a whole lot. TRUE if updates only happen once every few ticks. */
protected boolean shouldClientReRender() {
return true;
}
@Override
public Packet getDescriptionPacket() {

View File

@ -0,0 +1,60 @@
package com.hbm.tileentity.machine;
import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.Mats.MaterialStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
public class TileEntityFoundryBasin extends TileEntityFoundryBase {
@Override
public int getCapacity() {
return MaterialShapes.BLOCK.q(1);
}
@Override
public void updateEntity() {
super.updateEntity();
//TODO: cool off
}
//TODO: move to block
@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
for(String name : stack.material.names) {
String od = "block" + name;
if(!OreDictionary.getOres(od).isEmpty()) {
return true; //at least one block for this material? return TRUE
}
}
return false; //no OD match -> no pouring
}
@Override
public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) {
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) { return false; }
@Override public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { return stack; }
}