Block breaker and placer are functional
This commit is contained in:
parent
dbe2ce3612
commit
6e3f0b9fd3
3 changed files with 148 additions and 81 deletions
|
@ -65,7 +65,11 @@ allprojects {
|
|||
|
||||
dependencies {
|
||||
compile group: 'universalelectricity', name: 'Universal-Electricity', version: "${rootProject.config.version.universalelectricity}", classifier: "dev"
|
||||
if (ENV.JOB_NAME == "Resonant-Induction-Development")
|
||||
compile group: 'calclavia-core-development', name: 'calclavia-core', version: "${rootProject.config.version.calclaviacore}", classifier: "dev"
|
||||
else
|
||||
compile group: 'calclaviacore', name: 'calclavia-core', version: "${config.version.calclaviacore}", classifier: "dev"
|
||||
|
||||
compile name: 'CodeChickenLib', version: "${config.version.minecraft}-${config.version.cclib}", ext: 'jar'
|
||||
compile name: 'ForgeMultipart', version: "${config.version.minecraft}-${config.version.fmp}", ext: 'jar'
|
||||
compile name: 'NotEnoughItems', version: "${config.version.nei}", ext: 'jar'
|
||||
|
|
|
@ -30,6 +30,8 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class TileBreaker extends TileInventory implements IRotatable, IPacketReceiver
|
||||
{
|
||||
private boolean doWork = false;
|
||||
|
||||
public TileBreaker()
|
||||
{
|
||||
super(Material.iron);
|
||||
|
@ -48,7 +50,26 @@ public class TileBreaker extends TileInventory implements IRotatable, IPacketRec
|
|||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (doWork)
|
||||
{
|
||||
doWork();
|
||||
doWork = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void work()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
doWork = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void doWork()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
@ -28,6 +29,8 @@ import universalelectricity.api.vector.Vector3;
|
|||
*/
|
||||
public class TilePlacer extends TileInventory implements IRotatable, IPacketReceiver
|
||||
{
|
||||
private boolean doWork = false;
|
||||
|
||||
public TilePlacer()
|
||||
{
|
||||
super(Material.iron);
|
||||
|
@ -46,12 +49,32 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (doWork)
|
||||
{
|
||||
doWork();
|
||||
doWork = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void work()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
doWork = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void doWork()
|
||||
{
|
||||
ForgeDirection dir = getDirection();
|
||||
ItemStack placeStack = null;
|
||||
Vector3 placePos = position().translate(dir);
|
||||
|
||||
if (world().isAirBlock(placePos.intX(), placePos.intY(), placePos.intZ()))
|
||||
{
|
||||
|
||||
if (getStackInSlot(0) == null)
|
||||
{
|
||||
ForgeDirection op = dir.getOpposite();
|
||||
|
@ -61,11 +84,30 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
{
|
||||
ItemStack candidate = InventoryUtility.takeTopItemFromInventory((IInventory) tile, dir.ordinal());
|
||||
if (candidate != null)
|
||||
this.incrStackSize(0, candidate);
|
||||
{
|
||||
incrStackSize(0, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
placeStack = getStackInSlot(0);
|
||||
|
||||
ItemStack placeStack = getStackInSlot(0);
|
||||
|
||||
if (placeStack != null && placeStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
ItemBlock itemBlock = ((ItemBlock) placeStack.getItem());
|
||||
|
||||
try
|
||||
{
|
||||
itemBlock.placeBlockAt(placeStack, null, world(), placePos.intX(), placePos.intY(), placePos.intZ(), 0, 0, 0, 0, 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
decrStackSize(0, 1);
|
||||
markUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue