use of net.minecraft.entity.player.InventoryPlayer in project MorePlanets by SteveKunG.
the class BlockInfectedVines method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
if (entity instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) entity;
if (living instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
InventoryPlayer inventory = player.inventory;
for (int i = 0; i < 4; i++) {
if (!(inventory.armorInventory.get(i) != null && inventory.armorInventory.get(i).getItem() instanceof ItemArmor)) {
if (!player.capabilities.isCreativeMode) {
player.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
player.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
}
}
}
}
if (!(living instanceof EntityPlayer) && !(entity instanceof ISpaceMob && ((ISpaceMob) entity).getMobType() == EnumMobType.NIBIRU)) {
living.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
living.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
}
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Totemic by TeamTotemic.
the class CeremonyFluteInfusion method effect.
@Override
public void effect(World world, BlockPos pos, CeremonyEffectContext context) {
if (world.isRemote)
return;
for (EntityItem entity : EntityUtil.getEntitiesInRange(EntityItem.class, world, pos, 5, 5)) {
if (entity.getItem().getItem() == ModItems.flute) {
EntityUtil.dropItem(world, entity.posX, entity.posY, entity.posZ, new ItemStack(ModItems.flute, 1, 1));
entity.setDead();
}
}
for (EntityPlayer player : EntityUtil.getEntitiesInRange(EntityPlayer.class, world, pos, 5, 5)) {
InventoryPlayer inv = player.inventory;
for (int i = 0; i < inv.getSizeInventory(); i++) {
if (inv.getStackInSlot(i).getItem() == ModItems.flute)
inv.setInventorySlotContents(i, new ItemStack(ModItems.flute, 1, 1));
}
player.inventoryContainer.detectAndSendChanges();
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Charset by CharsetMC.
the class TileEntityDayBarrel method addAllItems.
void addAllItems(EntityPlayer entityplayer, EnumHand hand) {
switch(insertFromItemHandler(entityplayer, true)) {
case PASS:
break;
case SUCCESS:
return;
case FAIL:
info(entityplayer);
return;
}
ItemStack held = entityplayer.getHeldItem(hand);
InventoryPlayer inv = entityplayer.inventory;
int total_delta = 0;
for (int i = 0; i < inv.getSizeInventory(); i++) {
int free_space = getMaxItemCount() - (getItemCount() + total_delta);
if (free_space <= 0) {
break;
}
ItemStack is = inv.getStackInSlot(i);
if (is.isEmpty() || !itemMatch(is)) {
continue;
}
int toAdd = Math.min(is.getCount(), free_space);
if (is == held && toAdd > 1) {
toAdd -= 1;
}
total_delta += toAdd;
is.shrink(toAdd);
}
if (total_delta > 0) {
item.grow(total_delta);
onItemChange(false);
entityplayer.inventory.markDirty();
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Charset by CharsetMC.
the class CharsetTweakAutoReplace method onPlayerDestroyItem.
@SubscribeEvent
public void onPlayerDestroyItem(PlayerDestroyItemEvent event) {
if (!(event.getEntity() instanceof EntityPlayerMP) || event.getEntity().world.isRemote || event.getOriginal().isEmpty()) {
return;
}
EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer();
InventoryPlayer inv = player.inventory;
ItemStack currentItem = inv.getCurrentItem();
if (currentItem != event.getOriginal()) {
return;
}
int row, lastEmptiedSlot = -1;
boolean changed = false;
for (row = 2; row >= 0; row--) {
int slot = inv.currentItem + row * 9 + 9;
ItemStack stackAbove = inv.getStackInSlot(slot);
if (!canReplace(stackAbove, event.getOriginal()))
break;
int targetSlot = ((slot < 27) ? (slot + 9) : (slot - 27));
ItemStack stackTarget = stackAbove.copy();
inv.setInventorySlotContents(targetSlot, stackTarget);
inv.setInventorySlotContents(slot, ItemStack.EMPTY);
player.connection.sendPacket(new SPacketSetSlot(-1, targetSlot, stackTarget));
changed = true;
lastEmptiedSlot = slot;
}
if (changed) {
player.connection.sendPacket(new SPacketSetSlot(-1, lastEmptiedSlot, ItemStack.EMPTY));
}
inv.markDirty();
}
use of net.minecraft.entity.player.InventoryPlayer in project VoodooCraft by Mod-DevCafeTeam.
the class TileDeathGlyph method savePlayerInventory.
/**
* Saves the player's inventory to this tile entity
*/
public void savePlayerInventory(EntityPlayer player) {
playerInventory = new NBTTagCompound();
InventoryPlayer playerInv = player.inventory;
writeStacksToNBT(playerInventory, "main", playerInv.mainInventory);
for (int i = 0; i < playerInv.mainInventory.length; i++) playerInv.mainInventory[i] = null;
writeStacksToNBT(playerInventory, "armour", playerInv.armorInventory);
for (int i = 0; i < playerInv.armorInventory.length; i++) playerInv.armorInventory[i] = null;
writeStacksToNBT(playerInventory, "offhand", playerInv.offHandInventory);
for (int i = 0; i < playerInv.offHandInventory.length; i++) playerInv.offHandInventory[i] = null;
}
Aggregations