|
|
@ -9,6 +9,7 @@ import net.minecraft.client.item.TooltipContext;
|
|
|
|
import net.minecraft.entity.damage.DamageSource;
|
|
|
|
import net.minecraft.entity.damage.DamageSource;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemGroup;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
|
|
@ -33,7 +34,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class TargetedEnderPearlItem extends Item {
|
|
|
|
public class TargetedEnderPearlItem extends Item {
|
|
|
|
public TargetedEnderPearlItem() {
|
|
|
|
public TargetedEnderPearlItem() {
|
|
|
|
super(new Settings().rarity(Rarity.UNCOMMON).maxCount(16));
|
|
|
|
super(new Settings().rarity(Rarity.UNCOMMON).group(ItemGroup.MISC).maxCount(16));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -48,7 +49,7 @@ public class TargetedEnderPearlItem extends Item {
|
|
|
|
if (!world.isClient()) {
|
|
|
|
if (!world.isClient()) {
|
|
|
|
CompoundTag tag = stack.getTag();
|
|
|
|
CompoundTag tag = stack.getTag();
|
|
|
|
if (tag == null) {
|
|
|
|
if (tag == null) {
|
|
|
|
tag = new CompoundTag();
|
|
|
|
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockPos target = new BlockPos(tag.getInt("TargetX"), tag.getInt("TargetY"), tag.getInt("TargetZ"));
|
|
|
|
BlockPos target = new BlockPos(tag.getInt("TargetX"), tag.getInt("TargetY"), tag.getInt("TargetZ"));
|
|
|
@ -57,11 +58,13 @@ public class TargetedEnderPearlItem extends Item {
|
|
|
|
|
|
|
|
|
|
|
|
if (user.dimension != dimension || dimension == null) {
|
|
|
|
if (user.dimension != dimension || dimension == null) {
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_in_different_dimension"));
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_in_different_dimension"));
|
|
|
|
} else {
|
|
|
|
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
|
|
|
if (((TeleportationRestrictorBlock.TeleportingEntity) user).cannotTeleport()) {
|
|
|
|
} else if (((TeleportationRestrictorBlock.TeleportingEntity) user).cannotTeleport()) {
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_restricted"));
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_restricted"));
|
|
|
|
|
|
|
|
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
|
|
|
} else if (world.getBlockState(target).getBlock() != RelicCraft.TELEPORTATION_BEACON_BLOCK || !world.getBlockState(target).get(AbstractDragonEggHolderBlock.ACTIVE)) {
|
|
|
|
} else if (world.getBlockState(target).getBlock() != RelicCraft.TELEPORTATION_BEACON_BLOCK || !world.getBlockState(target).get(AbstractDragonEggHolderBlock.ACTIVE)) {
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".missing_teleportation_beacon"));
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".missing_teleportation_beacon"));
|
|
|
|
|
|
|
|
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Vec3d oldPos = user.getPos();
|
|
|
|
Vec3d oldPos = user.getPos();
|
|
|
|
if (user.teleport(teleportTarget.getX(), teleportTarget.getY(), teleportTarget.getZ(), true)) {
|
|
|
|
if (user.teleport(teleportTarget.getX(), teleportTarget.getY(), teleportTarget.getZ(), true)) {
|
|
|
@ -79,7 +82,7 @@ public class TargetedEnderPearlItem extends Item {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_obstructed"));
|
|
|
|
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_obstructed"));
|
|
|
|
}
|
|
|
|
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,8 +97,9 @@ public class TargetedEnderPearlItem extends Item {
|
|
|
|
|
|
|
|
|
|
|
|
CompoundTag tag = stack.getTag();
|
|
|
|
CompoundTag tag = stack.getTag();
|
|
|
|
if (tag == null) {
|
|
|
|
if (tag == null) {
|
|
|
|
tag = new CompoundTag();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".tooltip.targeted_ender_pearl.x", new LiteralText(String.valueOf(tag.getInt("TargetX"))).formatted(Formatting.GRAY)).formatted(Formatting.WHITE));
|
|
|
|
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".tooltip.targeted_ender_pearl.x", new LiteralText(String.valueOf(tag.getInt("TargetX"))).formatted(Formatting.GRAY)).formatted(Formatting.WHITE));
|
|
|
|
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".tooltip.targeted_ender_pearl.y", new LiteralText(String.valueOf(tag.getInt("TargetY"))).formatted(Formatting.GRAY)).formatted(Formatting.WHITE));
|
|
|
|
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".tooltip.targeted_ender_pearl.y", new LiteralText(String.valueOf(tag.getInt("TargetY"))).formatted(Formatting.GRAY)).formatted(Formatting.WHITE));
|
|
|
|
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".tooltip.targeted_ender_pearl.z", new LiteralText(String.valueOf(tag.getInt("TargetZ"))).formatted(Formatting.GRAY)).formatted(Formatting.WHITE));
|
|
|
|
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".tooltip.targeted_ender_pearl.z", new LiteralText(String.valueOf(tag.getInt("TargetZ"))).formatted(Formatting.GRAY)).formatted(Formatting.WHITE));
|
|
|
|