Skip to content

Commit

Permalink
Merge pull request #304 from FTBTeam/feature/1.21/pointer-large-map
Browse files Browse the repository at this point in the history
[1.21] Add pointer to large minimap
  • Loading branch information
desht authored Jul 12, 2024
2 parents 50fa54f + a734dd1 commit c00ebbc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ private void mapIcons(MapIconEvent event) {

if (!event.getMapType().isMinimap()) {
event.add(new EntityMapIcon(mc.player, FaceIcon.getFace(mc.player.getGameProfile())));
event.add(new PointerIcon());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package dev.ftb.mods.ftbchunks.client.gui;

import com.mojang.math.Axis;
import dev.ftb.mods.ftbchunks.api.FTBChunksAPI;
import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon;
import dev.ftb.mods.ftbchunks.api.client.icon.MapType;
import dev.ftb.mods.ftblibrary.icon.Icon;
import dev.ftb.mods.ftblibrary.ui.BaseScreen;
import dev.ftb.mods.ftblibrary.ui.input.Key;
import dev.ftb.mods.ftblibrary.ui.input.MouseButton;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;

public class PointerIcon implements MapIcon {

private static final Icon POINTER = Icon.getIcon(FTBChunksAPI.rl("textures/player.png"));

@Override
public Vec3 getPos(float partialTick) {
Player player = Minecraft.getInstance().player;
return partialTick >= 1F ? player.position() : player.getPosition(partialTick);
}

@Override
public boolean onMousePressed(BaseScreen screen, MouseButton button) {
return false;
}

@Override
public boolean onKeyPressed(BaseScreen screen, Key key) {
return false;
}

@Override
public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int h, boolean outsideVisibleArea, int iconAlpha) {
Player player = Minecraft.getInstance().player;
graphics.pose().pushPose();
graphics.pose().translate(x + w / 2f, y + h / 2f, 0F);
graphics.pose().scale(2f, 2f, 2f);
graphics.pose().mulPose(Axis.ZP.rotationDegrees(player.getYRot() + 180F));
POINTER.draw(graphics, - w / 2, -h / 2, w, h);
graphics.pose().popPose();
}
}

0 comments on commit c00ebbc

Please sign in to comment.