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 PneumaticCraft by MineMaarten.
the class ClientSemiBlockManager method renderWorldLastEvent.
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.thePlayer;
double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.partialTicks;
double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.partialTicks;
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.partialTicks;
GL11.glPushMatrix();
GL11.glTranslated(-playerX, -playerY, -playerZ);
// GL11.glEnable(GL11.GL_BLEND);
// GL11.glEnable(GL11.GL_LIGHTING);
RenderHelper.enableStandardItemLighting();
for (Map<ChunkPosition, ISemiBlock> map : SemiBlockManager.getInstance(player.worldObj).getSemiBlocks().values()) {
for (ISemiBlock semiBlock : map.values()) {
ISemiBlockRenderer renderer = getRenderer(semiBlock);
if (renderer != null) {
GL11.glPushMatrix();
GL11.glTranslated(semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
renderer.render(semiBlock, event.partialTicks);
GL11.glPopMatrix();
}
}
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.
the class CommonHUDHandler method tickEnd.
@SubscribeEvent
public void tickEnd(TickEvent.PlayerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
EntityPlayer player = event.player;
if (this == PneumaticCraft.proxy.getCommonHudHandler()) {
getHandlerForPlayer(player).tickEnd(event);
} else {
ItemStack helmetStack = player.getCurrentArmor(3);
if (helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet) {
helmetPressure = ((IPressurizable) helmetStack.getItem()).getPressure(helmetStack);
if (ticksExisted == 0) {
checkHelmetInventory(helmetStack);
}
ticksExisted++;
if (!player.worldObj.isRemote) {
if (ticksExisted > getStartupTime() && !player.capabilities.isCreativeMode) {
((IPressurizable) helmetStack.getItem()).addAir(helmetStack, (int) -UpgradeRenderHandlerList.instance().getAirUsage(player, false));
}
}
} else {
ticksExisted = 0;
}
if (!player.worldObj.isRemote)
handleHacking(player);
}
}
}
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);
}
}
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);
}
}
Aggregations