本文整理汇总了Java中net.minecraftforge.common.IExtendedEntityProperties类的典型用法代码示例。如果您正苦于以下问题:Java IExtendedEntityProperties类的具体用法?Java IExtendedEntityProperties怎么用?Java IExtendedEntityProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IExtendedEntityProperties类属于net.minecraftforge.common包,在下文中一共展示了IExtendedEntityProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
@Override
public void handle(EntityPlayer player) {
Entity entity = player.worldObj.getEntityByID(entityId);
if (entity == null) {
copycore.log.warn("Couldn't find entity to sync to for properties '{}'.", identifier);
return;
}
IExtendedEntityProperties properties = entity.getExtendedProperties(identifier);
if (!(properties instanceof EntityPropertiesBase)) {
copycore.log.warn("No valid syncable properties found for '{}'.", identifier);
return;
}
EntityPropertiesBase syncProperties = (EntityPropertiesBase)properties;
int amount = propertyBuffer.readByte();
for (int i = 0; i < amount; i++)
syncProperties.getPropertyById(propertyBuffer.readByte()).read(propertyBuffer);
}
示例2: onPlayerRespawn
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
/**
* Upon respawn the EntityPlayer is constructed anew, however, with a wrong
* entityID at the moment of EntityConstructing event dispatch. That entityID
* is changed later on, but the ExtendedProperties have already been written
* and cannot be removed. So let us manually copy the required values into
* the existing ExtendedProperties.
*/
@Override
public void onPlayerRespawn(EntityPlayer player) {
IExtendedEntityProperties props = (player.getExtendedProperties(EXT_PROP_STATS));
if (props != null) {
EntityStats oldStats = getOrCreateEntityStats(player);
EntityStats newStats = (EntityStats)props;
newStats.entity = player;
newStats.setGold(oldStats.getReliableGold(), oldStats.getUnreliableGold());
Map<EntityLivingBase, EntityStats> entityStats = getEntityStatsMap(getSide(player));
entityStats.put(player, newStats);
newStats.setMana(newStats.getMaxMana());
newStats.sendSyncPacketToClient(player);
}
}
示例3: visitMethodInsn
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
super.visitMethodInsn(opcode, owner, name, desc);
if (opcode == INVOKEINTERFACE
&& owner.equals(Type.getInternalName(IExtendedEntityProperties.class))
&& name.equals(ieepMethod)) {
Type objectType = Type.getType(Object.class);
Type stringType = Type.getType(String.class);
Type nbtCompType = Type.getObjectType("net/minecraft/nbt/NBTTagCompound");
super.visitVarInsn(ALOAD, lastSavedVar);
super.visitVarInsn(ALOAD, prevLastSavedVar);
super.visitVarInsn(ALOAD, 1);
super.visitMethodInsn(INVOKESTATIC,
Type.getInternalName(ASMHooks.class),
ieepHookMethod,
Type.getMethodDescriptor(VOID_TYPE, objectType, stringType, nbtCompType));
}
}
示例4: clonePlayer
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public void clonePlayer(EntityPlayer p_71049_1_, boolean p_71049_2_)
{
if (p_71049_2_)
{
this.inventory.copyInventory(p_71049_1_.inventory);
setHealth(p_71049_1_.getHealth());
this.foodStats = p_71049_1_.foodStats;
this.experienceLevel = p_71049_1_.experienceLevel;
this.experienceTotal = p_71049_1_.experienceTotal;
this.experience = p_71049_1_.experience;
setScore(p_71049_1_.getScore());
this.teleportDirection = p_71049_1_.teleportDirection;
this.extendedProperties = p_71049_1_.extendedProperties;
for (IExtendedEntityProperties p : this.extendedProperties.values()) {
p.init(this, this.worldObj);
}
}
else if (this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
{
this.inventory.copyInventory(p_71049_1_.inventory);
this.experienceLevel = p_71049_1_.experienceLevel;
this.experienceTotal = p_71049_1_.experienceTotal;
this.experience = p_71049_1_.experience;
setScore(p_71049_1_.getScore());
}
this.theInventoryEnderChest = p_71049_1_.theInventoryEnderChest;
this.spawnChunkMap = p_71049_1_.spawnChunkMap;
this.spawnForcedMap = p_71049_1_.spawnForcedMap;
NBTTagCompound old = p_71049_1_.getEntityData();
if (old.hasKey("PlayerPersisted")) {
getEntityData().setTag("PlayerPersisted", old.getCompoundTag("PlayerPersisted"));
}
MinecraftForge.EVENT_BUS.post(new PlayerEvent.Clone(this, p_71049_1_, !p_71049_2_));
}
示例5: getPlayerMagic
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
private PlayerMagicProperty getPlayerMagic(EntityPlayer player) {
IExtendedEntityProperties property = player.getExtendedProperties(PlayerMagicProperty.KEY);
if (property == null) {
return null;
}
if (!(property instanceof PlayerMagicProperty)) {
return null;
}
return (PlayerMagicProperty) property;
}
示例6: Entity
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
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_);
}
}
示例7: registerExtendedProperties
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
/**
* 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;
}
示例8: get
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public static RacePlayer get(EntityPlayer player) {
IExtendedEntityProperties entityProperties = ExtendedEntityHandler
.getExtended(player, RacePlayer.class);
if (entityProperties != null) {
return (RacePlayer) entityProperties;
}
else {
return null;
}
}
示例9: getIdentifier
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public static String getIdentifier(Class<? extends IExtendedEntityProperties> propertiesClass) {
String identifier = propertiesLookup.get(propertiesClass);
if (identifier == null) {
try { identifier = (String)propertiesClass.getField("IDENTIFIER").get(null); }
catch (Exception e) { throw new Error(e); }
propertiesLookup.put(propertiesClass, identifier);
}
return identifier;
}
示例10: createProperties
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public static <T extends IExtendedEntityProperties> T createProperties(Entity entity, Class<T> propertiesClass) {
try {
T properties = propertiesClass.getConstructor().newInstance();
entity.registerExtendedProperties(getIdentifier(propertiesClass), properties);
return properties;
} catch (Exception e) { throw new Error(e); }
}
示例11: onUpdate
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void onUpdate(ItemStack stack, World world, Entity p, int slot, boolean held) {
checkCompound(stack);
if (this.getDamage(stack) == 1 && !world.isRemote) {
int rangeX = 8;
int rangeY = 4;
int ench = EnchantmentHelper.getEnchantmentLevel(QAEnchant.RANGE.get().effectId, stack);
if (ench > 0) {
rangeX += ench * 2;
rangeY += ench;
}
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(p.posX - rangeX, p.posY - rangeY, p.posZ - rangeY, p.posX + rangeX, p.posY + rangeY, p.posZ + rangeX));
itemLoop:
for (EntityItem item : items) {
IExtendedEntityProperties properties = item.getExtendedProperties("tossData");
if (properties != null) {
PropertiesItem prop = (PropertiesItem) properties;
if (p.getUniqueID().toString().equals(prop.tosser) && item.age <= 300) return;
}
NBTTagList list = (NBTTagList) stack.stackTagCompound.getTag("blacklist");
if (list != null)
for (int i = 0; i < list.tagCount(); i++) {
int dmg = list.getCompoundTagAt(i).getInteger("dmg");
String nm = list.getCompoundTagAt(i).getString("id");
if (item.getEntityItem().getUnlocalizedName().equals(nm) && item.getEntityItem().getItemDamage() == dmg) continue itemLoop;
}
item.delayBeforeCanPickup = 0;
item.setPosition(p.posX, p.posY, p.posZ);
}
}
}
示例12: get
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public static InventoryPersistProperty get(EntityPlayer player)
{
IExtendedEntityProperties property = player.getExtendedProperties(ID);
if(property != null && property instanceof InventoryPersistProperty)
{
return (InventoryPersistProperty)property;
} else
{
return null;
}
}
示例13: Entity
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public Entity(World par1World)
{
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.dataWatcher = new DataWatcher();
this.entityUniqueID = UUID.randomUUID();
this.myEntitySize = EnumEntitySize.SIZE_2;
this.worldObj = par1World;
this.setPosition(0.0D, 0.0D, 0.0D);
if (par1World != null)
{
this.dimension = par1World.provider.dimensionId;
}
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, par1World);
}
}
示例14: onNewEntityProps
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
public static void onNewEntityProps(Entity entity, IExtendedEntityProperties props, String identifier) throws Throwable {
IEEPSyncCompanion companion = (IEEPSyncCompanion) SyncCompanions.newCompanion(props.getClass());
if (companion == null) {
return;
}
List<IEEPSyncCompanion> companions = ((EntityProxy) entity)._sc$getPropsCompanions();
if (companions == null) {
companions = new ArrayList<>();
((EntityProxy) entity)._sc$setPropsCompanions(companions);
}
companion._sc$ieep = props;
companion._sc$entity = entity;
companion._sc$ident = identifier;
// maintain ordering in the list
int len = companions.size();
int index = 0;
for (int i = 0; i < len; i++) {
if (companions.get(i)._sc$ident.compareTo(identifier) >= 0) {
index = i;
break;
}
}
companions.add(index, companion);
}
示例15: getSyncType
import net.minecraftforge.common.IExtendedEntityProperties; //导入依赖的package包/类
static SyncType getSyncType(Class<?> clazz) {
if (TileEntity.class.isAssignableFrom(clazz)) {
return SyncType.TILE_ENTITY;
} else if (Entity.class.isAssignableFrom(clazz)) {
return SyncType.ENTITY;
} else if (Container.class.isAssignableFrom(clazz)) {
return SyncType.CONTAINER;
} else if (IExtendedEntityProperties.class.isAssignableFrom(clazz)) {
return SyncType.ENTITY_PROPS;
} else {
throw new IllegalArgumentException("@Sync in invalid class " + clazz);
}
}