本文整理汇总了Java中net.minecraftforge.fml.common.eventhandler.EventPriority.LOW属性的典型用法代码示例。如果您正苦于以下问题:Java EventPriority.LOW属性的具体用法?Java EventPriority.LOW怎么用?Java EventPriority.LOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraftforge.fml.common.eventhandler.EventPriority
的用法示例。
在下文中一共展示了EventPriority.LOW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHeal
@SubscribeEvent(priority = EventPriority.LOW)
public static void onHeal(LivingHealEvent event) {
EntityLivingBase entity = event.getEntityLiving();
if (!entity.hasCapability(CapabilityExtendedHealthSystem.INSTANCE, null))
return;
event.setCanceled(true);
if (!FirstAid.activeHealingConfig.allowOtherHealingItems)
return;
float amount = event.getAmount();
//Hacky shit to reduce vanilla regen
if (FirstAid.activeHealingConfig.allowNaturalRegeneration && Arrays.stream(Thread.currentThread().getStackTrace()).anyMatch(stackTraceElement -> stackTraceElement.getClassName().equals(FoodStats.class.getName())))
amount = amount * (float) FirstAid.activeHealingConfig.naturalRegenMultiplier;
else
amount = amount * (float) FirstAid.activeHealingConfig.otherRegenMultiplier;
HealthDistribution.distributeHealth(amount, (EntityPlayer) entity, true);
}
示例2: onGuiKeyboardEvent
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiKeyboardEvent(GuiScreenEvent.KeyboardInputEvent.Post event) {
if (Keyboard.getEventKeyState()) {
int eventKey = Keyboard.getEventKey();
if (KeyBindings.TOGGLE.isActiveAndMatches(eventKey)) {
Config.toggleEnabled();
event.setCanceled(true);
} else if (KeyBindings.ZOOM_IN.isActiveAndMatches(eventKey)) {
Config.increaseZoom();
event.setCanceled(true);
} else if (KeyBindings.ZOOM_OUT.isActiveAndMatches(eventKey)) {
Config.decreaseZoom();
event.setCanceled(true);
}
}
}
示例3: onItemStackTooltip
@SubscribeEvent(priority = EventPriority.LOW)
public void onItemStackTooltip(RenderTooltipEvent.Pre event) {
if (!Config.isToggledEnabled() && !isEnableKeyHeld()) {
return;
}
ItemStack itemStack = event.getStack();
//noinspection ConstantConditions
if (itemStack == null || itemStack.isEmpty()) {
return;
}
if (Config.isJeiOnly() && !ItemStack.areItemStacksEqual(itemStack, JeiCompat.getStackUnderMouse())) {
return;
}
Minecraft minecraft = Minecraft.getMinecraft();
GuiScreen currentScreen = minecraft.currentScreen;
if (currentScreen instanceof GuiContainer) {
GuiContainer guiContainer = (GuiContainer) currentScreen;
renderZoomedStack(itemStack, guiContainer, minecraft);
}
}
示例4: onTick
@SubscribeEvent(priority = EventPriority.LOW)
public void onTick(TickEvent.RenderTickEvent event) {
if (TextDisplayerMod.getInstance().getWebsiteUtils().isDisabled()) return;
boolean isClickedLeft = Mouse.isButtonDown(0);
if (isClickedLeft != this.lastLeft) {
this.lastLeft = isClickedLeft;
if (isClickedLeft) {
this.leftClicks.add(System.currentTimeMillis());
}
}
boolean isClickedRight = Mouse.isButtonDown(1);
if (isClickedRight != this.lastRight) {
this.lastRight = isClickedRight;
if (isClickedRight) {
this.rightClicks.add(System.currentTimeMillis());
}
}
}
示例5: diagnostics
@SubscribeEvent(priority = EventPriority.LOW)
public void diagnostics(final DiagnosticEvent.Gather event) {
final TObjectIntHashMap<String> counts = new TObjectIntHashMap<String>();
final Iterator<Entry<String, ISound>> iterator = this.playingSounds.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, ISound> entry = iterator.next();
ISound isound = entry.getValue();
counts.adjustOrPutValue(isound.getSound().getSoundLocation().toString(), 1, 1);
}
final ArrayList<String> results = new ArrayList<String>();
final TObjectIntIterator<String> itr = counts.iterator();
while (itr.hasNext()) {
itr.advance();
results.add(String.format(TextFormatting.GOLD + "%s: %d", itr.key(), itr.value()));
}
Collections.sort(results);
event.output.addAll(results);
}
示例6: onLivingHeal
@SubscribeEvent(priority = EventPriority.LOW)
public void onLivingHeal(@Nonnull final LivingHealEvent event) {
if (!ModOptions.enableDamagePopoffs)
return;
if (event == null || event.getEntity() == null || event.getEntity().world == null
|| event.getEntity().world.isRemote)
return;
// Just in case
if (event.getAmount() <= 0 || event.getEntityLiving() == null
|| event.getEntityLiving().getHealth() == event.getEntityLiving().getMaxHealth())
return;
final Entity entity = event.getEntityLiving();
final Locus point = new Locus(entity, RANGE);
final PacketHealthChange packet = new PacketHealthChange(entity.getEntityId(), (float) entity.posX,
(float) entity.posY + (entity.height / 2.0F), (float) entity.posZ, false, -(int) event.getAmount());
Network.sendToAllAround(point, packet);
}
示例7: entityDeathEvent
@SubscribeEvent(priority= EventPriority.LOW)
public void entityDeathEvent(LivingDeathEvent e){
if(e.getEntity() instanceof EntityPlayer
&& e.getResult() != Event.Result.DENY
&& !e.getEntity().getEntityWorld().isRemote) {
final EntityPlayer player = (EntityPlayer)e.getEntity();
if(player.isSpectator()) return;
Map<ItemStack,EntityEquipmentSlot> cache = equipmentCache.computeIfAbsent(player,(EntityPlayer p)->new HashMap<>());
for(EntityEquipmentSlot slot : EntityLootableBody.EQUIPMENT_SLOTS){
cache.put(player.getItemStackFromSlot(slot),slot);
}
if(player.getPrimaryHand() == EnumHandSide.LEFT){
// swap main and off hand items (easier than messing with the rendering code)
cache.put(player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND),EntityEquipmentSlot.OFFHAND);
cache.put(player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND),EntityEquipmentSlot.MAINHAND);
}
}
}
示例8: supressExcessiveSound
@SubscribeEvent(priority = EventPriority.LOW)
public void supressExcessiveSound(PlaySoundEvent event) {
// Basically, divide the volume by the number of events minus some threshold
Minecraft mc = Minecraft.getMinecraft();
if (mc.theWorld == null) {
present_tick = -100;
return;
}
if (event.result == null) return;
if (event.isCanceled()) return;
long now = mc.theWorld.getTotalWorldTime();
if (now != present_tick) {
present_tick = now;
event_count = 0;
}
if (event_count++ < max_event) return;
final double origVolume = event.result.getVolume();
final float newVolume = (float)(origVolume / Math.log(event_count) * logMax);
event.result = new ProxiedSound(event.result) {
@Override
public float getVolume() {
return newVolume;
}
};
}
示例9: removeMask
@SubscribeEvent(priority = EventPriority.LOW)
public void removeMask(PlayerInteractEvent event) {
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return;
final EntityPlayer player = event.entityPlayer;
if (player.worldObj.isRemote) return;
if (!player.isSneaking()) return;
if (player.getHeldItem() != null) return;
final ItemStack helmet = player.getCurrentArmor(3);
if (helmet == null || !(helmet.getItem() == this)) return;
if (!isBowed(player)) return;
player.setCurrentItemOrArmor(4, null);
player.setCurrentItemOrArmor(0, helmet);
event.setCanceled(true);
Core.proxy.updatePlayerInventory(player); // Only seems necessary for removal specifically.
}
示例10: onWorldCreateSpawn
@SubscribeEvent(priority = EventPriority.LOW)
public void onWorldCreateSpawn(WorldEvent.CreateSpawnPosition event)
{
World world = event.getWorld();
JustEnoughDimensions.logInfo("WorldEvent.CreateSpawnPosition - DIM: {}", world.provider.getDimension());
overrideWorldInfoAndBiomeProvider(world);
// Find a proper spawn point for the overworld that isn't inside ground...
// For other dimensions than the regular overworld, this is done after
// (and only if) setting up the custom WorldInfo override for a newly
// created dimension, see overrideBiomeProviderAndFindSpawn().
if (world.provider.getDimension() == 0)
{
WorldUtils.findAndSetWorldSpawn(world);
if (event.getSettings().isBonusChestEnabled())
{
JustEnoughDimensions.logInfo("WorldEvent.CreateSpawnPosition - Generating a bonus chest");
WorldUtils.createBonusChest(world);
}
event.setCanceled(true);
}
}
示例11: onRenderGameOverlayEvent
@SubscribeEvent(priority = EventPriority.LOW)
public void onRenderGameOverlayEvent(RenderGameOverlayEvent.Text event) {
if (renderPosition.getAsBoolean())
if (event.getType().equals(RenderGameOverlayEvent.ElementType.TEXT)) {
for (logoutPos pos : Lists.newArrayList(logoutPositions)) {
Vec3d topVec = new Vec3d((pos.pos[0].x+pos.pos[1].x)/2, pos.pos[1].y, (pos.pos[0].z+pos.pos[1].z)/2); // position where to place the text in the world
VectorUtils.ScreenPos textPos = VectorUtils._toScreen(topVec.x, topVec.y, topVec.z); // where to place the text on the screen
double distance = MC.player.getDistance((pos.pos[0].x+pos.pos[1].x)/2, pos.pos[0].y, (pos.pos[0].z+pos.pos[1].z)/2); // distance from player to logout spot
if (textPos.isVisible) {
String name = pos.name + String.format((" (%.1f)"), distance);
SurfaceHelper.drawTextShadow(name, textPos.x - (SurfaceHelper.getTextWidth(name) / 2), textPos.y - (SurfaceHelper.getTextHeight() + 1), Utils.toRGBA(255,0,0,0));
}
}
}
}
示例12: PlayerLoggedIn
@SubscribeEvent(priority = EventPriority.LOW)
public void PlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent evt) {
if(Main.debug==1)System.out.println(evt.player.getName() + " called PlayentLoggedIn");
Main.posX.put(evt.player.getName(), evt.player.posX);
Main.posY.put(evt.player.getName(), evt.player.posY);
Main.posZ.put(evt.player.getName(), evt.player.posZ);
Main.time.put(evt.player.getName(), 0);
MinecraftServer minecraftServer = FMLServerHandler.instance().getServer();
String brut = minecraftServer.getPlayerList().getPlayerByUsername(evt.player.getName()).connection.getNetworkManager().getRemoteAddress().toString().replaceAll("/", "");
int lenght = brut.length();
brut = brut.substring(0, lenght-6);
if(Integer.parseInt((String) Main.config.get("iplogin")) > 0 && Main.ips.containsKey(brut)){
Main.logged.add(evt.player.getName());
evt.player.addChatMessage(new TextComponentString(TextFormatting.GREEN + (String)Main.config.get("iploginmessage")));
Main.ips.remove(brut);
Main.time.remove(evt.player.getName());
}
if(!Main.logged.contains(evt.player.getName())){
if(Main.passwords.containsKey(evt.player.getName())){
evt.player.addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
} else {
evt.player.addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
}
}
}
示例13: onLivingDeath
@SubscribeEvent(priority = EventPriority.LOW)
public static void onLivingDeath(LivingDeathEvent event) {
EntityLivingBase entityLiving = event.getEntityLiving();
if (entityLiving instanceof EntityPlayer && !(entityLiving instanceof FakePlayer)) {
PlayerDataManager.clearPlayer((EntityPlayer) entityLiving);
}
}
示例14: onGameTick
@SubscribeEvent(priority = EventPriority.LOW)
public void onGameTick(TickEvent.RenderTickEvent event) {
if (TextDisplayerMod.getInstance().getWebsiteUtils().isDisabled()) return;
if (mc.currentScreen != null) {
if (this.mc.currentScreen instanceof MainGui) {
try {
this.mc.currentScreen.handleInput();
} catch (IOException ignored) {
}
}
} else if (this.mc.inGameHasFocus && !this.mc.gameSettings.showDebugInfo && mc.thePlayer != null) {
TextDisplayerMod.getInstance().getLoader().renderAll(false);
}
}
示例15: dropFakeItems
@SubscribeEvent(priority = EventPriority.LOW)
public void dropFakeItems(PlayerDropsEvent event) {
InventoryWearables inv = event.getEntityLiving().getCapability(TF2weapons.INVENTORY_CAP, null);
for (int i = 3; i < 13; i++)
if (inv.getStackInSlot(i) != null) {
event.getEntityPlayer().dropItem(inv.getStackInSlot(i), true, false);
}
if(WeaponsCapability.get(event.getEntity()).isFeign())
for(EntityItem item:event.getDrops()) {
item.getEntityData().setBoolean("Fake", true);
item.setAgeToCreativeDespawnTime();
}
}