net.minecraftforge.common.IExtendedEntityProperties Java Examples
The following examples show how to use
net.minecraftforge.common.IExtendedEntityProperties.
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: Entity.java From TickDynamic with MIT License | 5 votes |
public Entity(World p_i1582_1_) { this.entityId = nextEntityID++; this.renderDistanceWeight = 1.0D; this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); this.field_70135_K = true; this.width = 0.6F; this.height = 1.8F; this.nextStepDistance = 1; this.rand = new Random(); this.fireResistance = 1; this.firstUpdate = true; this.entityUniqueID = UUID.randomUUID(); this.myEntitySize = Entity.EnumEntitySize.SIZE_2; this.worldObj = p_i1582_1_; this.setPosition(0.0D, 0.0D, 0.0D); if (p_i1582_1_ != null) { this.dimension = p_i1582_1_.provider.dimensionId; } this.dataWatcher = new DataWatcher(this); this.dataWatcher.addObject(0, Byte.valueOf((byte)0)); this.dataWatcher.addObject(1, Short.valueOf((short)300)); this.entityInit(); extendedProperties = new HashMap<String, IExtendedEntityProperties>(); MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this)); for (IExtendedEntityProperties props : this.extendedProperties.values()) { props.init(this, p_i1582_1_); } }
Example #2
Source File: Entity.java From TickDynamic with MIT License | 5 votes |
/** * Register the instance of IExtendedProperties into the entity's collection. * @param identifier The identifier which you can use to retrieve these properties for the entity. * @param properties The instanceof IExtendedProperties to register * @return The identifier that was used to register the extended properties. Empty String indicates an error. If your requested key already existed, this will return a modified one that is unique. */ public String registerExtendedProperties(String identifier, IExtendedEntityProperties properties) { if (identifier == null) { FMLLog.warning("Someone is attempting to register extended properties using a null identifier. This is not allowed. Aborting. This may have caused instability."); return ""; } if (properties == null) { FMLLog.warning("Someone is attempting to register null extended properties. This is not allowed. Aborting. This may have caused instability."); return ""; } String baseIdentifier = identifier; int identifierModCount = 1; while (this.extendedProperties.containsKey(identifier)) { identifier = String.format("%s%d", baseIdentifier, identifierModCount++); } if (baseIdentifier != identifier) { FMLLog.info("An attempt was made to register exended properties using an existing key. The duplicate identifier (%s) has been remapped to %s.", baseIdentifier, identifier); } this.extendedProperties.put(identifier, properties); return identifier; }
Example #3
Source File: Entity.java From TickDynamic with MIT License | 4 votes |
/** * Save the entity to NBT (calls an abstract helper method to write extra data) */ public void writeToNBT(NBTTagCompound p_70109_1_) { try { p_70109_1_.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ})); p_70109_1_.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch})); p_70109_1_.setFloat("FallDistance", this.fallDistance); p_70109_1_.setShort("Fire", (short)this.fire); p_70109_1_.setShort("Air", (short)this.getAir()); p_70109_1_.setBoolean("OnGround", this.onGround); p_70109_1_.setInteger("Dimension", this.dimension); p_70109_1_.setBoolean("Invulnerable", this.invulnerable); p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal); p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); if (customEntityData != null) { p_70109_1_.setTag("ForgeData", customEntityData); } for (String identifier : this.extendedProperties.keySet()) { try { IExtendedEntityProperties props = this.extendedProperties.get(identifier); props.saveNBTData(p_70109_1_); } catch (Throwable t) { FMLLog.severe("Failed to save extended properties for %s. This is a mod issue.", identifier); t.printStackTrace(); } } this.writeEntityToNBT(p_70109_1_); if (this.ridingEntity != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); if (this.ridingEntity.writeMountToNBT(nbttagcompound1)) { p_70109_1_.setTag("Riding", nbttagcompound1); } } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Saving entity NBT"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being saved"); this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } }
Example #4
Source File: Entity.java From TickDynamic with MIT License | 4 votes |
/** * Reads the entity from NBT (calls an abstract helper method to read specialized data) */ public void readFromNBT(NBTTagCompound p_70020_1_) { try { NBTTagList nbttaglist = p_70020_1_.getTagList("Pos", 6); NBTTagList nbttaglist1 = p_70020_1_.getTagList("Motion", 6); NBTTagList nbttaglist2 = p_70020_1_.getTagList("Rotation", 5); this.motionX = nbttaglist1.func_150309_d(0); this.motionY = nbttaglist1.func_150309_d(1); this.motionZ = nbttaglist1.func_150309_d(2); if (Math.abs(this.motionX) > 10.0D) { this.motionX = 0.0D; } if (Math.abs(this.motionY) > 10.0D) { this.motionY = 0.0D; } if (Math.abs(this.motionZ) > 10.0D) { this.motionZ = 0.0D; } this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0); this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1); this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2); this.prevRotationYaw = this.rotationYaw = nbttaglist2.func_150308_e(0); this.prevRotationPitch = this.rotationPitch = nbttaglist2.func_150308_e(1); this.fallDistance = p_70020_1_.getFloat("FallDistance"); this.fire = p_70020_1_.getShort("Fire"); this.setAir(p_70020_1_.getShort("Air")); this.onGround = p_70020_1_.getBoolean("OnGround"); this.dimension = p_70020_1_.getInteger("Dimension"); this.invulnerable = p_70020_1_.getBoolean("Invulnerable"); this.timeUntilPortal = p_70020_1_.getInteger("PortalCooldown"); if (p_70020_1_.hasKey("UUIDMost", 4) && p_70020_1_.hasKey("UUIDLeast", 4)) { this.entityUniqueID = new UUID(p_70020_1_.getLong("UUIDMost"), p_70020_1_.getLong("UUIDLeast")); } this.setPosition(this.posX, this.posY, this.posZ); this.setRotation(this.rotationYaw, this.rotationPitch); if (p_70020_1_.hasKey("ForgeData")) { customEntityData = p_70020_1_.getCompoundTag("ForgeData"); } for (String identifier : this.extendedProperties.keySet()) { try { IExtendedEntityProperties props = this.extendedProperties.get(identifier); props.loadNBTData(p_70020_1_); } catch (Throwable t) { FMLLog.severe("Failed to load extended properties for %s. This is a mod issue.", identifier); t.printStackTrace(); } } //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly if (p_70020_1_.hasKey("PersistentIDMSB") && p_70020_1_.hasKey("PersistentIDLSB")) { this.entityUniqueID = new UUID(p_70020_1_.getLong("PersistentIDMSB"), p_70020_1_.getLong("PersistentIDLSB")); } this.readEntityFromNBT(p_70020_1_); if (this.shouldSetPosAfterLoading()) { this.setPosition(this.posX, this.posY, this.posZ); } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded"); this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } }
Example #5
Source File: EntityDrone.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public IExtendedEntityProperties getProperty(String key){ return getExtendedProperties(key); }
Example #6
Source File: EntityDrone.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void setProperty(String key, IExtendedEntityProperties property){ registerExtendedProperties(key, property); }
Example #7
Source File: TileEntityProgrammableController.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public IExtendedEntityProperties getProperty(String key){ return properties.get(key); }
Example #8
Source File: TileEntityProgrammableController.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void setProperty(String key, IExtendedEntityProperties property){ properties.put(key, property); }
Example #9
Source File: Entity.java From TickDynamic with MIT License | 2 votes |
/** * Gets the extended properties identified by the passed in key * @param identifier The key that identifies the extended properties. * @return The instance of IExtendedProperties that was found, or null. */ public IExtendedEntityProperties getExtendedProperties(String identifier) { return this.extendedProperties.get(identifier); }
Example #10
Source File: IDrone.java From PneumaticCraft with GNU General Public License v3.0 | votes |
public IExtendedEntityProperties getProperty(String key);
Example #11
Source File: IDrone.java From PneumaticCraft with GNU General Public License v3.0 | votes |
public void setProperty(String key, IExtendedEntityProperties property);