working but not breaking
This commit is contained in:
@@ -62,12 +62,12 @@ public class Breaker extends CustomContainerFacing {
|
||||
if(!world.isRemote){
|
||||
TileBreaker tile = (TileBreaker) world.getTileEntity(pos);
|
||||
ItemStack pItem = player.inventory.getCurrentItem();
|
||||
System.out.println(tile.getSlotStack(0));
|
||||
|
||||
if(state.getValue(ACTIVE) == true && player.isSneaking() && pItem.isEmpty()){
|
||||
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(ACTIVE, false));
|
||||
tile.setCharge(0.0F);
|
||||
tile.charge = 0.0f;
|
||||
if (state.getValue(FACING) == EnumFacing.EAST) {
|
||||
if(tile.getCharge() > world.getBlockState(pos.east()).getBlockHardness(world, pos.east())) {
|
||||
if(tile.charge > world.getBlockState(pos.east()).getBlockHardness(world, pos.east())) {
|
||||
if (world.getBlockState(pos.east()).getBlock() == Blocks.IRON_ORE) {
|
||||
world.setBlockToAir(pos.east());
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
|
||||
@@ -79,7 +79,7 @@ public class Breaker extends CustomContainerFacing {
|
||||
}
|
||||
}
|
||||
if (state.getValue(FACING) == EnumFacing.WEST) {
|
||||
if(tile.getCharge() > world.getBlockState(pos.west()).getBlockHardness(world, pos.west())) {
|
||||
if(tile.charge > world.getBlockState(pos.west()).getBlockHardness(world, pos.west())) {
|
||||
if (world.getBlockState(pos.west()).getBlock() == Blocks.IRON_ORE) {
|
||||
world.setBlockToAir(pos.west());
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
|
||||
@@ -91,7 +91,7 @@ public class Breaker extends CustomContainerFacing {
|
||||
}
|
||||
}
|
||||
if (state.getValue(FACING) == EnumFacing.SOUTH) {
|
||||
if(tile.getCharge() > world.getBlockState(pos.south()).getBlockHardness(world, pos.south())) {
|
||||
if(tile.charge > world.getBlockState(pos.south()).getBlockHardness(world, pos.south())) {
|
||||
if (world.getBlockState(pos.south()).getBlock() == Blocks.IRON_ORE) {
|
||||
world.setBlockToAir(pos.south());
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
|
||||
@@ -104,35 +104,39 @@ public class Breaker extends CustomContainerFacing {
|
||||
|
||||
}
|
||||
if (state.getValue(FACING) == EnumFacing.NORTH) {
|
||||
if(tile.getCharge() > world.getBlockState(pos.north()).getBlockHardness(world, pos.north())) {
|
||||
System.out.println(tile.charge + ":" + world.getBlockState(pos.north()).getBlockHardness(world, pos.north()));
|
||||
if(tile.charge > world.getBlockState(pos.north()).getBlockHardness(world, pos.north())) {
|
||||
if (world.getBlockState(pos.north()).getBlock() == Blocks.IRON_ORE) {
|
||||
world.setBlockToAir(pos.north());
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
tile.getSlotStack(0).damageItem(10, null);
|
||||
//tile.getSlotStack(0).damageItem(10, (EntityPlayer) null);
|
||||
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()-10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(state.getValue(ACTIVE) == false && !player.isSneaking() && pItem.isEmpty()){
|
||||
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(ACTIVE, true), 2);
|
||||
tile.setCharge(tile.getCharge() + 2.0f);
|
||||
if(!player.isSneaking() && pItem.isEmpty()) {
|
||||
if (!state.getValue(ACTIVE)) {
|
||||
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(ACTIVE, true), 2);
|
||||
}
|
||||
tile.charge = tile.charge + 2.0f;
|
||||
tile.updateBlock();
|
||||
System.out.println(tile.charge);
|
||||
return true;
|
||||
}
|
||||
/*if(state.getValue(ACTIVE) == true && !player.isSneaking() && pItem.isEmpty()){
|
||||
//world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(ACTIVE, true), 2);
|
||||
tile.setCharge(tile.getCharge() + 2.0f);
|
||||
return true;
|
||||
}*/
|
||||
|
||||
if(pItem.getItem() instanceof WorkMallet){
|
||||
//System.out.println(pItem);
|
||||
for(int i = 0; i < tile.getSlotListSize(); i++) {
|
||||
tile.setSlotStack(i, pItem);
|
||||
System.out.println(tile.getSlotStack(i));
|
||||
tile.update();
|
||||
tile.updateBlock();
|
||||
tile.updateContainingBlockInfo();
|
||||
}
|
||||
pItem.shrink(1);
|
||||
|
||||
tile.setSlotStack(0, player.inventory.getCurrentItem());
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ public class TileBreakerRender extends TileEntitySpecialRenderer<TileBreaker>
|
||||
|
||||
if(state.getValue(Breaker.FACING) == EnumFacing.NORTH) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(tile.getCharge(), 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotated(90, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glRotatef(tile.charge, 0.0f, 0.0f, 1.0f);
|
||||
renderItem.renderItem(tile.getSlotStack(0), ItemCameraTransforms.TransformType.FIXED);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -13,30 +13,20 @@ import java.util.List;
|
||||
/**
|
||||
* Created by mminaie on 4/9/17.
|
||||
*/
|
||||
public class TileBreaker extends TileBaseSlot implements ITickable {
|
||||
public class TileBreaker extends TileBaseSlot {
|
||||
|
||||
private float charge;
|
||||
public float charge = 0.0f;
|
||||
|
||||
public float getCharge() {
|
||||
/*public float getCharge() {
|
||||
return charge;
|
||||
}
|
||||
|
||||
public void setCharge(float charge) {
|
||||
this.charge = charge;
|
||||
}
|
||||
public void setCharge(float a) {
|
||||
this.charge = a;
|
||||
this.updateBlock();
|
||||
}*/
|
||||
|
||||
public NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(10, ItemStack.EMPTY);
|
||||
|
||||
@Override
|
||||
public void update () {
|
||||
World world = this.getWorld();
|
||||
if (!world.isRemote) {
|
||||
IBlockState state = world.getBlockState(this.pos);
|
||||
for(int i =0; i < this.getSlotListSize(); i++) {
|
||||
//System.out.println(this.getSlotStack(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
public NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY);
|
||||
|
||||
@Override
|
||||
public int getSlotLimit() {
|
||||
@@ -46,7 +36,7 @@ public class TileBreaker extends TileBaseSlot implements ITickable {
|
||||
// ***************************************************************************** //
|
||||
// NBT
|
||||
// ***************************************************************************** //
|
||||
/*@Override
|
||||
@Override
|
||||
public NBTTagCompound readNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readNBT(nbt);
|
||||
@@ -60,6 +50,6 @@ public class TileBreaker extends TileBaseSlot implements ITickable {
|
||||
nbt.setFloat("charge", this.charge);
|
||||
super.writeNBT(nbt);
|
||||
return nbt;
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user