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;
}
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);
}
}
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);
}
}
}
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;
}
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();
}
}
}
}
}
Aggregations