本文整理了Java中net.minecraft.entity.Entity.getEntityWorld()
方法的一些代码示例,展示了Entity.getEntityWorld()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getEntityWorld()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getEntityWorld
暂无
代码示例来源:origin: SleepyTrousers/EnderIO
public static boolean isPlayerWithinRange(@Nonnull Entity entity, double range) {
List<EntityPlayer> res = entity.getEntityWorld().getEntitiesWithinAABB(EntityPlayer.class, getBoundsAround(entity, range));
return !res.isEmpty();
}
代码示例来源:origin: TeamLapen/Vampirism
/**
* Syncs the entity to players tracking this entity using the given data
* Entity has to implement {@link ISyncable}
*
* @param entity
*/
public static void sync(Entity entity, NBTTagCompound data) {
if (!entity.getEntityWorld().isRemote) {
IMessage m = UpdateEntityPacket.create(entity, data);
VampLib.dispatcher.sendToAllTrackingPlayers(m, entity);
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
public static double getDistanceSqToNearestPlayer(@Nonnull Entity entity, double maxRange) {
AxisAlignedBB bounds = getBoundsAround(entity, maxRange);
EntityPlayer nearest = (EntityPlayer) entity.getEntityWorld().findNearestEntityWithinAABB(EntityPlayer.class, bounds, entity);
if (nearest == null) {
return 1;
}
return nearest.getDistanceSq(entity);
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
public void dataChanged(Entity entity) {
if ((entity != null) && entity instanceof EntityPlayer && !entity.getEntityWorld().isRemote)
PacketHandler.NETWORK.sendTo(new PacketUpdateCaps(serializeNBT()), (EntityPlayerMP) entity);
}
}
代码示例来源:origin: OpenModularTurretsTeam/OpenModularTurrets
public static boolean canDamageEntity(Entity entity, TurretBase base) {
if (entity != null && !entity.getEntityWorld().isRemote && !(entity instanceof TurretProjectile)) {
if (entity instanceof EntityTameable) {
EntityLivingBase entityOwner = ((EntityTameable) entity).getOwner();
if (entityOwner instanceof EntityPlayer) {
EntityPlayer owner = (EntityPlayer) entityOwner;
return !isPlayerOwner(owner, base) && !isPlayerTrusted(owner, base);
}
}
}
return true;
}
代码示例来源:origin: SquidDev-CC/plethora
@Nonnull
@Override
public IWorldLocation safeGet() throws LuaException {
Entity entity = pocket.getEntity();
if (entity == null) {
throw new LuaException("Entity is not there");
} else {
return new WorldLocation(entity.getEntityWorld(), entity.getPosition());
}
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
public void dataChanged(Entity entity) {
if ((entity != null) && entity instanceof EntityPlayer && !entity.getEntityWorld().isRemote)
PacketHandler.NETWORK.sendTo(new PacketUpdateCaps(serializeNBT()), (EntityPlayerMP) entity);
}
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
public void dataChanged(Entity entity) {
if (entity instanceof EntityPlayer && !entity.getEntityWorld().isRemote)
PacketHandler.NETWORK.sendTo(new PacketUpdateCaps(serializeNBT()), (EntityPlayerMP) entity);
}
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
if (!world.isRemote && entity instanceof EntityLiving)
if (entity.getEntityWorld().getBlockState(pos).getBlock() == ModBlocks.INSECT_REPELLENT && ((EntityLiving) entity).getCreatureAttribute().equals(EnumCreatureAttribute.ARTHROPOD)) {
int Knockback = 1;
entity.addVelocity(MathHelper.sin(entity.rotationYaw * 3.141593F / 180.0F) * Knockback * 0.1F, 0.1D, MathHelper.cos(entity.rotationYaw * 3.141593F / 180.0F) * Knockback * 0.1F);
entity.getEntityWorld().playSound(null, pos, SoundEvents.ENTITY_PLAYER_SMALL_FALL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
}
代码示例来源:origin: SquidDev-CC/plethora
@Override
public void update(@Nonnull IVehicleAccess vehicle, @Nonnull IPeripheral peripheral) {
Entity entity = vehicle.getVehicle();
update(entity.getEntityWorld(), entity.getPositionVector());
if (peripheral instanceof ModemPeripheral) {
ModemPeripheral modem = (ModemPeripheral) peripheral;
if (modem.pollChanged()) {
vehicle.getData().setBoolean("active", modem.isActive());
vehicle.markDataDirty();
}
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
if(event.getEntity().getEntityWorld().isRemote || !(event.getEntity() instanceof EntityChicken))
return;
EntityChicken chicken = (EntityChicken) event.getEntity();
if((chicksDropFeathers || !chicken.isChild()) && chicken.getEntityWorld().rand.nextInt(dropFreq) == 0)
chicken.dropItem(Items.FEATHER, 1);
}
代码示例来源:origin: iLexiconn/LLibrary
@Override
public void deserializeNBT(NBTBase nbt) {
Capability<IEntityDataCapability> capability = LLibrary.ENTITY_DATA_CAPABILITY;
IEntityDataCapability instance = capability.getDefaultInstance();
instance.init(event.getEntity(), event.getEntity().getEntityWorld(), true);
capability.getStorage().readNBT(capability, instance, null, nbt);
}
代码示例来源:origin: WesCook/Nutrition
@SubscribeEvent
public void AttachCapabilitiesEvent(AttachCapabilitiesEvent<Entity> event) {
Entity entity = event.getObject();
// Only check against players
if (!(entity instanceof EntityPlayer))
return;
// Start tracking nutrition
if (!entity.getEntityWorld().isRemote) // Server
event.addCapability(new ResourceLocation(Nutrition.MODID, "nutrition"), new CapabilityManager.Provider()); // Attach capability to player
else // Client
ClientProxy.localNutrition = new SimpleImpl(); // Initialize local dummy copy
}
代码示例来源:origin: TehNut/HWYLA
public RayTraceResult rayTrace(Entity entity, double playerReach, float partialTicks) {
Vec3d eyePosition = entity.getPositionEyes(partialTicks);
Vec3d lookVector = entity.getLook(partialTicks);
Vec3d traceEnd = eyePosition.addVector(lookVector.x * playerReach, lookVector.y * playerReach, lookVector.z * playerReach);
return entity.getEntityWorld().rayTraceBlocks(eyePosition, traceEnd, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
}
代码示例来源:origin: Vazkii/Psi
public static RayTraceResult raycast(Entity e, double len) throws SpellRuntimeException {
Vector3 vec = Vector3.fromEntity(e);
if(e instanceof EntityPlayer)
vec.add(0, e.getEyeHeight(), 0);
Vec3d look = e.getLookVec();
if(look == null)
throw new SpellRuntimeException(SpellRuntimeException.NULL_VECTOR);
return raycast(e.getEntityWorld(), vec, new Vector3(look), len);
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
if(event.getEntityLiving() instanceof EntityWitch && (!verifyTruePlayer || event.getSource().getTrueSource() instanceof EntityPlayer) && Math.random() < dropRate + lootingBoost * event.getLootingLevel())
event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, new ItemStack(witch_hat)));
}
代码示例来源:origin: WayofTime/BloodMagic
public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range) {
int targX = MathHelper.floor(targetEntity.posX);
int targY = MathHelper.floor(targetEntity.posY + 1.0D);
int targZ = MathHelper.floor(targetEntity.posZ);
PathFinder pf = new PathFinder(new WalkNodeProcessor());
return pf.findPath(targetEntity.getEntityWorld(), (EntityLiving) entity, new BlockPos(targX, targY, targZ), range);
}
代码示例来源:origin: TehNut/HWYLA
public static RayTraceResult rayTraceServer(Entity entity, double distance) {
double eyeHeight = entity.posY + entity.getEyeHeight();
Vec3d headVec = new Vec3d(entity.posX, eyeHeight, entity.posZ);
Vec3d start = new Vec3d(headVec.x, headVec.y, headVec.z);
Vec3d lookVec = entity.getLook(1.0F);
headVec.add(new Vec3d(lookVec.x * distance, lookVec.y * distance, lookVec.z * distance));
return entity.getEntityWorld().rayTraceBlocks(start, headVec, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
Entity e = event.getEntity();
if(e.hasCustomName() && e instanceof EntitySnowman && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityWitch) {
EntitySnowman snowman = (EntitySnowman) e;
if(snowman.isPumpkinEquipped()) {
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(stack, "SkullOwner", e.getCustomNameTag());
event.getDrops().add(new EntityItem(e.getEntityWorld(), e.posX, e.posY, e.posZ, stack));
}
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onEntityTick(LivingUpdateEvent event) {
if(event.getEntityLiving() instanceof EntityDragon && !event.getEntity().getEntityWorld().isRemote) {
EntityDragon dragon = (EntityDragon) event.getEntity();
if(dragon.getFightManager() != null && dragon.getFightManager().hasPreviouslyKilledDragon() && dragon.deathTicks == 100) {
EntityItem item = new EntityItem(dragon.world, dragon.posX, dragon.posY, dragon.posZ, new ItemStack(enderdragonScale, dropped));
dragon.world.spawnEntity(item);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!