use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SimplyJetpacks by Tonius.
the class PlatingReturnHandler method onItemCrafted.
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent evt) {
if (evt.player.worldObj.isRemote || !(evt.crafting.getItem() instanceof ItemPack)) {
return;
}
PackBase outputPack = ((ItemPack) evt.crafting.getItem()).getPack(evt.crafting);
if (outputPack.isArmored) {
return;
}
for (int i = 0; i < evt.craftMatrix.getSizeInventory(); i++) {
ItemStack input = evt.craftMatrix.getStackInSlot(i);
if (input == null || !(input.getItem() instanceof ItemPack)) {
continue;
}
PackBase inputPack = ((ItemPack) input.getItem()).getPack(input);
if (inputPack != null && inputPack.isArmored && inputPack.platingMeta != null) {
EntityItem item = evt.player.entityDropItem(new ItemStack(ModItems.armorPlatings, 1, inputPack.platingMeta), 0.0F);
item.delayBeforeCanPickup = 0;
break;
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SimplyJetpacks by Tonius.
the class EntityInteractHandler method onEntityInteract.
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent evt) {
if (evt.entityPlayer.isSneaking() && (evt.target instanceof EntityZombie || evt.target instanceof EntitySkeleton)) {
EntityLiving target = (EntityLiving) evt.target;
ItemStack heldStack = evt.entityPlayer.getHeldItem();
if (heldStack != null && heldStack.getItem() instanceof ItemJetpack) {
if (!target.worldObj.isRemote) {
target.dropEquipment(true, 3);
}
target.setCurrentItemOrArmor(3, heldStack.copy());
target.equipmentDropChances[3] = 2.0F;
target.persistenceRequired = true;
evt.entityPlayer.getHeldItem().stackSize--;
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SimplyJetpacks by Tonius.
the class LivingTickHandler method mobUseJetpack.
@SubscribeEvent
public void mobUseJetpack(LivingUpdateEvent evt) {
if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) {
ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
if (armor != null && armor.getItem() instanceof ItemJetpack) {
ItemJetpack jetpackItem = (ItemJetpack) armor.getItem();
Jetpack jetpack = jetpackItem.getPack(armor);
if (jetpack != null) {
if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) {
jetpack.setMobMode(armor);
jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false);
}
}
if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) {
evt.entityLiving.attackEntityFrom(DamageSource.generic, 80);
}
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project BluePower by Qmunity.
the class IconSupplier method onTextureStitch.
@SubscribeEvent
public void onTextureStitch(TextureStitchEvent.Pre event) {
TextureMap reg = event.map;
if (reg.getTextureType() == 0) {
pneumaticTubeSide = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side");
pneumaticTubeGlass = reg.registerIcon(Refs.MODID + ":tubes/glass");
pneumaticTubeGlass2 = reg.registerIcon(Refs.MODID + ":tubes/glass2");
pneumaticTubeOpaqueSide = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side_opaque");
pneumaticTubeOpaqueNode = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_end_opaque");
restrictionTubeSide = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_side");
restrictionTubeNodeOpaque = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_end_opaque");
restrictionTubeSideOpaque = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_side_opaque");
magTubeSide = reg.registerIcon(Refs.MODID + ":tubes/mag_side");
magCoilSide = reg.registerIcon(Refs.MODID + ":tubes/mag_casing");
magCoilFront = reg.registerIcon(Refs.MODID + ":tubes/mag_casing_end");
magTubeGlass = reg.registerIcon(Refs.MODID + ":tubes/glass_reinforced");
magTubeGlass2 = reg.registerIcon(Refs.MODID + ":tubes/glass_reinforced2");
acceleratorFront = reg.registerIcon(Refs.MODID + ":machines/accelerator_front");
acceleratorFrontPowered = reg.registerIcon(Refs.MODID + ":machines/accelerator_front_powered");
acceleratorSide = reg.registerIcon(Refs.MODID + ":machines/accelerator_side");
acceleratorSidePowered = reg.registerIcon(Refs.MODID + ":machines/accelerator_side_powered");
acceleratorInside = reg.registerIcon(Refs.MODID + ":machines/accelerator_inside");
pneumaticTubeColoring = reg.registerIcon(Refs.MODID + ":tubes/coloring");
cagedLampFootSide = reg.registerIcon(Refs.MODID + ":lamps/cage_foot_side");
cagedLampFootTop = reg.registerIcon(Refs.MODID + ":lamps/cage_foot_top");
cagedLampCageSide = reg.registerIcon(Refs.MODID + ":lamps/cage");
cagedLampCageTop = reg.registerIcon(Refs.MODID + ":lamps/cage_top");
cagedLampLampActive = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_on");
cagedLampLampInactive = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_off");
cagedLampLampActiveTop = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_on_top");
cagedLampLampInactiveTop = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_off_top");
fixtureFootSide = reg.registerIcon(Refs.MODID + ":lamps/fixture_foot_side");
fixtureFootTop = reg.registerIcon(Refs.MODID + ":lamps/fixture_foot_top");
fixtureLampSideOn = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on");
fixtureLampTopOn = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on_top");
fixtureLampSideOff = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off");
fixtureLampTopOff = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off_top");
lampOn = reg.registerIcon(Refs.MODID + ":lamps/lamp_off");
lampOff = reg.registerIcon(Refs.MODID + ":lamps/lamp_on");
bluestoneTorchOff = reg.registerIcon(Refs.MODID + ":bluestone_torch_off");
bluestoneTorchOn = reg.registerIcon(Refs.MODID + ":bluestone_torch_on");
wire = reg.registerIcon(Refs.MODID + ":wire/wire");
wireInsulation1 = reg.registerIcon(Refs.MODID + ":wire/insulation1");
wireInsulation2 = reg.registerIcon(Refs.MODID + ":wire/insulation2");
wireBundledConnection = reg.registerIcon(Refs.MODID + ":wire/bundled_connection");
wireBundledCross = reg.registerIcon(Refs.MODID + ":wire/bundled_cross");
wireBundledStraight1 = reg.registerIcon(Refs.MODID + ":wire/bundled_straight_1");
wireBundledStraight2 = reg.registerIcon(Refs.MODID + ":wire/bundled_straight_2");
wireBundledSide1 = reg.registerIcon(Refs.MODID + ":wire/bundled_side_1");
wireBundledSide2 = reg.registerIcon(Refs.MODID + ":wire/bundled_side_2");
gateButton = reg.registerIcon(Refs.MODID + ":gates/components/button");
siliconChipOff = reg.registerIcon(Refs.MODID + ":gates/components/silicon_chip_off");
siliconChipOn = reg.registerIcon(Refs.MODID + ":gates/components/silicon_chip_on");
taintedSiliconChipOff = reg.registerIcon(Refs.MODID + ":gates/components/tainted_silicon_chip_off");
taintedSiliconChipOn = reg.registerIcon(Refs.MODID + ":gates/components/tainted_silicon_chip_on");
quartzResonator = reg.registerIcon(Refs.MODID + ":gates/components/resonator");
gateSolarPanel = reg.registerIcon(Refs.MODID + ":gates/components/solarpanel");
for (PartInfo i : PartManager.getRegisteredParts()) i.getExample().registerIcons(reg);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project LogisticsPipes by RS485.
the class LogisticsEventListener method clientLoggedIn.
@SubscribeEvent
public void clientLoggedIn(ClientConnectedToServerEvent event) {
SimpleServiceLocator.clientBufferHandler.clear();
if (Configs.CHECK_FOR_UPDATES) {
LogisticsPipes.singleThreadExecutor.execute(() -> {
// try to get player entity ten times, once a second
int times = 0;
EntityClientPlayerMP playerEntity;
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return;
}
playerEntity = FMLClientHandler.instance().getClientPlayerEntity();
++times;
} while (playerEntity == null && times <= 10);
if (times > 10) {
return;
}
assert playerEntity != null;
VersionChecker checker = LogisticsPipes.versionChecker;
// send player message
String versionMessage = checker.getVersionCheckerStatus();
if (checker.isVersionCheckDone() && checker.getVersionInfo().isNewVersionAvailable() && !checker.getVersionInfo().isImcMessageSent()) {
playerEntity.addChatComponentMessage(new ChatComponentText(versionMessage));
playerEntity.addChatComponentMessage(new ChatComponentText("Use \"/logisticspipes changelog\" to see a changelog."));
} else if (!checker.isVersionCheckDone()) {
playerEntity.addChatComponentMessage(new ChatComponentText(versionMessage));
}
});
}
}
Aggregations