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


Java Constants類代碼示例

本文整理匯總了Java中net.minecraftforge.common.util.Constants的典型用法代碼示例。如果您正苦於以下問題:Java Constants類的具體用法?Java Constants怎麽用?Java Constants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Constants類屬於net.minecraftforge.common.util包,在下文中一共展示了Constants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onChunkLoad

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@SubscribeEvent
public static void onChunkLoad(ChunkDataEvent.Load event)
{
	World world = event.getWorld();
	ChunkPos chunkPos = event.getChunk().getPos();
	
	IChunkLevelHolder chunkLevelHolder = getChunkLevelHolder(world);
	ChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, getAreaLevel(world, chunkPos));
	
	NBTTagCompound nbt = event.getData();
	
	if (nbt.hasKey(ID.toString(), Constants.NBT.TAG_INT))
	{
		NBTTagInt levelTag = (NBTTagInt) nbt.getTag(ID.toString());
		chunkLevel.deserializeNBT(levelTag);
	}
	
	chunkLevelHolder.setChunkLevel(null, chunkLevel);
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:20,代碼來源:CapabilityChunkLevel.java

示例2: readNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void readNBT(Capability<IHacking> capability, IHacking instance, EnumFacing side, NBTBase nbt) {
    instance.getCurrentHacks().clear();
    NBTTagList tagList = ((NBTTagCompound) nbt).getTagList("hackables", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < tagList.tagCount(); i++) {
        String hackableId = tagList.getCompoundTagAt(i).getString("id");
        Class<? extends IHackableEntity> hackableClass = PneumaticHelmetRegistry.getInstance().stringToEntityHackables.get(hackableId);
        if (hackableClass != null) {
            try {
                instance.getCurrentHacks().add(hackableClass.newInstance());
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            Log.warning("hackable \"" + hackableId + "\" not found when constructing from NBT. Was it deleted?");
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:19,代碼來源:HackingImpl.java

示例3: serializeTank

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
/**
 * Serialize some tank data onto an ItemStack.  Useful to preserve tile entity tank data when breaking
 * the block.
 *
 * @param tank the fluid tank
 * @param stack the itemstack to save to
 * @param tagName name of the tag in the itemstack's NBT to store the tank data
 */
public static void serializeTank(FluidTank tank, ItemStack stack, String tagName) {
    if (tank.getFluidAmount() > 0) {
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
        }
        NBTTagCompound tag = stack.getTagCompound();
        if (!tag.hasKey(SAVED_TANKS, Constants.NBT.TAG_COMPOUND)) {
            tag.setTag(SAVED_TANKS, new NBTTagCompound());
        }
        NBTTagCompound subTag = tag.getCompoundTag(SAVED_TANKS);
        NBTTagCompound tankTag = new NBTTagCompound();
        tank.writeToNBT(tankTag);
        subTag.setTag(tagName, tankTag);
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:24,代碼來源:PneumaticCraftUtils.java

示例4: loadData

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
public void loadData(NBTTagCompound compound, ModelObj model) 
{	
	NBTTagList partList = compound.getTagList("Groups", 10);
	if (compound.hasKey("PartOrder", Constants.NBT.TAG_LIST))
		model.setPartOrderFromList(compound.getTagList("PartOrder", Constants.NBT.TAG_STRING));
	for (int i = 0; i < partList.tagCount(); i++)
	{
		NBTTagCompound partCompound = partList.getCompoundTagAt(i);
		PartObj part = model.getPartObjFromName(partCompound.getString("Name"));
		part.setDisplayName(partCompound.getString("DisplayName"));
		String group = partCompound.getString("Group");
		if(!groups.containsKey(group))
			addGroup(group);
		setPartGroup(group, part);
	}
}
 
開發者ID:ObsidianSuite,項目名稱:ObsidianSuite,代碼行數:17,代碼來源:PartGroups.java

示例5: readNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
public void readNBT(NBTTagCompound nbt, NBTType type) {
    if (type != NBTType.DROP) {
        NBTTagCompound caps = nbt.getCompoundTag("TileBaseCapabilities");
        for (EnumFacing side : EnumFacing.values()) {
            String name = side.toString().toLowerCase(Locale.ROOT);
            if (caps.hasKey(name, Constants.NBT.TAG_COMPOUND)) {
                this.readCapabilities(caps.getCompoundTag(name), side);
            }
        }
        if (caps.hasKey("default", Constants.NBT.TAG_COMPOUND)) {
            this.readCapabilities(caps.getCompoundTag("default"), null);
        }
    } else if (this.getEnergy(null) != null) {
        this.getEnergy(null).receiveEnergy(nbt.getInteger("Energy"), false);
    }
}
 
開發者ID:canitzp,項目名稱:Metalworks,代碼行數:17,代碼來源:TileBase.java

示例6: readFromNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    timeout = compound.getInteger("timeout");
    portalSide = EnumFacing.VALUES[compound.getByte("portalSide")];
    BlockPos pos = BlockPos.fromLong(compound.getLong("pos"));
    int dim = compound.getInteger("dim");
    EnumFacing side = EnumFacing.VALUES[compound.getByte("side")];
    other = new TeleportDestination("", dim, pos, side);
    NBTTagList list = compound.getTagList("bl", Constants.NBT.TAG_COMPOUND);
    blackListed.clear();
    for (int i = 0 ; i < list.tagCount() ; i++) {
        NBTTagCompound tc = list.getCompoundTagAt(i);
        UUID uuid = new UUID(tc.getLong("m"), tc.getLong("l"));
        blackListed.add(uuid);
    }
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:18,代碼來源:PortalTileEntity.java

示例7: readFromNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound tag) {
    NBTTagList list = tag.getTagList("blocks", Constants.NBT.TAG_LONG);
    blocks.clear();
    for (int i = 0; i < list.tagCount(); i++) {
        blocks.add(BlockPos.fromLong(((NBTTagLong) list.get(i)).getLong()));
    }
    list = tag.getTagList("leaves", Constants.NBT.TAG_COMPOUND);
    leavesToTick.clear();
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound tc = list.getCompoundTagAt(i);
        BlockPos pos = BlockPos.fromLong(tc.getLong("p"));
        int counter = tc.getInteger("c");
        leavesToTick.put(pos, counter);
    }
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:17,代碼來源:ChopTreeActionWorker.java

示例8: getDestinations

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
public static List<TeleportDestination> getDestinations(ItemStack stack) {
    List<TeleportDestination> destinations = new ArrayList<>();
    if (!stack.hasTagCompound()) {
        for (int i = 0; i < 8; i++) {
            destinations.add(null);
        }
    } else {
        NBTTagCompound tag = stack.getTagCompound();
        NBTTagList dests = tag.getTagList("dests", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < 8; i++) {
            NBTTagCompound tc = i < dests.tagCount() ? dests.getCompoundTagAt(i) : null;
            if (tc != null && tc.hasKey("dim")) {
                destinations.add(new TeleportDestination(tc));
            } else {
                destinations.add(null);
            }
        }
    }
    return destinations;
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:21,代碼來源:PortalGunItem.java

示例9: deserializeNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void deserializeNBT(NBTBase nbtIn) {
	if (nbtIn instanceof NBTTagCompound) {
		NBTTagCompound nbt = (NBTTagCompound) nbtIn;
		setSize(nbt.hasKey("Size", Constants.NBT.TAG_INT) ? nbt.getInteger("Size") : stacks.size());
		NBTTagList tagList = nbt.getTagList(getName(), Constants.NBT.TAG_COMPOUND);
		for (int i = 0; i < tagList.tagCount(); i++) {
			NBTTagCompound itemTags = tagList.getCompoundTagAt(i);
			int slot = itemTags.getInteger("Slot");

			if (slot >= 0 && slot < stacks.size()) {
				stacks.set(slot, new ItemStack(itemTags));
				stacks.get(slot).setCount(itemTags.getInteger("RealCount"));
			}
		}
		CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(this, null, tagList);
		onLoad();
	}
}
 
開發者ID:p455w0rd,項目名稱:DankNull,代碼行數:20,代碼來源:DankNullItemHandler.java

示例10: getStackInSlot

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public ItemStack getStackInSlot(int slot)
{
    validateSlotIndex(slot);
    NBTTagList tagList = getTag().getTagList("Items", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < tagList.tagCount(); i++)
    {
        NBTTagCompound itemTags = tagList.getCompoundTagAt(i);
        if (itemTags.getInteger("Slot") != slot)
            continue;

        return new ItemStack(itemTags);
    }

    return ItemStack.EMPTY;
}
 
開發者ID:gigaherz,項目名稱:ToolBelt,代碼行數:17,代碼來源:ToolBeltInventory.java

示例11: readFromNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);

	if (compound.getString("ownerUUID") != null) {
		ownerUUID = UUID.fromString(compound.getString("ownerUUID"));
	}

	shopControllerPos = new BlockPos(compound.getInteger("shopx"), compound.getInteger("shopy"), compound.getInteger("shopz"));

	NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);

	for (int i = 0; i < items.tagCount(); ++i) {
		NBTTagCompound item = items.getCompoundTagAt(i);
		int slot = item.getInteger("Slot");

		if (slot >= 0 && slot < getSizeInventory()) {
			inventory.set(slot, new ItemStack(item));
		}
	}
}
 
開發者ID:Zundrel,項目名稱:Never-Enough-Currency,代碼行數:22,代碼來源:TileEntityDisplay.java

示例12: readFromNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
/**
 * A custom method to read our inventory from an ItemStack's NBT compound
 */
public void readFromNBT(NBTTagCompound compound) {
	if ("".equals(uniqueID)) {
		// try to read unique ID from NBT
		uniqueID = compound.getString("uniqueID");
		// if it's still "", assign a new one:
		if ("".equals(uniqueID)) {
			uniqueID = UUID.randomUUID().toString();
		}
	}

	NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);

	for (int i = 0; i < items.tagCount(); ++i) {
		NBTTagCompound item = items.getCompoundTagAt(i);
		int slot = item.getInteger("Slot");

		if (slot >= 0 && slot < getSizeInventory()) {
			inventory.set(slot, new ItemStack(item));
		}
	}
}
 
開發者ID:Zundrel,項目名稱:Never-Enough-Currency,代碼行數:25,代碼來源:InventoryItem.java

示例13: onBlockPlacedBy

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    TileEntity te = worldIn.getTileEntity(pos);
    if (te != null && te instanceof TileCodeStorage)
    {
        TileCodeStorage storage = (TileCodeStorage) te;
        //meta == 0 - lockable; meta == 1 - not lockable
        storage.setLockable(stack.getMetadata() == 0);
        boolean unloc = true;
        if (stack.hasTagCompound())
        {
            NBTTagCompound tag = stack.getTagCompound();
            if(tag.hasKey("data", Constants.NBT.TAG_COMPOUND))
            {
                storage.deserializeMin(tag.getCompoundTag("data"));
                unloc = false;
            }
        }
        if(unloc)
            storage.setUnlocked(true);
    }
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:24,代碼來源:BlockCodeStorage.java

示例14: readFromNBT

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	NBTTagList nbttaglist = nbt.getTagList("Items", 10);
	inventory = new ItemStack[getSizeInventory()];

	for (int i = 0; i < nbttaglist.tagCount(); i++) {
		NBTTagCompound nbt1 = nbttaglist.getCompoundTagAt(i);
		byte b0 = nbt1.getByte("Slot");

		if (b0 >= 0 && b0 < inventory.length)
			inventory[b0] = ItemStack.loadItemStackFromNBT(nbt1);
	}

	brewTime = nbt.getShort("BrewTime");

	if (nbt.hasKey("Fuel", Constants.NBT.TAG_SHORT)) {
		fuel = nbt.getShort("Fuel");
		if (fuel > 0)
			currentFuel = 30;
	} else {
		fuel = nbt.getInteger("Fuel");
		currentFuel = nbt.getInteger("CurrentFuel");
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:26,代碼來源:TileEntityNewBrewingStand.java

示例15: onWorldTick

import net.minecraftforge.common.util.Constants; //導入依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unchecked")
public void onWorldTick(TickEvent.ServerTickEvent event) {
	if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER)
		return;

	if (EtFuturum.enablePlayerSkinOverlay)
		if (playerLoggedInCooldown != null)
			if (--playerLoggedInCooldown <= 0) {
				for (World world : MinecraftServer.getServer().worldServers)
					for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
						NBTTagCompound nbt = player.getEntityData();
						if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) {
							boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY);
							EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex));
						}
					}
				playerLoggedInCooldown = null;
			}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:21,代碼來源:ServerEventHandler.java


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