aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/item/MapItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/MapItem.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/item/MapItem.java.patch615
1 files changed, 615 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/MapItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/MapItem.java.patch
new file mode 100644
index 0000000000..6556502cec
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/item/MapItem.java.patch
@@ -0,0 +1,615 @@
+--- a/net/minecraft/world/item/MapItem.java
++++ b/net/minecraft/world/item/MapItem.java
+@@ -26,7 +26,7 @@
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.biome.Biome;
+ import net.minecraft.world.level.block.Blocks;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.chunk.LevelChunk;
+ import net.minecraft.world.level.levelgen.Heightmap;
+ import net.minecraft.world.level.material.FluidState;
+@@ -34,6 +34,7 @@
+ import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
+
+ public class MapItem extends ComplexItem {
++
+ public static final int IMAGE_WIDTH = 128;
+ public static final int IMAGE_HEIGHT = 128;
+ private static final int DEFAULT_MAP_COLOR = -12173266;
+@@ -46,9 +47,10 @@
+ }
+
+ public static ItemStack create(Level level, int levelX, int levelZ, byte scale, boolean trackingPosition, boolean unlimitedTracking) {
+- ItemStack itemStack = new ItemStack(Items.FILLED_MAP);
+- createAndStoreSavedData(itemStack, level, levelX, levelZ, scale, trackingPosition, unlimitedTracking, level.dimension());
+- return itemStack;
++ ItemStack itemstack = new ItemStack(Items.FILLED_MAP);
++
++ createAndStoreSavedData(itemstack, level, levelX, levelZ, scale, trackingPosition, unlimitedTracking, level.dimension());
++ return itemstack;
+ }
+
+ @Nullable
+@@ -58,34 +60,34 @@
+
+ @Nullable
+ public static MapItemSavedData getSavedData(ItemStack stack, Level level) {
+- Integer mapId = getMapId(stack);
+- return getSavedData(mapId, level);
++ Integer integer = getMapId(stack);
++
++ return getSavedData(integer, level);
+ }
+
+ @Nullable
+ public static Integer getMapId(ItemStack stack) {
+- CompoundTag tag = stack.getTag();
+- return tag != null && tag.contains("map", 99) ? tag.getInt("map") : null;
++ CompoundTag nbttagcompound = stack.getTag();
++
++ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
+ }
+
+- private static int createNewSavedData(
+- Level level, int x, int z, int scale, boolean trackingPosition, boolean unlimitedTracking, ResourceKey<Level> dimension
+- ) {
+- MapItemSavedData mapItemSavedData = MapItemSavedData.createFresh((double)x, (double)z, (byte)scale, trackingPosition, unlimitedTracking, dimension);
+- int freeMapId = level.getFreeMapId();
+- level.setMapData(makeKey(freeMapId), mapItemSavedData);
+- return freeMapId;
++ public static int createNewSavedData(Level level, int x, int z, int scale, boolean trackingPosition, boolean unlimitedTracking, ResourceKey<Level> dimension) {
++ MapItemSavedData worldmap = MapItemSavedData.createFresh((double) x, (double) z, (byte) scale, trackingPosition, unlimitedTracking, dimension);
++ int l = level.getFreeMapId();
++
++ level.setMapData(makeKey(l), worldmap);
++ return l;
+ }
+
+ private static void storeMapData(ItemStack stack, int mapId) {
+ stack.getOrCreateTag().putInt("map", mapId);
+ }
+
+- private static void createAndStoreSavedData(
+- ItemStack stack, Level level, int x, int z, int scale, boolean trackingPosition, boolean unlimitedTracking, ResourceKey<Level> dimension
+- ) {
+- int i = createNewSavedData(level, x, z, scale, trackingPosition, unlimitedTracking, dimension);
+- storeMapData(stack, i);
++ private static void createAndStoreSavedData(ItemStack stack, Level level, int x, int z, int scale, boolean trackingPosition, boolean unlimitedTracking, ResourceKey<Level> dimension) {
++ int l = createNewSavedData(level, x, z, scale, trackingPosition, unlimitedTracking, dimension);
++
++ storeMapData(stack, l);
+ }
+
+ public static String makeKey(int mapId) {
+@@ -95,121 +97,134 @@
+ public void update(Level level, Entity viewer, MapItemSavedData data) {
+ if (level.dimension() == data.dimension && viewer instanceof Player) {
+ int i = 1 << data.scale;
+- int i1 = data.centerX;
+- int i2 = data.centerZ;
+- int i3 = Mth.floor(viewer.getX() - (double)i1) / i + 64;
+- int i4 = Mth.floor(viewer.getZ() - (double)i2) / i + 64;
+- int i5 = 128 / i;
++ int j = data.centerX;
++ int k = data.centerZ;
++ int l = Mth.floor(viewer.getX() - (double) j) / i + 64;
++ int i1 = Mth.floor(viewer.getZ() - (double) k) / i + 64;
++ int j1 = 128 / i;
++
+ if (level.dimensionType().hasCeiling()) {
+- i5 /= 2;
++ j1 /= 2;
+ }
+
+- MapItemSavedData.HoldingPlayer holdingPlayer = data.getHoldingPlayer((Player)viewer);
+- holdingPlayer.step++;
+- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
+- BlockPos.MutableBlockPos mutableBlockPos1 = new BlockPos.MutableBlockPos();
++ MapItemSavedData.HoldingPlayer worldmap_worldmaphumantracker = data.getHoldingPlayer((Player) viewer);
++
++ ++worldmap_worldmaphumantracker.step;
++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
++ BlockPos.MutableBlockPos blockposition_mutableblockposition1 = new BlockPos.MutableBlockPos();
+ boolean flag = false;
+
+- for (int i6 = i3 - i5 + 1; i6 < i3 + i5; i6++) {
+- if ((i6 & 15) == (holdingPlayer.step & 15) || flag) {
++ for (int k1 = l - j1 + 1; k1 < l + j1; ++k1) {
++ if ((k1 & 15) == (worldmap_worldmaphumantracker.step & 15) || flag) {
+ flag = false;
+- double d = 0.0;
++ double d0 = 0.0D;
+
+- for (int i7 = i4 - i5 - 1; i7 < i4 + i5; i7++) {
+- if (i6 >= 0 && i7 >= -1 && i6 < 128 && i7 < 128) {
+- int i8 = Mth.square(i6 - i3) + Mth.square(i7 - i4);
+- boolean flag1 = i8 > (i5 - 2) * (i5 - 2);
+- int i9 = (i1 / i + i6 - 64) * i;
+- int i10 = (i2 / i + i7 - 64) * i;
++ for (int l1 = i1 - j1 - 1; l1 < i1 + j1; ++l1) {
++ if (k1 >= 0 && l1 >= -1 && k1 < 128 && l1 < 128) {
++ int i2 = Mth.square(k1 - l) + Mth.square(l1 - i1);
++ boolean flag1 = i2 > (j1 - 2) * (j1 - 2);
++ int j2 = (j / i + k1 - 64) * i;
++ int k2 = (k / i + l1 - 64) * i;
+ Multiset<MapColor> multiset = LinkedHashMultiset.create();
+- LevelChunk chunk = level.getChunk(SectionPos.blockToSectionCoord(i9), SectionPos.blockToSectionCoord(i10));
++ LevelChunk chunk = level.getChunk(SectionPos.blockToSectionCoord(j2), SectionPos.blockToSectionCoord(k2));
++
+ if (!chunk.isEmpty()) {
+- int i11 = 0;
+- double d1 = 0.0;
++ int l2 = 0;
++ double d1 = 0.0D;
++ int i3;
++
+ if (level.dimensionType().hasCeiling()) {
+- int i12 = i9 + i10 * 231871;
+- i12 = i12 * i12 * 31287121 + i12 * 11;
+- if ((i12 >> 20 & 1) == 0) {
++ i3 = j2 + k2 * 231871;
++ i3 = i3 * i3 * 31287121 + i3 * 11;
++ if ((i3 >> 20 & 1) == 0) {
+ multiset.add(Blocks.DIRT.defaultBlockState().getMapColor(level, BlockPos.ZERO), 10);
+ } else {
+ multiset.add(Blocks.STONE.defaultBlockState().getMapColor(level, BlockPos.ZERO), 100);
+ }
+
+- d1 = 100.0;
++ d1 = 100.0D;
+ } else {
+- for (int i12 = 0; i12 < i; i12++) {
+- for (int i13 = 0; i13 < i; i13++) {
+- mutableBlockPos.set(i9 + i12, 0, i10 + i13);
+- int i14 = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, mutableBlockPos.getX(), mutableBlockPos.getZ()) + 1;
+- BlockState blockState;
+- if (i14 <= level.getMinBuildHeight() + 1) {
+- blockState = Blocks.BEDROCK.defaultBlockState();
+- } else {
++ for (i3 = 0; i3 < i; ++i3) {
++ for (int j3 = 0; j3 < i; ++j3) {
++ blockposition_mutableblockposition.set(j2 + i3, 0, k2 + j3);
++ int k3 = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getZ()) + 1;
++ IBlockData iblockdata;
++
++ if (k3 > level.getMinBuildHeight() + 1) {
+ do {
+- mutableBlockPos.setY(--i14);
+- blockState = chunk.getBlockState(mutableBlockPos);
+- } while (blockState.getMapColor(level, mutableBlockPos) == MapColor.NONE && i14 > level.getMinBuildHeight());
++ --k3;
++ blockposition_mutableblockposition.setY(k3);
++ iblockdata = chunk.getBlockState(blockposition_mutableblockposition);
++ } while (iblockdata.getMapColor(level, blockposition_mutableblockposition) == MapColor.NONE && k3 > level.getMinBuildHeight());
+
+- if (i14 > level.getMinBuildHeight() && !blockState.getFluidState().isEmpty()) {
+- int i15 = i14 - 1;
+- mutableBlockPos1.set(mutableBlockPos);
++ if (k3 > level.getMinBuildHeight() && !iblockdata.getFluidState().isEmpty()) {
++ int l3 = k3 - 1;
+
+- BlockState blockState1;
++ blockposition_mutableblockposition1.set(blockposition_mutableblockposition);
++
++ IBlockData iblockdata1;
++
+ do {
+- mutableBlockPos1.setY(i15--);
+- blockState1 = chunk.getBlockState(mutableBlockPos1);
+- i11++;
+- } while (i15 > level.getMinBuildHeight() && !blockState1.getFluidState().isEmpty());
++ blockposition_mutableblockposition1.setY(l3--);
++ iblockdata1 = chunk.getBlockState(blockposition_mutableblockposition1);
++ ++l2;
++ } while (l3 > level.getMinBuildHeight() && !iblockdata1.getFluidState().isEmpty());
+
+- blockState = this.getCorrectStateForFluidBlock(level, blockState, mutableBlockPos);
++ iblockdata = this.getCorrectStateForFluidBlock(level, iblockdata, blockposition_mutableblockposition);
+ }
++ } else {
++ iblockdata = Blocks.BEDROCK.defaultBlockState();
+ }
+
+- data.checkBanners(level, mutableBlockPos.getX(), mutableBlockPos.getZ());
+- d1 += (double)i14 / (double)(i * i);
+- multiset.add(blockState.getMapColor(level, mutableBlockPos));
++ data.checkBanners(level, blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getZ());
++ d1 += (double) k3 / (double) (i * i);
++ multiset.add(iblockdata.getMapColor(level, blockposition_mutableblockposition));
+ }
+ }
+ }
+
+- int var33 = i11 / (i * i);
+- MapColor mapColor = Iterables.getFirst(Multisets.copyHighestCountFirst(multiset), MapColor.NONE);
+- MapColor.Brightness brightness;
+- if (mapColor == MapColor.WATER) {
+- double d2 = (double)var33 * 0.1 + (double)(i6 + i7 & 1) * 0.2;
+- if (d2 < 0.5) {
+- brightness = MapColor.Brightness.HIGH;
+- } else if (d2 > 0.9) {
+- brightness = MapColor.Brightness.LOW;
++ l2 /= i * i;
++ MapColor materialmapcolor = (MapColor) Iterables.getFirst(Multisets.copyHighestCountFirst(multiset), MapColor.NONE);
++ double d2;
++ MapColor.Brightness materialmapcolor_a;
++
++ if (materialmapcolor == MapColor.WATER) {
++ d2 = (double) l2 * 0.1D + (double) (k1 + l1 & 1) * 0.2D;
++ if (d2 < 0.5D) {
++ materialmapcolor_a = MapColor.Brightness.HIGH;
++ } else if (d2 > 0.9D) {
++ materialmapcolor_a = MapColor.Brightness.LOW;
+ } else {
+- brightness = MapColor.Brightness.NORMAL;
++ materialmapcolor_a = MapColor.Brightness.NORMAL;
+ }
+ } else {
+- double d2 = (d1 - d) * 4.0 / (double)(i + 4) + ((double)(i6 + i7 & 1) - 0.5) * 0.4;
+- if (d2 > 0.6) {
+- brightness = MapColor.Brightness.HIGH;
+- } else if (d2 < -0.6) {
+- brightness = MapColor.Brightness.LOW;
++ d2 = (d1 - d0) * 4.0D / (double) (i + 4) + ((double) (k1 + l1 & 1) - 0.5D) * 0.4D;
++ if (d2 > 0.6D) {
++ materialmapcolor_a = MapColor.Brightness.HIGH;
++ } else if (d2 < -0.6D) {
++ materialmapcolor_a = MapColor.Brightness.LOW;
+ } else {
+- brightness = MapColor.Brightness.NORMAL;
++ materialmapcolor_a = MapColor.Brightness.NORMAL;
+ }
+ }
+
+- d = d1;
+- if (i7 >= 0 && i8 < i5 * i5 && (!flag1 || (i6 + i7 & 1) != 0)) {
+- flag |= data.updateColor(i6, i7, mapColor.getPackedId(brightness));
++ d0 = d1;
++ if (l1 >= 0 && i2 < j1 * j1 && (!flag1 || (k1 + l1 & 1) != 0)) {
++ flag |= data.updateColor(k1, l1, materialmapcolor.getPackedId(materialmapcolor_a));
+ }
+ }
+ }
+ }
+ }
+ }
++
+ }
+ }
+
+- private BlockState getCorrectStateForFluidBlock(Level level, BlockState state, BlockPos pos) {
+- FluidState fluidState = state.getFluidState();
+- return !fluidState.isEmpty() && !state.isFaceSturdy(level, pos, Direction.UP) ? fluidState.createLegacyBlock() : state;
++ private IBlockData getCorrectStateForFluidBlock(Level level, IBlockData state, BlockPos pos) {
++ FluidState fluid = state.getFluidState();
++
++ return !fluid.isEmpty() && !state.isFaceSturdy(level, pos, Direction.UP) ? fluid.createLegacyBlock() : state;
+ }
+
+ private static boolean isBiomeWatery(boolean[] wateryMap, int xSample, int zSample) {
+@@ -217,76 +232,83 @@
+ }
+
+ public static void renderBiomePreviewMap(ServerLevel serverLevel, ItemStack stack) {
+- MapItemSavedData savedData = getSavedData(stack, serverLevel);
+- if (savedData != null) {
+- if (serverLevel.dimension() == savedData.dimension) {
+- int i = 1 << savedData.scale;
+- int i1 = savedData.centerX;
+- int i2 = savedData.centerZ;
+- boolean[] flags = new boolean[16384];
+- int i3 = i1 / i - 64;
+- int i4 = i2 / i - 64;
+- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
++ MapItemSavedData worldmap = getSavedData(stack, serverLevel);
+
+- for (int i5 = 0; i5 < 128; i5++) {
+- for (int i6 = 0; i6 < 128; i6++) {
+- Holder<Biome> biome = serverLevel.getBiome(mutableBlockPos.set((i3 + i6) * i, 0, (i4 + i5) * i));
+- flags[i5 * 128 + i6] = biome.is(BiomeTags.WATER_ON_MAP_OUTLINES);
++ if (worldmap != null) {
++ if (serverLevel.dimension() == worldmap.dimension) {
++ int i = 1 << worldmap.scale;
++ int j = worldmap.centerX;
++ int k = worldmap.centerZ;
++ boolean[] aboolean = new boolean[16384];
++ int l = j / i - 64;
++ int i1 = k / i - 64;
++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
++
++ int j1;
++ int k1;
++
++ for (j1 = 0; j1 < 128; ++j1) {
++ for (k1 = 0; k1 < 128; ++k1) {
++ Holder<Biome> holder = serverLevel.getBiome(blockposition_mutableblockposition.set((l + k1) * i, 0, (i1 + j1) * i));
++
++ aboolean[j1 * 128 + k1] = holder.is(BiomeTags.WATER_ON_MAP_OUTLINES);
+ }
+ }
+
+- for (int i5 = 1; i5 < 127; i5++) {
+- for (int i6 = 1; i6 < 127; i6++) {
+- int i7 = 0;
++ for (j1 = 1; j1 < 127; ++j1) {
++ for (k1 = 1; k1 < 127; ++k1) {
++ int l1 = 0;
+
+- for (int i8 = -1; i8 < 2; i8++) {
+- for (int i9 = -1; i9 < 2; i9++) {
+- if ((i8 != 0 || i9 != 0) && isBiomeWatery(flags, i5 + i8, i6 + i9)) {
+- i7++;
++ for (int i2 = -1; i2 < 2; ++i2) {
++ for (int j2 = -1; j2 < 2; ++j2) {
++ if ((i2 != 0 || j2 != 0) && isBiomeWatery(aboolean, j1 + i2, k1 + j2)) {
++ ++l1;
+ }
+ }
+ }
+
+- MapColor.Brightness brightness = MapColor.Brightness.LOWEST;
+- MapColor mapColor = MapColor.NONE;
+- if (isBiomeWatery(flags, i5, i6)) {
+- mapColor = MapColor.COLOR_ORANGE;
+- if (i7 > 7 && i6 % 2 == 0) {
+- switch ((i5 + (int)(Mth.sin((float)i6 + 0.0F) * 7.0F)) / 8 % 5) {
++ MapColor.Brightness materialmapcolor_a = MapColor.Brightness.LOWEST;
++ MapColor materialmapcolor = MapColor.NONE;
++
++ if (isBiomeWatery(aboolean, j1, k1)) {
++ materialmapcolor = MapColor.COLOR_ORANGE;
++ if (l1 > 7 && k1 % 2 == 0) {
++ switch ((j1 + (int) (Mth.sin((float) k1 + 0.0F) * 7.0F)) / 8 % 5) {
+ case 0:
+ case 4:
+- brightness = MapColor.Brightness.LOW;
++ materialmapcolor_a = MapColor.Brightness.LOW;
+ break;
+ case 1:
+ case 3:
+- brightness = MapColor.Brightness.NORMAL;
++ materialmapcolor_a = MapColor.Brightness.NORMAL;
+ break;
+ case 2:
+- brightness = MapColor.Brightness.HIGH;
++ materialmapcolor_a = MapColor.Brightness.HIGH;
+ }
+- } else if (i7 > 7) {
+- mapColor = MapColor.NONE;
+- } else if (i7 > 5) {
+- brightness = MapColor.Brightness.NORMAL;
+- } else if (i7 > 3) {
+- brightness = MapColor.Brightness.LOW;
+- } else if (i7 > 1) {
+- brightness = MapColor.Brightness.LOW;
++ } else if (l1 > 7) {
++ materialmapcolor = MapColor.NONE;
++ } else if (l1 > 5) {
++ materialmapcolor_a = MapColor.Brightness.NORMAL;
++ } else if (l1 > 3) {
++ materialmapcolor_a = MapColor.Brightness.LOW;
++ } else if (l1 > 1) {
++ materialmapcolor_a = MapColor.Brightness.LOW;
+ }
+- } else if (i7 > 0) {
+- mapColor = MapColor.COLOR_BROWN;
+- if (i7 > 3) {
+- brightness = MapColor.Brightness.NORMAL;
++ } else if (l1 > 0) {
++ materialmapcolor = MapColor.COLOR_BROWN;
++ if (l1 > 3) {
++ materialmapcolor_a = MapColor.Brightness.NORMAL;
+ } else {
+- brightness = MapColor.Brightness.LOWEST;
++ materialmapcolor_a = MapColor.Brightness.LOWEST;
+ }
+ }
+
+- if (mapColor != MapColor.NONE) {
+- savedData.setColor(i5, i6, mapColor.getPackedId(brightness));
++ if (materialmapcolor != MapColor.NONE) {
++ worldmap.setColor(j1, k1, materialmapcolor.getPackedId(materialmapcolor_a));
+ }
+ }
+ }
++
+ }
+ }
+ }
+@@ -294,15 +316,19 @@
+ @Override
+ public void inventoryTick(ItemStack stack, Level level, Entity entity, int itemSlot, boolean isSelected) {
+ if (!level.isClientSide) {
+- MapItemSavedData savedData = getSavedData(stack, level);
+- if (savedData != null) {
+- if (entity instanceof Player player) {
+- savedData.tickCarriedBy(player, stack);
++ MapItemSavedData worldmap = getSavedData(stack, level);
++
++ if (worldmap != null) {
++ if (entity instanceof Player) {
++ Player entityhuman = (Player) entity;
++
++ worldmap.tickCarriedBy(entityhuman, stack);
+ }
+
+- if (!savedData.locked && (isSelected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
+- this.update(level, entity, savedData);
++ if (!worldmap.locked && (isSelected || entity instanceof Player && ((Player) entity).getOffhandItem() == stack)) {
++ this.update(level, entity, worldmap);
+ }
++
+ }
+ }
+ }
+@@ -310,90 +336,104 @@
+ @Nullable
+ @Override
+ public Packet<?> getUpdatePacket(ItemStack stack, Level level, Player player) {
+- Integer mapId = getMapId(stack);
+- MapItemSavedData savedData = getSavedData(mapId, level);
+- return savedData != null ? savedData.getUpdatePacket(mapId, player) : null;
++ Integer integer = getMapId(stack);
++ MapItemSavedData worldmap = getSavedData(integer, level);
++
++ return worldmap != null ? worldmap.getUpdatePacket(integer, player) : null;
+ }
+
+ @Override
+- public void onCraftedPostProcess(ItemStack itemStack, Level level) {
+- CompoundTag tag = itemStack.getTag();
+- if (tag != null && tag.contains("map_scale_direction", 99)) {
+- scaleMap(itemStack, level, tag.getInt("map_scale_direction"));
+- tag.remove("map_scale_direction");
+- } else if (tag != null && tag.contains("map_to_lock", 1) && tag.getBoolean("map_to_lock")) {
+- lockMap(level, itemStack);
+- tag.remove("map_to_lock");
++ public void onCraftedPostProcess(ItemStack itemstack, Level world) {
++ CompoundTag nbttagcompound = itemstack.getTag();
++
++ if (nbttagcompound != null && nbttagcompound.contains("map_scale_direction", 99)) {
++ scaleMap(itemstack, world, nbttagcompound.getInt("map_scale_direction"));
++ nbttagcompound.remove("map_scale_direction");
++ } else if (nbttagcompound != null && nbttagcompound.contains("map_to_lock", 1) && nbttagcompound.getBoolean("map_to_lock")) {
++ lockMap(world, itemstack);
++ nbttagcompound.remove("map_to_lock");
+ }
++
+ }
+
+ private static void scaleMap(ItemStack stack, Level level, int scale) {
+- MapItemSavedData savedData = getSavedData(stack, level);
+- if (savedData != null) {
+- int freeMapId = level.getFreeMapId();
+- level.setMapData(makeKey(freeMapId), savedData.scaled(scale));
+- storeMapData(stack, freeMapId);
++ MapItemSavedData worldmap = getSavedData(stack, level);
++
++ if (worldmap != null) {
++ int j = level.getFreeMapId();
++
++ level.setMapData(makeKey(j), worldmap.scaled(scale));
++ storeMapData(stack, j);
+ }
++
+ }
+
+ public static void lockMap(Level level, ItemStack stack) {
+- MapItemSavedData savedData = getSavedData(stack, level);
+- if (savedData != null) {
+- int freeMapId = level.getFreeMapId();
+- String string = makeKey(freeMapId);
+- MapItemSavedData mapItemSavedData = savedData.locked();
+- level.setMapData(string, mapItemSavedData);
+- storeMapData(stack, freeMapId);
++ MapItemSavedData worldmap = getSavedData(stack, level);
++
++ if (worldmap != null) {
++ int i = level.getFreeMapId();
++ String s = makeKey(i);
++ MapItemSavedData worldmap1 = worldmap.locked();
++
++ level.setMapData(s, worldmap1);
++ storeMapData(stack, i);
+ }
++
+ }
+
+ @Override
+ public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) {
+- Integer mapId = getMapId(stack);
+- MapItemSavedData mapItemSavedData = level == null ? null : getSavedData(mapId, level);
+- CompoundTag tag = stack.getTag();
+- boolean _boolean;
+- byte _byte;
+- if (tag != null) {
+- _boolean = tag.getBoolean("map_to_lock");
+- _byte = tag.getByte("map_scale_direction");
++ Integer integer = getMapId(stack);
++ MapItemSavedData worldmap = level == null ? null : getSavedData(integer, level);
++ CompoundTag nbttagcompound = stack.getTag();
++ boolean flag;
++ byte b0;
++
++ if (nbttagcompound != null) {
++ flag = nbttagcompound.getBoolean("map_to_lock");
++ b0 = nbttagcompound.getByte("map_scale_direction");
+ } else {
+- _boolean = false;
+- _byte = 0;
++ flag = false;
++ b0 = 0;
+ }
+
+- if (mapItemSavedData != null && (mapItemSavedData.locked || _boolean)) {
+- tooltip.add(Component.translatable("filled_map.locked", mapId).withStyle(ChatFormatting.GRAY));
++ if (worldmap != null && (worldmap.locked || flag)) {
++ tooltip.add(Component.translatable("filled_map.locked", integer).withStyle(ChatFormatting.GRAY));
+ }
+
+ if (flag.isAdvanced()) {
+- if (mapItemSavedData != null) {
+- if (!_boolean && _byte == 0) {
+- tooltip.add(getTooltipForId(mapId));
++ if (worldmap != null) {
++ if (!flag && b0 == 0) {
++ tooltip.add(getTooltipForId(integer));
+ }
+
+- int min = Math.min(mapItemSavedData.scale + _byte, 4);
+- tooltip.add(Component.translatable("filled_map.scale", 1 << min).withStyle(ChatFormatting.GRAY));
+- tooltip.add(Component.translatable("filled_map.level", min, 4).withStyle(ChatFormatting.GRAY));
++ int i = Math.min(worldmap.scale + b0, 4);
++
++ tooltip.add(Component.translatable("filled_map.scale", 1 << i).withStyle(ChatFormatting.GRAY));
++ tooltip.add(Component.translatable("filled_map.level", i, 4).withStyle(ChatFormatting.GRAY));
+ } else {
+ tooltip.add(Component.translatable("filled_map.unknown").withStyle(ChatFormatting.GRAY));
+ }
+ }
++
+ }
+
+ private static Component getTooltipForId(int i) {
+ return Component.translatable("filled_map.id", i).withStyle(ChatFormatting.GRAY);
+ }
+
+- public static Component getTooltipForId(ItemStack itemStack) {
+- return getTooltipForId(getMapId(itemStack));
++ public static Component getTooltipForId(ItemStack itemstack) {
++ return getTooltipForId(getMapId(itemstack));
+ }
+
+ public static int getColor(ItemStack stack) {
+- CompoundTag tagElement = stack.getTagElement("display");
+- if (tagElement != null && tagElement.contains("MapColor", 99)) {
+- int _int = tagElement.getInt("MapColor");
+- return 0xFF000000 | _int & 16777215;
++ CompoundTag nbttagcompound = stack.getTagElement("display");
++
++ if (nbttagcompound != null && nbttagcompound.contains("MapColor", 99)) {
++ int i = nbttagcompound.getInt("MapColor");
++
++ return -16777216 | i & 16777215;
+ } else {
+ return -12173266;
+ }
+@@ -401,11 +441,13 @@
+
+ @Override
+ public InteractionResult useOn(UseOnContext context) {
+- BlockState blockState = context.getLevel().getBlockState(context.getClickedPos());
+- if (blockState.is(BlockTags.BANNERS)) {
++ IBlockData iblockdata = context.getLevel().getBlockState(context.getClickedPos());
++
++ if (iblockdata.is(BlockTags.BANNERS)) {
+ if (!context.getLevel().isClientSide) {
+- MapItemSavedData savedData = getSavedData(context.getItemInHand(), context.getLevel());
+- if (savedData != null && !savedData.toggleBanner(context.getLevel(), context.getClickedPos())) {
++ MapItemSavedData worldmap = getSavedData(context.getItemInHand(), context.getLevel());
++
++ if (worldmap != null && !worldmap.toggleBanner(context.getLevel(), context.getClickedPos())) {
+ return InteractionResult.FAIL;
+ }
+ }