Search in sources :

Example 6 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project takumicraft by TNTModders.

the class EntityLostCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    for (Entity entity : event.getAffectedEntities()) {
        if (entity instanceof EntityLivingBase) {
            ((EntityLivingBase) entity).getHeldItemMainhand().shrink(this.rand.nextInt(5) + 1);
            ((EntityLivingBase) entity).getHeldItemOffhand().shrink(this.rand.nextInt(5) + 1);
            if (this.getPowered()) {
                EntityEquipmentSlot slot = EntityEquipmentSlot.MAINHAND;
                switch(this.rand.nextInt(4)) {
                    case 0:
                        slot = EntityEquipmentSlot.HEAD;
                        break;
                    case 1:
                        slot = EntityEquipmentSlot.CHEST;
                        break;
                    case 2:
                        slot = EntityEquipmentSlot.LEGS;
                        break;
                    case 3:
                        slot = EntityEquipmentSlot.FEET;
                        break;
                }
                entity.setItemStackToSlot(slot, ItemStack.EMPTY);
            }
        }
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 7 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project BuildCraft by BuildCraft.

the class SchematicArmorStand method readFromWorld.

@Override
public void readFromWorld(IBuilderContext context, Entity entity) {
    super.readFromWorld(context, entity);
    List<ItemStack> requirements = new ArrayList<>();
    EntityArmorStand stand = (EntityArmorStand) entity;
    requirements.add(new ItemStack(Items.ARMOR_STAND));
    for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
        ItemStack stack = stand.getItemStackFromSlot(slot);
        if (stack != null) {
            requirements.add(stack);
        }
    }
    storedRequirements = requirements.toArray(new ItemStack[requirements.size()]);
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ArrayList(java.util.ArrayList) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) ItemStack(net.minecraft.item.ItemStack)

Example 8 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method getClientGuiElement.

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    if (ID >= Lib.GUIID_Base_Item) {
        EntityEquipmentSlot slot = EntityEquipmentSlot.values()[ID / 100];
        // Slot determined, get actual ID
        ID %= 100;
        ItemStack item = player.getItemStackFromSlot(slot);
        if (!item.isEmpty() && item.getItem() instanceof IGuiItem && ((IGuiItem) item.getItem()).getGuiID(item) == ID) {
            if (ID == Lib.GUIID_Manual && ManualHelper.getManual() != null && OreDictionary.itemMatches(new ItemStack(IEContent.itemTool, 1, 3), item, false))
                return ManualHelper.getManual().getGui();
            if (ID == Lib.GUIID_Revolver && item.getItem() instanceof IEItemInterfaces.IBulletContainer)
                return new GuiRevolver(player.inventory, world, slot, item);
            if (ID == Lib.GUIID_Toolbox && item.getItem() instanceof ItemToolbox)
                return new GuiToolbox(player.inventory, world, slot, item);
            if (ID == Lib.GUIID_MaintenanceKit && item.getItem() instanceof ItemMaintenanceKit)
                return new GuiMaintenanceKit(player.inventory, world, slot, item);
        }
    }
    if (ID >= Lib.GUIID_Base_Item) {
        ItemStack item = ItemStack.EMPTY;
        for (EnumHand hand : EnumHand.values()) {
            ItemStack held = player.getHeldItem(hand);
            if (!held.isEmpty() && held.getItem() instanceof IGuiItem && ((IGuiItem) held.getItem()).getGuiID(held) == ID)
                item = held;
        }
        if (!item.isEmpty()) {
        }
    } else {
        TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
        if (te instanceof IGuiTile) {
            Object gui = null;
            if (ID == Lib.GUIID_CokeOven && te instanceof TileEntityCokeOven)
                gui = new GuiCokeOven(player.inventory, (TileEntityCokeOven) te);
            if (ID == Lib.GUIID_AlloySmelter && te instanceof TileEntityAlloySmelter)
                gui = new GuiAlloySmelter(player.inventory, (TileEntityAlloySmelter) te);
            if (ID == Lib.GUIID_BlastFurnace && te instanceof TileEntityBlastFurnace)
                gui = new GuiBlastFurnace(player.inventory, (TileEntityBlastFurnace) te);
            if (ID == Lib.GUIID_WoodenCrate && te instanceof TileEntityWoodenCrate)
                gui = new GuiCrate(player.inventory, (TileEntityWoodenCrate) te);
            if (ID == Lib.GUIID_Workbench && te instanceof TileEntityModWorkbench)
                gui = new GuiModWorkbench(player.inventory, world, (TileEntityModWorkbench) te);
            if (ID == Lib.GUIID_Sorter && te instanceof TileEntitySorter)
                gui = new GuiSorter(player.inventory, (TileEntitySorter) te);
            if (ID == Lib.GUIID_Squeezer && te instanceof TileEntitySqueezer)
                gui = new GuiSqueezer(player.inventory, (TileEntitySqueezer) te);
            if (ID == Lib.GUIID_Fermenter && te instanceof TileEntityFermenter)
                gui = new GuiFermenter(player.inventory, (TileEntityFermenter) te);
            if (ID == Lib.GUIID_Refinery && te instanceof TileEntityRefinery)
                gui = new GuiRefinery(player.inventory, (TileEntityRefinery) te);
            if (ID == Lib.GUIID_ArcFurnace && te instanceof TileEntityArcFurnace)
                gui = new GuiArcFurnace(player.inventory, (TileEntityArcFurnace) te);
            if (ID == Lib.GUIID_Assembler && te instanceof TileEntityAssembler)
                gui = new GuiAssembler(player.inventory, (TileEntityAssembler) te);
            if (ID == Lib.GUIID_AutoWorkbench && te instanceof TileEntityAutoWorkbench)
                gui = new GuiAutoWorkbench(player.inventory, (TileEntityAutoWorkbench) te);
            if (ID == Lib.GUIID_Mixer && te instanceof TileEntityMixer)
                gui = new GuiMixer(player.inventory, (TileEntityMixer) te);
            if (ID == Lib.GUIID_Turret && te instanceof TileEntityTurret)
                gui = new GuiTurret(player.inventory, (TileEntityTurret) te);
            if (ID == Lib.GUIID_FluidSorter && te instanceof TileEntityFluidSorter)
                gui = new GuiFluidSorter(player.inventory, (TileEntityFluidSorter) te);
            if (ID == Lib.GUIID_Belljar && te instanceof TileEntityBelljar)
                gui = new GuiBelljar(player.inventory, (TileEntityBelljar) te);
            if (ID == Lib.GUIID_ToolboxBlock && te instanceof TileEntityToolbox)
                gui = new GuiToolboxBlock(player.inventory, (TileEntityToolbox) te);
            if (gui != null)
                ((IGuiTile) te).onGuiOpened(player, true);
            return gui;
        }
    }
    return null;
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) BlockPos(net.minecraft.util.math.BlockPos) IGuiTile(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile) JsonObject(com.google.gson.JsonObject) PositionedItemStack(blusunrize.lib.manual.ManualPages.PositionedItemStack) IGuiItem(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem) TileEntity(net.minecraft.tileentity.TileEntity)

Example 9 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project ImmersiveEngineering by BluSunrize.

the class EntityRevolvershot method secondaryImpact.

public void secondaryImpact(RayTraceResult mop) {
    if (bulletElectro && mop.entityHit instanceof EntityLivingBase) {
        IBullet bullet = BulletHandler.getBullet(bulletType);
        float percentualDrain = .15f / (bullet == null ? 1 : bullet.getProjectileCount(shootingEntity instanceof EntityPlayer ? (EntityPlayer) this.shootingEntity : null));
        ((EntityLivingBase) mop.entityHit).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 15, 4));
        for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
            ItemStack stack = ((EntityLivingBase) mop.entityHit).getItemStackFromSlot(slot);
            if (EnergyHelper.isFluxItem(stack) && EnergyHelper.getEnergyStored(stack) > 0) {
                int drain = (int) Math.max(EnergyHelper.getEnergyStored(stack), EnergyHelper.getMaxEnergyStored(stack) * percentualDrain);
                int hasDrained = 0;
                while (hasDrained < drain) {
                    int actualDrain = EnergyHelper.forceExtractFlux(stack, drain, false);
                    if (actualDrain <= 0)
                        break;
                    hasDrained += actualDrain;
                }
            }
        }
    }
// if(bulletType==6)
// {
// Vec3d v = new Vec3d(-motionX, -motionY, -motionZ);
// int split = 6;
// for(int i=0; i<split; i++)
// {
// float angle = i * (360f/split);
// Matrix4 matrix = new Matrix4();
// matrix.rotate(angle, v.xCoord,v.yCoord,v.zCoord);
// Vec3d vecDir = new Vec3d(0, 1, 0);
// vecDir = matrix.apply(vecDir);
// 
// EntityWolfpackShot bullet = new EntityWolfpackShot(world, this.shootingEntity, vecDir.xCoord*1.5,vecDir.yCoord*1.5,vecDir.zCoord*1.5, this.bulletType, null);
// if(mop.entityHit instanceof EntityLivingBase)
// bullet.targetOverride = (EntityLivingBase)mop.entityHit;
// bullet.setPosition(posX+vecDir.xCoord, posY+vecDir.yCoord, posZ+vecDir.zCoord);
// bullet.motionX = vecDir.xCoord*.375;
// bullet.motionY = vecDir.yCoord*.375;
// bullet.motionZ = vecDir.zCoord*.375;
// world.spawnEntity(bullet);
// }
// }
// if(bulletType==8 && bulletPotion!=null && bulletPotion.getItem() instanceof ItemPotion)
// {
// PotionType potionType = PotionUtils.getPotionFromItem(bulletPotion);
// List<PotionEffect> effects = PotionUtils.getEffectsFromStack(bulletPotion);
// if(effects!=null)
// if(bulletPotion.getItem() instanceof ItemLingeringPotion)
// {
// EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
// entityareaeffectcloud.setOwner(shootingEntity);
// entityareaeffectcloud.setRadius(3.0F);
// entityareaeffectcloud.setRadiusOnUse(-0.5F);
// entityareaeffectcloud.setWaitTime(10);
// entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.getDuration());
// entityareaeffectcloud.setPotion(potionType);
// for(PotionEffect potioneffect : effects)
// entityareaeffectcloud.addEffect(new PotionEffect(potioneffect.getPotion(), potioneffect.getDuration(), potioneffect.getAmplifier()));
// this.world.spawnEntity(entityareaeffectcloud);
// }
// else if(bulletPotion.getItem() instanceof ItemSplashPotion)
// {
// List<EntityLivingBase> livingEntities = this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D));
// if(livingEntities!=null && !livingEntities.isEmpty())
// for(EntityLivingBase living : livingEntities)
// if(living.canBeHitWithPotion())
// {
// double dist = this.getDistanceSqToEntity(living);
// if(dist<16D)
// {
// double dist2 = 1-Math.sqrt(dist)/4D;
// if(living == mop.entityHit)
// dist2 = 1D;
// for(PotionEffect p : effects)
// if(p.getPotion().isInstant())
// p.getPotion().affectEntity(this, this.shootingEntity, living,  p.getAmplifier(), dist2);
// else
// {
// int j = (int)(dist2*p.getDuration()+.5D);
// if(j>20)
// living.addPotionEffect(new PotionEffect(p.getPotion(),j, p.getAmplifier()));
// }
// }
// }
// 
// }
// else if(mop.entityHit instanceof EntityLivingBase)
// for(PotionEffect p : effects)
// {
// if(p.getDuration()<1)
// p = new PotionEffect(p.getPotion(),1);
// ((EntityLivingBase)mop.entityHit).addPotionEffect(p);
// }
// world.playEvent(2002, new BlockPos(this), PotionType.getID(potionType));
// }
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 10 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project pnc-repressurized by TeamPneumatic.

the class TileEntityProgrammableController method initializeFakePlayer.

private void initializeFakePlayer() {
    fakePlayer = new DroneFakePlayer((WorldServer) getWorld(), new GameProfile(getOwnerUUID(), ownerName), this);
    fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {

        private ItemStack oldStack = ItemStack.EMPTY;

        @Override
        public int getSizeInventory() {
            return getDroneSlots();
        }

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                for (EntityEquipmentSlot ee : EntityEquipmentSlot.values()) {
                    if (!oldStack.isEmpty()) {
                        getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers(ee));
                    }
                    if (!stack.isEmpty()) {
                        getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(ee));
                    }
                }
                oldStack = stack;
            }
        }
    };
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) DroneFakePlayer(me.desht.pneumaticcraft.common.entity.living.EntityDrone.DroneFakePlayer) NetworkManager(net.minecraft.network.NetworkManager) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Aggregations

EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)23 ItemStack (net.minecraft.item.ItemStack)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ArrayList (java.util.ArrayList)3 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 ItemArmor (net.minecraft.item.ItemArmor)3 BlockPos (net.minecraft.util.math.BlockPos)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IGuiTile (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile)2 IGuiItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem)2 IDarkSteelItem (crazypants.enderio.api.upgrades.IDarkSteelItem)2 IDarkSteelUpgrade (crazypants.enderio.api.upgrades.IDarkSteelUpgrade)2 UUID (java.util.UUID)2 Nullable (javax.annotation.Nullable)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 Item (net.minecraft.item.Item)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)1 TileEntityAlloySmelter (blusunrize.immersiveengineering.common.blocks.stone.TileEntityAlloySmelter)1