Skip to content

Commit

Permalink
Fixed tpx and clickable coords
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Aug 1, 2017
1 parent 29d67e5 commit ada7d95
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -30,7 +30,7 @@ apply plugin: "idea-utils"
apply plugin: "maven"

group = "net.doubledoordev.d3commands"
version = "1.3.0"
version = "1.3.1"

targetCompatibility = 1.7
sourceCompatibility = 1.7
Expand Down Expand Up @@ -60,6 +60,7 @@ if (System.getenv().BUILD_NUMBER != null) version += "." + System.getenv().BUILD
//noinspection GroovyAssignabilityCheck
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version':project.version, 'mcversion':project.minecraft.version, 'modid':project.archivesBaseName, 'githuborg':githuborg, 'description':description, 'group':project.group, 'artifactId':project.archivesBaseName
}

Expand Down
Expand Up @@ -39,6 +39,8 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.Teleporter;
import net.minecraftforge.fml.common.FMLCommonHandler;

import javax.annotation.Nullable;
import java.util.EnumSet;
Expand Down Expand Up @@ -97,9 +99,14 @@ else if (target.worldObj != null)
CommandBase.CoordinateArg yaw = parseCoordinate((double)target.rotationYaw, args.length > j ? args[j++] : "~", false);
CommandBase.CoordinateArg pitch = parseCoordinate((double)target.rotationPitch, args.length > j ? args[j] : "~", false);

BlockPosDim dest;
if (target.dimension != dim) target.changeDimension(dim);
target.dismountRidingEntity();
if (target.dimension != dim)
{
target = dimChange(target, dim);
if (target == null) return;
}

BlockPosDim dest;
if (target instanceof EntityPlayerMP)
{
Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class);
Expand All @@ -115,7 +122,7 @@ else if (target.worldObj != null)
target.dismountRidingEntity();
((EntityPlayerMP)target).connection.setPlayerLocation(x.getAmount(), y.getAmount(), z.getAmount(), f, f1, set);
target.setRotationYawHead(f);
dest = new BlockPosDim(x.getAmount(), y.getAmount(), z.getAmount(), dim);
dest = new BlockPosDim(x.getResult(), y.getResult(), z.getResult(), dim);
}
else
{
Expand All @@ -133,8 +140,12 @@ else if (target.worldObj != null)
{
Entity dest = getEntity(server, sender, args[args.length - 1]);

if (target.dimension != dest.dimension) target.changeDimension(dest.dimension);
target.dismountRidingEntity();
if (target.dimension != dest.dimension)
{
target = dimChange(target, dest.dimension);
if (target == null) return;
}

if (target instanceof EntityPlayerMP)
{
Expand All @@ -150,6 +161,42 @@ else if (target.worldObj != null)
}
}

private Entity dimChange(Entity target, int dimension)
{
if (target instanceof EntityPlayerMP)
{
MinecraftServer s = FMLCommonHandler.instance().getMinecraftServerInstance();
Teleporter t = new Teleporter(s.worldServerForDimension(dimension)) {
@Override
public void placeInPortal(Entity entityIn, float rotationYaw)
{

}

@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
{
return true;
}

@Override
public boolean makePortal(Entity entityIn)
{
return true;
}

@Override
public void removeStalePortalLocations(long worldTime)
{

}
};
s.getPlayerList().transferPlayerToDimension(((EntityPlayerMP) target), dimension, t);
return target;
}
return target.changeDimension(dimension);
}

@Override
public int getRequiredPermissionLevel()
{
Expand Down
Expand Up @@ -75,7 +75,7 @@ public BlockPosDim(Vec3i source, int dim)

public ITextComponent toClickableChatString()
{
return new TextComponentString("[" + getX() + "X " + getY() + "Y " + getZ() + "Z]").setStyle(new Style().setClickEvent(
return new TextComponentString("[" + getX() + " " + getY() + " " + getZ() + "]").setStyle(new Style().setItalic(true).setClickEvent(
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpx " + dim + " " + getX() + " " + getY() + " " + getZ())));
}

Expand Down

0 comments on commit ada7d95

Please sign in to comment.