Created
May 22, 2017 00:15
-
-
Save anonymous/df2656774483a6f335c1fa4be4d1fff4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package modmercenario.poderes; | |
import modmercenario.utilidades.util; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.nbt.NBTBase; | |
import net.minecraft.nbt.NBTTagCompound; | |
import net.minecraft.util.EnumFacing; | |
import net.minecraftforge.common.capabilities.Capability; | |
import net.minecraftforge.common.capabilities.ICapabilityProvider; | |
import net.minecraftforge.common.capabilities.ICapabilitySerializable; | |
import net.minecraftforge.items.CapabilityItemHandler; | |
import net.minecraftforge.items.ItemStackHandler; | |
public class cdalm implements ICapabilityProvider, ICapabilitySerializable { | |
private int redstone = 0; | |
private int municion = 0; | |
private byte tipomunicion = 0; | |
private boolean inicializada = false; | |
private boolean ejecutar = false; | |
private byte accion = 0; | |
private long accionstart = 0; | |
private int ticksmax = 0; | |
private long currenttime = 0;//llevar las animaciones en el mundo local | |
private long maxtimed = 0;//dexbloquear si se atasca en el servidor | |
private long inicializaciontime = 0L;//fecha de la primera inicializacion | |
private long ultrevisioninv = 0L;//ultima vez que se revizo el inventario | |
private Entity entidad = null; | |
private int entidadId = 0; | |
private ItemStack stack = ItemStack.EMPTY; | |
private NBTTagCompound nbt = new NBTTagCompound(); | |
//constructor | |
public cdalm(ItemStack item, NBTTagCompound nbtIn){ | |
//this.entidad = entidadIn; | |
this.stack = item; | |
//this.nbt = nbtIn; | |
} | |
public void clearNbt(){ | |
nbt = new NBTTagCompound(); | |
} | |
//########################################################### | |
@Override | |
public NBTBase serializeNBT() | |
{ | |
System.out.println("### >>> serializeNBT()"); | |
nbt.setInteger("redstone", redstone); | |
nbt.setBoolean("inizializada", inicializada); | |
nbt.setInteger("municion",municion); | |
nbt.setByte("tipomunicion",tipomunicion); | |
nbt.setBoolean("inicializada",inicializada); | |
nbt.setBoolean("ejecutar",ejecutar); | |
nbt.setByte("accion",accion); | |
nbt.setLong("accionstart",accionstart); | |
nbt.setInteger("ticksmax",ticksmax); | |
nbt.setLong("currenttime",currenttime);//llevar las animaciones en el mundo local | |
nbt.setLong("maxtimed",maxtimed);//dexbloquear si se atasca en el servidor | |
nbt.setLong("inicializaciontime",inicializaciontime);//fecha de la primera inicializacion | |
nbt.setLong("ultrevisioninv",ultrevisioninv);//ultima vez que se revizo el inventario | |
nbt.setInteger("entidadId",entidadId); | |
return nbt; | |
} | |
//########################################################### | |
@Override | |
public void deserializeNBT(NBTBase nbtIn) | |
{ | |
//System.out.println("### >>> deserializeNBT"); | |
NBTTagCompound nbt = (NBTTagCompound) nbtIn; | |
redstone = (nbt.hasKey("redstone"))? | |
nbt.getInteger("redstone") : 0; | |
inicializada = nbt.hasKey("inicializada")? | |
nbt.getBoolean("inicializada") : false ; | |
municion = (nbt.hasKey("municion"))? | |
nbt.getInteger("municion") : 0; | |
ticksmax = (nbt.hasKey("ticksmax"))? | |
nbt.getInteger("ticksmax") : 0; | |
entidadId = (nbt.hasKey("entidadId"))? | |
nbt.getInteger("entidadId") : 0; | |
tipomunicion = (nbt.hasKey("tipomunicion"))? | |
nbt.getByte("tipomunicion") : 0; | |
accion = (nbt.hasKey("accion"))? | |
nbt.getByte("accion") : 0; | |
ejecutar = nbt.hasKey("ejecutar")? | |
nbt.getBoolean("ejecutar") : false ; | |
accionstart = nbt.hasKey("accionstart")? | |
nbt.getLong("accionstart") : 0L ; | |
currenttime = nbt.hasKey("currenttime")? | |
nbt.getLong("currenttime") : 0L ; | |
maxtimed = nbt.hasKey("maxtimed")? | |
nbt.getLong("maxtimed") : 0L ; | |
inicializaciontime = nbt.hasKey("inicializaciontime")? | |
nbt.getLong("inicializaciontime") : 0L ; | |
ultrevisioninv = nbt.hasKey("ultrevisioninv")? | |
nbt.getLong("ultrevisioninv") : 0L ; | |
} | |
//########################################################### | |
@Override | |
public boolean hasCapability(Capability<?> capability, EnumFacing facing) | |
{ | |
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) | |
{ | |
return true; | |
} | |
return false; | |
} | |
//########################################################### | |
@Override | |
public <T> T getCapability(Capability<T> capability, EnumFacing facing) | |
{ | |
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) | |
{ | |
return (T) this; | |
//return (T) new ItemStackHandler(2/**the amount of slots you want*/); | |
//This is the default implementation by forge, but you'll likely want to make your own by overriding. | |
} | |
return null; | |
} | |
//########################################################### | |
public int getRedstone() { | |
return redstone; | |
} | |
public void setRedstone(int redstone) { | |
this.redstone = redstone; | |
} | |
public int getMunicion() { | |
return municion; | |
} | |
public void setMunicion(int municion) { | |
this.municion = municion; | |
} | |
public byte getTipomunicion() { | |
return tipomunicion; | |
} | |
public void setTipomunicion(byte tipomunicion) { | |
this.tipomunicion = tipomunicion; | |
} | |
public boolean isInicializada() { | |
return inicializada; | |
} | |
public void setInicializada(boolean inicializada) { | |
this.inicializada = inicializada; | |
} | |
public boolean getEjecutar() { | |
return ejecutar; | |
} | |
public void setEjecutar(boolean ejecutar) { | |
this.ejecutar = ejecutar; | |
} | |
public byte getAccion() { | |
return accion; | |
} | |
public void setAccion(int accion) { | |
this.accion = (byte)accion; | |
} | |
public void setAccion(byte accion) { | |
this.accion = accion; | |
} | |
public long getAccionstart() { | |
return accionstart; | |
} | |
public void setAccionstart(long accionstart) { | |
this.accionstart = accionstart; | |
} | |
public int getTicksmax() { | |
return ticksmax; | |
} | |
public void setTicksmax(int ticksmax) { | |
this.ticksmax = ticksmax; | |
} | |
public long getCurrenttime() { | |
return currenttime; | |
} | |
public void setCurrenttime(long currenttime) { | |
this.currenttime = currenttime; | |
} | |
public long getMaxtimed() { | |
return maxtimed; | |
} | |
public void setMaxtimed(long maxtimed) { | |
this.maxtimed = maxtimed; | |
} | |
public long getInicializaciontime() { | |
return inicializaciontime; | |
} | |
public void setInicializaciontime(long inicializaciontime) { | |
this.inicializaciontime = inicializaciontime; | |
} | |
public long getUltrevisioninv() { | |
return ultrevisioninv; | |
} | |
public void setUltrevisioninv(long ultrevisioninv) { | |
this.ultrevisioninv = ultrevisioninv; | |
} | |
public Entity getEntidad() { | |
return entidad; | |
} | |
public void setEntidad(Entity entidad) { | |
this.entidad = entidad; | |
} | |
public int getEntidadId() { | |
return entidadId; | |
} | |
public void setEntidadId(int entidadId) { | |
this.entidadId = entidadId; | |
} | |
public ItemStack getStack() { | |
return stack; | |
} | |
public void setStack(ItemStack stack) { | |
this.stack = stack; | |
} | |
public NBTTagCompound getNbt() { | |
return nbt; | |
} | |
public void setNbt(NBTTagCompound nbt) { | |
this.nbt = nbt; | |
} | |
//########################################################### | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment