/** * Handles the creation of a nearby player entity, sets the position and held item */ public void handleSpawnPlayer(SPacketSpawnPlayer packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.world, this.getPlayerInfo(packetIn.getUniqueId()).getGameProfile()); entityotherplayermp.prevPosX = d0; entityotherplayermp.lastTickPosX = d0; entityotherplayermp.prevPosY = d1; entityotherplayermp.lastTickPosY = d1; entityotherplayermp.prevPosZ = d2; entityotherplayermp.lastTickPosZ = d2; EntityTracker.updateServerPosition(entityotherplayermp, d0, d1, d2); entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entityotherplayermp); List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries(); if (list != null) { entityotherplayermp.getDataManager().setEntryValues(list); } }
/** * Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity * itself if a player. */ private void sendMetadataToAllAssociatedPlayers() { EntityDataManager entitydatamanager = this.trackedEntity.getDataManager(); if (entitydatamanager.isDirty()) { this.sendToTrackingAndSelf(new SPacketEntityMetadata(this.trackedEntity.getEntityId(), entitydatamanager, false)); } if (this.trackedEntity instanceof EntityLivingBase) { AttributeMap attributemap = (AttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap(); Set<IAttributeInstance> set = attributemap.getAttributeInstanceSet(); if (!set.isEmpty()) { this.sendToTrackingAndSelf(new SPacketEntityProperties(this.trackedEntity.getEntityId(), set)); } set.clear(); } }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readVarIntFromBuffer(); this.uniqueId = buf.readUuid(); this.type = buf.readVarIntFromBuffer(); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.yaw = buf.readByte(); this.pitch = buf.readByte(); this.headPitch = buf.readByte(); this.velocityX = buf.readShort(); this.velocityY = buf.readShort(); this.velocityZ = buf.readShort(); this.dataManagerEntries = EntityDataManager.readEntries(buf); }
@Override public void fromBytes(ByteBuf buf) { entityID = buf.readInt(); healTarget = buf.readInt(); try { entries = EntityDataManager.readEntries(new PacketBuffer(buf)); //System.out.println("Entries rec: "+(entries != null ? entries.size() : 0)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* * try { tag=CompressedStreamTools.read(new ByteBufInputStream(buf), * new NBTSizeTracker(2097152L)); } catch (IOException e) { // TODO * Auto-generated catch block e.printStackTrace(); } */ }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(entityID); buf.writeInt(healTarget); //System.out.println("Entries: "+entries.size()); try { EntityDataManager.writeEntries(entries,new PacketBuffer(buf)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* * try { CompressedStreamTools.write(tag, new * ByteBufOutputStream(buf)); } catch (IOException e) { // TODO * Auto-generated catch block e.printStackTrace(); } */ }
public WeaponsCapability(EntityLivingBase entity) { this.owner = entity; this.dataManager = new EntityDataManager(entity); this.dataManager.register(CRIT_TIME, 0); this.dataManager.register(HEADS, 0); this.dataManager.register(HEAL_TARGET, -1); this.dataManager.register(PHLOG_RAGE, 0f); this.dataManager.register(KNOCKBACK_RAGE, 0f); this.dataManager.register(METAL, MAX_METAL); this.dataManager.register(FEIGN, false); this.dataManager.register(INVIS, false); this.dataManager.register(DISGUISED, false); this.dataManager.register(DISGUISE_TYPE, ""); this.dataManager.register(EXP_JUMP, false); this.dataManager.register(CHARGING, false); //this.nextBossTicks = (int) (entity.world.getWorldTime() + entity.getRNG().nextInt(360000)); }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readVarIntFromBuffer(); this.uniqueId = buf.readUuid(); this.type = buf.readByte() & 255; this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.yaw = buf.readByte(); this.pitch = buf.readByte(); this.headPitch = buf.readByte(); this.velocityX = buf.readShort(); this.velocityY = buf.readShort(); this.velocityZ = buf.readShort(); this.dataManagerEntries = EntityDataManager.readEntries(buf); }
/** * Handles the creation of a nearby player entity, sets the position and held item */ public void handleSpawnPlayer(SPacketSpawnPlayer packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.theWorld, this.getPlayerInfo(packetIn.getUniqueId()).getGameProfile()); entityotherplayermp.prevPosX = d0; entityotherplayermp.lastTickPosX = d0; entityotherplayermp.prevPosY = d1; entityotherplayermp.lastTickPosY = d1; entityotherplayermp.prevPosZ = d2; entityotherplayermp.lastTickPosZ = d2; EntityTracker.updateServerPosition(entityotherplayermp, d0, d1, d2); entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entityotherplayermp); List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries(); if (list != null) { entityotherplayermp.getDataManager().setEntryValues(list); } }
@Override public boolean execute(EntityPlayerMP target) { for (int i = 0; i < 15; i++) { EntityCreeper creeper = new EntityCreeper(target.world); EXPLOSION_RADIUS.set(creeper, 0); EntityDataManager watcher = creeper.getDataManager(); watcher.set(POWERED_DATA_PARAMETER.get(null), true); creeper.setPosition(target.posX + 20 * (random.nextFloat() - 0.5), target.posY + 5 * (1 + random.nextFloat()), target.posZ + 20 * (random.nextFloat() - 0.5)); target.world.spawnEntity(creeper); } return true; }
@Override public EntityDataManager getDataManager() { if (m_realPlayer == null) { return super.getDataManager(); } else { syncToRealPlayer(); return syncPublicFieldsFromRealAndReturn(m_realPlayer.getDataManager()); } }
@Override public EntityDataManager getDataManager() { if (m_realPlayer == null) { return super.getDataManager(); } else { return m_realPlayer.getDataManager(); } }
@Override public EntityMetadata createSnapshot(EntityMetadata metadata) { EntityDataManager manager = new EntityDataManager((net.minecraft.entity.Entity)metadata.getEntity()); List<DataEntry<?>> entries = ((EntityDataManager)metadata).getAll(); if(entries != null) { for(DataEntry<?> entry : entries) { register(manager, entry); } } return (EntityMetadata)manager; }
public Entity(World worldIn) { this.entityId = nextEntityID++; this.riddenByEntities = Lists.<Entity>newArrayList(); this.boundingBox = ZERO_AABB; this.width = 0.6F; this.height = 1.8F; this.nextStepDistance = 1; this.rand = new Random(); this.field_190534_ay = -this.func_190531_bD(); this.firstUpdate = true; this.entityUniqueID = MathHelper.getRandomUUID(this.rand); this.cachedUniqueIdString = this.entityUniqueID.toString(); this.cmdResultStats = new CommandResultStats(); this.tags = Sets.<String>newHashSet(); this.field_191505_aI = new double[] {0.0D, 0.0D, 0.0D}; this.world = worldIn; this.setPosition(0.0D, 0.0D, 0.0D); if (worldIn != null) { this.dimension = worldIn.provider.getDimensionType().getId(); } this.dataManager = new EntityDataManager(this); this.dataManager.register(FLAGS, Byte.valueOf((byte)0)); this.dataManager.register(AIR, Integer.valueOf(300)); this.dataManager.register(CUSTOM_NAME_VISIBLE, Boolean.valueOf(false)); this.dataManager.register(CUSTOM_NAME, ""); this.dataManager.register(SILENT, Boolean.valueOf(false)); this.dataManager.register(NO_GRAVITY, Boolean.valueOf(false)); this.entityInit(); }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readVarIntFromBuffer(); this.uniqueId = buf.readUuid(); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.yaw = buf.readByte(); this.pitch = buf.readByte(); this.dataManagerEntries = EntityDataManager.readEntries(buf); }
public SPacketEntityMetadata(int entityIdIn, EntityDataManager dataManagerIn, boolean sendAll) { this.entityId = entityIdIn; if (sendAll) { this.dataManagerEntries = dataManagerIn.getAll(); dataManagerIn.setClean(); } else { this.dataManagerEntries = dataManagerIn.getDirty(); } }
@Override void fromBytes(ByteBuf dat) { super.fromBytes(dat); modId = ByteBufUtils.readUTF8String(dat); modEntityTypeId = dat.readInt(); entityUUID = new UUID(dat.readLong(), dat.readLong()); rawX = dat.readDouble(); rawY = dat.readDouble(); rawZ = dat.readDouble(); scaledYaw = dat.readByte() * 360F / 256F; scaledPitch = dat.readByte() * 360F / 256F; scaledHeadYaw = dat.readByte() * 360F / 256F; try { dataWatcherList = EntityDataManager.readEntries(new PacketBuffer(dat)); } catch (IOException e) { FMLLog.log(Level.FATAL, e, "There was a critical error decoding the datawatcher stream for a mod entity."); throw Throwables.propagate(e); } throwerId = dat.readInt(); if (throwerId != 0) { speedScaledX = dat.readInt() / 8000D; speedScaledY = dat.readInt() / 8000D; speedScaledZ = dat.readInt() / 8000D; } this.dataStream = dat; }
public Entity(World worldIn) { this.entityId = nextEntityID++; this.riddenByEntities = Lists.<Entity>newArrayList(); this.boundingBox = ZERO_AABB; this.width = 0.6F; this.height = 1.8F; this.nextStepDistance = 1; this.rand = new Random(); this.fireResistance = 1; this.firstUpdate = true; this.entityUniqueID = MathHelper.getRandomUuid(this.rand); this.cachedUniqueIdString = this.entityUniqueID.toString(); this.cmdResultStats = new CommandResultStats(); this.emptyItemStackList = Lists.<ItemStack>newArrayList(); this.tags = Sets.<String>newHashSet(); this.worldObj = worldIn; this.setPosition(0.0D, 0.0D, 0.0D); if (worldIn != null) { this.dimension = worldIn.provider.getDimension(); } this.dataManager = new EntityDataManager(this); this.dataManager.register(FLAGS, Byte.valueOf((byte)0)); this.dataManager.register(AIR, Integer.valueOf(300)); this.dataManager.register(CUSTOM_NAME_VISIBLE, Boolean.valueOf(false)); this.dataManager.register(CUSTOM_NAME, ""); this.dataManager.register(SILENT, Boolean.valueOf(false)); this.dataManager.register(NO_GRAVITY, Boolean.valueOf(false)); this.entityInit(); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this); }
@Nullable @SideOnly(Side.CLIENT) public List < EntityDataManager.DataEntry<? >> getDataManagerEntries() { if (this.dataManagerEntries == null) { this.dataManagerEntries = this.watcher.getAll(); } return this.dataManagerEntries; }
@Nullable @SideOnly(Side.CLIENT) public List < EntityDataManager.DataEntry<? >> getDataManagerEntries() { if (this.dataManagerEntries == null) { this.dataManagerEntries = this.dataManager.getAll(); } return this.dataManagerEntries; }
public SPacketEntityMetadata(int entityIdIn, EntityDataManager dataManagerIn, boolean sendAll) { this.entityId = entityIdIn; if (sendAll) { this.dataManagerEntries = dataManagerIn.getAll(); } else { this.dataManagerEntries = dataManagerIn.getDirty(); } }
@Override public void fromBytes(ByteBuf buffer) { this.entityID = buffer.readInt(); try { this.entries = EntityDataManager.readEntries(new PacketBuffer(buffer)); } catch (IOException e) { e.printStackTrace(); } }
@Override public void toBytes(ByteBuf buffer) { buffer.writeInt(this.entityID); try { EntityDataManager.writeEntries(this.entries, new PacketBuffer(buffer)); } catch (IOException e) { e.printStackTrace(); } }
public AbstractEntityFrozen(World world) { super(world); this.isImmuneToFire = true; this.firstUpdate = false; this.dataManager = new EntityDataManager(this); this.motionX = 0; this.motionY = 0; this.motionZ = 0; this.rotationYaw = 0; this.rotationPitch = 0; this.prevRotationYaw = 0; this.prevRotationPitch = 0; }
public Entity(World worldIn) { this.entityId = nextEntityID++; this.riddenByEntities = Lists.<Entity>newArrayList(); this.boundingBox = ZERO_AABB; this.width = 0.6F; this.height = 1.8F; this.nextStepDistance = 1; this.rand = new Random(); this.fireResistance = 1; this.firstUpdate = true; this.entityUniqueID = MathHelper.getRandomUuid(this.rand); this.cachedUniqueIdString = this.entityUniqueID.toString(); this.cmdResultStats = new CommandResultStats(); this.emptyItemStackList = Lists.<ItemStack>newArrayList(); this.tags = Sets.<String>newHashSet(); this.worldObj = worldIn; this.setPosition(0.0D, 0.0D, 0.0D); if (worldIn != null) { this.dimension = worldIn.provider.getDimension(); } this.dataManager = new EntityDataManager(this); this.dataManager.register(FLAGS, Byte.valueOf((byte)0)); this.dataManager.register(AIR, Integer.valueOf(300)); this.dataManager.register(CUSTOM_NAME_VISIBLE, Boolean.valueOf(false)); this.dataManager.register(CUSTOM_NAME, ""); this.dataManager.register(SILENT, Boolean.valueOf(false)); this.dataManager.register(field_189655_aD, Boolean.valueOf(false)); this.entityInit(); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this); }
public DataManagerWrapper(EntityPlayer player, EntityDataManager parent) { super(player); this.player = player; this.parent = parent; }
/** * Spawns the mob entity at the specified location, with the specified rotation, momentum and type. Updates the * entities Datawatchers with the entity metadata specified in the packet */ public void handleSpawnMob(SPacketSpawnMob packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.createEntityByID(packetIn.getEntityType(), this.gameController.world); if (entitylivingbase != null) { EntityTracker.updateServerPosition(entitylivingbase, d0, d1, d2); entitylivingbase.renderYawOffset = (float)(packetIn.getHeadPitch() * 360) / 256.0F; entitylivingbase.rotationYawHead = (float)(packetIn.getHeadPitch() * 360) / 256.0F; Entity[] aentity = entitylivingbase.getParts(); if (aentity != null) { int i = packetIn.getEntityID() - entitylivingbase.getEntityId(); for (Entity entity : aentity) { entity.setEntityId(entity.getEntityId() + i); } } entitylivingbase.setEntityId(packetIn.getEntityID()); entitylivingbase.setUniqueId(packetIn.getUniqueId()); entitylivingbase.setPositionAndRotation(d0, d1, d2, f, f1); entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F); entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F); entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entitylivingbase); List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries(); if (list != null) { entitylivingbase.getDataManager().setEntryValues(list); } } else { LOGGER.warn("Skipping Entity with id {}", new Object[] {Integer.valueOf(packetIn.getEntityType())}); } }
private <T> void register(EntityDataManager manager, DataEntry<T> entry) { manager.register(entry.getKey(), entry.getValue()); }
@Override public void setMetadata(EntityMetadata metadata) { dataManager = (EntityDataManager)metadata; }
@Inject(method = "<init>(ILnet/minecraft/network/datasync/EntityDataManager;Z)V", at = @At("RETURN")) public void onConstructed(int id, EntityDataManager manager, boolean sendAll, CallbackInfo ci) { packetMetadata = (EntityMetadata)manager; }
@Override public void setMetadata(EntityMetadata metadata) { dataManagerEntries = ((EntityDataManager)metadata).getAll(); packetMetadata = metadata; }
@Override public void setMetadata(EntityMetadata metadata) { watcher = (EntityDataManager)metadata; }
public EntityDataManager getDataManager() { return this.dataManager; }
@Nullable public List < EntityDataManager.DataEntry<? >> getDataManagerEntries() { return this.dataManagerEntries; }
/** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readVarIntFromBuffer(); this.dataManagerEntries = EntityDataManager.readEntries(buf); }