Lathe working

This commit is contained in:
KitsuShadow
2015-08-25 07:44:24 -04:00
parent 1af78e907b
commit 16ff900333
7 changed files with 70 additions and 94 deletions

View File

@@ -18,6 +18,7 @@ import nmd.primal.energy.item.ModItems;
import nmd.primal.energy.render.RenderID;
import nmd.primal.energy.tileents.TileEntLatheBase;
import nmd.primal.energy.util.CustomTab;
import nmd.primal.energy.util.LatheRecipes;
public abstract class LatheBase extends BlockContainer implements ITileEntityProvider{
@@ -39,6 +40,7 @@ public abstract class LatheBase extends BlockContainer implements ITileEntityPro
if(!world.isRemote){
TileEntLatheBase tileEnt = (TileEntLatheBase) world.getTileEntity(x, y, z);
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()!=ModItems.schiselItem){
if (tileEnt.getStackInSlot(0)==null){
@@ -97,11 +99,14 @@ public abstract class LatheBase extends BlockContainer implements ITileEntityPro
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==ModItems.schiselItem){
if(tileEnt.getStackInSlot(0)!=null){
if(tileEnt.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.wooden_slab))){
if(LatheRecipes.latheCheck.contains(tileEnt.getStackInSlot(0).getItem())){
tileEnt.workCount++;
player.inventory.getCurrentItem().damageItem(1, player);
//System.out.println(tileEnt.workCount);
return true;
if(tileEnt.workCount>=20){
tileEnt.setInventorySlotContents(0, LatheRecipes.lathe.get(tileEnt.getStackInSlot(0).getItem()));
tileEnt.workCount=0;
tileEnt.markForUpdate();
tileEnt.markDirty();
}
}
}
}

View File

@@ -34,66 +34,6 @@ public class SChiselItem extends Item{
GameRegistry.registerItem(this, name);
}
/*public void onUpdate(ItemStack stack, World world, Entity ent, int slot, boolean active) {
if(active == true){
EntityPlayer player = (EntityPlayer) ent;
if(player.isUsingItem()==true){
int dir = (MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3);
if(dir==0){
world.getBlock((int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ)+1);
System.out.println(world.getBlock((int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ)+1));
System.out.println(((int)Math.floor(player.posX)) +" "+ ((int)Math.floor(player.posY)) +" "+ ((int)Math.floor(player.posZ)+1));
}
if(dir==1){
}
if(dir==2){
}
if(dir==3){
}
}
}
}*/
/*@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) {
System.out.println("Stopped Using "+ count);
}*/
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int d, float u, float i, float j)
{
/*if(!world.isRemote){
System.out.println("Using");
if(world.getBlock(x, y, z).equals(ModBlocks.flintLathe)){
TileEntLatheBase tileLathe = (TileEntLatheBase) world.getTileEntity(x, y, z);
//if(tileLathe.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.wooden_slab))){
//tileLathe.workCount++;
tileLathe.markForUpdate();
System.out.println(tileLathe.workCount);
//}
}
}*/
return true;
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
//System.out.println("In Use");
if(!world.isRemote){
//player.setItemInUse(stack, 72000);
}
return stack;
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemstack) {
return false;

View File

@@ -16,6 +16,7 @@ import net.minecraft.world.World;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import nmd.primal.energy.block.ModBlocks;
import nmd.primal.energy.item.ModItems;
import nmd.primal.energy.tileents.TileEntLatheBase;
public class RenderLathe extends TileEntitySpecialRenderer {
@@ -58,13 +59,15 @@ public class RenderLathe extends TileEntitySpecialRenderer {
this.entItem.hoverStart = 0.0F;
RenderItem.renderInFrame = true;
GL11.glScalef(1.0f, 1.0f, 1.0f);
if(tile.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.wooden_slab))){
if(tile.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.wooden_slab))
||tile.getStackInSlot(0).getItem().equals(ModItems.saxleItem)){
GL11.glRotatef(90f, 1.0F, 0.0F, 0.0F);
}
if(tile.isPowered == true){
if(tile.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.wooden_slab))){
if(tile.getStackInSlot(0).getItem().equals(Item.getItemFromBlock(Blocks.wooden_slab))
||tile.getStackInSlot(0).getItem().equals(ModItems.saxleItem)){
GL11.glRotatef(i, 0.0F, 1.0F, 0.0F);
}else{
GL11.glRotatef(i, 0.0F, 0.0F, 1.0F);

View File

@@ -8,7 +8,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileBase extends TileEntity{
public abstract class TileBase extends TileEntity{
protected String specName;
@@ -20,17 +20,4 @@ public class TileBase extends TileEntity{
worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -998, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}

View File

@@ -1,6 +1,9 @@
package nmd.primal.energy.tileents;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -44,6 +47,19 @@ public class TileEntCrank extends TileBase {
super.writeToNBT(tagCompound);
tagCompound.setBoolean("ISPOWERED", this.isPowered);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -998, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}

View File

@@ -4,6 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
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;
@@ -14,15 +15,16 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import nmd.primal.energy.item.ModItems;
import nmd.primal.energy.util.LatheRecipes;
public class TileEntLatheBase extends TileEntity implements IInventory {
private ItemStack[] inv;
private int i;
public boolean isPowered = true;
public int workCount;
protected String specName = "TileEntLatheBase";
public TileEntLatheBase() {
this.inv = new ItemStack[1];
}
@@ -53,7 +55,7 @@ public class TileEntLatheBase extends TileEntity implements IInventory {
readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void updateEntity() {
World world = this.getWorldObj();
@@ -65,20 +67,15 @@ public class TileEntLatheBase extends TileEntity implements IInventory {
if(i>16){
//this.isPowered=false;
i=0;
if(this.workCount>=20){
this.setInventorySlotContents(0, new ItemStack(ModItems.swheelItem, 1));
this.workCount=0;
this.markForUpdate();
this.markDirty();
}
//latheWork();
}
}
if (worldObj.isRemote) return;
if (!worldObj.isRemote) return;
//System.out.println(this.isPowered + " " + i);
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
if (this.inv[slot] != null)
@@ -209,6 +206,6 @@ public class TileEntLatheBase extends TileEntity implements IInventory {
tagCompound.setBoolean("ISPOWERED", this.isPowered);
tagCompound.setInteger("WORKCOUNT", this.workCount);
}
}

View File

@@ -0,0 +1,28 @@
package nmd.primal.energy.util;
import java.util.Hashtable;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import nmd.primal.energy.item.ModItems;
public interface LatheRecipes {
static final Hashtable<Item, ItemStack> lathe = new Hashtable <Item, ItemStack>(){{
//put(ModItems.ironAxeForm, new ItemStack(ModItems.ironaxeHead, 1));
put(Item.getItemFromBlock(Blocks.wooden_slab), new ItemStack(ModItems.swheelItem));
put(Item.getItemFromBlock(Blocks.planks), new ItemStack(ModItems.saxleItem));
}};
static final Hashtable<Item, Item> latheCheck = new Hashtable <Item, Item>(){{
//put(ModItems.ironAxeForm, new ItemStack(ModItems.ironaxeHead, 1));
put(ModItems.swheelItem, Item.getItemFromBlock(Blocks.wooden_slab));
put(ModItems.saxleItem, Item.getItemFromBlock(Blocks.planks));
}};
}