use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project NyaSamaRailway by NSDN.
the class EntityInteractHandler method onEntityInteract.
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
if (event.entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (player.worldObj.isRemote)
return;
Entity entity = event.target;
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null) {
if (stack.getItem() instanceof ItemNTP8Bit) {
if (player.isSneaking()) {
((ItemNTP8Bit) stack.getItem()).clearCart(stack, player);
return;
}
if (entity instanceof EntityMinecart) {
((ItemNTP8Bit) stack.getItem()).addCart(stack, player, entity);
}
} else if (stack.getItem() instanceof ItemNTP32Bit) {
if (player.isSneaking()) {
((ItemNTP32Bit) stack.getItem()).clearCart(stack, player);
return;
}
if (entity instanceof EntityMinecart) {
((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
} else {
if (ExRollerCoaster.getInstance() != null) {
if (ExRollerCoaster.getInstance().verifyEntity(entity)) {
((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
}
}
if (RailsOfWar.getInstance() != null) {
if (RailsOfWar.getInstance().verifyEntity(entity)) {
((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
}
}
}
} else if (stack.getItem() instanceof Item1N4148) {
if (entity instanceof NSPCT8J) {
NSPCT8J loco = (NSPCT8J) entity;
loco.modifyHighSpeedMode(player);
}
} else if (stack.getItem() instanceof ItemNSPCT5) {
if (entity instanceof NSPCT5) {
((NSPCT5) entity).modifyLength();
}
} else if (stack.getItem() instanceof ItemNSPCT5L) {
if (entity instanceof NSPCT5L) {
((NSPCT5L) entity).modifyLength();
}
}
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ClaySoldiersMod by SanAndreasP.
the class RenderStatDisplayOverlay method renderText.
@SubscribeEvent
public void renderText(RenderGameOverlayEvent.Text event) {
Minecraft mc = Minecraft.getMinecraft();
if (this.p_titleRenderer == null) {
this.p_titleRenderer = mc.fontRenderer;
}
if (this.p_statRenderer == null) {
this.p_statRenderer = new FontRenderer(mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), mc.renderEngine, true);
if (mc.gameSettings.language != null) {
this.p_statRenderer.setBidiFlag(mc.getLanguageManager().isCurrentLanguageBidirectional());
}
}
ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem();
if (!mc.gameSettings.showDebugInfo && equippedStack != null && equippedStack.getItem() == RegistryItems.statDisplay) {
this.renderSoldiers(mc);
this.renderMounts(mc);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ClaySoldiersMod by SanAndreasP.
the class RenderClayCamHandler method onRenderTick.
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event) {
Minecraft mc = Minecraft.getMinecraft();
if (event.phase == Phase.START) {
if (mc.thePlayer != null && ClientProxy.s_clayCamEntity != null) {
if (this.viewMode == -1) {
this.viewMode = mc.gameSettings.thirdPersonView;
}
mc.gameSettings.thirdPersonView = 1;
if (this.p_clayCamRenderer == null) {
this.p_clayCamRenderer = new EntityRendererClayCam(mc, mc.getResourceManager());
}
if (mc.entityRenderer != this.p_clayCamRenderer) {
// be sure to store the previous renderer
this.p_prevEntityRenderer = mc.entityRenderer;
mc.entityRenderer = this.p_clayCamRenderer;
}
if (mc.thePlayer.isSneaking() || ClientProxy.s_clayCamEntity.isDead) {
mc.gameSettings.thirdPersonView = this.viewMode;
this.viewMode = -1;
ClaySoldiersMod.proxy.switchClayCam(false, null);
}
} else if (this.p_prevEntityRenderer != null && mc.entityRenderer != this.p_prevEntityRenderer) {
// reset the renderer
mc.entityRenderer = this.p_prevEntityRenderer;
}
} else if (ClientProxy.s_clayCamEntity != null) {
mc.gameSettings.thirdPersonView = this.viewMode;
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project pvp-mode by VulcanForge.
the class PvPEventHandler method interceptPvP.
/**
* Cancels combat events associated with PvP-disabled players.
*/
@SubscribeEvent
public void interceptPvP(LivingAttackEvent event) {
EntityPlayerMP attacker = getMaster(event.source.getEntity());
EntityPlayerMP victim = getMaster(event.entity);
if (attacker == null || victim == null)
return;
if (attacker.capabilities.allowFlying) {
if (attacker == event.source.getEntity())
fly(attacker);
event.setCanceled(true);
return;
}
if (victim.capabilities.allowFlying) {
event.setCanceled(true);
return;
}
if (attacker.capabilities.isCreativeMode) {
if (attacker == event.source.getEntity())
gm1(attacker);
event.setCanceled(true);
return;
}
if (!victim.getEntityData().getBoolean("PvPEnabled")) {
if (attacker == event.source.getEntity())
disabled(attacker);
event.setCanceled(true);
return;
}
if (!attacker.getEntityData().getBoolean("PvPEnabled")) {
event.setCanceled(true);
return;
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project pvp-mode by VulcanForge.
the class PvPEventHandler method onNewPlayer.
/**
* Adds a PvPEnabled tag to a new player.
*/
@SubscribeEvent
public void onNewPlayer(PlayerLoggedInEvent event) {
EntityPlayerMP player = (EntityPlayerMP) event.player;
if (!player.getEntityData().hasKey("PvPEnabled")) {
player.getEntityData().setBoolean("PvPEnabled", false);
player.getEntityData().setLong("PvPWarmup", 0);
player.getEntityData().setLong("PvPCooldown", 0);
}
}
Aggregations