當前位置: 首頁>>代碼示例>>Java>>正文


Java IExtendedEntityProperties類代碼示例

本文整理匯總了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);
}
 
開發者ID:copygirl,項目名稱:copycore,代碼行數:18,代碼來源:MessageSyncProperties.java

示例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);
	}
}
 
開發者ID:Hunternif,項目名稱:Dota2Items,代碼行數:23,代碼來源:StatsTracker.java

示例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));
    }
}
 
開發者ID:diesieben07,項目名稱:SevenCommons,代碼行數:22,代碼來源:EntityNBTHook.java

示例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_));
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:40,代碼來源:EntityPlayer.java

示例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;

}
 
開發者ID:InfinityRaider,項目名稱:Elemancy,代碼行數:12,代碼來源:ItemMagicWeapon.java

示例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_);
    }
}
 
開發者ID:wildex999,項目名稱:TickDynamic,代碼行數:37,代碼來源:Entity.java

示例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;
}
 
開發者ID:wildex999,項目名稱:TickDynamic,代碼行數:35,代碼來源:Entity.java

示例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;
	}
}
 
開發者ID:TheTemportalist,項目名稱:RacesForMinecraft,代碼行數:11,代碼來源:RacePlayer.java

示例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;
}
 
開發者ID:copygirl,項目名稱:copycore,代碼行數:10,代碼來源:EntityUtils.java

示例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); }
}
 
開發者ID:copygirl,項目名稱:copycore,代碼行數:8,代碼來源:EntityUtils.java

示例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);
        }
    }
}
 
開發者ID:MSourceCoded,項目名稱:Quantum-Anomalies,代碼行數:39,代碼來源:ItemRiftMagnet.java

示例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;
	}
}
 
開發者ID:PrinceOfAmber,項目名稱:SamsPowerups,代碼行數:13,代碼來源:InventoryPersistProperty.java

示例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);
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:37,代碼來源:Entity.java

示例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);
}
 
開發者ID:diesieben07,項目名稱:SevenCommons,代碼行數:28,代碼來源:ASMHooks.java

示例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);
    }
}
 
開發者ID:diesieben07,項目名稱:SevenCommons,代碼行數:14,代碼來源:SyncHelpers.java


注:本文中的net.minecraftforge.common.IExtendedEntityProperties類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。