Gutter now uses new block registration system
This commit is contained in:
parent
a42f273420
commit
8131256e08
4 changed files with 104 additions and 231 deletions
|
@ -21,7 +21,6 @@ import resonantinduction.archaic.firebox.TileFirebox;
|
|||
import resonantinduction.archaic.firebox.TileHotPlate;
|
||||
import resonantinduction.archaic.fluid.grate.BlockGrate;
|
||||
import resonantinduction.archaic.fluid.grate.TileGrate;
|
||||
import resonantinduction.archaic.fluid.gutter.BlockGutter;
|
||||
import resonantinduction.archaic.fluid.gutter.TileGutter;
|
||||
import resonantinduction.archaic.fluid.tank.TileTank;
|
||||
import resonantinduction.archaic.process.BlockCastingMold;
|
||||
|
@ -109,7 +108,7 @@ public class Archaic
|
|||
blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class);
|
||||
blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class);
|
||||
blockCast = contentRegistry.createTile(BlockCastingMold.class, TileCastingMold.class);
|
||||
blockGutter = contentRegistry.createTile(BlockGutter.class, TileGutter.class);
|
||||
blockGutter = contentRegistry.newBlock(TileGutter.class);
|
||||
blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class);
|
||||
blockFilter = contentRegistry.createTile(BlockFilter.class, TileFilter.class);
|
||||
blockTank = contentRegistry.newBlock(TileTank.class);
|
||||
|
|
|
@ -1,175 +0,0 @@
|
|||
package resonantinduction.archaic.fluid.gutter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.fluid.BlockFluidNode;
|
||||
import universalelectricity.api.UniversalElectricity;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.render.block.BlockRenderingHandler;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Early tier version of the basic pipe. Open on the top, and can't support pressure.
|
||||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
public class BlockGutter extends BlockFluidNode
|
||||
{
|
||||
public BlockGutter(int id)
|
||||
{
|
||||
super(id, UniversalElectricity.machine);
|
||||
setTextureName(Reference.PREFIX + "material_wood_surface");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
|
||||
{
|
||||
float thickness = 0.1F;
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileGutter)
|
||||
{
|
||||
byte renderSides = ((TileGutter) tile).renderSides;
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.DOWN))
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.WEST))
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.NORTH))
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.EAST))
|
||||
{
|
||||
this.setBlockBounds(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.SOUTH))
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
}
|
||||
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1, 0.99f, 1);
|
||||
}
|
||||
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWithRain(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!world.isRemote && tile instanceof TileGutter)
|
||||
{
|
||||
((TileGutter) tile).fill(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 10), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileGutter)
|
||||
{
|
||||
if (((TileGutter) tile).getInternalTank().getFluidAmount() > 0)
|
||||
{
|
||||
int pressure = ((TileGutter) tile).getPressure(null);
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
Vector3 position = new Vector3(x, y, z).translate(dir);
|
||||
|
||||
TileEntity checkTile = position.getTileEntity(world);
|
||||
|
||||
if (checkTile instanceof TileGutter)
|
||||
{
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).getPressure(null);
|
||||
|
||||
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
entity.noClip = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() == ResonantInduction.itemDust)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!world.isRemote && tile instanceof TileGutter)
|
||||
{
|
||||
return FluidUtility.playerActivatedFluidItem(world, x, y, z, entityplayer, side);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileGutter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderingHandler.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,24 @@
|
|||
package resonantinduction.archaic.fluid.gutter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.fluid.IPressurizedNode;
|
||||
import resonantinduction.core.fluid.TilePressurizedNode;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.vector.Cuboid;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
|
||||
|
@ -23,6 +33,99 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
public TileGutter()
|
||||
{
|
||||
super(Material.wood);
|
||||
textureName = "material_wood_surface";
|
||||
isOpaqueCube = false;
|
||||
normalRender = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid> getCollisionBoxes()
|
||||
{
|
||||
List<Cuboid> list = new ArrayList<Cuboid>();
|
||||
|
||||
float thickness = 0.1F;
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.DOWN))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F));
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.WEST))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F));
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.NORTH))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness));
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.EAST))
|
||||
{
|
||||
list.add(new Cuboid(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.SOUTH))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(Entity entity)
|
||||
{
|
||||
if (getInternalTank().getFluidAmount() > 0)
|
||||
{
|
||||
int pressure = getPressure(null);
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
Vector3 position = position().translate(dir);
|
||||
|
||||
TileEntity checkTile = position.getTileEntity(world());
|
||||
|
||||
if (checkTile instanceof TileGutter)
|
||||
{
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).getPressure(null);
|
||||
|
||||
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
entity.noClip = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, int side, Vector3 vector3)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == ResonantInduction.itemDust)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillRain()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
fill(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 10), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
package resonantinduction.core.fluid;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import calclavia.lib.prefab.block.BlockTile;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
public abstract class BlockFluidNode extends BlockTile
|
||||
{
|
||||
public BlockFluidNode(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidDistribution)
|
||||
{
|
||||
((TileFluidDistribution) tile).refresh();
|
||||
((TileFluidDistribution) tile).getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
if (tile instanceof TilePressurizedNode)
|
||||
{
|
||||
((TilePressurizedNode) tile).refresh();
|
||||
((TilePressurizedNode) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidDistribution)
|
||||
{
|
||||
((TileFluidDistribution) tile).refresh();
|
||||
((TileFluidDistribution) tile).getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
if (tile instanceof TilePressurizedNode)
|
||||
{
|
||||
((TilePressurizedNode) tile).refresh();
|
||||
((TilePressurizedNode) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue