Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.rexozz.pixelengine.entity;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.INpc;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAIAttackMelee;
- import net.minecraft.entity.ai.EntityAIBase;
- import net.minecraft.entity.ai.EntityAIFleeSun;
- import net.minecraft.entity.ai.EntityAIHurtByTarget;
- import net.minecraft.entity.ai.EntityAILookIdle;
- import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
- import net.minecraft.entity.ai.EntityAIRestrictSun;
- import net.minecraft.entity.ai.EntityAISwimming;
- import net.minecraft.entity.ai.EntityAIWander;
- import net.minecraft.entity.item.EntityBoat;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraft.inventory.EntityEquipmentSlot;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.inventory.IInventoryChangedListener;
- import net.minecraft.inventory.InventoryBasic;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.network.datasync.DataParameter;
- import net.minecraft.network.datasync.DataSerializers;
- import net.minecraft.network.datasync.EntityDataManager;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.SoundEvent;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- import net.rexozz.pixelengine.PEGuiHandler;
- import net.rexozz.pixelengine.PEItems;
- import net.rexozz.pixelengine.PixelEngine;
- import net.rexozz.pixelengine.entity.ai.EntityAISwitchable;
- import net.rexozz.pixelengine.entity.ai.EntityAITargetSwitchable;
- import net.rexozz.pixelengine.entity.ai.EntityAIWatchClosestAdvanced;
- import net.rexozz.pixelengine.network.C01PacketOpenNPCGui;
- import net.rexozz.pixelengine.network.PacketHandler;
- import net.rexozz.pixelengine.server.container.ContainerNPC;
- public class EntityNPC extends PEEntityCreature implements INpc, IInventoryChangedListener{
- /**Method to use bitflags
- public static final int REVENGE=1, FIRE_IMMUNE=2, CAN_BREATH=4, FALL_DAMAGE=8, CAN_SWIM=16;
- private static int flags=0;
- private boolean getValue(int type){
- return (this.dataManager.get(DATA_FLAGS)&type)==type;
- }
- private void setValue(int type, boolean value){
- int flags=this.dataManager.get(DATA_FLAGS);
- if(value)
- flags=flags|type;
- else
- flags=flags&~type;
- this.dataManager.set(DATA_FLAGS, flags);
- }**/
- //private static final DataParameter<Integer> DATA_FLAGS=EntityDataManager.<Integer>createKey(EntityNPC.class, DataSerializers.VARINT);
- private static final DataParameter<String> DATA_TEXTURE=EntityDataManager.<String>createKey(EntityNPC.class, DataSerializers.STRING);
- private static final DataParameter<Integer> DATA_SUN_MODE=EntityDataManager.<Integer>createKey(EntityNPC.class, DataSerializers.VARINT);
- private static final DataParameter<String> DATA_DEATH_SOUND=EntityDataManager.<String>createKey(EntityNPC.class, DataSerializers.STRING);
- private static final DataParameter<String> DATA_HIT_SOUND=EntityDataManager.<String>createKey(EntityNPC.class, DataSerializers.STRING);
- private static final DataParameter<Integer> DATA_LOOK_MODE=EntityDataManager.<Integer>createKey(EntityNPC.class, DataSerializers.VARINT);
- private static final DataParameter<Float> DATA_LOOK_RANGE=EntityDataManager.<Float>createKey(EntityNPC.class, DataSerializers.FLOAT);
- private static final DataParameter<Integer> DATA_WALK_MODE=EntityDataManager.<Integer>createKey(EntityNPC.class, DataSerializers.VARINT);
- private static final DataParameter<Integer> DATA_ATTACK=EntityDataManager.<Integer>createKey(EntityNPC.class, DataSerializers.VARINT);
- private static final DataParameter<Boolean> DATA_FIRE_IMMUNE=EntityDataManager.<Boolean>createKey(EntityNPC.class, DataSerializers.BOOLEAN);
- private static final DataParameter<Boolean> DATA_CAN_BREATHE=EntityDataManager.<Boolean>createKey(EntityNPC.class, DataSerializers.BOOLEAN);
- private static final DataParameter<Boolean> DATA_FALL_DAMAGE=EntityDataManager.<Boolean>createKey(EntityNPC.class, DataSerializers.BOOLEAN);
- private static final DataParameter<Boolean> DATA_CAN_SWIM=EntityDataManager.<Boolean>createKey(EntityNPC.class, DataSerializers.BOOLEAN);
- private int interactlevel=0;
- private EntityAISwitchable swimAI;
- private EntityAISwitchable fleeSun;
- private EntityAISwitchable restrictSun;
- private EntityAIWatchClosestAdvanced lookPlayer;
- private EntityAISwitchable lookIdle;
- private EntityAISwitchable wander;
- private EntityAITargetSwitchable revenge;
- private EntityAITargetSwitchable nearest;
- public InventoryBasic inventory;
- private double maxHealth;
- private double movespeed;
- private double attackspeed;
- private double armor;
- private double armortoughness;
- public EntityNPC(World world){
- super(world);
- this.setCustomNameTag("NPC");
- this.setSize(1.0f, 2.0f);
- this.setAlwaysRenderNameTag(true);
- this.initInv();
- }
- private void initInv() {
- InventoryBasic inv=this.inventory;
- this.inventory=new InventoryBasic("InventoryNPC", false, 12);
- this.inventory.setCustomName(this.getName());
- if (inv!=null){
- inv.removeInventoryChangeListener(this);
- int i = Math.min(inv.getSizeInventory(), this.inventory.getSizeInventory());
- for (int j = 0; j < i; ++j){
- ItemStack itemstack=inv.getStackInSlot(j);
- if (itemstack != null)
- this.inventory.setInventorySlotContents(j, itemstack.copy());
- }
- }
- this.inventory.addInventoryChangeListener(this);
- }
- private void openGui(EntityPlayer player){
- EntityPlayerMP playerMP=(EntityPlayerMP)player;
- playerMP.getNextWindowId();
- PacketHandler.sendTo(new C01PacketOpenNPCGui(playerMP.currentWindowId, this.inventory.getDisplayName(), this.inventory.getSizeInventory(), this.getEntityId()), playerMP);
- playerMP.openContainer = new ContainerNPC(playerMP.inventory, this.inventory, this, playerMP);
- playerMP.openContainer.windowId = playerMP.currentWindowId;
- playerMP.openContainer.addListener(playerMP);
- }
- @SuppressWarnings({ "unchecked", "rawtypes" })
- protected void initEntityAI() {
- this.targetTasks.taskEntries.clear();
- this.swimAI=new EntityAISwitchable(new EntityAISwimming(this), true);
- this.fleeSun=new EntityAISwitchable(new EntityAIFleeSun(this, 1.0D), false);
- this.restrictSun=new EntityAISwitchable(new EntityAIRestrictSun(this), false);
- this.lookIdle=new EntityAISwitchable(new EntityAILookIdle(this), true);
- this.lookPlayer=new EntityAIWatchClosestAdvanced(this, EntityPlayer.class, 5.0f, 1.0f, false);
- this.wander=new EntityAISwitchable(new EntityAIWander(this, 1.0D, 60), false);
- this.revenge=new EntityAITargetSwitchable(this, new EntityAIHurtByTarget(this, false), false);
- this.nearest=new EntityAITargetSwitchable(this, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true), false);
- this.tasks.addTask(1, this.swimAI);
- this.tasks.addTask(2, this.restrictSun);
- this.tasks.addTask(3, new EntityAIAttackMelee(this, 1.2D, false));
- this.tasks.addTask(3, this.fleeSun);
- this.tasks.addTask(4, this.wander);
- this.tasks.addTask(6, this.lookIdle);
- this.tasks.addTask(6, this.lookPlayer);
- this.targetTasks.addTask(0, this.revenge);
- this.targetTasks.addTask(1, this.nearest);
- }
- private void changeAI(EntityAIBase ai, boolean value){
- if(ai instanceof EntityAISwitchable){
- EntityAISwitchable eis=(EntityAISwitchable)ai;
- if(eis.isActive()!=value)
- eis.setActive(value);
- }else if(ai instanceof EntityAITargetSwitchable){
- EntityAITargetSwitchable eits=(EntityAITargetSwitchable)ai;
- if(eits.isActive()!=value)
- eits.setActive(value);
- }
- }
- protected void updateAITasks() {
- this.changeAI(this.swimAI, this.dataManager.get(DATA_CAN_SWIM));
- this.changeAI(this.fleeSun, this.dataManager.get(DATA_SUN_MODE)==2);
- this.changeAI(this.restrictSun, this.dataManager.get(DATA_SUN_MODE)==2);
- this.changeAI(this.lookIdle, this.dataManager.get(DATA_LOOK_MODE)==1||this.dataManager.get(DATA_LOOK_MODE)==2);
- if(this.lookPlayer.isActive()!=(this.dataManager.get(DATA_LOOK_MODE)==2||this.dataManager.get(DATA_LOOK_MODE)==3))
- this.lookPlayer.setActive(!this.lookPlayer.isActive());
- if(this.lookPlayer.getFollowRange()!=this.dataManager.get(DATA_LOOK_RANGE))
- this.lookPlayer.setFollowRange(this.dataManager.get(DATA_LOOK_RANGE));
- this.changeAI(this.wander,this.dataManager.get(DATA_WALK_MODE)==1);
- this.changeAI(this.revenge, this.dataManager.get(DATA_ATTACK)==1);
- this.changeAI(this.nearest, this.dataManager.get(DATA_ATTACK)==2);
- }
- public float getBlockPathWeight(BlockPos pos){
- return 0.5F - this.worldObj.getLightBrightness(pos);
- }
- public void fall(float distance, float damageMultiplier) {
- if(this.dataManager.get(DATA_FALL_DAMAGE))
- super.fall(distance, damageMultiplier);
- else{}
- }
- public boolean attackEntityAsMob(Entity entityIn){
- return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()));
- }
- public void onLivingUpdate() {
- super.onLivingUpdate();
- if (this.worldObj.isDaytime() && !this.worldObj.isRemote && (this.dataManager.get(DATA_SUN_MODE)==1||this.dataManager.get(DATA_SUN_MODE)==2))
- {
- float f = this.getBrightness(1.0F);
- BlockPos blockpos = this.getRidingEntity() instanceof EntityBoat ? (new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ)).up() : new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);
- if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
- {
- boolean flag = true;
- ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
- if (itemstack != null)
- {
- if (itemstack.isItemStackDamageable())
- {
- itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
- if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
- {
- this.renderBrokenItemStack(itemstack);
- this.setItemStackToSlot(EntityEquipmentSlot.HEAD, (ItemStack)null);
- }
- }
- flag = false;
- }
- if (flag)
- {
- this.setFire(8);
- }
- }
- }
- }
- public void applyEntityAttributes() {
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MAX_HEALTH);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(15.0D);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_SPEED);
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
- }
- public void updateEntityAttributes() {
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(this.maxHealth);
- this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(this.movespeed);
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(this.attackspeed);
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(this.armor);
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(this.armortoughness);
- }
- public SoundEvent getDeathSound() {
- return new SoundEvent(new ResourceLocation("mapres",this.dataManager.get(DATA_DEATH_SOUND)));
- }
- public SoundEvent getHurtSound() {
- return new SoundEvent(new ResourceLocation("mapres",this.dataManager.get(DATA_HIT_SOUND)));
- }
- public void entityInit() {
- super.entityInit();
- //this.dataManager.register(DATA_FLAGS, 0);
- this.dataManager.register(DATA_TEXTURE, "steve");
- this.dataManager.register(DATA_FIRE_IMMUNE, false);
- this.dataManager.register(DATA_CAN_BREATHE, false);
- this.dataManager.register(DATA_SUN_MODE, 0);
- this.dataManager.register(DATA_FALL_DAMAGE, true);
- this.dataManager.register(DATA_DEATH_SOUND, "playerDeath");
- this.dataManager.register(DATA_HIT_SOUND, "playerHit");
- this.dataManager.register(DATA_CAN_SWIM, true);
- this.dataManager.register(DATA_LOOK_MODE, 0);
- this.dataManager.register(DATA_LOOK_RANGE, 5.0F);
- this.dataManager.register(DATA_WALK_MODE, 0);
- this.dataManager.register(DATA_ATTACK, 0);
- }
- public boolean isAIDisabled() {
- return false;
- }
- public boolean isFireImmune(){
- return this.dataManager.get(DATA_FIRE_IMMUNE);
- }
- public boolean canBreatheUnderwater() {
- return this.dataManager.get(DATA_CAN_BREATHE);
- }
- public boolean takesFallDamage(){
- return this.dataManager.get(DATA_FALL_DAMAGE);
- }
- public int burnsInSun(){
- return this.dataManager.get(DATA_SUN_MODE);
- }
- public void readEntityFromNBT(NBTTagCompound compound) {
- super.readEntityFromNBT(compound);
- this.dataManager.set(DATA_TEXTURE, compound.getString("tex"));
- this.dataManager.set(DATA_FIRE_IMMUNE, compound.getBoolean("fireimm"));
- this.dataManager.set(DATA_CAN_BREATHE, compound.getBoolean("canbreathe"));
- this.dataManager.set(DATA_SUN_MODE, compound.getInteger("sunburn"));
- this.dataManager.set(DATA_FALL_DAMAGE, compound.getBoolean("falldmg"));
- this.dataManager.set(DATA_DEATH_SOUND, compound.getString("deathSound"));
- this.dataManager.set(DATA_HIT_SOUND, compound.getString("hitSound"));
- this.dataManager.set(DATA_CAN_SWIM, compound.getBoolean("canSwim"));
- this.dataManager.set(DATA_LOOK_MODE, compound.getInteger("lookMode"));
- this.dataManager.set(DATA_LOOK_RANGE, compound.getFloat("watchRange"));
- this.dataManager.set(DATA_WALK_MODE, compound.getInteger("walkMode"));
- this.dataManager.set(DATA_ATTACK, compound.getInteger("revenge"));
- this.interactlevel=compound.getInteger("ilevel");
- this.maxHealth=compound.getDouble("maxhealth");
- this.movespeed=compound.getDouble("movespeed");
- this.attackspeed=compound.getDouble("attackspeed");
- this.armor=compound.getDouble("armor");
- this.armortoughness=compound.getDouble("armort");
- this.updateEntityAttributes();
- this.setHealth(compound.getFloat("currHealth"));
- this.isImmuneToFire=this.dataManager.get(DATA_FIRE_IMMUNE);
- NBTTagList nbttaglist = compound.getTagList("Items", 10);
- this.initInv();
- for (int i = 0; i < nbttaglist.tagCount(); ++i){
- NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
- this.inventory.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(nbttagcompound));
- }
- }
- public void writeEntityToNBT(NBTTagCompound compound) {
- super.writeEntityToNBT(compound);
- compound.setString("tex", this.dataManager.get(DATA_TEXTURE));
- compound.setBoolean("fireimm", this.dataManager.get(DATA_FIRE_IMMUNE));
- compound.setBoolean("canbreathe", this.dataManager.get(DATA_CAN_BREATHE));
- compound.setInteger("sunburn", this.dataManager.get(DATA_SUN_MODE));
- compound.setBoolean("falldmg", this.dataManager.get(DATA_FALL_DAMAGE));
- compound.setString("deathSound", this.dataManager.get(DATA_DEATH_SOUND));
- compound.setString("hitSound", this.dataManager.get(DATA_HIT_SOUND));
- compound.setBoolean("canSwim", this.dataManager.get(DATA_CAN_SWIM));
- compound.setInteger("lookMode", this.dataManager.get(DATA_LOOK_MODE));
- compound.setFloat("watchRange", this.dataManager.get(DATA_LOOK_RANGE));
- compound.setInteger("walkMode", this.dataManager.get(DATA_WALK_MODE));
- compound.setInteger("revenge", this.dataManager.get(DATA_ATTACK));
- compound.setInteger("ilevel", this.interactlevel);
- compound.setDouble("maxhealth", this.maxHealth);
- compound.setDouble("movespeed", this.movespeed);
- compound.setDouble("attackspeed", this.attackspeed);
- compound.setDouble("armor", this.armor);
- compound.setDouble("armort", this.armortoughness);
- compound.setFloat("currHealth", this.getHealth());
- NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < this.inventory.getSizeInventory(); ++i)
- {
- ItemStack itemstack=this.inventory.getStackInSlot(i);
- if (itemstack != null)
- {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- itemstack.writeToNBT(nbttagcompound);
- nbttaglist.appendTag(nbttagcompound);
- }
- }
- compound.setTag("Items", nbttaglist);
- }
- protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) {
- if(player.getHeldItemMainhand()!=null){
- if(player.getHeldItemMainhand().getItem()==PEItems.itemNPCWand){
- if(!this.worldObj.isRemote){
- this.inventory.setCustomName(this.getName());
- player.openGui(PixelEngine.INSTANCE, PEGuiHandler.NPCGUI, this.worldObj, this.getEntityId(), 0, 0);
- //this.openGui(player);
- }
- }
- }
- //TODO interaction behaviour
- return super.processInteract(player, hand, stack);
- }
- //______________________________________________________________________________________________________
- //
- //-----------------------------------------Getters & Setters--------------------------------------------
- //______________________________________________________________________________________________________
- public void setName(String name){
- this.setCustomNameTag(name);
- }
- public void setTexture(String tex){
- this.dataManager.set(DATA_TEXTURE, tex);
- }
- public String getTexture(){
- return this.dataManager.get(DATA_TEXTURE);
- }
- public void setMaxHealth(double hearts){
- this.maxHealth=hearts;
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(hearts);
- this.setHealth((float)hearts);
- }
- public void setDeathSound(String sound){
- this.dataManager.set(DATA_DEATH_SOUND, sound);
- }
- public void setHitSound(String sound){
- this.dataManager.set(DATA_HIT_SOUND, sound);
- }
- public String getDeathsSound(){
- return this.dataManager.get(DATA_DEATH_SOUND);
- }
- public String getHitSound(){
- return this.dataManager.get(DATA_HIT_SOUND);
- }
- public void setMoveSpeed(double speed){
- this.movespeed=speed;
- this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(speed);
- }
- public final float getMoveSpeed(){
- return (float)this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue();
- }
- public void isAttackable(boolean attackable){
- this.setEntityInvulnerable(!attackable);
- }
- public void setAttackSpeed(double speed){
- this.attackspeed=speed;
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(speed);
- }
- public final float getAttackSpeed(){
- return (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getAttributeValue();
- }
- public void setArmor(double armor){
- this.armor=armor;
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(armor);
- }
- public final float getArmor(){
- return (float)this.getEntityAttribute(SharedMonsterAttributes.ARMOR).getAttributeValue();
- }
- public void setArmorToughness(double toughness){
- this.armortoughness=toughness;
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(toughness);
- }
- public final float getArmorToughness(){
- return (float)this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue();
- }
- public void setImmuneToFire(boolean immune){
- this.dataManager.set(DATA_FIRE_IMMUNE, immune);
- this.isImmuneToFire=immune;
- }
- public void canDrown(boolean drown){
- this.dataManager.set(DATA_CAN_BREATHE, !drown);
- }
- public void canBurnInSun(int mode){
- this.dataManager.set(DATA_SUN_MODE, mode);
- }
- public void setTakesFallDamage(boolean damage){
- this.dataManager.set(DATA_FALL_DAMAGE, damage);
- }
- public void renderName(boolean render){
- this.setAlwaysRenderNameTag(render);
- }
- public boolean canSwim(){
- return this.dataManager.get(DATA_CAN_SWIM);
- }
- public void setCanSwim(boolean canSwim){
- this.dataManager.set(DATA_CAN_SWIM, canSwim);
- }
- public void setLookMode(int lookMode){
- this.dataManager.set(DATA_LOOK_MODE, lookMode);
- }
- public String getName()
- {
- return this.hasCustomName() ? this.getCustomNameTag() : "NPC";
- }
- public int getLookMode(){
- return this.dataManager.get(DATA_LOOK_MODE);
- }
- public void setWatchRange(float range){
- this.dataManager.set(DATA_LOOK_RANGE, range);
- }
- public float getWatchRange(){
- return this.dataManager.get(DATA_LOOK_RANGE);
- }
- public void setWalkMode(int mode){
- this.dataManager.set(DATA_WALK_MODE, mode);
- }
- public int getWalkMode(){
- return this.dataManager.get(DATA_WALK_MODE);
- }
- public int getAttackMode(){
- return this.dataManager.get(DATA_ATTACK);
- }
- public void setAttackMode(int mode){
- this.dataManager.set(DATA_ATTACK,mode);
- this.setAttackTarget(null);
- this.setRevengeTarget(null);
- this.setLastAttacker(null);
- }
- public void onInventoryChanged(InventoryBasic invBasic) {
- if(invBasic!=null){
- for(int slot=0; slot<4; slot++){
- ItemStack stack=invBasic.getStackInSlot(slot);
- if(stack!=null){
- EntityEquipmentSlot equip=EntityLiving.getSlotForItemStack(stack);
- this.setItemStackToSlot(equip, stack);
- }
- }
- ItemStack offhandItem=invBasic.getStackInSlot(4);
- ItemStack mainhandItem=invBasic.getStackInSlot(5);
- if(offhandItem!=null)
- this.setHeldItem(EnumHand.OFF_HAND, offhandItem);
- if(mainhandItem!=null)
- this.setHeldItem(EnumHand.MAIN_HAND, mainhandItem);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment