Grinder Initial Test Working
This commit is contained in:
@@ -52,8 +52,12 @@ public class CrankBlock extends Block implements ITileEntityProvider{
|
||||
if(tile.getBlockMetadata()==1){
|
||||
if(world.getBlock(x, y-1, z) instanceof CrankGrinder){
|
||||
TileEntCrankGrinder tileGrinder = (TileEntCrankGrinder) world.getTileEntity(x, y-1, z);
|
||||
tileGrinder.isPowered=true;
|
||||
tileGrinder.power+=15;
|
||||
if(tileGrinder.getStackInSlot(1)!=null){
|
||||
tileGrinder.isPowered=true;
|
||||
tileGrinder.power+=15;
|
||||
tileGrinder.workCount+=20;
|
||||
tileGrinder.getStackInSlot(1).setItemDamage(tileGrinder.getStackInSlot(1).getItemDamage()+1);
|
||||
}
|
||||
tileGrinder.markDirty();
|
||||
tileGrinder.markForUpdate();
|
||||
}
|
||||
@@ -135,9 +139,9 @@ public class CrankBlock extends Block implements ITileEntityProvider{
|
||||
if(p==5){
|
||||
this.setBlockBounds(0.0F, 0.2F, 0.2F, 0.5F, 0.8F, 0.8F);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RenderID.crankID;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CrankGrinder extends BlockContainer{
|
||||
|
||||
if(!world.isRemote){
|
||||
TileEntCrankGrinder tileEnt = (TileEntCrankGrinder) world.getTileEntity(x, y, z);
|
||||
System.out.println("Slot 0:"+tileEnt.getStackInSlot(0) +" Slot 1:"+ tileEnt.getStackInSlot(1));
|
||||
//System.out.println("Slot 0:"+tileEnt.getStackInSlot(0) +" Slot 1:"+ tileEnt.getStackInSlot(1));
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if(player.inventory.getCurrentItem().getItem()!=ModItems.stoneGrinder){
|
||||
//System.out.println(player.inventory.getCurrentItem());
|
||||
@@ -120,7 +120,7 @@ public class CrankGrinder extends BlockContainer{
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
|
||||
@@ -82,8 +82,6 @@ public class TileEntLatheBase extends TileEntity implements IInventory {
|
||||
if (worldObj.isRemote) return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
if (this.inv[slot] != null)
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package nmd.primal.energy.tileents.grinder;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -12,18 +18,66 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntCrankGrinder extends TileEntity implements IInventory {
|
||||
|
||||
|
||||
private ItemStack[] inv;
|
||||
private int i;
|
||||
public boolean isPowered = true;
|
||||
public int power, workCount;
|
||||
protected String specName = "TileEntCrankGrinder";
|
||||
public float rot = 0;
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
World world = this.getWorldObj();
|
||||
int x = this.xCoord;
|
||||
int y = this.yCoord;
|
||||
int z = this.zCoord;
|
||||
if(!world.isRemote){
|
||||
doRotation();
|
||||
doWork(world, x,y,z);
|
||||
}
|
||||
if (worldObj.isRemote) return;
|
||||
}
|
||||
|
||||
private void doRotation(){
|
||||
if(this.isPowered==true){
|
||||
this.power--;
|
||||
rot-=45;
|
||||
System.out.println(rot);
|
||||
if(rot>=360||rot<=-360){
|
||||
rot=0;
|
||||
}
|
||||
if(power<=0){
|
||||
this.isPowered=false;
|
||||
this.power=0;
|
||||
}
|
||||
this.markForUpdate();
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void doWork(World world, int x, int y, int z){
|
||||
|
||||
if(workCount>=100){
|
||||
if(this.getStackInSlot(0)!=null){
|
||||
if(this.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.redstone_ore))){
|
||||
this.decrStackSize(0, 1);
|
||||
EntityItem eItem = new EntityItem(world, x+0.5f, y+0.35f, z+0.5f, new ItemStack(Items.redstone, 2+random.nextInt(4)));
|
||||
world.spawnEntityInWorld(eItem);
|
||||
workCount=0;
|
||||
this.markForUpdate();
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TileEntCrankGrinder() {
|
||||
this.inv = new ItemStack[2];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return this.inv.length;
|
||||
@@ -51,33 +105,6 @@ public class TileEntCrankGrinder extends TileEntity implements IInventory {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
World world = this.getWorldObj();
|
||||
int x = this.xCoord;
|
||||
int y = this.yCoord;
|
||||
int z = this.zCoord;
|
||||
if(!world.isRemote){
|
||||
if(this.isPowered==true){
|
||||
this.power--;
|
||||
rot-=45;
|
||||
System.out.println(rot);
|
||||
if(rot>=360||rot<=-360){
|
||||
rot=0;
|
||||
}
|
||||
if(power<=0){
|
||||
this.isPowered=false;
|
||||
this.power=0;
|
||||
}
|
||||
this.markForUpdate();
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
if (worldObj.isRemote) return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
if (this.inv[slot] != null)
|
||||
@@ -149,7 +176,7 @@ public class TileEntCrankGrinder extends TileEntity implements IInventory {
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 806 B |
BIN
src/main/resources/assets/energy/models/StoneGrindWheelOrig.png
Normal file
BIN
src/main/resources/assets/energy/models/StoneGrindWheelOrig.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Reference in New Issue
Block a user