Java Code Examples for net.minecraftforge.event.entity.living.LivingEvent#LivingUpdateEvent

The following examples show how to use net.minecraftforge.event.entity.living.LivingEvent#LivingUpdateEvent . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SquashableMod.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (entity.world.isRemote) {
        return;
    }

    if (entity.collidedHorizontally && isBeingPushedByPiston(entity)) {
        Squashable squashable = entity.getCapability(squashableCap(), null);
        if (squashable == null) {
            return;
        }

        double[] pistonDeltas = getPistonDeltas(entity);
        double pushedAngle = Math.atan2(pistonDeltas[2], pistonDeltas[0]);

        EnumFacing.Axis faceAxis = EnumFacing.fromAngle(entity.rotationYaw).getAxis();
        EnumFacing.Axis pushAxis = EnumFacing.fromAngle(pushedAngle).getAxis();

        EnumFacing.Axis squashAxis = faceAxis == pushAxis ? EnumFacing.Axis.Z : EnumFacing.Axis.X;

        squashable.squash(squashAxis);

        NETWORK.sendToAllTracking(new SquashEntityMessage(entity, squashAxis), entity);
    }
}
 
Example 2
Source File: PlayerEventHandler.java    From HexxitGear with GNU General Public License v3.0 6 votes vote down vote up
@ForgeSubscribe
public void playerUpdate(LivingEvent.LivingUpdateEvent event) {
    if (ticks > 16) {
        if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) {
            if (!event.entityLiving.worldObj.isRemote)
                return;

            EntityPlayer player = (EntityPlayer) event.entityLiving;
            String capeUrl = CapeHandler.getCapeUrl(player.username);
            if (capeUrl != null && !capeUrl.equals(player.cloakUrl)) {
                player.cloakUrl = capeUrl;
                FMLClientHandler.instance().getClient().renderEngine.obtainImageData(player.cloakUrl, null);
            }
        }
    ticks = 0;
    }
    ticks++;
}
 
Example 3
Source File: EventHandlerEntity.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void on(LivingEvent.LivingUpdateEvent event) {
    if (event.entityLiving == null || !(event.entityLiving instanceof EntityPlayer)) return;
    EntityPlayer player = (EntityPlayer) event.entity;
    if ((event.entity.worldObj.provider.dimensionId == ModConfig.dimOuterId) && ((player.ticksExisted & 7) == 0) && ((player.capabilities.isFlying) || (Hover.getHover(player.getEntityId())))) {
        if(player.capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(player)) return;
        player.capabilities.isFlying = false;
        Hover.setHover(player.getEntityId(), false);
        if (!((EntityPlayer) event.entityLiving).worldObj.isRemote) {
            String msg = StatCollector.translateToLocal("tc.break.fly");
            if (player.capabilities.isCreativeMode) {
                msg += " " + StatCollector.translateToLocal("gadomancy.eldritch.noflyCreative");
            }
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + msg));
        }
    }
}
 
Example 4
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTick(LivingEvent.LivingUpdateEvent event) {
	EntityLivingBase e = event.getEntityLiving();
	if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) {
		boolean shouldFreeze = true;
		if(e.isDead || e.getHealth() <= 0) {
			shouldFreeze = false;
		}
		if(e instanceof EntityDragon && ((EntityDragon) e).getPhaseManager().getCurrentPhase().getType() == PhaseList.DYING) {
			shouldFreeze = false;
		}
		if(shouldFreeze) {
			handleImportantEntityTicks(e);
			event.setCanceled(true);
		}
	}
}
 
Example 5
Source File: ModuleEffectLeap.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void tickEntity(LivingEvent.LivingUpdateEvent event) {
	ItemStack stack = event.getEntityLiving().getHeldItemMainhand();
	if (stack.isEmpty()) return;

	if (NBTHelper.hasNBTEntry(stack, "jump_timer")) {
		int x = NBTHelper.getInt(stack, "jump_timer", 0);

		if (x <= 0 || event.getEntityLiving().collidedVertically) {
			NBTHelper.removeNBTEntry(stack, "jump_timer");
			NBTHelper.removeNBTEntry(stack, "jump_count");
			NBTHelper.removeNBTEntry(stack, "max_jumps");

		} else NBTHelper.setInt(stack, "jump_timer", x - 1);
	}
}
 
Example 6
Source File: ModuleEffectTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void skipTick(LivingEvent.LivingUpdateEvent event) {
	if (event.getEntity().getEntityData().hasKey("skip_tick")
			&& event.getEntity().getEntityData().hasKey("skip_tick_interval")
			&& event.getEntity().getEntityData().hasKey("skip_tick_interval_save")) {
		int tickCountdown = event.getEntity().getEntityData().getInteger("skip_tick");
		int tickInterval = event.getEntity().getEntityData().getInteger("skip_tick_interval");

		if (tickInterval <= 0) {
			event.getEntity().getEntityData().setInteger("skip_tick_interval", event.getEntity().getEntityData().getInteger("skip_tick_interval_save"));

			if (tickCountdown <= 0) {
				event.getEntity().getEntityData().removeTag("skip_tick");
				event.getEntity().getEntityData().removeTag("skip_tick_interval");
				event.getEntity().getEntityData().removeTag("skip_tick_interval_save");
			} else {
				event.getEntity().getEntityData().setInteger("skip_tick", --tickCountdown);
				event.setCanceled(true);
			}
		} else {
			event.getEntity().getEntityData().setInteger("skip_tick_interval", --tickInterval);
		}
	}
}
 
Example 7
Source File: LocalPlayerUpdateEventService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(LivingEvent.LivingUpdateEvent event) {
  if (getWorld() != null
      && event.getEntity().getEntityWorld().isRemote
      && event.getEntityLiving().equals(getLocalPlayer())) {
    Event ev = new LocalPlayerUpdateEvent(event.getEntityLiving());
    MinecraftForge.EVENT_BUS.post(ev);
    event.setCanceled(ev.isCanceled());
  }
}
 
Example 8
Source File: PigmenAngerCooldownService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(LivingEvent.LivingUpdateEvent event) {
  if (event.getEntityLiving() instanceof EntityPigZombie) {
    // update pigmens anger level
    EntityPigZombie pigZombie = (EntityPigZombie) event.getEntityLiving();
    if (pigZombie.isArmsRaised()) {
      FastReflection.Fields.EntityPigZombie_angerLevel.set(pigZombie, 400);
    } else if (pigZombie.isAngry()) {
      FastReflection.Fields.EntityPigZombie_angerLevel.set(
          pigZombie, FastReflection.Fields.EntityPigZombie_angerLevel.get(pigZombie) - 1);
    }
  }
}
 
Example 9
Source File: AntiEffectsMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
  EntityLivingBase living = event.getEntityLiving();
  if (living.equals(MC.player)) {
    living.setInvisible(false);
    living.removePotionEffect(MobEffects.NAUSEA);
    living.removePotionEffect(MobEffects.INVISIBILITY);
    living.removePotionEffect(MobEffects.BLINDNESS);
    // removes particle effect
    FastReflection.Methods.EntityLivingBase_resetPotionEffectMetadata.invoke(living);
  } else if (no_particles.get()) {
    living.setInvisible(false);
    FastReflection.Methods.EntityLivingBase_resetPotionEffectMetadata.invoke(living);
  }
}
 
Example 10
Source File: ArenaManager.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void tickBoss(LivingEvent.LivingUpdateEvent event) {
	for (Arena arena : arenas) {
		if (event.getEntityLiving().getEntityId() != arena.getBossID()) continue;

		if (event.getEntityLiving().getDistance(arena.getCenter().getX() + 0.5, arena.getCenter().getY(), arena.getCenter().getZ() + 0.5) > arena.getRadius()) {
			event.getEntityLiving().move(MoverType.SELF, arena.getCenter().getX() + 0.5, arena.getCenter().getY() + 0.5, arena.getCenter().getZ() + 0.5);
		}
	}
}
 
Example 11
Source File: HorseStats.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
  if (EntityUtils.isDrivenByPlayer(event.getEntity())
      && getRidingEntity() instanceof AbstractHorse) {
    
    double newSpeed = speed.getAsDouble();
    if (getLocalPlayer().isSprinting()) {
      newSpeed *= multiplier.getAsDouble();
    }
    applyStats(jumpHeight.getAsDouble(), newSpeed);
  }
}
 
Example 12
Source File: Events.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onLiving(LivingEvent.LivingUpdateEvent event) {
    if (!cheatEnabled) {
        return;
    }
    ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> {
        mod.onLiving(event);
    });
}
 
Example 13
Source File: HandlerEvents.java    From burlapcraft with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void givePickaxeEvent(LivingEvent.LivingUpdateEvent event) {
	if (event.entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.entity;
		if (!player.inventory.hasItem(Items.diamond_pickaxe)) {
			player.inventory.addItemStackToInventory(new ItemStack(Items.diamond_pickaxe));
		}
	}
}
 
Example 14
Source File: Nyan.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
	final Entity entity = event.getEntity();
	final World world = entity.getEntityWorld();

	if(world.isRemote) {
		return;
	}

	final MinecraftServer server = world.getMinecraftServer();
	final NBTTagCompound data = entity.getEntityData();

	if(data.hasUniqueId(NYANED_ENTITY_UUID_KEY)) {
		final Entity nyanedEntity =
				server.getEntityFromUuid(data.getUniqueId(NYANED_ENTITY_UUID_KEY));

		if(nyanedEntity == null || nyanedEntity.isDead) {
			world.removeEntity(entity);
			return;
		}
	}

	if(data.getBoolean(HAS_NYAN_ENTITY_KEY)) {
		updateNyanEntity(server, (WorldServer) world, entity, data);
	} else if(!data.hasKey(HAS_NYAN_ENTITY_KEY)) {
		if(entity instanceof EntityPlayer || random.nextInt(10) == 0) {
			data.setBoolean(HAS_NYAN_ENTITY_KEY, true);
			updateNyanEntity(server, (WorldServer) world, entity, data);
		} else {
			data.setBoolean(HAS_NYAN_ENTITY_KEY, false);
		}
	}
}
 
Example 15
Source File: DamagePopOffs.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLiving(LivingEvent.LivingUpdateEvent event) {
    updateHealth(event.entityLiving);
}
 
Example 16
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(LivingEvent.LivingUpdateEvent e) {
    if(!e.entityLiving.worldObj.isRemote) {
        lastUpdated = e.entityLiving;
    }
}
 
Example 17
Source File: Module.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public void onLiving(LivingEvent.LivingUpdateEvent event) {
}