diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationMarker.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationMarker.java index 97c7e4f57..f188f0486 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationMarker.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationMarker.java @@ -9,6 +9,7 @@ import com.mojang.math.Matrix4f; import com.simibubi.create.AllTileEntities; import com.simibubi.create.Create; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; +import com.simibubi.create.foundation.map.CustomRenderedMapDecoration; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Components; @@ -25,15 +26,19 @@ import net.minecraft.world.level.saveddata.maps.MapDecoration; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; public class StationMarker { + // Not MANSION or MONUMENT to allow map extending + public static final MapDecoration.Type TYPE = MapDecoration.Type.RED_MARKER; private final BlockPos source; private final BlockPos target; private final Component name; + private final String id; public StationMarker(BlockPos source, BlockPos target, Component name) { this.source = source; this.target = target; this.name = name; + id = "create:station-" + target.getX() + "," + target.getY() + "," + target.getZ(); } public static StationMarker load(CompoundTag tag) { @@ -59,13 +64,29 @@ public class StationMarker { public CompoundTag save() { CompoundTag tag = new CompoundTag(); - tag.put("source", NbtUtils.writeBlockPos(this.source)); - tag.put("target", NbtUtils.writeBlockPos(this.target)); - tag.putString("name", Component.Serializer.toJson(this.name)); + tag.put("source", NbtUtils.writeBlockPos(source)); + tag.put("target", NbtUtils.writeBlockPos(target)); + tag.putString("name", Component.Serializer.toJson(name)); return tag; } + public BlockPos getSource() { + return source; + } + + public BlockPos getTarget() { + return target; + } + + public Component getName() { + return name; + } + + public String getId() { + return id; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -79,33 +100,18 @@ public class StationMarker { @Override public int hashCode() { - return Objects.hash(this.target, this.name); + return Objects.hash(target, name); } - public BlockPos getTarget() { - return this.target; - } + public static class Decoration extends MapDecoration implements CustomRenderedMapDecoration { + private static final RenderType RENDER_TYPE = RenderType.text(Create.asResource("textures/gui/station_map_icon.png")); - public BlockPos getSource() { - return this.source; - } + public Decoration(byte x, byte y, Component name) { + super(TYPE, x, y, (byte) 0, name); + } - public Component getName() { - return name; - } - - public MapDecoration.Type getType() { - return MapDecoration.Type.MANSION; - } - - public String getId() { - return "create:station-" + this.target.getX() + "," + this.target.getY() + "," + this.target.getZ(); - } - - public static class Decoration extends MapDecoration { - - public Decoration(byte pX, byte pY, Component pName) { - super(Type.MANSION, pX, pY, (byte) 0, pName); + public static Decoration from(MapDecoration decoration) { + return new StationMarker.Decoration(decoration.getX(), decoration.getY(), decoration.getName()); } @Override @@ -114,52 +120,48 @@ public class StationMarker { } @Override - public boolean render(int index) { - return true; - } + public void render(PoseStack poseStack, MultiBufferSource bufferSource, boolean active, int packedLight, MapItemSavedData mapData, int index) { + poseStack.pushPose(); - public boolean render(PoseStack ms, MultiBufferSource bufferSource, int mapId, MapItemSavedData mapData, boolean active, int packedLight, int index) { - ms.pushPose(); + poseStack.translate(getX() / 2D + 64.0, getY() / 2D + 64.0, -0.02D); - ms.translate(getX() / 2D + 64.0, getY() / 2D + 64.0, -0.02D); + poseStack.pushPose(); - ms.pushPose(); - - ms.translate(0.5f, 0f, 0); - ms.scale(4.5F, 4.5F, 3.0F); - - VertexConsumer buffer = bufferSource.getBuffer(RenderType.text(Create.asResource("textures/gui/station_map_icon.png"))); + poseStack.translate(0.5f, 0f, 0); + poseStack.scale(4.5F, 4.5F, 3.0F); + VertexConsumer buffer = bufferSource.getBuffer(RENDER_TYPE); + Matrix4f mat = poseStack.last().pose(); float zOffset = -0.001f; - float alpha = 1f; + buffer.vertex(mat, -1, -1, zOffset * index).color(255, 255, 255, 255).uv(0.0f , 0.0f ).uv2(packedLight).endVertex(); + buffer.vertex(mat, -1, 1, zOffset * index).color(255, 255, 255, 255).uv(0.0f , 0.0f + 1.0f).uv2(packedLight).endVertex(); + buffer.vertex(mat, 1, 1, zOffset * index).color(255, 255, 255, 255).uv(0.0f + 1.0f, 0.0f + 1.0f).uv2(packedLight).endVertex(); + buffer.vertex(mat, 1, -1, zOffset * index).color(255, 255, 255, 255).uv(0.0f + 1.0f, 0.0f ).uv2(packedLight).endVertex(); - Matrix4f mat = ms.last().pose(); - buffer.vertex(mat, -1, -1, zOffset * index).color(1f, 1f, 1f, alpha).uv(0.0f , 0.0f ).uv2(packedLight).endVertex(); - buffer.vertex(mat, -1, 1, zOffset * index).color(1f, 1f, 1f, alpha).uv(0.0f , 0.0f + 1.0f).uv2(packedLight).endVertex(); - buffer.vertex(mat, 1, 1, zOffset * index).color(1f, 1f, 1f, alpha).uv(0.0f + 1.0f, 0.0f + 1.0f).uv2(packedLight).endVertex(); - buffer.vertex(mat, 1, -1, zOffset * index).color(1f, 1f, 1f, alpha).uv(0.0f + 1.0f, 0.0f ).uv2(packedLight).endVertex(); - - ms.popPose(); + poseStack.popPose(); if (getName() != null) { Font font = Minecraft.getInstance().font; Component component = getName(); float f6 = (float)font.width(component); // float f7 = Mth.clamp(25.0F / f6, 0.0F, 6.0F / 9.0F); - ms.pushPose(); - //ms.translate((double)(0.0F + (float)getX() / 2.0F + 64.0F / 2.0F), (double)(0.0F + (float)getY() / 2.0F + 64.0F + 4.0F), (double)-0.025F); - ms.translate(0, 6.0D, -0.005F); + poseStack.pushPose(); +// poseStack.translate((double)(0.0F + (float)getX() / 2.0F + 64.0F / 2.0F), (double)(0.0F + (float)getY() / 2.0F + 64.0F + 4.0F), (double)-0.025F); + poseStack.translate(0, 6.0D, -0.005F); - ms.scale(0.8f, 0.8f, 1.0F); - ms.translate(-f6 / 2f + .5f, 0, 0); - //ms.scale(f7, f7, 1.0F); - font.drawInBatch(component, 0.0F, 0.0F, -1, false, ms.last().pose(), bufferSource, false, Integer.MIN_VALUE, 15728880); - ms.popPose(); + poseStack.scale(0.8f, 0.8f, 1.0F); + poseStack.translate(-f6 / 2f + .5f, 0, 0); +// poseStack.scale(f7, f7, 1.0F); + font.drawInBatch(component, 0.0F, 0.0F, -1, false, poseStack.last().pose(), bufferSource, false, Integer.MIN_VALUE, 15728880); + poseStack.popPose(); } - ms.popPose(); + poseStack.popPose(); + } - return false; + @Override + public boolean render(int index) { + return true; } } } diff --git a/src/main/java/com/simibubi/create/foundation/map/CustomRenderedMapDecoration.java b/src/main/java/com/simibubi/create/foundation/map/CustomRenderedMapDecoration.java new file mode 100644 index 000000000..0692f133e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/map/CustomRenderedMapDecoration.java @@ -0,0 +1,10 @@ +package com.simibubi.create.foundation.map; + +import com.mojang.blaze3d.vertex.PoseStack; + +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.level.saveddata.maps.MapItemSavedData; + +public interface CustomRenderedMapDecoration { + void render(PoseStack poseStack, MultiBufferSource bufferSource, boolean active, int packedLight, MapItemSavedData mapData, int index); +} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/ClientboundMapItemDataPacketMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/ClientboundMapItemDataPacketMixin.java new file mode 100644 index 000000000..e1cfdeabd --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/ClientboundMapItemDataPacketMixin.java @@ -0,0 +1,73 @@ +package com.simibubi.create.foundation.mixin; + +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nullable; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationMarker; + +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket; +import net.minecraft.world.level.saveddata.maps.MapDecoration; +import net.minecraft.world.level.saveddata.maps.MapItemSavedData; + +// random priority to prevent networking conflicts +@Mixin(value = ClientboundMapItemDataPacket.class, priority = 826) +public class ClientboundMapItemDataPacketMixin { + @Shadow + @Final + private List decorations; + + @Unique + private int[] stationIndices; + + @Inject(method = "(IBZLjava/util/Collection;Lnet/minecraft/world/level/saveddata/maps/MapItemSavedData$MapPatch;)V", at = @At("RETURN")) + private void onInit(int mapId, byte scale, boolean locked, @Nullable Collection decorations, @Nullable MapItemSavedData.MapPatch colorPatch, CallbackInfo ci) { + stationIndices = getStationIndices(this.decorations); + } + + private static int[] getStationIndices(List decorations) { + if (decorations == null) { + return new int[0]; + } + + IntList indices = new IntArrayList(); + for (int i = 0; i < decorations.size(); i++) { + MapDecoration decoration = decorations.get(i); + if (decoration instanceof StationMarker.Decoration) { + indices.add(i); + } + } + return indices.toIntArray(); + } + + @Inject(method = "(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At("RETURN")) + private void onInit(FriendlyByteBuf buf, CallbackInfo ci) { + stationIndices = buf.readVarIntArray(); + + if (decorations != null) { + for (int i : stationIndices) { + if (i >= 0 && i < decorations.size()) { + MapDecoration decoration = decorations.get(i); + decorations.set(i, StationMarker.Decoration.from(decoration)); + } + } + } + } + + @Inject(method = "write(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At("RETURN")) + private void onWrite(FriendlyByteBuf buf, CallbackInfo ci) { + buf.writeVarIntArray(stationIndices); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixin.java index ae842bd6b..203401f6c 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixin.java @@ -1,11 +1,14 @@ package com.simibubi.create.foundation.mixin; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Map; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -19,6 +22,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.station import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.saveddata.maps.MapDecoration; @@ -26,80 +30,101 @@ import net.minecraft.world.level.saveddata.maps.MapItemSavedData; @Mixin(MapItemSavedData.class) public class MapItemSavedDataMixin implements StationMapData { + @Unique + private static final String STATION_MARKERS_KEY = "create:stations"; - @Final @Shadow + @Final public int x; - @Final @Shadow + @Final public int z; - @Final @Shadow + @Final public byte scale; - @Final @Shadow + @Final Map decorations; - private final Map stationMarkers = Maps.newLinkedHashMap(); + @Shadow + private int trackedDecorationCount; - @Inject( - method = "save(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;", - at = @At("RETURN") - ) - public void save(CompoundTag compound, CallbackInfoReturnable cir) { - - ListTag listTag = new ListTag(); - for (StationMarker stationMarker : this.stationMarkers.values()) { - listTag.add(stationMarker.save()); - } - - cir.getReturnValue().put("create:stations", listTag); - } + @Unique + private final Map stationMarkers = Maps.newHashMap(); @Inject( method = "load(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/level/saveddata/maps/MapItemSavedData;", at = @At("RETURN") ) - private static void load(CompoundTag compound, CallbackInfoReturnable cir) { + private static void onLoad(CompoundTag compound, CallbackInfoReturnable cir) { MapItemSavedData mapData = cir.getReturnValue(); StationMapData stationMapData = (StationMapData) mapData; - ListTag listTag = compound.getList("create:stations", 10); - for (int k = 0; k < listTag.size(); ++k) { - StationMarker stationMarker = StationMarker.load(listTag.getCompound(k)); + ListTag listTag = compound.getList(STATION_MARKERS_KEY, Tag.TAG_COMPOUND); + for (int i = 0; i < listTag.size(); ++i) { + StationMarker stationMarker = StationMarker.load(listTag.getCompound(i)); stationMapData.addStationMarker(stationMarker); } } + @Inject( + method = "save(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;", + at = @At("RETURN") + ) + public void onSave(CompoundTag compound, CallbackInfoReturnable cir) { + ListTag listTag = new ListTag(); + for (StationMarker stationMarker : stationMarkers.values()) { + listTag.add(stationMarker.save()); + } + compound.put(STATION_MARKERS_KEY, listTag); + } + @Override public void addStationMarker(StationMarker marker) { stationMarkers.put(marker.getId(), marker); - int scaleMultiplier = 1 << this.scale; + int scaleMultiplier = 1 << scale; + float localX = (marker.getTarget().getX() - x) / (float) scaleMultiplier; + float localZ = (marker.getTarget().getZ() - z) / (float) scaleMultiplier; - double localX = ((double) marker.getTarget().getX() - (double) this.x) / (double) scaleMultiplier; - double localZ = ((double) marker.getTarget().getZ() - (double) this.z) / (double) scaleMultiplier; - - if (localX < -63.0D || localX > 63.0D || localZ < -63.0D || localZ > 63.0D) + if (localX < -63.0F || localX > 63.0F || localZ < -63.0F || localZ > 63.0F) { + removeDecoration(marker.getId()); return; + } - byte localXByte = (byte) (int) (localX * 2.0F + 0.5D); - byte localZByte = (byte) (int) (localZ * 2.0F + 0.5D); + byte localXByte = (byte) (int) (localX * 2.0F + 0.5F); + byte localZByte = (byte) (int) (localZ * 2.0F + 0.5F); MapDecoration decoration = new StationMarker.Decoration(localXByte, localZByte, marker.getName()); - this.decorations.put(marker.getId(), decoration); + MapDecoration oldDecoration = decorations.put(marker.getId(), decoration); + if (!decoration.equals(oldDecoration)) { + if (oldDecoration != null && oldDecoration.getType().shouldTrackCount()) { + --trackedDecorationCount; + } + + if (decoration.getType().shouldTrackCount()) { + ++trackedDecorationCount; + } + + setDecorationsDirty(); + } } @Shadow - private void removeDecoration(String pIdentifier) { + private void removeDecoration(String identifier) { throw new AssertionError(); } @Shadow - public boolean isTrackedCountOverLimit(int pTrackedCount) { + private void setDecorationsDirty() { + throw new AssertionError(); + } + + @Shadow + public boolean isTrackedCountOverLimit(int trackedCount) { throw new AssertionError(); } @@ -107,10 +132,10 @@ public class MapItemSavedDataMixin implements StationMapData { public boolean toggleStation(LevelAccessor level, BlockPos pos, StationTileEntity stationTileEntity) { double xCenter = pos.getX() + 0.5D; double zCenter = pos.getZ() + 0.5D; - int scaleMultiplier = 1 << this.scale; + int scaleMultiplier = 1 << scale; - double localX = (xCenter - (double) this.x) / (double) scaleMultiplier; - double localZ = (zCenter - (double) this.z) / (double) scaleMultiplier; + double localX = (xCenter - (double) x) / (double) scaleMultiplier; + double localZ = (zCenter - (double) z) / (double) scaleMultiplier; if (localX < -63.0D || localX > 63.0D || localZ < -63.0D || localZ > 63.0D) return false; @@ -119,13 +144,14 @@ public class MapItemSavedDataMixin implements StationMapData { if (marker == null) return false; - if (this.stationMarkers.remove(marker.getId(), marker)) { - this.removeDecoration(marker.getId()); + if (stationMarkers.remove(marker.getId(), marker)) { + removeDecoration(marker.getId()); return true; } - if (!this.isTrackedCountOverLimit(256)) { + if (!isTrackedCountOverLimit(256)) { addStationMarker(marker); + return true; } return false; @@ -135,26 +161,31 @@ public class MapItemSavedDataMixin implements StationMapData { method = "checkBanners(Lnet/minecraft/world/level/BlockGetter;II)V", at = @At("RETURN") ) - public void checkBanners(BlockGetter pReader, int pX, int pZ, CallbackInfo ci) { - checkStations(pReader, pX, pZ); + public void checkBanners(BlockGetter blockGetter, int x, int z, CallbackInfo ci) { + checkStations(blockGetter, x, z); } - private void checkStations(BlockGetter pReader, int pX, int pZ) { - Iterator iterator = this.stationMarkers.values().iterator(); + private void checkStations(BlockGetter blockGetter, int x, int z) { + Iterator iterator = stationMarkers.values().iterator(); + List newMarkers = new ArrayList<>(); while (iterator.hasNext()) { StationMarker marker = iterator.next(); - if (marker.getTarget().getX() == pX && marker.getTarget().getZ() == pZ) { - StationMarker other = StationMarker.fromWorld(pReader, marker.getSource()); + if (marker.getTarget().getX() == x && marker.getTarget().getZ() == z) { + StationMarker other = StationMarker.fromWorld(blockGetter, marker.getSource()); if (!marker.equals(other)) { iterator.remove(); - this.removeDecoration(marker.getId()); + removeDecoration(marker.getId()); if (other != null && marker.getTarget().equals(other.getTarget())) { - addStationMarker(other); + newMarkers.add(other); } } } } + + for (StationMarker marker : newMarkers) { + addStationMarker(marker); + } } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixinClient.java b/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixinClient.java deleted file mode 100644 index 2898b7023..000000000 --- a/src/main/java/com/simibubi/create/foundation/mixin/MapItemSavedDataMixinClient.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.simibubi.create.foundation.mixin; - -import java.util.List; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationMarker; - -import net.minecraft.world.level.saveddata.maps.MapDecoration; -import net.minecraft.world.level.saveddata.maps.MapDecoration.Type; -import net.minecraft.world.level.saveddata.maps.MapItemSavedData; - -@Mixin(MapItemSavedData.class) -public class MapItemSavedDataMixinClient { - - @Inject(method = "addClientSideDecorations(Ljava/util/List;)V", at = @At("HEAD")) - private void addClientSideDecorations(List pDecorations, CallbackInfo ci) { - for (int i = 0; i < pDecorations.size(); i++) { - MapDecoration deco = pDecorations.get(i); - if (deco.getType() != Type.MANSION) - continue; - if (deco.getName() == null) - continue; - pDecorations.set(i, new StationMarker.Decoration(deco.getX(), deco.getY(), deco.getName())); - } - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/MapRendererMapInstanceMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/MapRendererMapInstanceMixin.java new file mode 100644 index 000000000..376dd888c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/MapRendererMapInstanceMixin.java @@ -0,0 +1,32 @@ +package com.simibubi.create.foundation.mixin; + +import java.util.Iterator; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Matrix4f; +import com.simibubi.create.foundation.map.CustomRenderedMapDecoration; + +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.level.saveddata.maps.MapDecoration; +import net.minecraft.world.level.saveddata.maps.MapItemSavedData; + +@Mixin(targets = "net.minecraft.client.gui.MapRenderer$MapInstance") +public class MapRendererMapInstanceMixin { + @Shadow + private MapItemSavedData data; + + @Inject(method = "draw(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ZI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/saveddata/maps/MapDecoration;render(I)Z", remap = false), locals = LocalCapture.CAPTURE_FAILHARD) + private void onDraw(PoseStack poseStack, MultiBufferSource bufferSource, boolean active, int packedLight, CallbackInfo ci, int i, int j, float f, Matrix4f matrix4f, VertexConsumer vertexConsumer, int index, Iterator iterator, MapDecoration decoration) { + if (decoration instanceof CustomRenderedMapDecoration renderer) { + renderer.render(poseStack, bufferSource, active, packedLight, data, index); + } + } +} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/MapRendererMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/MapRendererMixin.java deleted file mode 100644 index acf8efad2..000000000 --- a/src/main/java/com/simibubi/create/foundation/mixin/MapRendererMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.simibubi.create.foundation.mixin; - -import java.util.Collection; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationMarker; - -import net.minecraft.client.gui.MapRenderer; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.world.level.saveddata.maps.MapDecoration; -import net.minecraft.world.level.saveddata.maps.MapItemSavedData; - -@Mixin(MapRenderer.class) -public class MapRendererMixin { - - @Inject( - method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/level/saveddata/maps/MapItemSavedData;ZI)V", - at = @At("TAIL") - ) - public void render(PoseStack ms, MultiBufferSource buffer, int mapId, MapItemSavedData mapData, boolean active, int packedLight, CallbackInfo ci) { - Iterable decorations = mapData.getDecorations(); - int index = 32; - if (decorations instanceof Collection) { - index = ((Collection) decorations).size(); - } - - for (MapDecoration deco : decorations) { - if (!(deco instanceof StationMarker.Decoration stationDeco)) - continue; - - stationDeco.render(ms, buffer, mapId, mapData, active, packedLight, index++); - } - } - -} diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index f3af76190..beb183914 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -5,6 +5,8 @@ "compatibilityLevel": "JAVA_16", "refmap": "create.refmap.json", "mixins": [ + "ClientboundMapItemDataPacketMixin", + "ContraptionDriverInteractMixin", "CustomItemUseEffectsMixin", "MapItemSavedDataMixin", "ContraptionDriverInteractMixin", @@ -15,14 +17,13 @@ "accessor.ServerLevelAccessor" ], "client": [ - "MapItemSavedDataMixinClient", "CameraMixin", "DestroyProgressMixin", "EntityContraptionInteractionMixin", "FixNormalScalingMixin", "GameRendererMixin", "HeavyBootsOnPlayerMixin", - "MapRendererMixin", + "MapRendererMapInstanceMixin", "ModelDataRefreshMixin", "WindowResizeMixin", "accessor.AgeableListModelAccessor",