Bounding blocks for miner!

This commit is contained in:
Aidan C. Brady 2013-11-21 14:35:33 -05:00
parent 44ca9d1067
commit 68f3d28119
9 changed files with 418 additions and 8 deletions

View file

@ -13,6 +13,7 @@ import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemBlock;
@ -300,7 +301,10 @@ public class GuiDigitalMiner extends GuiMekanism
{
if(stack.getItem() instanceof ItemBlock)
{
toUse = stack.copy();
if(stack.itemID != Block.bedrock.blockID)
{
toUse = stack.copy();
}
}
}
else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))

View file

@ -13,6 +13,7 @@ import mekanism.common.network.PacketNewFilter;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
@ -205,8 +206,11 @@ public class GuiMItemStackFilter extends GuiMekanism
{
if(stack.getItem() instanceof ItemBlock)
{
filter.itemType = stack.copy();
filter.itemType.stackSize = 1;
if(stack.itemID != Block.bedrock.blockID)
{
filter.itemType = stack.copy();
filter.itemType.stackSize = 1;
}
}
}
else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))

View file

@ -0,0 +1,18 @@
package mekanism.common;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import buildcraft.api.power.IPowerReceptor;
import cofh.api.energy.IEnergyHandler;
import mekanism.api.Object3D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import net.minecraft.inventory.ISidedInventory;
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
{
public int[] getBoundSlots(Object3D location, int slotID);
}

View file

@ -75,6 +75,7 @@ import mekanism.common.network.PacketTileEntity;
import mekanism.common.network.PacketTransmitterTransferUpdate;
import mekanism.common.network.PacketTransmitterTransferUpdate.TransmitterTransferType;
import mekanism.common.network.PacketWalkieTalkieState;
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
import mekanism.common.tileentity.TileEntityBoundingBlock;
import mekanism.common.tileentity.TileEntityElectricBlock;
import mekanism.common.tileentity.TileEntityTeleporter;
@ -1015,6 +1016,7 @@ public class Mekanism
//Tile entities
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
GameRegistry.registerTileEntity(TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock");
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
//Load tile entities that have special renderers.

View file

@ -2,8 +2,7 @@ package mekanism.common.block;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
import mekanism.common.tileentity.TileEntityBoundingBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -13,6 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBounding extends Block
{
@ -99,6 +100,15 @@ public class BlockBounding extends Block
@Override
public TileEntity createTileEntity(World world, int metadata)
{
return new TileEntityBoundingBlock();
if(metadata == 0)
{
return new TileEntityBoundingBlock();
}
else if(metadata == 1)
{
return new TileEntityAdvancedBoundingBlock();
}
return null;
}
}

View file

@ -160,7 +160,22 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
if(stack.getItemDamage() == MachineType.DIGITAL_MINER.meta)
{
for(int xPos = x-1; xPos <= x+1; xPos++)
{
for(int yPos = y; yPos <= y+1; yPos++)
{
for(int zPos = z-1; zPos <= z+1; zPos++)
{
Block b = Block.blocksList[world.getBlockId(xPos, yPos, zPos)];
if(yPos > 255)
place = false;
if(b != null && b.blockID != 0 && !b.isBlockReplaceable(world, xPos, yPos, zPos))
return false;
}
}
}
}
if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))

View file

@ -0,0 +1,276 @@
package mekanism.common.tileentity;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.electricity.ElectricityPack;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cofh.api.energy.IEnergyHandler;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import mekanism.api.Object3D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.common.IAdvancedBoundingBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
{
@Override
public int getSizeInventory()
{
return getInv().getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i)
{
return getInv().getStackInSlot(i);
}
@Override
public ItemStack decrStackSize(int i, int j)
{
return getInv().decrStackSize(i, j);
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
return getInv().getStackInSlotOnClosing(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
getInv().setInventorySlotContents(i, itemstack);
}
@Override
public String getInvName()
{
return getInv().getInvName();
}
@Override
public boolean isInvNameLocalized()
{
return getInv().isInvNameLocalized();
}
@Override
public int getInventoryStackLimit()
{
return getInv().getInventoryStackLimit();
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return getInv().isUseableByPlayer(entityplayer);
}
@Override
public void openChest()
{
getInv().openChest();
}
@Override
public void closeChest()
{
getInv().closeChest();
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return getInv().isItemValidForSlot(i, itemstack);
}
@Override
public int[] getAccessibleSlotsFromSide(int slotID)
{
return getInv().getBoundSlots(Object3D.get(this), slotID);
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j)
{
return getInv().canInsertItem(i, itemstack, j);
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j)
{
return getInv().canExtractItem(i, itemstack, j);
}
@Override
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
return getInv().acceptsEnergyFrom(emitter, direction);
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
return getInv().receiveEnergy(from, maxReceive, simulate);
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
return getInv().extractEnergy(from, maxExtract, simulate);
}
@Override
public boolean canInterface(ForgeDirection from)
{
return getInv().canInterface(from);
}
@Override
public int getEnergyStored(ForgeDirection from)
{
return getInv().getEnergyStored(from);
}
@Override
public int getMaxEnergyStored(ForgeDirection from)
{
return getInv().getMaxEnergyStored(from);
}
@Override
public double getEnergy()
{
return getInv().getEnergy();
}
@Override
public void setEnergy(double energy)
{
getInv().setEnergy(energy);
}
@Override
public double getMaxEnergy()
{
return getInv().getMaxEnergy();
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return getInv().canConnect(direction);
}
@Override
public void setEnergyStored(float energy)
{
getInv().setEnergyStored(energy);
}
@Override
public float getEnergyStored()
{
return getInv().getEnergyStored();
}
@Override
public float getMaxEnergyStored()
{
return getInv().getMaxEnergyStored();
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
{
return getInv().receiveElectricity(from, receive, doReceive);
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
return getInv().provideElectricity(from, request, doProvide);
}
@Override
public float getRequest(ForgeDirection direction)
{
return getInv().getRequest(direction);
}
@Override
public float getProvide(ForgeDirection direction)
{
return getInv().getProvide(direction);
}
@Override
public float getVoltage()
{
return getInv().getVoltage();
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
return getInv().getPowerReceiver(side);
}
@Override
public void doWork(PowerHandler workProvider)
{
getInv().doWork(workProvider);
}
@Override
public World getWorld()
{
return getInv().getWorld();
}
@Override
public double transferEnergyToAcceptor(double amount)
{
return getInv().transferEnergyToAcceptor(amount);
}
@Override
public boolean canReceiveEnergy(ForgeDirection side)
{
return getInv().canReceiveEnergy(side);
}
@Override
public double demandedEnergyUnits()
{
return getInv().demandedEnergyUnits();
}
@Override
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
{
return getInv().injectEnergyUnits(directionFrom, amount);
}
@Override
public int getMaxSafeInput()
{
return getInv().getMaxSafeInput();
}
public IAdvancedBoundingBlock getInv()
{
return (IAdvancedBoundingBlock)new Object3D(mainX, mainY, mainZ).getTileEntity(worldObj);
}
}

View file

@ -11,6 +11,7 @@ import mekanism.api.Object3D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.common.HashList;
import mekanism.common.IActiveState;
import mekanism.common.IAdvancedBoundingBlock;
import mekanism.common.IRedstoneControl;
import mekanism.common.IUpgradeTile;
import mekanism.common.Mekanism;
@ -41,7 +42,7 @@ import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IEnergySink, IStrictEnergyAcceptor, IUpgradeTile, IRedstoneControl, IActiveState
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IEnergySink, IStrictEnergyAcceptor, IUpgradeTile, IRedstoneControl, IActiveState, IAdvancedBoundingBlock
{
public Set<Object3D> oresToMine = new HashSet<Object3D>();
@ -845,4 +846,73 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{
return INFINITE_EXTENT_AABB;
}
@Override
public void onPlace()
{
for(int x = xCoord-1; x <= xCoord+1; x++)
{
for(int y = yCoord; y <= yCoord+1; y++)
{
for(int z = zCoord-1; z <= zCoord+1; z++)
{
if(x == xCoord && y == yCoord && z == zCoord)
{
continue;
}
MekanismUtils.makeAdvancedBoundingBlock(worldObj, x, y, z, Object3D.get(this));
}
}
}
}
@Override
public boolean canSetFacing(int side)
{
return side != 0 && side != 1;
}
@Override
public void onBreak()
{
for(int x = xCoord-1; x <= xCoord+1; x++)
{
for(int y = yCoord; y <= yCoord+2; y++)
{
for(int z = zCoord-1; z <= zCoord+1; z++)
{
worldObj.setBlockToAir(x, y, z);
}
}
}
}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{
return null;
}
@Override
public int[] getBoundSlots(Object3D location, int slotID)
{
ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite();
Object3D obj = new Object3D(xCoord+side.offsetX, yCoord+1, zCoord+side.offsetZ, worldObj.provider.dimensionId);
if(location.equals(obj))
{
int[] ret = new int[27];
for(int i = 0; i < ret.length; i++)
{
ret[i] = i;
}
return ret;
}
return null;
}
}

View file

@ -34,6 +34,7 @@ import mekanism.common.item.ItemBlockEnergyCube;
import mekanism.common.item.ItemBlockGasTank;
import mekanism.common.network.PacketElectricChest;
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
import mekanism.common.tileentity.TileEntityBoundingBlock;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityElectricChest;
@ -598,6 +599,16 @@ public final class MekanismUtils
}
}
public static void makeAdvancedBoundingBlock(World world, int x, int y, int z, Object3D orig)
{
world.setBlock(x, y, z, Mekanism.BoundingBlock.blockID, 1, 3);
if(!world.isRemote)
{
((TileEntityAdvancedBoundingBlock)world.getBlockTileEntity(x, y, z)).setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord);
}
}
/**
* Updates a block's light value and marks it for a render update.
* @param world - world the block is in