aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/mixins/MapRendererMixin.java
blob: 36620fdf4ab5a66322866e0a4df607d5ac86530c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package de.hysky.skyblocker.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.client.render.MapRenderer;
import net.minecraft.item.map.MapDecoration;
import net.minecraft.item.map.MapDecorationType;
import net.minecraft.item.map.MapDecorationTypes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(MapRenderer.class)
public class MapRendererMixin {
	@ModifyExpressionValue(method = "createDecoration", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/map/MapDecoration;isAlwaysRendered()Z"))
	private boolean preventDecorationInDungeons(boolean alwaysRendered, @Local(argsOnly = true) MapDecoration decoration) {
		// Allow alwaysRendered if
		// 1. not in dungeons and map is disabled OR
		// 2. the decoration type is frame (self player) and don't show self head OR
		// 3. the decoration type is blue marker (other player) and the fancy map is off
		if (Utils.isInDungeons() && SkyblockerConfigManager.get().dungeons.dungeonMap.enableMap) {
			MapDecorationType decorationType = decoration.type().value();
			boolean shouldShowSelfMarker = decorationType.equals(MapDecorationTypes.FRAME.value()) && !SkyblockerConfigManager.get().dungeons.dungeonMap.showSelfHead;
			boolean shouldShowOtherPlayerMarkers = decorationType.equals(MapDecorationTypes.BLUE_MARKER.value()) && !SkyblockerConfigManager.get().dungeons.dungeonMap.fancyMap;

			return shouldShowSelfMarker || shouldShowOtherPlayerMarkers;
		}

		return alwaysRendered;
	}
}