public static ItemStack setupNewMap(World worldIn, double worldX, double worldZ, byte scale, boolean trackingPosition, boolean unlimitedTracking) { ItemStack itemstack = new ItemStack(ModItems.EREBUS_MAP_FILLED, 1, worldIn.getUniqueDataId("map")); String s = "map_" + itemstack.getMetadata(); MapData mapdata = new MapData(s); worldIn.setData(s, mapdata); mapdata.scale = scale; mapdata.calculateMapCenter(worldX, worldZ, mapdata.scale); mapdata.dimension = worldIn.provider.getDimension(); mapdata.trackingPosition = trackingPosition; mapdata.unlimitedTracking = unlimitedTracking; mapdata.markDirty(); return itemstack; }
protected static void scaleMap(ItemStack p_185063_0_, World p_185063_1_, int p_185063_2_) { MapData mapdata = ((ItemErebusMap) ModItems.EREBUS_MAP_FILLED).getMapData(p_185063_0_, p_185063_1_); p_185063_0_.setItemDamage(p_185063_1_.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + p_185063_0_.getMetadata()); if (mapdata != null) { mapdata1.scale = (byte)MathHelper.clamp(mapdata.scale + p_185063_2_, 0, 4); mapdata1.trackingPosition = mapdata.trackingPosition; mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale); mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); p_185063_1_.setData("map_" + p_185063_0_.getMetadata(), mapdata1); } }
@Nullable public MapData getMapData(ItemStack stack, World worldIn) { String s = "map_" + stack.getMetadata(); MapData mapdata = (MapData)worldIn.loadData(MapData.class, s); if (mapdata == null && !worldIn.isRemote) { stack.setItemDamage(worldIn.getUniqueDataId("map")); s = "map_" + stack.getMetadata(); mapdata = new MapData(s); mapdata.scale = 3; mapdata.calculateMapCenter((double)worldIn.getWorldInfo().getSpawnX(), (double)worldIn.getWorldInfo().getSpawnZ(), mapdata.scale); mapdata.dimension = worldIn.provider.getDimension(); mapdata.markDirty(); worldIn.setData(s, mapdata); } return mapdata; }