Search in sources :

Example 1 with ParticleType

use of tonius.simplyjetpacks.setup.ParticleType in project SimplyJetpacks by Tonius.

the class UpgradingRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
    int addedEnergy = 0;
    ParticleType particleType = null;
    NBTTagCompound tags = null;
    boolean enderiumUpgrade = false;
    ItemStack slotStack;
    for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) {
        slotStack = inventoryCrafting.getStackInSlot(i);
        if (slotStack != null && slotStack.getItem() != null) {
            if (slotStack.getItem() instanceof ItemPack) {
                tags = (NBTTagCompound) NBTHelper.getNBT(slotStack).copy();
            }
            if (slotStack.getItem() instanceof IEnergyContainerItem) {
                addedEnergy += ((IEnergyContainerItem) slotStack.getItem()).getEnergyStored(slotStack);
            } else if (slotStack.getItem() == ModItems.particleCustomizers) {
                particleType = ParticleType.values()[slotStack.getItemDamage()];
            } else if (ModItems.enderiumUpgrade != null && slotStack.getItem() == ModItems.enderiumUpgrade.getItem() && slotStack.getItemDamage() == ModItems.enderiumUpgrade.getItemDamage()) {
                enderiumUpgrade = true;
            }
        }
    }
    ItemStack result = new ItemStack((Item) this.resultItem, 1, this.resultMeta);
    if (tags != null) {
        result.setTagCompound(tags);
    }
    NBTHelper.getNBT(result).setInteger("Energy", Math.min(addedEnergy, this.resultItem.getMaxEnergyStored(result)));
    if (this.resultItem instanceof ItemJetpack && particleType != null) {
        ((ItemJetpack) this.resultItem).getPack(result).setParticleType(result, particleType);
    }
    if (enderiumUpgrade && this.resultItem instanceof ItemPack) {
        PackBase pack = ((ItemPack) this.resultItem).getPack(result);
        if (pack instanceof JetPlate) {
            ((JetPlate) pack).setEnderiumUpgrade(result, true);
        }
    }
    return result;
}
Also used : ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) JetPlate(tonius.simplyjetpacks.item.meta.JetPlate) PackBase(tonius.simplyjetpacks.item.meta.PackBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemPack(tonius.simplyjetpacks.item.ItemPack) ItemStack(net.minecraft.item.ItemStack) IEnergyContainerItem(cofh.api.energy.IEnergyContainerItem)

Example 2 with ParticleType

use of tonius.simplyjetpacks.setup.ParticleType in project SimplyJetpacks by Tonius.

the class ClientTickHandler method tickStart.

private static void tickStart() {
    if (mc.thePlayer == null) {
        return;
    }
    ParticleType jetpackState = null;
    ItemStack armor = mc.thePlayer.getEquipmentInSlot(3);
    if (armor != null && armor.getItem() instanceof ItemJetpack) {
        Jetpack jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
        if (jetpack != null) {
            jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), mc.thePlayer);
        }
        wearingJetpack = true;
    } else {
        wearingJetpack = false;
    }
    if (jetpackState != lastJetpackState) {
        lastJetpackState = jetpackState;
        SyncHandler.processJetpackUpdate(mc.thePlayer.getEntityId(), jetpackState);
    }
}
Also used : ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemStack(net.minecraft.item.ItemStack) SoundJetpack(tonius.simplyjetpacks.client.audio.SoundJetpack) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack)

Example 3 with ParticleType

use of tonius.simplyjetpacks.setup.ParticleType 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 4 with ParticleType

use of tonius.simplyjetpacks.setup.ParticleType 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 5 with ParticleType

use of tonius.simplyjetpacks.setup.ParticleType in project SimplyJetpacks by Tonius.

the class LivingTickHandler method onLivingTick.

@SubscribeEvent
public void onLivingTick(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote) {
        ParticleType jetpackState = null;
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        Jetpack jetpack = null;
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
            if (jetpack != null) {
                jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), evt.entityLiving);
            }
        }
        if (jetpackState != lastJetpackState.get(evt.entityLiving.getEntityId())) {
            if (jetpackState == null) {
                lastJetpackState.remove(evt.entityLiving.getEntityId());
            } else {
                lastJetpackState.put(evt.entityLiving.getEntityId(), jetpackState);
            }
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        } else if (jetpack != null && evt.entityLiving.worldObj.getTotalWorldTime() % 160L == 0) {
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        }
        if (evt.entityLiving.worldObj.getTotalWorldTime() % 200L == 0) {
            Iterator<Integer> itr = lastJetpackState.keySet().iterator();
            while (itr.hasNext()) {
                int entityId = itr.next();
                if (evt.entityLiving.worldObj.getEntityByID(entityId) == null) {
                    itr.remove();
                }
            }
        }
    }
}
Also used : MessageJetpackSync(tonius.simplyjetpacks.network.message.MessageJetpackSync) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemStack(net.minecraft.item.ItemStack) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

ParticleType (tonius.simplyjetpacks.setup.ParticleType)6 ItemStack (net.minecraft.item.ItemStack)3 ItemJetpack (tonius.simplyjetpacks.item.ItemPack.ItemJetpack)3 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 SoundJetpack (tonius.simplyjetpacks.client.audio.SoundJetpack)2 Jetpack (tonius.simplyjetpacks.item.meta.Jetpack)2 IEnergyContainerItem (cofh.api.energy.IEnergyContainerItem)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ItemPack (tonius.simplyjetpacks.item.ItemPack)1 JetPlate (tonius.simplyjetpacks.item.meta.JetPlate)1 PackBase (tonius.simplyjetpacks.item.meta.PackBase)1 MessageJetpackSync (tonius.simplyjetpacks.network.message.MessageJetpackSync)1