public void func_152339_d(Entity p_152339_1_) { if (p_152339_1_ instanceof EntityPlayer) { this.playerNetServerHandler.sendPacket( new S13PacketDestroyEntities(new int[] {p_152339_1_.getEntityId()})); } else { this.destroyedItemsNetCache.add(Integer.valueOf(p_152339_1_.getEntityId())); } }
public static FMLProxyPacket getPacketForRelativeMotion( Entity ent, double motionX, double motionY, double motionZ) { NBTTagCompound data = new NBTTagCompound(); data.setString("command", "Ent_Motion"); data.setInteger("entityID", ent.getEntityId()); data.setDouble("motionX", motionX); data.setDouble("motionY", motionY); data.setDouble("motionZ", motionZ); return getNBTPacket(data, CoroAI.eventChannelName); }
public S2CPacketSpawnGlobalEntity(Entity p_i45191_1_) { this.field_149059_a = p_i45191_1_.getEntityId(); this.field_149057_b = MathHelper.floor_double(p_i45191_1_.posX * 32.0D); this.field_149058_c = MathHelper.floor_double(p_i45191_1_.posY * 32.0D); this.field_149055_d = MathHelper.floor_double(p_i45191_1_.posZ * 32.0D); if (p_i45191_1_ instanceof EntityLightningBolt) { this.field_149056_e = 1; } }
@Override public boolean onUse(final EntityPlayer player) { if (player.worldObj.isRemote) { return false; } Entity targetCl = Minecraft.getMinecraft().pointedEntity; Entity targetSr = null; if (targetCl != null) { targetSr = player.worldObj.getEntityByID(targetCl.getEntityId()); } float base = (float) player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); float extra = new Random().nextFloat() * 1024 / (2048 - this.getExperience(player)); if (targetSr instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) targetSr; if (entity instanceof EntitySlime) { base = Math.min(base / 5, entity.getHealth() - 0.1F); extra = 0F; } entity.attackEntityFrom(DamageSource.causePlayerDamage(player), base); entity.attackEntityFrom(NullaDamageSource.CauseAuroraDamage(player), base * extra); double vx = 0.2D * (entity.posX - player.posX); double vy = 0.2D * (entity.posY - player.posY + 2D); double vz = 0.2D * (entity.posZ - player.posZ); Minecraft.getMinecraft().thePlayer.setVelocity(vx, vy, vz); } else { return false; } if (player.getHeldItem() != null) { player.getHeldItem().damageItem(16, player); } // 随机事件只在服务器发生 if (!player.worldObj.isRemote) { Random rand = new Random(); int exp = rand.nextInt(5) + 1; modifyExperience(player, exp); } return true; }
public static void sendNoSpacePacket(Entity player) { ByteBuf buf = Unpooled.buffer(); ByteBufOutputStream out = new ByteBufOutputStream(buf); try { out.writeByte(2); out.writeInt(player.worldObj.provider.dimensionId); out.writeInt(player.getEntityId()); } catch (IOException e) { } FMLProxyPacket packet = new FMLProxyPacket(buf, "steamcraft"); Steamcraft.channel.sendToServer(packet); try { out.close(); } catch (IOException e) { e.printStackTrace(); } }
// TODO check for side.client??? @Override public void readFrom(ByteBuf buffer, Side side, EntityPlayer player) { int id = buffer.readInt(); String name; while (id != -2) { name = ByteBufUtils.readUTF8String(buffer); Entity ent = Minecraft.getMinecraft().theWorld.getEntityByID(id); if (ent != null && ent instanceof EntityLivingBase) { HatInfo hatInfo = new HatInfo(name); EntityHat hat = new EntityHat(ent.worldObj, (EntityLivingBase) ent, hatInfo); Hats.proxy.tickHandlerClient.mobHats.put(ent.getEntityId(), hat); ent.worldObj.spawnEntityInWorld(hat); } id = buffer.readInt(); } }
@SubscribeEvent public void pokemobMoveMessage(MoveMessageEvent evt) { Entity user = (Entity) evt.sender; if (user.getEntityData().getBoolean("isPlayer") && !user.worldObj.isRemote) { Entity e = user.worldObj.getEntityByID(user.getEntityId()); if (e instanceof EntityPlayer) { EntityPlayer owner = (EntityPlayer) e; PacketBuffer buffer = new PacketBuffer(Unpooled.buffer(10)); buffer.writeByte(PokecubeClientPacket.MOVEMESSAGE); buffer.writeInt(owner.getEntityId()); try { buffer.writeChatComponent(evt.message); } catch (IOException e1) { e1.printStackTrace(); } PokecubeClientPacket mess = new PokecubeClientPacket(buffer); PokecubePacketHandler.sendToClient(mess, (EntityPlayer) owner); } } }
public static void sendConnectPacket( Entity player, int x, int y, int z, MovingObjectPosition pos) { ByteBuf buf = Unpooled.buffer(); ByteBufOutputStream out = new ByteBufOutputStream(buf); try { out.writeByte(4); out.writeInt(player.worldObj.provider.dimensionId); out.writeInt(player.getEntityId()); out.writeInt(x); out.writeInt(y); out.writeInt(z); out.writeInt(pos.subHit); } catch (IOException e) { } FMLProxyPacket packet = new FMLProxyPacket(buf, "steamcraft"); Steamcraft.channel.sendToServer(packet); try { out.close(); } catch (IOException e) { e.printStackTrace(); } }
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg) { ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId); EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId); WorldClient wc = FMLClientHandler.instance().getWorldClient(); Class<? extends Entity> cls = er.getEntityClass(); try { Entity entity; if (er.hasCustomSpawning()) { entity = er.doCustomSpawning(spawnMsg); } else { entity = (Entity) (cls.getConstructor(World.class).newInstance(wc)); int offset = spawnMsg.entityId - entity.getEntityId(); entity.setEntityId(spawnMsg.entityId); entity.setLocationAndAngles( spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch); if (entity instanceof EntityLiving) { ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw; } Entity parts[] = entity.getParts(); if (parts != null) { for (int j = 0; j < parts.length; j++) { parts[j].setEntityId(parts[j].getEntityId() + offset); } } } entity.serverPosX = spawnMsg.rawX; entity.serverPosY = spawnMsg.rawY; entity.serverPosZ = spawnMsg.rawZ; EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity(); if (entity instanceof IThrowableEntity) { Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId); ((IThrowableEntity) entity).setThrower(thrower); } if (spawnMsg.dataWatcherList != null) { entity.getDataWatcher().updateWatchedObjectsFromList((List<?>) spawnMsg.dataWatcherList); } if (spawnMsg.throwerId > 0) { entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ); } if (entity instanceof IEntityAdditionalSpawnData) { ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream); } wc.addEntityToWorld(spawnMsg.entityId, entity); } catch (Exception e) { FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity"); throw Throwables.propagate(e); } }
private EntityPair(Entity a, Entity b) { idA = a.getEntityId(); idB = b.getEntityId(); }
public PacketHackingEntityStart(Entity entity) { entityId = entity.getEntityId(); }
public int getEntityId() { return entity.getEntityId(); }
@Override public float getExplosionResistance( World world, net.minecraft.util.math.BlockPos pos, Entity exploder, Explosion explosion) { return this.getBlockHardness(this.getStateById(exploder.getEntityId()), world, pos) * explosionFactor; }