Search in sources :

Example 1 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project SimplyJetpacks by Tonius.

the class ClientTickHandler method tickEnd.

private static void tickEnd() {
    if (mc.thePlayer == null || mc.theWorld == null) {
        return;
    }
    if (!mc.isGamePaused()) {
        Iterator<Integer> itr = SyncHandler.getJetpackStates().keySet().iterator();
        int currentEntity;
        while (itr.hasNext()) {
            currentEntity = itr.next();
            Entity entity = mc.theWorld.getEntityByID(currentEntity);
            if (entity == null || !(entity instanceof EntityLivingBase) || entity.dimension != mc.thePlayer.dimension) {
                itr.remove();
            } else {
                ParticleType particle = SyncHandler.getJetpackStates().get(currentEntity);
                if (particle != null) {
                    if (entity.isInWater() && particle != ParticleType.NONE) {
                        particle = ParticleType.BUBBLE;
                    }
                    SimplyJetpacks.proxy.showJetpackParticles(mc.theWorld, (EntityLivingBase) entity, particle);
                    if (Config.jetpackSounds && !SoundJetpack.isPlayingFor(entity.getEntityId())) {
                        Minecraft.getMinecraft().getSoundHandler().playSound(new SoundJetpack((EntityLivingBase) entity));
                    }
                } else {
                    itr.remove();
                }
            }
        }
    }
    if (sprintKeyCheck && mc.thePlayer.movementInput.moveForward < 1.0F) {
        sprintKeyCheck = false;
    }
    if (!Config.doubleTapSprintInAir || !wearingJetpack || mc.thePlayer.onGround || mc.thePlayer.isSprinting() || mc.thePlayer.isUsingItem() || mc.thePlayer.isPotionActive(Potion.blindness)) {
        return;
    }
    if (!sprintKeyCheck && mc.thePlayer.movementInput.moveForward >= 1.0F && !mc.thePlayer.isCollidedHorizontally && (mc.thePlayer.getFoodStats().getFoodLevel() > 6.0F || mc.thePlayer.capabilities.allowFlying)) {
        if (mc.thePlayer.sprintToggleTimer <= 0 && !mc.gameSettings.keyBindSprint.getIsKeyPressed()) {
            mc.thePlayer.sprintToggleTimer = 7;
            sprintKeyCheck = true;
        } else {
            mc.thePlayer.setSprinting(true);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ParticleType(tonius.simplyjetpacks.setup.ParticleType) SoundJetpack(tonius.simplyjetpacks.client.audio.SoundJetpack)

Example 2 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project SimplyJetpacks by Tonius.

the class MessageJetpackSync method onMessage.

@Override
public IMessage onMessage(MessageJetpackSync msg, MessageContext ctx) {
    Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityId);
    if (entity != null && entity instanceof EntityLivingBase && entity != FMLClientHandler.instance().getClient().thePlayer) {
        if (msg.particleId >= 0) {
            ParticleType particle = ParticleType.values()[msg.particleId];
            SyncHandler.processJetpackUpdate(msg.entityId, particle);
        } else {
            SyncHandler.processJetpackUpdate(msg.entityId, null);
        }
    }
    return null;
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ParticleType(tonius.simplyjetpacks.setup.ParticleType)

Example 3 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project BetterStorage by copygirl.

the class ModelDrinkingHelmet method render.

@Override
public void render(Entity entity, float v1, float v2, float v3, float v4, float v5, float v6) {
    ItemStack[] potions = new ItemStack[2];
    if (entity instanceof EntityLivingBase) {
        ItemStack drinkingHelmet = ItemDrinkingHelmet.getDrinkingHelmet((EntityLivingBase) entity);
        // rendering in the enchantment effect render pass. 
        if (!drinkingHelmet.isItemEnchanted() || (pass++ == 0))
            potions = ItemDrinkingHelmet.getPotions(drinkingHelmet);
        else if (pass > 2)
            pass = 0;
    }
    left.stack = potions[0];
    right.stack = potions[1];
    setRotationAngles(v1, v2, v3, v4, v5, v6, entity);
    bipedHead.render(v6);
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack)

Example 4 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project BetterStorage by copygirl.

the class BackpackHandler method onSpecialSpawn.

@SubscribeEvent
public void onSpecialSpawn(SpecialSpawn event) {
    // When a mob spawns naturally, see if it has a chance to spawn with a backpack.
    EntityLivingBase entity = event.entityLiving;
    World world = entity.worldObj;
    double probability = 0.0;
    for (BetterStorageBackpack.BackpackSpawnEntry entry : BetterStorageBackpack.spawnWithBackpack) {
        if (!entity.getClass().equals(entry.entityClass))
            continue;
        probability = entry.probability;
        break;
    }
    if (!RandomUtils.getBoolean(probability) || entity.isChild())
        return;
    // If entity is a vanilla enderman, replace it with a friendly one.
    if (entity.getClass().equals(EntityEnderman.class)) {
        if ((BetterStorageTiles.enderBackpack != null) && // Don't spawn friendly endermen in the end or end biome, would make them too easy to get.
        (world.provider.dimensionId != 1) && (world.getBiomeGenForCoords((int) entity.posX, (int) entity.posZ) != BiomeGenBase.sky)) {
            EntityFrienderman frienderman = new EntityFrienderman(world);
            frienderman.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, 0);
            world.spawnEntityInWorld(frienderman);
            ItemBackpack.getBackpackData(frienderman).spawnsWithBackpack = true;
            entity.setDead();
        }
    // Otherwise, just mark it to spawn with a backpack.
    } else if (BetterStorageTiles.backpack != null)
        ItemBackpack.getBackpackData(entity).spawnsWithBackpack = true;
}
Also used : EntityFrienderman(net.mcft.copy.betterstorage.entity.EntityFrienderman) EntityLivingBase(net.minecraft.entity.EntityLivingBase) World(net.minecraft.world.World) BetterStorageBackpack(net.mcft.copy.betterstorage.api.BetterStorageBackpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 5 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project BetterStorage by copygirl.

the class BackpackHandler method onLivingUpdate.

@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
    EntityLivingBase entity = event.entityLiving;
    EntityPlayer player = ((entity instanceof EntityPlayer) ? (EntityPlayer) entity : null);
    ItemStack backpack = ItemBackpack.getBackpack(entity);
    PropertiesBackpack backpackData;
    if (backpack == null) {
        backpackData = EntityUtils.getProperties(entity, PropertiesBackpack.class);
        if (backpackData == null)
            return;
        // with a backpack, equip it with one.
        if (backpackData.spawnsWithBackpack) {
            ItemStack[] contents = null;
            if (entity instanceof EntityFrienderman) {
                backpack = new ItemStack(BetterStorageItems.itemEnderBackpack);
                // Remove drop chance for the backpack.
                ((EntityLiving) entity).setEquipmentDropChance(EquipmentSlot.CHEST, 0.0F);
            } else {
                backpack = new ItemStack(BetterStorageItems.itemBackpack, 1, RandomUtils.getInt(120, 240));
                ItemBackpack backpackType = (ItemBackpack) backpack.getItem();
                if (RandomUtils.getBoolean(0.15)) {
                    // Give the backpack a random color.
                    int r = RandomUtils.getInt(32, 224);
                    int g = RandomUtils.getInt(32, 224);
                    int b = RandomUtils.getInt(32, 224);
                    int color = (r << 16) | (g << 8) | b;
                    StackUtils.set(backpack, color, "display", "color");
                }
                contents = new ItemStack[backpackType.getBackpackColumns() * backpackType.getBackpackRows()];
                // Set drop chance for the backpack to 100%.
                ((EntityLiving) entity).setEquipmentDropChance(EquipmentSlot.CHEST, 1.0F);
            }
            // If the entity spawned with enchanted armor,
            // move the enchantments over to the backpack.
            ItemStack armor = entity.getEquipmentInSlot(EquipmentSlot.CHEST);
            if (armor != null && armor.isItemEnchanted()) {
                NBTTagCompound compound = new NBTTagCompound();
                compound.setTag("ench", armor.getTagCompound().getTag("ench"));
                backpack.setTagCompound(compound);
            }
            if (contents != null) {
                // Add random items to the backpack.
                InventoryStacks inventory = new InventoryStacks(contents);
                // Add normal random backpack loot.
                WeightedRandomChestContent.generateChestContents(RandomUtils.random, randomBackpackItems, inventory, 20);
                // With a chance of 10%, add some random dungeon loot.
                if (RandomUtils.getDouble() < 0.1) {
                    ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);
                    WeightedRandomChestContent.generateChestContents(RandomUtils.random, info.getItems(RandomUtils.random), inventory, 5);
                }
            }
            ItemBackpack.setBackpack(entity, backpack, contents);
            backpackData.spawnsWithBackpack = false;
        } else {
            // but still has some backpack data, drop the items.
            if (backpackData.contents != null) {
                for (ItemStack stack : backpackData.contents) WorldUtils.dropStackFromEntity(entity, stack, 1.5F);
                backpackData.contents = null;
            }
        }
    }
    ItemBackpack.getBackpackData(entity).update(entity);
    if (backpack != null)
        ((ItemBackpack) backpack.getItem()).onEquippedUpdate(entity, backpack);
}
Also used : EntityFrienderman(net.mcft.copy.betterstorage.entity.EntityFrienderman) EntityLiving(net.minecraft.entity.EntityLiving) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ChestGenHooks(net.minecraftforge.common.ChestGenHooks) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PropertiesBackpack(net.mcft.copy.betterstorage.misc.PropertiesBackpack) ItemBackpack(net.mcft.copy.betterstorage.item.ItemBackpack) ItemStack(net.minecraft.item.ItemStack) InventoryStacks(net.mcft.copy.betterstorage.inventory.InventoryStacks) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)594 EntityPlayer (net.minecraft.entity.player.EntityPlayer)201 Entity (net.minecraft.entity.Entity)177 PotionEffect (net.minecraft.potion.PotionEffect)106 ItemStack (net.minecraft.item.ItemStack)88 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)86 BlockPos (net.minecraft.util.math.BlockPos)77 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)77 Vec3d (net.minecraft.util.math.Vec3d)65 World (net.minecraft.world.World)57 IBlockState (net.minecraft.block.state.IBlockState)45 List (java.util.List)38 ArrayList (java.util.ArrayList)37 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)37 TileEntity (net.minecraft.tileentity.TileEntity)37 EntityItem (net.minecraft.entity.item.EntityItem)32 DamageSource (net.minecraft.util.DamageSource)25 Block (net.minecraft.block.Block)24 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)23 WorldServer (net.minecraft.world.WorldServer)23