added GPS by Ayutac (#3054)
* added GPS by Ayutac * removed the broken tooltip Co-authored-by: ayutac <fly.high.android@gmail.com>
This commit is contained in:
parent
f9bf648bfe
commit
3d5300e908
8 changed files with 123 additions and 0 deletions
64
src/main/java/techreborn/items/GpsItem.java
Normal file
64
src/main/java/techreborn/items/GpsItem.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2020 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.items;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
public class GpsItem extends Item {
|
||||
|
||||
public GpsItem() {
|
||||
super(new Settings().group(TechReborn.ITEMGROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
if (player instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
BlockPos pos = player.getBlockPos();
|
||||
ChatUtils.sendNoSpamMessage(serverPlayerEntity, MessageIDs.freqTransmitterID,
|
||||
Text.literal(" X:").formatted(Formatting.GRAY)
|
||||
.append(Text.literal(String.valueOf(pos.getX())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Y:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getY())).formatted(Formatting.GOLD))
|
||||
.append(Text.literal(" Z:").formatted(Formatting.GRAY))
|
||||
.append(Text.literal(String.valueOf(pos.getZ())).formatted(Formatting.GOLD)));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.PASS, stack);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue