本文整理汇总了Java中net.minecraft.nbt.NBTTagInt类的典型用法代码示例。如果您正苦于以下问题:Java NBTTagInt类的具体用法?Java NBTTagInt怎么用?Java NBTTagInt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NBTTagInt类属于net.minecraft.nbt包,在下文中一共展示了NBTTagInt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChunkLoad
import net.minecraft.nbt.NBTTagInt; //导入依赖的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);
}
示例2: getChildTag
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
private static NBTBase getChildTag(NBTBase p_getChildTag_0_, String p_getChildTag_1_)
{
if (p_getChildTag_0_ instanceof NBTTagCompound)
{
NBTTagCompound nbttagcompound = (NBTTagCompound)p_getChildTag_0_;
return nbttagcompound.getTag(p_getChildTag_1_);
}
else if (p_getChildTag_0_ instanceof NBTTagList)
{
NBTTagList nbttaglist = (NBTTagList)p_getChildTag_0_;
if (p_getChildTag_1_.equals("count"))
{
return new NBTTagInt(nbttaglist.tagCount());
}
else
{
int i = Config.parseInt(p_getChildTag_1_, -1);
return i < 0 ? null : nbttaglist.get(i);
}
}
else
{
return null;
}
}
示例3: serializeNBT
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
@Override
public NBTTagCompound serializeNBT() {
NBTTagCompound nbt=new NBTTagCompound();
nbt.setInteger("Event", eventFlag);
NBTTagCompound items=new NBTTagCompound();
nbt.setTag("Items", items);
NBTTagList bannersS = new NBTTagList();
for(BlockPos pos:banners){
NBTTagList coords = new NBTTagList();
coords.appendTag(new NBTTagInt(pos.getX()));
coords.appendTag(new NBTTagInt(pos.getY()));
coords.appendTag(new NBTTagInt(pos.getZ()));
bannersS.appendTag(coords);
}
nbt.setTag("Banners", bannersS);
for(Entry<String,MerchantRecipeList> entry:lostItems.entrySet()){
items.setTag(entry.getKey(), entry.getValue().getRecipiesAsTags());
}
return nbt;
}
示例4: readFromNBT
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
public void readFromNBT(final NBTTagCompound par1NBTTagCompound) {
super.readFromNBT(par1NBTTagCompound);
if (par1NBTTagCompound.hasKey("block_no") && par1NBTTagCompound.getTag("block_no") instanceof NBTTagInt) {
this.b = par1NBTTagCompound.getInteger("block_no");
}
else {
LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (block_no)", new Object[0]);
}
if (par1NBTTagCompound.hasKey("chunk_no") && par1NBTTagCompound.getTag("chunk_no") instanceof NBTTagByte) {
this.chunk_no = par1NBTTagCompound.getByte("chunk_no");
}
else {
LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (chunk_no)", new Object[0]);
}
if (this.chunk_no == -128) {
this.finished = true;
}
else {
this.setChunk(this.chunk_no);
}
this.tank.readFromNBT(par1NBTTagCompound.getCompoundTag("tank"));
this.init = true;
}
示例5: linkPortalWithOrigin
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
private void linkPortalWithOrigin(EntityPlayer player, World world, ItemStack stack, ControlBlockLocation thisPortal,
PortalLinkerOrigin remoteInfo) {
ControlBlockLocation remotePortal = findControllerBlock(world, remoteInfo.pos, STANDARD_SIZER);
stack.setTagInfo("origin", new NBTTagLong(0));
stack.setTagInfo("dimid", new NBTTagInt(0));
if (remotePortal == null) {
return;
}
linkPortalTo(world, thisPortal, remotePortal, remoteInfo.dimId, remoteInfo.side);
linkPortalTo(world, remotePortal, thisPortal, player.dimension, getSide(player, thisPortal));
playSound(player);
stack.damageItem(1, player);
}
示例6: displayDamageDealt
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
@Override
public void displayDamageDealt(EntityLivingBase entity) {
if (!entity.world.isRemote) {
return;
}
if (!ConfigurationHandler.showDamageParticles) {
return;
}
int currentHealth = (int) Math.ceil(entity.getHealth());
if (entity.getEntityData().hasKey("health")) {
int entityHealth = ((NBTTagInt) entity.getEntityData().getTag("health")).getInt();
if (entityHealth != currentHealth) {
displayParticle(entity, (int) entityHealth - currentHealth);
}
}
entity.getEntityData().setTag("health", new NBTTagInt(currentHealth));
}
示例7: onPlayerLogin
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
@SubscribeEvent
public static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent e) {
if (MCFlux.UPDATE_CHECK_FINISHED && !MCFlux.NEWER_VERSION.isEmpty() && e.player instanceof EntityPlayerMP)
MCFluxNetwork.to(Msg.newVersion(MCFlux.NEWER_VERSION), (EntityPlayerMP) e.player);
if (SpecialEventHandler.getEventStatus() == SpecialEventHandler.EventStatus.DOWNLOADED) {
final SpecialEventReceiver ser = e.player.getCapability(SpecialEventReceiver.SELF_CAP, null);
if (ser != null) {
final int[] seids = SpecialEventHandler.getEventIDs();
for (int l : seids) {
if (ser.alreadyReceived(l))
continue;
final ItemStack is = new ItemStack(MCFluxResources.SPECIAL);
is.setTagInfo("seid", new NBTTagInt(l));
e.player.dropItem(is, false, true);
ser.addReceived(l);
}
}
}
}
示例8: writeToNBT
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
NBTTagCompound itemsMap = new NBTTagCompound();
NBTTagList keys = new NBTTagList();
NBTTagList values = new NBTTagList();
itemsMap.setInteger("size", itemMap.size());
for (Map.Entry<Integer, Integer> ent : itemMap.entrySet()) {
NBTTagInt key = new NBTTagInt(ent.getKey());
NBTTagInt value = new NBTTagInt(ent.getValue());
keys.appendTag(key);
values.appendTag(value);
}
itemsMap.setTag("keys", keys);
itemsMap.setTag("values", values);
compound.setTag("itemsMap", itemsMap);
compound.setTag("items", itemStackHandler.serializeNBT());
return compound;
}
示例9: toNBT
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
public NBTTagCompound toNBT(){
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("x", xPos);
tag.setInteger("y", yPos);
tag.setInteger("z", zPos);
tag.setInteger("width", width);
tag.setInteger("height", height);
tag.setInteger("length", length);
tag.setInteger("world", world.provider.getDimension());
NBTTagList list = new NBTTagList();
for(IBlockState state : blocks){
list.appendTag(new NBTTagInt(Block.getStateId(state)));
}
tag.setTag("blocks", list);
return tag;
}
示例10: asJson
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
private static void asJson(NBTBase tag, StringBuilder builder) {
switch(tag.getId()) {
case NBT.TAG_BYTE: builder.append(((NBTTagByte)tag).getByte()).append('b'); break;
case NBT.TAG_SHORT: builder.append(((NBTTagShort)tag).getByte()).append('b'); break;
case NBT.TAG_INT: builder.append(((NBTTagInt)tag).getInt()); break;
case NBT.TAG_LONG: builder.append(((NBTTagLong)tag).getByte()).append('l'); break;
case NBT.TAG_FLOAT: builder.append(((NBTTagFloat)tag).getFloat()).append('f'); break;
case NBT.TAG_DOUBLE: builder.append(((NBTTagDouble)tag).getDouble()).append('d'); break;
case NBT.TAG_STRING: builder.append('"').append(((NBTTagString)tag).getString()).append('"'); break;
case NBT.TAG_BYTE_ARRAY: builder.append(Arrays.toString(((NBTTagByteArray)tag).getByteArray())); break;
case NBT.TAG_INT_ARRAY: builder.append(Arrays.toString(((NBTTagIntArray)tag).getIntArray())); break;
case NBT.TAG_COMPOUND: asJson((NBTTagCompound) tag, builder); break;
case NBT.TAG_LIST: asJson((NBTTagList) tag, builder); break;
}
}
示例11: Tech
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
private Tech(NBTTagCompound nbt, String name) {
this.name = name;
NBTTagList parents = nbt.getTagList("parents", Lib.NBT.STRING);
for (int idx = 0; idx < parents.tagCount(); idx++) {
String parentName = parents.getStringTagAt(idx);
Tech parent = TechTree.this.getTech(parentName);
addRequirement(parent);
}
NBTTagList sciencePacks = nbt.getTagList("sciencePacks", Lib.NBT.INTEGER);
int[] required = new int[sciencePacks.tagCount()];
for (int idx = 0; idx < sciencePacks.tagCount(); idx++) {
required[idx] = ((NBTTagInt) sciencePacks.get(idx)).getInt();
}
this.sciencePacks = required;
leafTech = nbt.getBoolean("leaf");
if (leafTech)
setLeafTech();
}
示例12: addTechs
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void addTechs(AddTechs t) {
TechTree tree = t.tree;
NBTTagCompound n = t.treeNBTCompound;
NBTTagCompound techs = n.getCompoundTag("techs");
for (Object key : techs.getKeySet()) {
NBTTagCompound tech = techs.getCompoundTag((String) key);
// Almost directly copied from new TechTree.Tech()
Tech techAdded = tree.addTech((String) key);
NBTTagList nbtparents = tech.getTagList("parents", Lib.NBT.STRING);
for (int idx = 0; idx < nbtparents.tagCount(); idx++) {
String parentName = nbtparents.getStringTagAt(idx);
Tech parent = tree.getTech(parentName);
techAdded.addRequirement(parent);
}
NBTTagList sciencePacks = tech.getTagList("sciencePacks", Lib.NBT.INTEGER);
int[] required = new int[sciencePacks.tagCount()];
for (int idx = 0; idx < sciencePacks.tagCount(); idx++) {
required[idx] = ((NBTTagInt) sciencePacks.get(idx)).getInt();
}
techAdded.setSciencePacksNeeded(required);
if (tech.getBoolean("leaf"))
techAdded.setLeafTech();
}
}
示例13: updateRemainingChangeBlocks
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
public static void updateRemainingChangeBlocks(ItemStack stack, World world)
{
ControllerInfo info = new ControllerInfo(stack);
if (info.initialized)
{
int x = info.x, y = info.y, z = info.z;
TileEntity entity = world.getTileEntity(x, y, z);
if (entity instanceof IToggleController)
{
IToggleController controller = (IToggleController) entity;
int max = controller.getMaxChangeBlocks();
int remaining = max != -1 ? controller.getMaxChangeBlocks() - controller.getRegisteredChangeBlockCount() : -1;
if (remaining == 0)
stack.stackSize = 0;
stack.setTagInfo(REMAINING_CHANGE_BLOCKS, new NBTTagInt(remaining));
}
}
}
示例14: createTag
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
/** Creates and returns a primitive NBT tag from a value.
* If the value already is an NBT tag, it is returned instead. */
public static NBTBase createTag(Object value) {
if (value == null)
throw new IllegalArgumentException("value is null");
if (value instanceof NBTBase) return (NBTBase)value;
if (value instanceof Byte) return new NBTTagByte((Byte)value);
if (value instanceof Short) return new NBTTagShort((Short)value);
if (value instanceof Integer) return new NBTTagInt((Integer)value);
if (value instanceof Long) return new NBTTagLong((Long)value);
if (value instanceof Float) return new NBTTagFloat((Float)value);
if (value instanceof Double) return new NBTTagDouble((Double)value);
if (value instanceof String) return new NBTTagString((String)value);
if (value instanceof byte[]) return new NBTTagByteArray((byte[])value);
if (value instanceof int[]) return new NBTTagIntArray((int[])value);
throw new IllegalArgumentException("Can't create an NBT tag of value: " + value);
}
示例15: getObject
import net.minecraft.nbt.NBTTagInt; //导入依赖的package包/类
public static Object getObject(NBTBase base)
{
if(base instanceof NBTTagByte)
return ((NBTTagByte)base).func_150290_f();
if(base instanceof NBTTagShort)
return ((NBTTagShort)base).func_150289_e();
if(base instanceof NBTTagInt)
return ((NBTTagInt)base).func_150287_d();
if(base instanceof NBTTagLong)
return ((NBTTagLong)base).func_150291_c();
if(base instanceof NBTTagFloat)
return ((NBTTagFloat)base).func_150288_h();
if(base instanceof NBTTagDouble)
return ((NBTTagDouble)base).func_150286_g();
if(base instanceof NBTTagByteArray)
return ((NBTTagByteArray)base).func_150292_c();
if(base instanceof NBTTagString)
return ((NBTTagString)base).func_150285_a_();
if(base instanceof NBTTagList)
return base;
if(base instanceof NBTTagCompound)
return ((NBTTagCompound)base);
if(base instanceof NBTTagIntArray)
return ((NBTTagIntArray)base).func_150302_c();
return null;
}