use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.
the class DroneSpecialVariableHandler method onSpecialVariableRetrieving.
@SubscribeEvent
public void onSpecialVariableRetrieving(SpecialVariableRetrievalEvent.CoordinateVariable.Drone event) {
if (event.specialVarName.equalsIgnoreCase("owner")) {
EntityDrone drone = (EntityDrone) event.drone;
EntityPlayer player = drone.getOwner();
if (player != null)
event.coordinate = getPosForEntity(player);
} else if (event.specialVarName.equalsIgnoreCase("drone")) {
event.coordinate = getPosForEntity(event.drone);
} else if (event.specialVarName.toLowerCase().startsWith("player=")) {
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.specialVarName.substring("player=".length()));
if (player != null)
event.coordinate = getPosForEntity(player);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.
the class GuiKeybindCheckBox method onKeyInput.
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
Minecraft mc = FMLClientHandler.instance().getClient();
if (mc.inGameHasFocus && keyBinding != null && keyBinding.isPressed()) {
onMouseClicked(0, 0, 0);
HUDHandler.instance().addMessage(I18n.format("pneumaticHelmet.message." + (checked ? "enable" : "disable") + "Setting", I18n.format(text)), new ArrayList<String>(), 60, 0x7000AA00);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Minechem by iopleke.
the class ScheduledTickHandler method checkForPoison.
@SubscribeEvent
public void checkForPoison(PlayerUseItemEvent.Finish event) {
if (event.item != null && event.item.getTagCompound() != null && Settings.FoodSpiking) {
NBTTagCompound stackTag = event.item.getTagCompound();
boolean isPoisoned = stackTag.getBoolean("minechem.isPoisoned");
int[] effectTypes = stackTag.getIntArray("minechem.effectTypes");
if (isPoisoned) {
for (int effectType : effectTypes) {
MoleculeEnum molecule = MoleculeEnum.getById(effectType);
PharmacologyEffectRegistry.applyEffect(molecule, event.entityPlayer);
}
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.
the class EventHandlerPneumaticCraft method onPlayerClick.
@SubscribeEvent
public void onPlayerClick(PlayerInteractEvent event) {
Block interactedBlock = event.world.getBlock(event.x, event.y, event.z);
if (!event.entityPlayer.capabilities.isCreativeMode || !event.entityPlayer.canCommandSenderUseCommand(2, "securityStation")) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR && event.world != null && !event.world.isRemote) {
if (interactedBlock != Blockss.securityStation || event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
ItemStack heldItem = event.entityPlayer.getCurrentEquippedItem();
boolean tryingToPlaceSecurityStation = heldItem != null && heldItem.getItem() instanceof ItemBlock && ((ItemBlock) heldItem.getItem()).field_150939_a == Blockss.securityStation;
int blockingStations = PneumaticCraftUtils.getProtectingSecurityStations(event.entity.worldObj, event.x, event.y, event.z, event.entityPlayer, true, tryingToPlaceSecurityStation);
if (blockingStations > 0) {
event.setCanceled(true);
event.entityPlayer.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(tryingToPlaceSecurityStation ? "message.securityStation.stationPlacementPrevented" : "message.securityStation.accessPrevented", blockingStations)));
}
}
}
}
/**
* Due to some weird quirk that causes Block#onBlockActivated not getting called on the server when the player is sneaking, this is a workaround.
*/
if (!event.isCanceled() && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && !event.world.isRemote) {
if (event.entityPlayer.isSneaking() && (interactedBlock == Blockss.elevatorCaller || interactedBlock == Blockss.chargingStation)) {
event.setCanceled(interactedBlock.onBlockActivated(event.world, event.x, event.y, event.z, event.entityPlayer, event.face, 0, 0, 0));
} else if (event.entityPlayer.getCurrentEquippedItem() != null && ModInteractionUtilImplementation.getInstance().isModdedWrench(event.entityPlayer.getCurrentEquippedItem().getItem())) {
if (interactedBlock instanceof IPneumaticWrenchable) {
((IPneumaticWrenchable) interactedBlock).rotateBlock(event.world, event.entityPlayer, event.x, event.y, event.z, ForgeDirection.getOrientation(event.face));
}
}
}
if (!event.isCanceled() && interactedBlock == Blocks.cobblestone) {
AchievementHandler.checkFor9x9(event.entityPlayer, event.x, event.y, event.z);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.
the class EventHandlerPneumaticCraft method FillBucket.
@SubscribeEvent
public void FillBucket(FillBucketEvent event) {
MovingObjectPosition p = event.target;
if (event.current == null || event.current.getItem() != Items.bucket || event.world.getBlockMetadata(p.blockX, p.blockY, p.blockZ) != 0)
return;
ItemStack result = attemptFill(event.world, event.target);
if (result != null) {
event.result = result;
AchievementHandler.giveAchievement(event.entityPlayer, result);
event.setResult(Result.ALLOW);
}
}
Aggregations