本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingEvent類的典型用法代碼示例。如果您正苦於以下問題:Java LivingEvent類的具體用法?Java LivingEvent怎麽用?Java LivingEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LivingEvent類屬於net.minecraftforge.event.entity.living包,在下文中一共展示了LivingEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTick
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void onTick(LivingEvent.LivingUpdateEvent event) {
if (!event.getEntityLiving().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (player.getFoodStats().needFood()) {
for (ItemStack stack : player.inventory.mainInventory) {
if (stack.getItem().equals(ItemRegistry.meatFeederItem)) {
int filledAmount = ((MeatFeederItem) stack.getItem()).getFilledAmount(stack);
if (filledAmount >= 200) {
((MeatFeederItem) stack.getItem()).drain(stack, 200);
player.getFoodStats().setFoodLevel(player.getFoodStats().getFoodLevel() + 1);
return;
}
}
}
}
}
}
示例2: getPlayer
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
public static EntityPlayer getPlayer(Event event)
{
if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer)
return (EntityPlayer)((LivingEvent)event).getEntity();
if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent)
return HarshenCastle.proxy.getPlayer();
if(event instanceof PlayerTickEvent)
return ((PlayerTickEvent)event).player;
if(event instanceof PlayerEvent)
return ((PlayerEvent)event).player;
if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent)
return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer();
if(event instanceof PlayerPunchedEvent)
return ((PlayerPunchedEvent)event).attacker;
if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource()))
return getPlayerFromSource(((LivingDropsEvent)event).getSource());
return null;
}
示例3: onLivingUpdate
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
if (!(event.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
if (player.isDead) {
this.hueManager.adjustColor(new Color(255, 0, 0));
return;
}
BlockPos pos = player.getPosition();
Chunk chunk = this.world.getChunkFromBlockCoords(pos);
Biome biome = chunk.getBiome(pos, this.world.getBiomeProvider());
String color = this.biomeMap.get(biome.getRegistryName().getResourcePath());
if (color != null) {
this.hueManager.adjustColor(color);
}
}
示例4: onUpdate
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void onUpdate(LivingEvent.LivingUpdateEvent ev) {
EntityLivingBase entity = ev.getEntityLiving();
for (EntityEquipmentSlot slot : armor) {
Map<UUID, AbilitySeries> associated = map.get(slot);
ItemStack stack = entity.getItemStackFromSlot(slot);
if (!stack.isEmpty() && RandoresItemData.hasData(stack) && stack.getItem() instanceof RandoresItemArmor && EmpoweredEnchantment.appliedTo(stack)) {
RandoresWorldData.delegateVoid(new RandoresItemData(stack), def -> {
associated.put(entity.getPersistentID(), def.getAbilitySeries());
def.getAbilitySeries().onArmorUpdate(entity);
}, () -> {});
} else if (associated.containsKey(entity.getPersistentID())) {
associated.remove(entity.getPersistentID()).onArmorCancel(entity);
}
}
}
示例5: maximumOvercluck
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void maximumOvercluck(LivingEvent.LivingUpdateEvent event) {
if (!event.getEntityLiving().worldObj.isRemote && event.getEntityLiving() instanceof EntityChicken) {
EntityChicken chicken = (EntityChicken)event.getEntityLiving();
NBTTagCompound tag = chicken.getEntityData();
if (!chicken.isChild() && tag.hasKey(ItemGeneric.TAG_OVERCLUCK)) {
int timer = tag.getInteger(ItemGeneric.TAG_OVERCLUCK);
tag.setInteger(ItemGeneric.TAG_OVERCLUCK, --timer);
if (--timer <= 0)
{
chicken.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (chicken.worldObj.rand.nextFloat() - chicken.worldObj.rand.nextFloat()) * 0.2F + 1.0F);
chicken.dropItem(Items.EGG, 1);
timer = chicken.worldObj.rand.nextInt(60) + 900;
tag.setInteger(ItemGeneric.TAG_OVERCLUCK, timer);
}
}
}
}
示例6: stopJump
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void stopJump(LivingEvent.LivingJumpEvent event) {
EntityLivingBase living=event.getEntityLiving();
if ((living.getActivePotionEffect(TF2weapons.stun) != null && living.getActivePotionEffect(TF2weapons.bombmrs) == null)
|| living.getActivePotionEffect(TF2weapons.charging) != null
|| (living.getHeldItemMainhand() != null && living.getHeldItemMainhand().getItem() instanceof ItemMinigun
&& living.hasCapability(TF2weapons.WEAPONS_CAP, null) && living.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks > 0)) {
living.isAirBorne = false;
living.motionY -= 0.5f;
if (living.isSprinting()) {
float f = living.rotationYaw * 0.017453292F;
living.motionX += MathHelper.sin(f) * 0.2F;
living.motionZ -= MathHelper.cos(f) * 0.2F;
}
}
}
示例7: updateEntity
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void updateEntity(final LivingEvent.LivingUpdateEvent event) {
if (event.entity.worldObj.isRemote) {
return;
}
if (event.entity.getEntityData().hasKey("CursedEarth")) {
int c = event.entity.getEntityData().getInteger("CursedEarth");
if (c == 0) {
event.entity.setDead();
NetworkHandler.sendParticle(event.entity.worldObj, "smoke", event.entity.posX, event.entity.posY + event.entity.height / 4.0f, event.entity.posZ, 0.0, 0.0, 0.0, false);
}
else {
--c;
event.entity.getEntityData().setInteger("CursedEarth", c);
}
}
}
示例8: skipTick
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@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);
}
}
}
示例9: tickEntity
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void tickEntity(LivingEvent.LivingUpdateEvent event) {
if (event.getEntityLiving().getEntityData().hasKey("jump_timer")) {
int x = event.getEntityLiving().getEntityData().getInteger("jump_timer");
if (event.getEntityLiving().collidedVertically) {
event.getEntityLiving().getEntityData().removeTag("jump_timer");
event.getEntityLiving().getEntityData().removeTag("jump_count");
return;
}
if (x <= 0) {
event.getEntityLiving().getEntityData().removeTag("jump_timer");
event.getEntityLiving().getEntityData().removeTag("jump_count");
} else event.getEntityLiving().getEntityData().setInteger("jump_timer", x - 1);
}
}
示例10: entityEvent
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void entityEvent(LivingEvent.LivingUpdateEvent event)
{
if (event.entity instanceof EntityPlayer)
{
if (((EntityPlayer) event.entity).getCurrentEquippedItem() != null)
{
canItemShowTess =
(RFUtilities.TE_LOADED && (/*(((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemToolBase ||
((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemMultimeter)) ||
(*/(EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemDialer);
}
else
{
canItemShowTess = false;
}
}
}
示例11: entityEvent
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void entityEvent(LivingEvent.LivingUpdateEvent event)
{
if (event.entity instanceof EntityPlayer)
{
if (((EntityPlayer) event.entity).getCurrentEquippedItem() != null)
{
canItemShowTess =
(RFUtilities.TE_LOADED && (((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemToolBase ||
((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemMultimeter)) ||
((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemDialer;
}
else
{
canItemShowTess = false;
}
}
}
示例12: onLivingUpdate
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
EntityLivingBase entity = event.getEntityLiving();
if(entity.getEntityWorld().isRemote) {
return;
}
PotionTracker tracker = CapabilityPotionTracker.getPotionTracker(entity);
if(tracker == null) {
return;
}
Collection<PotionEffect> potions = entity.getActivePotionEffects();
tracker.updatePotionEffects(potions.stream()
.filter(p -> p.getPotion() instanceof ISpecialPotion)
.map(PotionEffect::getPotion).collect(Collectors.toList()));
}
示例13: onSkeletonUpdate
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@SubscribeEvent
public void onSkeletonUpdate(LivingEvent.LivingUpdateEvent event) {
if (!(event.getEntityLiving() instanceof EntitySkeleton)) {
return;
}
EntitySkeleton skeleton = (EntitySkeleton) event.getEntityLiving();
EntityAITasks tasks = skeleton.tasks;
boolean containsOld = false;
Iterator<EntityAITasks.EntityAITaskEntry> itr = tasks.taskEntries.iterator();
while (itr.hasNext()) {
EntityAITasks.EntityAITaskEntry entry = itr.next();
if (entry.action instanceof EntityAIAttackRangedBow) {
itr.remove();
}
if (entry.action instanceof EntityAIAttackRanged) {
containsOld = true;
}
}
if (!containsOld) {
tasks.addTask(4, new EntityAIAttackRanged(skeleton, 1.0D, 20, 15.0F));
}
}
示例14: on
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
@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));
}
}
}
示例15: onPlayerJump
import net.minecraftforge.event.entity.living.LivingEvent; //導入依賴的package包/類
/**
* Used for the Piston Boots to give them their amazing powers.
*
* @param event
*/
@SubscribeEvent
public void onPlayerJump(LivingEvent.LivingJumpEvent event)
{
if (event.entity != null &&
event.entityLiving instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.entity;
if (Wearing.isWearingBoots(player) && player.onGround)
{
ServerActions.pistonBootsJump(player);
}
}
}