forked from plusls/xaero-map-addition
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccf1637
commit e3b3a53
Showing
8 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.plusls.xma.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; | ||
import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; | ||
import xaero.map.MapProcessor; | ||
import xaero.map.gui.GuiMap; | ||
|
||
@Dependencies(and = @Dependency("xaeroworldmap")) | ||
@Mixin(value = GuiMap.class, remap = false) | ||
public interface AccessorGuiMap { | ||
@Accessor | ||
int getMouseBlockPosX(); | ||
|
||
@Accessor | ||
int getMouseBlockPosY(); | ||
|
||
@Accessor | ||
int getMouseBlockPosZ(); | ||
|
||
@Accessor | ||
MapProcessor getMapProcessor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.plusls.xma.util; | ||
|
||
import com.plusls.xma.config.Configs; | ||
import com.plusls.xma.mixin.AccessorGuiMap; | ||
import fi.dy.masa.malilib.hotkeys.IKeybind; | ||
import fi.dy.masa.malilib.hotkeys.KeyAction; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.resources.sounds.SimpleSoundInstance; | ||
import net.minecraft.sounds.SoundEvents; | ||
import top.hendrixshen.magiclib.util.InfoUtil; | ||
import xaero.map.gui.GuiMap; | ||
import xaero.map.world.MapDimension; | ||
|
||
public class QuickTeleportUtil { | ||
public static boolean teleport(KeyAction keyAction, IKeybind iKeybind) { | ||
if (!(Minecraft.getInstance().screen instanceof GuiMap)) { | ||
return false; | ||
} | ||
|
||
GuiMap guiMap = ((GuiMap) Minecraft.getInstance().screen); | ||
MapDimension currentDimension = ((AccessorGuiMap) guiMap).getMapProcessor().getMapWorld().getCurrentDimension(); | ||
|
||
// Disable teleport feature in survival or current world un-writeable. | ||
if (Minecraft.getInstance().gameMode == null || Minecraft.getInstance().gameMode.canHurtPlayer() | ||
|| currentDimension == null || !currentDimension.currentMultiworldWritable | ||
) { | ||
return false; | ||
} | ||
|
||
int mouseBlockPosX = ((AccessorGuiMap) guiMap).getMouseBlockPosX(); | ||
int mouseBlockPosY = ((AccessorGuiMap) guiMap).getMouseBlockPosY(); | ||
int mouseBlockPosZ = ((AccessorGuiMap) guiMap).getMouseBlockPosZ(); | ||
|
||
// Disable teleport feature if xaero map denied or mouseBlockPos cannot get. | ||
if ( | ||
//#if MC > 11502 | ||
!((AccessorGuiMap) guiMap).getMapProcessor().getMapWorld().isTeleportAllowed() || | ||
//#endif | ||
mouseBlockPosY == 32767 | ||
) { | ||
return false; | ||
} | ||
|
||
InfoUtil.sendCommand(String.format("tp @s %s %s %s", mouseBlockPosX, Minecraft.getInstance().player == null ? | ||
mouseBlockPosY : Minecraft.getInstance().player.getBlockYCompat(), mouseBlockPosZ)); | ||
Minecraft.getInstance().getSoundManager() | ||
.play(SimpleSoundInstance.forUI(SoundEvents.CHORUS_FRUIT_TELEPORT, 1.0F)); | ||
|
||
if (Configs.closeMapAfterQuickTeleport) { | ||
guiMap.onClose(); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters