@Nullable /** * Loads the specified(XZ) chunk into the specified world. */ public Chunk loadChunk(World worldIn, int x, int z) throws IOException { ChunkPos chunkpos = new ChunkPos(x, z); NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkpos); if (nbttagcompound == null) { DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z); if (datainputstream == null) { return null; } nbttagcompound = this.dataFixer.process(FixTypes.CHUNK, CompressedStreamTools.read(datainputstream)); } return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound); }
public static void func_190533_a(DataFixer p_190533_0_) { p_190533_0_.registerWalker(FixTypes.ENTITY, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if (compound.hasKey("Passengers", 9)) { NBTTagList nbttaglist = compound.getTagList("Passengers", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { nbttaglist.set(i, fixer.process(FixTypes.ENTITY, nbttaglist.getCompoundTagAt(i), versionIn)); } } return compound; } }); }
public static void func_191522_a(DataFixer p_191522_0_) { p_191522_0_.registerWalker(FixTypes.PLAYER, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if (compound.hasKey("RootVehicle", 10)) { NBTTagCompound nbttagcompound = compound.getCompoundTag("RootVehicle"); if (nbttagcompound.hasKey("Entity", 10)) { nbttagcompound.setTag("Entity", fixer.process(FixTypes.ENTITY, nbttagcompound.getCompoundTag("Entity"), versionIn)); } } return compound; } }); }
@Nullable /** * called during player login. reads the player information from disk. */ public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP playerIn) { NBTTagCompound nbttagcompound = this.mcServer.worldServers[0].getWorldInfo().getPlayerNBTTagCompound(); NBTTagCompound nbttagcompound1; if (playerIn.getName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null) { nbttagcompound1 = this.mcServer.getDataFixer().process(FixTypes.PLAYER, nbttagcompound); playerIn.readFromNBT(nbttagcompound1); LOG.debug("loading single player"); } else { nbttagcompound1 = this.playerNBTManagerObj.readPlayerData(playerIn); } return nbttagcompound1; }
public Object[] loadChunk__Async(World worldIn, int x, int z) throws IOException { ChunkPos chunkpos = new ChunkPos(x, z); NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkpos); if (nbttagcompound == null) { DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z); if (datainputstream == null) { return null; } nbttagcompound = this.dataFixer.process(FixTypes.CHUNK, CompressedStreamTools.read(datainputstream)); } return this.checkedReadChunkFromNBT__Async(worldIn, x, z, nbttagcompound); }
public static WorldInfo loadAndFix(File file, DataFixer fixer, SaveHandler save) { try { NBTTagCompound nbt = CompressedStreamTools.readCompressed(new FileInputStream(file)); WorldInfo info = new WorldInfo(fixer.process(FixTypes.LEVEL, nbt.getCompoundTag("Data"))); net.minecraftforge.fml.common.FMLCommonHandler.instance().handleWorldDataLoad(save, info, nbt); return info; } catch (net.minecraftforge.fml.common.StartupQuery.AbortedException e) { throw e; } catch (Exception exception) { LOGGER.error((String)("Exception reading " + file), (Throwable)exception); return null; } }
/** * called during player login. reads the player information from disk. */ public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP playerIn) { NBTTagCompound nbttagcompound = this.mcServer.worldServers[0].getWorldInfo().getPlayerNBTTagCompound(); NBTTagCompound nbttagcompound1; if (playerIn.getName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null) { nbttagcompound1 = this.mcServer.getDataFixer().process(FixTypes.PLAYER, nbttagcompound); playerIn.readFromNBT(nbttagcompound1); LOG.debug("loading single player"); net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(playerIn, this.playerNBTManagerObj, playerIn.getUniqueID().toString()); } else { nbttagcompound1 = this.playerNBTManagerObj.readPlayerData(playerIn); } return nbttagcompound1; }
public IvWorldData(NBTTagCompound compound, MCRegistry registry) { compound = compound.copy(); // Copy since ID fix tags are being removed when being applied final DataFixer fixer = DataFixesManager.createFixer(); blockCollection = new IvBlockCollection(compound.getCompoundTag("blockCollection"), registry); tileEntities = new ArrayList<>(); tileEntities.addAll(NBTTagLists.compoundsFrom(compound, "tileEntities")); tileEntities.forEach(teCompound -> NBTStateInjector.recursivelyApply(teCompound, registry, false)); tileEntities.replaceAll(teCompound -> fixer.process(FixTypes.BLOCK_ENTITY, teCompound)); entities = new ArrayList<>(); entities.addAll(NBTTagLists.compoundsFrom(compound, "entities")); entities.forEach(entityCompound -> NBTStateInjector.recursivelyApply(entityCompound, registry, false)); tileEntities.replaceAll(teCompound -> fixer.process(FixTypes.ENTITY, teCompound)); }
public static void func_189670_a(DataFixer p_189670_0_) { EntityMinecart.func_189669_a(p_189670_0_, "MinecartCommandBlock"); p_189670_0_.registerWalker(FixTypes.ENTITY, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if ("MinecartCommandBlock".equals(compound.getString("id"))) { compound.setString("id", "Control"); fixer.process(FixTypes.BLOCK_ENTITY, compound, versionIn); compound.setString("id", "MinecartCommandBlock"); } return compound; } }); }
public static void func_189672_a(DataFixer p_189672_0_) { func_189669_a(p_189672_0_, "MinecartSpawner"); p_189672_0_.registerWalker(FixTypes.ENTITY, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if ("MinecartSpawner".equals(compound.getString("id"))) { compound.setString("id", "MobSpawner"); fixer.process(FixTypes.BLOCK_ENTITY, compound, versionIn); compound.setString("id", "MinecartSpawner"); } return compound; } }); }
/** * reads a template from an inputstream */ private void readTemplateFromStream(String id, InputStream stream) throws IOException { NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(stream); if (!nbttagcompound.hasKey("DataVersion", 99)) { nbttagcompound.setInteger("DataVersion", 500); } Template template = new Template(); template.read(this.field_191154_c.process(FixTypes.STRUCTURE, nbttagcompound)); this.templates.put(id, template); }
public static void func_191158_a(DataFixer p_191158_0_) { p_191158_0_.registerWalker(FixTypes.STRUCTURE, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if (compound.hasKey("entities", 9)) { NBTTagList nbttaglist = compound.getTagList("entities", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.get(i); if (nbttagcompound.hasKey("nbt", 10)) { nbttagcompound.setTag("nbt", fixer.process(FixTypes.ENTITY, nbttagcompound.getCompoundTag("nbt"), versionIn)); } } } if (compound.hasKey("blocks", 9)) { NBTTagList nbttaglist1 = compound.getTagList("blocks", 10); for (int j = 0; j < nbttaglist1.tagCount(); ++j) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist1.get(j); if (nbttagcompound1.hasKey("nbt", 10)) { nbttagcompound1.setTag("nbt", fixer.process(FixTypes.BLOCK_ENTITY, nbttagcompound1.getCompoundTag("nbt"), versionIn)); } } } return compound; } }); }
@Nullable public static WorldInfo getWorldData(File p_186353_0_, DataFixer dataFixerIn) { try { NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(p_186353_0_)); NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data"); return new WorldInfo(dataFixerIn.process(FixTypes.LEVEL, nbttagcompound1)); } catch (Exception exception) { LOGGER.error("Exception reading {}", new Object[] {p_186353_0_, exception}); return null; } }
@Nullable /** * Reads the player data from disk into the specified PlayerEntityMP. */ public NBTTagCompound readPlayerData(EntityPlayer player) { NBTTagCompound nbttagcompound = null; try { File file1 = new File(this.playersDirectory, player.getCachedUniqueIdString() + ".dat"); if (file1.exists() && file1.isFile()) { nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1)); } } catch (Exception var4) { LOGGER.warn("Failed to load player data for {}", new Object[] {player.getName()}); } if (nbttagcompound != null) { player.readFromNBT(this.dataFixer.process(FixTypes.PLAYER, nbttagcompound)); } return nbttagcompound; }
private NBTTagCompound dataFix(NBTTagCompound p_189988_1_) { int i = 0; try { i = Integer.parseInt(p_189988_1_.getString("version")); } catch (RuntimeException var4) { ; } return this.mc.getDataFixer().process(FixTypes.OPTIONS, p_189988_1_, i); }
public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if (!compound.hasKey("tag", 10)) { return compound; } else { NBTTagCompound nbttagcompound = compound.getCompoundTag("tag"); if (nbttagcompound.hasKey("BlockEntityTag", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("BlockEntityTag"); String s = compound.getString("id"); String s1 = getBlockEntityID(versionIn, s); boolean flag; if (s1 == null) { LOGGER.warn("Unable to resolve BlockEntity for ItemInstance: {}", new Object[] {s}); flag = false; } else { flag = !nbttagcompound1.hasKey("id"); nbttagcompound1.setString("id", s1); } fixer.process(FixTypes.BLOCK_ENTITY, nbttagcompound1, versionIn); if (flag) { nbttagcompound1.removeTag("id"); } } return compound; } }
/** * Reads the player data from disk into the specified PlayerEntityMP. */ public NBTTagCompound readPlayerData(EntityPlayer player) { NBTTagCompound nbttagcompound = null; try { File file1 = new File(this.playersDirectory, player.getCachedUniqueIdString() + ".dat"); if (file1.exists() && file1.isFile()) { nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1)); } } catch (Exception var4) { LOGGER.warn("Failed to load player data for {}", new Object[] {player.getName()}); } if (nbttagcompound != null) { player.readFromNBT(this.dataFixer.process(FixTypes.PLAYER, nbttagcompound)); } net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(player, playersDirectory, player.getUniqueID().toString()); return nbttagcompound; }
public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if (!compound.hasKey("tag", 10)) { return compound; } else { NBTTagCompound nbttagcompound = compound.getCompoundTag("tag"); if (nbttagcompound.hasKey("BlockEntityTag", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("BlockEntityTag"); String s = compound.getString("id"); String s1 = getBlockEntityID(s); boolean flag; if (s1 == null) { LOGGER.warn("Unable to resolve BlockEntity for ItemInstance: {}", new Object[] {s}); flag = false; } else { flag = !nbttagcompound1.hasKey("id"); nbttagcompound1.setString("id", s1); } fixer.process(FixTypes.BLOCK_ENTITY, nbttagcompound1, versionIn); if (flag) { nbttagcompound1.removeTag("id"); } } return compound; } }
public static NBTTagCompound loadWorldInfoFromFile(World world, @Nullable File worldDir) { if (worldDir == null) { JustEnoughDimensions.logInfo("WorldInfoUtils.loadWorldInfoFromFile(): null worldDir"); return null; } File levelFile = new File(worldDir, JED_LEVEL_FILENAME); if (levelFile.exists()) { try { NBTTagCompound nbt = CompressedStreamTools.readCompressed(new FileInputStream(levelFile)); nbt = world.getMinecraftServer().getDataFixer().process(FixTypes.LEVEL, nbt.getCompoundTag("Data")); //FMLCommonHandler.instance().handleWorldDataLoad((SaveHandler) world.getSaveHandler(), info, nbt); JustEnoughDimensions.logInfo("WorldInfoUtils.loadWorldInfoFromFile(): Read world info from file '{}'", levelFile.getPath()); return nbt; } catch (Exception e) { JustEnoughDimensions.logger.warn("Exception reading " + levelFile.getPath(), e); return null; } //return SaveFormatOld.loadAndFix(fileLevel, world.getMinecraftServer().getDataFixer(), (SaveHandler) world.getSaveHandler()); } JustEnoughDimensions.logInfo("WorldInfoUtils.loadWorldInfoFromFile(): '{}' didn't exist for dimension {}", JED_LEVEL_FILENAME, world.provider.getDimension()); return null; }
@Mod.EventHandler public void onServerAboutToStartEvent(FMLServerAboutToStartEvent event) { // Register data fixers ModFixs dataFixer = proxy.getDataFixer(); TileEntityID renames = new TileEntityID(); dataFixer.registerFix(FixTypes.BLOCK_ENTITY, renames); dataFixer.registerFix(FixTypes.ITEM_INSTANCE, renames); }
private void readTemplateFromStream(String id, InputStream stream) throws IOException { NBTTagCompound nbt = CompressedStreamTools.readCompressed(stream); if (nbt.hasKey("DataVersion", Constants.NBT.TAG_ANY_NUMERIC) == false) { nbt.setInteger("DataVersion", 500); } TemplateEnderUtilities template = new TemplateEnderUtilities(); template.read(this.fixer.process(FixTypes.STRUCTURE, nbt)); this.templates.put(id, template); }
public static void func_189806_a(DataFixer p_189806_0_) { p_189806_0_.registerWalker(FixTypes.PLAYER, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { DataFixesManager.processInventory(fixer, compound, versionIn, "Inventory"); DataFixesManager.processInventory(fixer, compound, versionIn, "EnderItems"); return compound; } }); }
public static void func_189785_b(DataFixer p_189785_0_) { EntityLiving.func_189752_a(p_189785_0_, "Villager"); p_189785_0_.registerWalker(FixTypes.ENTITY, new ItemStackDataLists("Villager", new String[] {"Inventory"})); p_189785_0_.registerWalker(FixTypes.ENTITY, new IDataWalker() { public NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn) { if ("Villager".equals(compound.getString("id")) && compound.hasKey("Offers", 10)) { NBTTagCompound nbttagcompound = compound.getCompoundTag("Offers"); if (nbttagcompound.hasKey("Recipes", 9)) { NBTTagList nbttaglist = nbttagcompound.getTagList("Recipes", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); DataFixesManager.processItemStack(fixer, nbttagcompound1, versionIn, "buy"); DataFixesManager.processItemStack(fixer, nbttagcompound1, versionIn, "buyB"); DataFixesManager.processItemStack(fixer, nbttagcompound1, versionIn, "sell"); nbttaglist.set(i, nbttagcompound1); } } } return compound; } }); }
private NBTTagCompound func_189988_a(NBTTagCompound p_189988_1_) { int i = 0; try { i = Integer.parseInt(p_189988_1_.getString("version")); } catch (RuntimeException var4) { ; } return this.mc.getDataFixer().process(FixTypes.OPTIONS, p_189988_1_, i); }
public static void registerFixes(DataFixer fixers, final Class<? extends EntityBlock> cls) { fixers.registerWalker(FixTypes.ENTITY, (fixer, compound, versionIn) -> { if (EntityList.getKey(cls).equals(new ResourceLocation(compound.getString("id")))) { if (compound.hasKey(TAG_TILE_ENTITY, Constants.NBT.TAG_COMPOUND)) { final NBTTagCompound teTag = compound.getCompoundTag(TAG_TILE_ENTITY); final NBTTagCompound fixedTeTag = fixer.process(FixTypes.BLOCK_ENTITY, teTag, versionIn); compound.setTag(TAG_TILE_ENTITY, fixedTeTag); } } return compound; }); }
protected HarshenTemplate(ResourceLocation location) { String s = location.getResourceDomain(); String s1 = location.getResourcePath(); InputStream stream = null; boolean flag; try { stream = getClass().getResourceAsStream("/assets/" + HarshenCastle.MODID + "/structures/" + s1 + ".nbt"); NBTTagCompound compound = CompressedStreamTools.readCompressed(stream); if (!compound.hasKey("DataVersion", 99)) { compound.setInteger("DataVersion", 500); } Template template = new Template(); DataFixer fixer; try { fixer = Minecraft.getMinecraft().getDataFixer(); } catch (Throwable e) { fixer = FMLServerHandler.instance().getDataFixer(); } template.read(fixer.process(FixTypes.STRUCTURE, compound)); this.blocks.clear(); NBTTagList nbttaglist = compound.getTagList("size", 3); this.size = new BlockPos(nbttaglist.getIntAt(0), nbttaglist.getIntAt(1), nbttaglist.getIntAt(2)); NBTTagList nbttaglist4 = compound.getTagList("pos", 3); if(nbttaglist4.hasNoTags()) this.pos = BlockPos.ORIGIN; else this.pos = new BlockPos(nbttaglist4.getIntAt(0), nbttaglist4.getIntAt(1), nbttaglist4.getIntAt(2)); BasicPalette template$basicpalette = new BasicPalette(); NBTTagList nbttaglist1 = compound.getTagList("palette", 10); for (int i = 0; i < nbttaglist1.tagCount(); ++i) { template$basicpalette.addMapping(NBTUtil.readBlockState(nbttaglist1.getCompoundTagAt(i)), i); } NBTTagList nbttaglist3 = compound.getTagList("blocks", 10); for (int j = 0; j < nbttaglist3.tagCount(); ++j) { NBTTagCompound nbttagcompound = nbttaglist3.getCompoundTagAt(j); NBTTagList nbttaglist2 = nbttagcompound.getTagList("pos", 3); BlockPos blockpos = new BlockPos(nbttaglist2.getIntAt(0), nbttaglist2.getIntAt(1), nbttaglist2.getIntAt(2)); IBlockState iblockstate = template$basicpalette.stateFor(nbttagcompound.getInteger("state")); NBTTagCompound nbttagcompound1; if (nbttagcompound.hasKey("nbt")) { nbttagcompound1 = nbttagcompound.getCompoundTag("nbt"); } else { nbttagcompound1 = null; } if(!(iblockstate.getBlock() instanceof BlockStructure)) this.blocks.add(new Template.BlockInfo(blockpos, iblockstate, nbttagcompound1)); } } catch (Throwable var10) { } finally { IOUtils.closeQuietly(stream); } }
public static void registerFixesItem(DataFixer fixer) { fixer.registerWalker(FixTypes.ENTITY, new ItemStackData(EntityItem.class, new String[] {"Item"})); }
public static void registerFixesFireworkRocket(DataFixer fixer) { fixer.registerWalker(FixTypes.ENTITY, new ItemStackData(EntityFireworkRocket.class, new String[] {"FireworksItem"})); }
public static void func_190574_b(DataFixer p_190574_0_, Class<?> p_190574_1_) { EntityMinecart.registerFixesMinecart(p_190574_0_, p_190574_1_); p_190574_0_.registerWalker(FixTypes.ENTITY, new ItemStackDataLists(p_190574_1_, new String[] {"Items"})); }
public static void registerFixesItemFrame(DataFixer fixer) { fixer.registerWalker(FixTypes.ENTITY, new ItemStackData(EntityItemFrame.class, new String[] {"Item"})); }
public static void registerFixesArmorStand(DataFixer fixer) { fixer.registerWalker(FixTypes.ENTITY, new ItemStackDataLists(EntityArmorStand.class, new String[] {"ArmorItems", "HandItems"})); }
public static void registerFixesMob(DataFixer fixer, Class<?> name) { fixer.registerWalker(FixTypes.ENTITY, new ItemStackDataLists(name, new String[] {"ArmorItems", "HandItems"})); }
public static void registerFixesPotion(DataFixer fixer) { EntityThrowable.registerFixesThrowable(fixer, "ThrownPotion"); fixer.registerWalker(FixTypes.ENTITY, new ItemStackData(EntityPotion.class, new String[] {"Potion"})); }
public static void func_190683_c(DataFixer p_190683_0_, Class<?> p_190683_1_) { EntityLiving.registerFixesMob(p_190683_0_, p_190683_1_); p_190683_0_.registerWalker(FixTypes.ENTITY, new ItemStackData(p_190683_1_, new String[] {"SaddleItem"})); }
public static void func_190694_b(DataFixer p_190694_0_, Class<?> p_190694_1_) { AbstractHorse.func_190683_c(p_190694_0_, p_190694_1_); p_190694_0_.registerWalker(FixTypes.ENTITY, new ItemStackDataLists(p_190694_1_, new String[] {"Items"})); }
public static void registerFixesHorse(DataFixer fixer) { AbstractHorse.func_190683_c(fixer, EntityHorse.class); fixer.registerWalker(FixTypes.ENTITY, new ItemStackData(EntityHorse.class, new String[] {"ArmorItem"})); }
public static void registerFixes(DataFixer fixer) { fixer.registerWalker(FixTypes.ITEM_INSTANCE, new BlockEntityTag()); fixer.registerWalker(FixTypes.ITEM_INSTANCE, new EntityTag()); }
public static void registerFixesJukebox(DataFixer fixer) { fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackData(BlockJukebox.TileEntityJukebox.class, new String[] {"RecordItem"})); }