1
0
forked from xjboss/KCauldronX

模块化方块捕获还原动作

This commit is contained in:
2017-07-04 14:29:35 +08:00
parent 559b9ad248
commit bfe43ae465
12 changed files with 992 additions and 402 deletions

View File

@ -0,0 +1,38 @@
package cc.capture;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class ItemSnapshot{
public final EntityPlayer mPlayer;
public final ItemStack mItem;
private boolean mApply=false;
public ItemSnapshot(EntityPlayer pPlayer,ItemStack pItem){
this.mPlayer=pPlayer;
this.mItem=pItem;
}
/**
* 将物品放到玩家身上
*
* @return 如果背包满,将生成物品在地上并返回false
*/
public boolean apply(){
if(!this.mApply){
this.mApply=true;
this.mPlayer.inventory.addItemStackToInventory(this.mItem);
if(!this.mPlayer.inventory.addItemStackToInventory(this.mItem)){
this.mPlayer.worldObj.spawnEntityInWorld(
new EntityItem(this.mPlayer.worldObj,this.mPlayer.posX,this.mPlayer.posY,this.mPlayer.posZ,this.mItem));
return false;
}
}
return true;
}
}