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:
Ayutac 2022-11-08 09:48:37 +01:00 committed by GitHub
parent f9bf648bfe
commit 3d5300e908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 123 additions and 0 deletions

View file

@ -221,6 +221,7 @@ public class ModRegistry {
RebornRegistry.registerItem(TRContent.CLOAKING_DEVICE = InitUtils.setup(new CloakingDeviceItem(), "cloaking_device"));
// Other
RebornRegistry.registerItem(TRContent.GPS = InitUtils.setup(new GpsItem(), "gps"));
RebornRegistry.registerItem(TRContent.FREQUENCY_TRANSMITTER = InitUtils.setup(new FrequencyTransmitterItem(), "frequency_transmitter"));
RebornRegistry.registerItem(TRContent.SCRAP_BOX = InitUtils.setup(new ScrapBoxItem(), "scrap_box"));
RebornRegistry.registerItem(TRContent.MANUAL = InitUtils.setup(new ManualItem(), "manual"));

View file

@ -163,6 +163,7 @@ public class TRContent {
// Other
public static Item FREQUENCY_TRANSMITTER;
public static Item GPS;
public static Item SCRAP_BOX;
public static Item MANUAL;
public static DynamicCellItem CELL;

View 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);
}
}

View file

@ -697,6 +697,7 @@
"_comment17": "Items-Misc",
"item.techreborn.cell": "Empty Cell",
"item.techreborn.cell.fluid": "$fluid$ Cell",
"item.techreborn.gps": "GPS",
"item.techreborn.frequency_transmitter": "Frequency Transmitter",
"item.techreborn.manual": "Tech Reborn Manual",
"item.techreborn.missingRecipe": "Missing Recipe Placeholder",

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/tool/gps"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

View file

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"techreborn:crafting_table/tool/gps"
]
},
"criteria": {
"has_basic_display": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": ["techreborn:basic_display"]
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "techreborn:crafting_table/tool/gps"
}
}
},
"requirements": [
[
"has_basic_display",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"B",
"C"
],
"key": {
"B": {
"item": "techreborn:basic_display"
},
"C": {
"item": "minecraft:compass"
}
},
"result": {
"item": "techreborn:gps"
}
}