Hi,
i'm trying to create a custom FilledMapItem which are filled with one color.
When I had one map (white) everything worked fine. The problem is that after creating a second map both maps appear the same and are flickering with white and black colors.
I don't know where else to search for help with this
package com.example.examplemod;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.entity.Entity;
import net.minecraft.item.FilledMapItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.storage.MapData;
public class ModImageMapItem extends FilledMapItem {
public ModImageMapItem(Item.Properties builder) {
super(builder);
}
protected MapData getCustomMapData(ItemStack stack, World worldIn) {
MapData mapdata = func_219994_a(stack, worldIn);
if (mapdata == null && !worldIn.isRemote) {
mapdata = createMapData(stack, worldIn, worldIn.getWorldInfo().getSpawnX(), worldIn.getWorldInfo().getSpawnZ(), 3, false, false, worldIn.dimension.getType());
}
drawMyMap(worldIn, null, mapdata, this);
return mapdata;
}
private static MapData createMapData(ItemStack p_195951_0_, World p_195951_1_, int p_195951_2_, int p_195951_3_, int p_195951_4_, boolean p_195951_5_, boolean p_195951_6_, DimensionType p_195951_7_) {
int i = p_195951_1_.getNextMapId();
MapData mapdata = new MapData(func_219993_a(i));
mapdata.func_212440_a(p_195951_2_, p_195951_3_, p_195951_4_, p_195951_5_, p_195951_6_, p_195951_7_);
p_195951_1_.func_217399_a(mapdata);
p_195951_0_.getOrCreateTag().putInt("map", i);
return mapdata;
}
public void updateMapData(World worldIn, Entity viewer, MapData mapdata) {
drawMyMap(worldIn, viewer, mapdata, this);
}
private static void drawMyMap(World worldIn, Entity viewer, MapData mapdata, ModImageMapItem item) {
byte bColor = 0;
if (item.getName().toString().contains("item.poison64.image_map_white")) {
bColor = (byte)(MaterialColor.SNOW.colorIndex*4+2);
} else if (item.getName().toString().contains("item.poison64.image_map_black")) {
bColor = (byte)(MaterialColor.BLACK.colorIndex*4+2);
}
for(int x=0;x<128;x++) {
for(int y=0;y<128;y++) {
mapdata.colors[y*128+x] = bColor;
mapdata.updateMapData(x, y);
}
}
mapdata.mapDecorations.clear();
mapdata.trackingPosition = false;
mapdata.markDirty();
}
}
new ModImageMapItem(new Item.Properties().group(ItemGroup.MISC).rarity(Rarity.RARE)).setRegistryName("poison64", "image_map_white"),
new ModImageMapItem(new Item.Properties().group(ItemGroup.MISC).rarity(Rarity.RARE)).setRegistryName("poison64", "image_map_black")
Thanks in advance,
poison64