@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
if (event.entityLiving.worldObj.isRemote)
return;
if (EtFuturum.enableSkullDrop)
dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);
Random rand = event.entityLiving.worldObj.rand;
if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
for (int i = 0; i < amount; i++)
if (event.entityLiving.isBurning())
addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
else
addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
}
}
java类cpw.mods.fml.common.eventhandler.EventPriority的实例源码
ServerEventHandler.java 文件源码
项目:connor41-etfuturum2
阅读 28
收藏 0
点赞 0
评论 0
EventHandlerServer.java 文件源码
项目:ExtraUtilities
阅读 28
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void updateSoulDrain(final LivingSpawnEvent event) {
if (event.world.isRemote) {
return;
}
if (!EntityPlayerMP.class.equals(event.getClass())) {
return;
}
final IAttributeInstance a = event.entityLiving.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName());
final AttributeModifier attr = a.getModifier(ItemSoul.uuid);
if (attr == null || attr.getOperation() == 2) {
return;
}
final double l = attr.getAmount() / 20.0;
a.removeModifier(attr);
a.applyModifier(new AttributeModifier(ItemSoul.uuid, "Missing Soul", l, 0));
}
EventHandlerClient.java 文件源码
项目:ExtraUtilities
阅读 22
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void entityColorRender(final RenderLivingEvent.Pre event) {
final String s = EnumChatFormatting.getTextWithoutFormattingCodes(event.entity.getCommandSenderName());
if (s.startsWith("Aureylian") && !(event.entity instanceof EntityPlayer)) {
GL11.glColor4f(0.9686f, 0.7059f, 0.8392f, 1.0f);
this.resetRender = true;
}
if (EventHandlerClient.holograms.contains(s) && (!(event.entity instanceof EntityPlayer) || !((EntityPlayer)event.entity).getHideCape())) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.45f);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
this.resetRender = true;
}
if (s.equals("RWTema") && !(event.entity instanceof EntityPlayer)) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.65f);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
this.resetRender = true;
}
if (s.equals("jadedcat") && (!(event.entity instanceof EntityPlayer) || !((EntityPlayer)event.entity).getHideCape())) {
GL11.glColor4f(0.69f, 0.392f, 0.847f, 1.0f);
this.resetRender = true;
}
}
TConEvents.java 文件源码
项目:ExtraUtilities
阅读 27
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void denyCraft(final ToolBuildEvent event) {
if (ExtraUtils.tcon_unstable_material_id <= 0) {
return;
}
final WorldServer world = DimensionManager.getWorld(0);
if (world == null) {
return;
}
if (isToolExpired(event.headStack, world) || isToolExpired(event.handleStack, world) || isToolExpired(event.accessoryStack, world) || isToolExpired(event.extraStack, world)) {
event.headStack = null;
event.handleStack = null;
event.accessoryStack = null;
event.extraStack = null;
}
}
GunRenderEvent.java 文件源码
项目:FissionWarfare
阅读 26
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority=EventPriority.LOW)
public void gunRenderEvent(RenderPlayerEvent.Pre event) {
ItemStack item = event.entityPlayer.getHeldItem();
RenderPlayer rp = event.renderer;
if (item != null && item.getItem() instanceof ItemGun) {
rp.modelBipedMain.aimedBow = true;
rp.modelArmor.aimedBow = true;
rp.modelArmorChestplate.aimedBow = true;
}
else {
rp.modelBipedMain.aimedBow = false;
rp.modelArmor.aimedBow = false;
rp.modelArmorChestplate.aimedBow = false;
}
}
EventHandler.java 文件源码
项目:BetterChat
阅读 21
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority=EventPriority.LOWEST)
public void onServerChat(ServerChatEvent e)
{
EntityPlayerMP sender = e.player;
List<EntityPlayerMP> players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
String finalMessage = ChatFormatter.ChatParser(sender);
for (EntityPlayerMP receiver : players)
{receiver.addChatMessage(new ChatComponentText(finalMessage + "<" + e.username + ">: " + e.message));
}
BetterChat.bLog.info(sender.getDisplayName() + " said: " + e.message);
e.setCanceled(true);
}
ClientProxy.java 文件源码
项目:PopularMMOS-EpicProportions-Mod
阅读 27
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PlayerTickEvent event)
{
if (!ClientProxy.haveWarnedVersionOutOfDate && event.player.worldObj.isRemote
&& !ClientProxy.versionChecker.isLatestVersion())
{
ClickEvent versionCheckChatClickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,
"http://www.planetminecraft.com/mod/popularmmos-epicproportions-mod-season-9/");
ChatStyle clickableChatStyle = new ChatStyle().setChatClickEvent(versionCheckChatClickEvent);
ChatComponentText versionWarningChatComponent =
new ChatComponentText("Your EpicProportions Mod is not latest version! Click here to update.");
versionWarningChatComponent.setChatStyle(clickableChatStyle);
event.player.addChatMessage(versionWarningChatComponent);
ClientProxy.haveWarnedVersionOutOfDate = true;
}
}
VersionChecker.java 文件源码
项目:PopularMMOS-EpicProportions-Mod
阅读 29
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PlayerTickEvent event)
{
if (!ClientProxy.haveWarnedVersionOutOfDate && event.player.worldObj.isRemote
&& !ClientProxy.versionChecker.isLatestVersion())
{
ClickEvent versionCheckChatClickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,
"http://www.planetminecraft.com/mod/popularmmos-epicproportions-mod-season-9/");
ChatStyle clickableChatStyle = new ChatStyle().setChatClickEvent(versionCheckChatClickEvent);
ChatComponentText versionWarningChatComponent =
new ChatComponentText("�4�l" + "Your EpicProportions Mod is not latest version! Click here to update.");
versionWarningChatComponent.setChatStyle(clickableChatStyle);
event.player.addChatMessage(versionWarningChatComponent);
ClientProxy.haveWarnedVersionOutOfDate = true;
}
}
EnderPearlListener.java 文件源码
项目:WorldBorder-Forge
阅读 26
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerPearl(EnderTeleportEvent event)
{
if ( !(event.entityLiving instanceof EntityPlayerMP) )
return;
if ( Config.getKnockBack() == 0.0 || !Config.getDenyEnderpearl() )
return;
EntityPlayerMP player = (EntityPlayerMP) event.entityLiving;
Log.trace( "Caught pearl teleport event by %s", player.getDisplayName() );
Location target = new Location(event, player);
Location newLoc = BorderCheck.checkPlayer(player, target, true, true);
if (newLoc != null)
{
event.setCanceled(true);
event.targetX = newLoc.posX;
event.targetY = newLoc.posY;
event.targetZ = newLoc.posZ;
}
}
WorldGenStones.java 文件源码
项目:PrimitiveCraft
阅读 23
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWorldDecoration(DecorateBiomeEvent.Decorate event)
{
if ((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) && event.type == EventType.FLOWERS)
{
for(int i = 0; i < 2; i++)
{
int x = event.chunkX + event.rand.nextInt(16) + 8;
int z = event.chunkZ + event.rand.nextInt(16) + 8;
int y = event.world.getTopSolidOrLiquidBlock(x, z);
if(event.world.isAirBlock(x, y, z) && Blocks.flower_pot.canBlockStay(event.world, x, y, z) && ConfigPrimitiveCraft.genrocks)
{
event.world.setBlock(x, y, z, ModBlocks.rock);
}
else if(event.world.getBlock(x, y, z) == Blocks.water && ConfigPrimitiveCraft.genshale)
{
event.world.setBlock(x, y-1, z, ModBlocks.shale);
}
}
}
}
OpenFM.java 文件源码
项目:OpenFM
阅读 24
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(GuiOpenEvent event) {
if (event.gui instanceof GuiIngameModOptions) {
event.gui = new GuiModList(new GuiIngameMenu());
}
}
BreedingItemManager.java 文件源码
项目:ThermalRecycling
阅读 20
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = false)
public void entityInteract(final EntityInteractEvent event) {
if(event.entityPlayer instanceof EntityPlayerMP && event.target instanceof EntityAnimal) {
final EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
final ItemStack heldItem = player.getCurrentEquippedItem();
if(heldItem != null) {
final EntityAnimal animal = (EntityAnimal)event.target;
if(canBreed(animal, player)) {
final Set<ItemStackKey> possibleFood = foodItems.get(event.target.getClass());
if(possibleFood != null && possibleFood.contains(ItemStackKey.getCachedKey(heldItem))) {
if (!event.entityPlayer.capabilities.isCreativeMode) {
heldItem.stackSize--;
if (heldItem.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
animal.func_146082_f(player);
}
}
}
}
}
TickDynamicMod.java 文件源码
项目:TickDynamic
阅读 23
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority=EventPriority.LOWEST)
public void tickEventEnd(ServerTickEvent event) {
if(event.phase == Phase.END)
{
getTimedGroup("other").endTimer();
root.endTick(true);
if(debugTimer)
System.out.println("Tick time used: " + (root.getTimeUsed()/root.timeMilisecond) + "ms");
//After every world is done ticking, re-balance the time slices according
//to the data gathered during the tick.
root.balanceTime();
//Calculate TPS
updateTPS();
if(saveConfig)
{
saveConfig = false;
config.save();
}
}
}
GunRenderEvent.java 文件源码
项目:FusionWarfare
阅读 32
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority=EventPriority.LOW)
public void gunRenderEvent(RenderPlayerEvent.Pre event) {
ItemStack item = event.entityPlayer.getHeldItem();
RenderPlayer rp = event.renderer;
if (item != null && (item.getItem() instanceof ItemFusionGun || item.getItem() instanceof ItemRocketLauncher)) {
rp.modelBipedMain.aimedBow = true;
rp.modelArmor.aimedBow = true;
rp.modelArmorChestplate.aimedBow = true;
} else {
rp.modelBipedMain.aimedBow = false;
rp.modelArmor.aimedBow = false;
rp.modelArmorChestplate.aimedBow = false;
}
}
TerrainEventHandler.java 文件源码
项目:Biota
阅读 20
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBiomeDecoration(DecorateBiomeEvent.Decorate event)
{
if (event.type == DecorateBiomeEvent.Decorate.EventType.FLOWERS && (event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT))
{
for (int i = 0; i < Settings.FLOWER_QUANTITY; i++)
{
int x = event.chunkX + event.rand.nextInt(16) + 8;
int z = event.chunkZ + event.rand.nextInt(16) + 8;
int y = event.world.getTopSolidOrLiquidBlock(x, z);
Block randomPlant = ModBlocks.plants[event.rand.nextInt(ModBlocks.plants.length)];
if (event.world.isAirBlock(x, y, z) && (!event.world.provider.hasNoSky || y < 255) && randomPlant.canBlockStay(event.world, x, y, z))
{
event.world.setBlock(x, y, z, randomPlant, 0, 2);
}
}
}
}
HS_PlayerAttackEntity.java 文件源码
项目:HarderStart
阅读 23
收藏 0
点赞 0
评论 0
/**
* Makes stick truly a rudimentary weapon TODO add damage to stick info
*
* @param event
*/
@SubscribeEvent(priority = EventPriority.NORMAL)
public void playerAttackEvent(AttackEntityEvent event)
{
EntityPlayer player = event.entityPlayer;
ItemStack itemstack = player.getCurrentEquippedItem();
if (player != null)
{
if (!player.capabilities.disableDamage && itemstack != null)
{
if (OreDictionary.itemMatches(new ItemStack(Items.stick), itemstack, true))
{
event.target.attackEntityFrom(DamageSource.causePlayerDamage(player), 2.0F);
}
}
}
return;
}
ServerEventHandler.java 文件源码
项目:Et-Futurum
阅读 26
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
if (event.entityLiving.worldObj.isRemote)
return;
if (EtFuturum.enableSkullDrop)
dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);
Random rand = event.entityLiving.worldObj.rand;
if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
for (int i = 0; i < amount; i++)
if (event.entityLiving.isBurning())
addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
else
addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
}
}
GuiManaBar.java 文件源码
项目:TheDarkEra
阅读 34
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event) {
if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {
return;
}
if (!mc.thePlayer.capabilities.isCreativeMode) {
int posX = event.resolution.getScaledWidth() / 2 + 10;
int posY = event.resolution.getScaledHeight() - 48;
ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) Minecraft.getMinecraft().thePlayer);
float maxMana = props.getMaxMana();
int manabarwidth = (int) ((float) props.getMana() / maxMana * 48);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
this.mc.getTextureManager().bindTexture(texturepath);
mc.renderEngine.bindTexture(new ResourceLocation(TheDarkEra.MODID + ":textures/gui/SoulBar.png"));
mc.ingameGUI.drawTexturedModalRect(posX, posY, 0, 0, 50, 5);
mc.ingameGUI.drawTexturedModalRect(posX + 1, posY + 1, 0, 6, manabarwidth, 3);
String a = ""+props.getMaxMana();
String b = ""+props.getMana();
mc.fontRenderer.drawStringWithShadow(a, posX, posY, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(b, posX, posY+8, 0xFFFFFF);
System.out.println(maxMana);
}
}
EventHandlerGolem.java 文件源码
项目:Gadomancy
阅读 23
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(LivingHurtEvent event) {
if (!event.entity.worldObj.isRemote) {
if(event.entity instanceof EntityGolemBase) {
EntityGolemBase golem = (EntityGolemBase) event.entity;
if(event.ammount > 0 && RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(golem)) {
event.ammount = RegisteredGolemStuff.upgradeRunicShield.absorb(golem, event.ammount, event.source);
}
}
/*if(event.source.getEntity() != null && event.source.getEntity() instanceof EntityGolemBase
&& ((EntityGolemBase) event.source.getEntity()).getGolemType()
== RegisteredGolemStuff.typeObsidian.getEnumEntry()) {
event.entityLiving.addPotionEffect(new PotionEffect(Potion.wither.getId(), 3*20, 1));
}*/
}
}
EventHandlerGolem.java 文件源码
项目:Gadomancy
阅读 22
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(ItemTooltipEvent event) {
if(event.itemStack != null) {
if(event.itemStack.getItem() instanceof ItemGolemPlacer
|| event.itemStack.getItem() instanceof ItemAdditionalGolemPlacer) {
if(RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(event.itemStack)) {
event.toolTip.add("\u00a76" + StatCollector.translateToLocal("item.runic.charge") + " +" + RegisteredGolemStuff.upgradeRunicShield.getChargeLimit(event.itemStack));
}
AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(event.itemStack);
if(core != null) {
String searchStr = StatCollector.translateToLocal("item.ItemGolemCore.name");
for(int i = 0; i < event.toolTip.size(); i++) {
String line = event.toolTip.get(i);
if(line.contains(searchStr)) {
int index = line.indexOf('\u00a7', searchStr.length()) + 2;
event.toolTip.remove(i);
event.toolTip.add(i, line.substring(0, index) + StatCollector.translateToLocal(core.getUnlocalizedName()));
break;
}
}
}
}
}
}
EventHandlerWorld.java 文件源码
项目:Gadomancy
阅读 18
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOW)
public void on(EntityJoinWorldEvent event) {
if(!event.world.isRemote && event.entity instanceof EntityItem) {
ItemStack stack = ((EntityItem) event.entity).getEntityItem();
if(isDisguised(stack)) {
long time = event.world.getTotalWorldTime() + event.world.rand.nextInt(60) + 40;
trackedItems.put((EntityItem) event.entity, time);
}
if(stack.getItem() instanceof ItemElement && !(event.entity instanceof EntityItemElement)) {
event.setCanceled(true);
EntityItem newItem = new EntityItemElement(event.world,
event.entity.posX, event.entity.posY, event.entity.posZ,
((EntityItem) event.entity).getEntityItem());
newItem.delayBeforeCanPickup = ((EntityItem) event.entity).delayBeforeCanPickup;
newItem.motionX = event.entity.motionX;
newItem.motionY = event.entity.motionY;
newItem.motionZ = event.entity.motionZ;
event.world.spawnEntityInWorld(newItem);
}
}
}
EventHandlerWorld.java 文件源码
项目:Gadomancy
阅读 24
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(BlockEvent.PlaceEvent e) {
if (e.isCanceled()) {
if (interacts != null)
interacts.remove(e.player);
} else {
if (!e.world.isRemote && isStickyJar(e.itemInHand)) {
TileEntity parent = e.world.getTileEntity(e.x, e.y, e.z);
if (parent instanceof TileJarFillable) {
int metadata = e.world.getBlockMetadata(e.x, e.y, e.z);
e.world.setBlock(e.x, e.y, e.z, RegisteredBlocks.blockStickyJar, metadata, 2);
TileEntity tile = e.world.getTileEntity(e.x, e.y, e.z);
if (tile instanceof TileStickyJar) {
Integer sideHit = interacts.get(e.player);
((TileStickyJar) tile).init((TileJarFillable) parent, e.placedBlock, metadata,
ForgeDirection.getOrientation(sideHit == null ? 1 : sideHit).getOpposite());
RegisteredBlocks.blockStickyJar.onBlockPlacedBy(e.world, e.x, e.y, e.z, e.player, e.itemInHand);
}
}
}
}
}
EventHandlerWorld.java 文件源码
项目:Gadomancy
阅读 18
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(PlayerInteractEvent e) {
if (!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
&& isStickyJar(e.entityPlayer.getHeldItem())) {
if (interacts == null) {
interacts = new HashMap<EntityPlayer, Integer>();
}
interacts.put(e.entityPlayer, e.face);
}
if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
ItemStack i = e.entityPlayer.getHeldItem();
if (i != null && (i.getItem() instanceof ItemWandCasting)) {
WandHandler.handleWandInteract(e.world, e.x, e.y, e.z, e.entityPlayer, i);
}
}
}
EventHandlerWorld.java 文件源码
项目:Gadomancy
阅读 27
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(ItemTooltipEvent e) {
if (e.toolTip.size() > 0 && e.itemStack.hasTagCompound()) {
if (e.itemStack.stackTagCompound.getBoolean("isStickyJar")) {
e.toolTip.add(1, "\u00a7a" + StatCollector.translateToLocal("gadomancy.lore.stickyjar"));
}
}
if(e.toolTip.size() > 0 && NBTHelper.hasPersistentData(e.itemStack)) {
NBTTagCompound compound = NBTHelper.getPersistentData(e.itemStack);
if(compound.hasKey("disguise")) {
NBTBase base = compound.getTag("disguise");
String lore;
if(base instanceof NBTTagCompound) {
ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) base);
lore = String.format(StatCollector.translateToLocal("gadomancy.lore.disguise.item"), EnumChatFormatting.getTextWithoutFormattingCodes(stack.getDisplayName()));
} else {
lore = StatCollector.translateToLocal("gadomancy.lore.disguise.none");
}
e.toolTip.add("\u00a7a" + lore);
}
}
}
ForgeEventHandlers.java 文件源码
项目:D3Log
阅读 21
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void playerInteractEvent(PlayerInteractEvent event)
{
WorldInteractLogEvent log = new WorldInteractLogEvent();
log.setType(TYPE_INTERACT_WORLD);
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR)
{
log.setPlayerPosAndUuid(event.entityPlayer);
}
else
{
log.setPlayerUUID(event.entityPlayer);
log.setPosition(event.entity.dimension, event.x, event.y, event.z);
log.setData(event.action, event.face, event.entityPlayer.getCurrentEquippedItem());
}
LoggingQueue.addToQueue(log);
}
ForgeEventHandlers.java 文件源码
项目:D3Log
阅读 27
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void blockBreakEvent(BlockEvent.BreakEvent event)
{
BlockSnapshotLogEvent log = new BlockSnapshotLogEvent();
log.setType(TYPE_BLOCK_BREAK);
log.setPlayerUUID(event.getPlayer());
log.setPosition(event.world.provider.dimensionId, event.x, event.y, event.z);
NBTTagCompound nbt = null;
if (event.block.hasTileEntity(event.blockMetadata))
{
TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
if (te != null)
{
nbt = new NBTTagCompound();
te.writeToNBT(nbt);
}
}
log.setData(new BlockSnapshot(event.world, event.x, event.y, event.z, event.block, event.blockMetadata, nbt));
LoggingQueue.addToQueue(log);
}
SCPGuiBlink.java 文件源码
项目:SecureCraftProtect
阅读 19
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event)
{
if (event.isCancelable() || event.type != EXPERIENCE) {
return;
}
int width = event.resolution.getScaledWidth();
int height = event.resolution.getScaledHeight();
int k2 = height - 20;
int blink = mc.thePlayer.getDataWatcher().getWatchableObjectInt(BLINK);
int i4 = width / 2 + 91;
int bar = MathHelper.ceiling_double_int((double) (blink + 2) * 10.0D
/ MAX_BLINK);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
glDisable(GL_LIGHTING);
mc.getTextureManager().bindTexture(icons);
drawTexturedModalRect(i4 - 281, k2 - 1, 0, 18, 83, 11);
drawTexturedModalRect(i4 - 301, k2 - 1, 83, 18, 17, 11);
for (int i = 0; i < 10; ++i) {
if (i < bar) {
drawTexturedModalRect(i4 + i * 8 - 280, k2, 100, 18, 9, 9);
}
}
}
EventHandler.java 文件源码
项目:Eureka
阅读 22
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.HIGHEST)
//make sure it gets trigered first to prevent handeling from other mods
public void onPlayerUsesBlock(PlayerInteractEvent event) {
String key = "";
if (event.world.isRemote)
return;
EntityPlayer player = event.entityPlayer;
PlayerResearch research = PlayerResearch.get(player);
if (player.getCurrentEquippedItem() != null)
key = EurekaAPI.API.getKey(player.getCurrentEquippedItem());
if (!research.isFinished(key) && !key.equals("")) {
ItemStack stack = player.getCurrentEquippedItem().copy();
stack.stackSize = 1;
dropItems(event.world, event.x, event.y, event.z, EurekaAPI.API.getDrops(stack));
if (event.entityPlayer.getCurrentEquippedItem().stackSize > 1)
event.entityPlayer.getCurrentEquippedItem().stackSize--;
else
event.entityPlayer.destroyCurrentEquippedItem();
event.setCanceled(true);
}
key = EurekaAPI.API.getKey(event.world.getBlock(event.x, event.y, event.z));
if (key != null && !key.equals("") && !research.isFinished(key))
event.setCanceled(true);
}
EventHandler.java 文件源码
项目:ItFellFromTheSky
阅读 24
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntitySpawn(EntityJoinWorldEvent event)
{
if(event.entity.worldObj.isRemote && event.entity instanceof EntityMeteorite && FMLCommonHandler.instance().getEffectiveSide().isClient() && !event.entity.isDead)
{
event.setCanceled(true);
if(!event.entity.worldObj.weatherEffects.contains(event.entity))
{
boolean has = false;
for(int i = 0; i < event.entity.worldObj.weatherEffects.size(); i++)
{
Entity ent = (Entity)event.entity.worldObj.weatherEffects.get(i);
if(ent instanceof EntityMeteorite && ent.getEntityId() == event.entity.getEntityId())
{
has = true;
ent.setLocationAndAngles(event.entity.posX, event.entity.posY, event.entity.posZ, 0F, 0F);
break;
}
}
if(!has)
{
event.entity.worldObj.weatherEffects.add(event.entity);
}
}
}
}
BiomeDecorHandler.java 文件源码
项目:MagicalRings
阅读 21
收藏 0
点赞 0
评论 0
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWorldDecoration(DecorateBiomeEvent.Decorate event) {
BiomeGenBase biome = event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ);
if (biome != null && isValidBiomeType(biome)) {
if ((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT) && event.type == DecorateBiomeEvent.Decorate.EventType.FLOWERS) {
for (int i = 0; i < ModLibs.manaFlowerQuantity; i++) {
int x = event.chunkX + event.rand.nextInt(16) + 8;
int z = event.chunkZ + event.rand.nextInt(16) + 8;
int y = event.world.getTopSolidOrLiquidBlock(x, z);
for (int j = 0; j < ModLibs.manaFlowerDensity; j++) {
int x1 = x + event.rand.nextInt(8) - event.rand.nextInt(8);
int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4);
int z1 = z + event.rand.nextInt(8) - event.rand.nextInt(8);
if (event.world.isAirBlock(x1, y1, z1) && (!event.world.provider.hasNoSky || y1 < 127) && ModBlocks.manaFlower.canBlockStay(event.world, x1, y1, z1))
event.world.setBlock(x1, y1, z1, ModBlocks.manaFlower, event.rand.nextInt(3), 2);
}
}
}
}
}