Skip to content

Commit

Permalink
gate compass start
Browse files Browse the repository at this point in the history
  • Loading branch information
Laz-The-Artist committed Nov 30, 2024
1 parent 12efa4b commit 57ff787
Show file tree
Hide file tree
Showing 74 changed files with 373 additions and 31 deletions.
Binary file added res/btc_assets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 9 additions & 26 deletions src/main/java/net/martianz/beyondtheclouds/BeyondTheClouds.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.martianz.beyondtheclouds;

import net.martianz.beyondtheclouds.component.DataComponentz;
import net.martianz.beyondtheclouds.item.Itemz;
import net.martianz.beyondtheclouds.util.ItemPropertiez;
import org.slf4j.Logger;

import com.mojang.logging.LogUtils;
Expand Down Expand Up @@ -41,34 +44,14 @@ public class BeyondTheClouds {
public static final String MODID = "beyondtheclouds";
private static final Logger LOGGER = LogUtils.getLogger();

/** Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID);
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
// Creates a new Block with the id "examplemod:example_block", combining the namespace and path
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerSimpleBlock("example_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
// Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path
public static final DeferredItem<BlockItem> EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem("example_block", EXAMPLE_BLOCK);
// Creates a new food item with the id "examplemod:example_id", nutrition 1 and saturation 2
public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder()
.alwaysEdible().nutrition(1).saturationModifier(2f).build()));
// Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup.examplemod")) //The language key for the title of your CreativeModeTab
.withTabsBefore(CreativeModeTabs.COMBAT)
.icon(() -> EXAMPLE_ITEM.get().getDefaultInstance())
.displayItems((parameters, output) -> {
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
}).build());
**/
public BeyondTheClouds(IEventBus modEventBus, ModContainer modContainer) {
modEventBus.addListener(this::commonSetup);
NeoForge.EVENT_BUS.register(this);

Itemz.register(modEventBus);

DataComponentz.register(modEventBus);

modEventBus.addListener(this::addCreative);
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
}
Expand All @@ -91,7 +74,7 @@ public static class ClientModEvents {

@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {

ItemPropertiez.addItemProperties();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.martianz.beyondtheclouds.component;

import net.martianz.beyondtheclouds.BeyondTheClouds;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.registries.Registries;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.UnaryOperator;

public class DataComponentz {
public static final DeferredRegister<DataComponentType<?>> DATA_COMPONENT_TYPES =
DeferredRegister.createDataComponents(Registries.DATA_COMPONENT_TYPE, BeyondTheClouds.MODID);

public static final DeferredHolder<DataComponentType<?>, DataComponentType<BlockPos>> COORDINATE_COMPONENT = register("coordinates", builder -> builder.persistent(BlockPos.CODEC));

private static <T>DeferredHolder<DataComponentType<?>, DataComponentType<T>> register(String name, UnaryOperator<DataComponentType.Builder<T>> builderOperator){
return DATA_COMPONENT_TYPES.register(name, () -> builderOperator.apply(DataComponentType.builder()).build());
}

public static void register(IEventBus bus){
DATA_COMPONENT_TYPES.register(bus);
}
}
36 changes: 36 additions & 0 deletions src/main/java/net/martianz/beyondtheclouds/item/Itemz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.martianz.beyondtheclouds.item;

import net.martianz.beyondtheclouds.BeyondTheClouds;
import net.martianz.beyondtheclouds.item.custom.GateCompass;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.CompassItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.Supplier;

public class Itemz {
public static final DeferredRegister.Items ITEMZ = DeferredRegister.createItems(BeyondTheClouds.MODID);
public static final DeferredRegister<CreativeModeTab> CREATIVE_TAB = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, BeyondTheClouds.MODID);

public static final DeferredItem<Item> GATE_COMPASS = ITEMZ.registerItem("gate_compass", GateCompass::new, new Item.Properties());


public static final Supplier<CreativeModeTab> CLOUDREALM_TAB = CREATIVE_TAB.register("cloud_realm_tab",
() -> CreativeModeTab.builder().icon(() -> new ItemStack(GATE_COMPASS.get()))
.title(Component.translatable("creativetab.beyondtheclouds.cloudrealm_tab"))
.displayItems((itemDisplayParamaters, output) -> {
output.accept(GATE_COMPASS);
}).build());

public static void register(IEventBus eventBus){
ITEMZ.register(eventBus);
CREATIVE_TAB.register(eventBus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package net.martianz.beyondtheclouds.item.custom;

import net.martianz.beyondtheclouds.component.DataComponentz;
import net.martianz.beyondtheclouds.item.Itemz;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CompassItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;

import java.util.List;

public class GateCompass extends CompassItem {

public GateCompass(Properties properties) {
super(properties);
}

@Override
public InteractionResult use(Level level, Player player, InteractionHand interactionHand) {
ItemStack thisStack = player.getItemInHand(interactionHand);
if(thisStack.is(Itemz.GATE_COMPASS.get())){
//TODO Figure out position tracking hier
thisStack.set(DataComponentz.COORDINATE_COMPONENT, player.blockPosition());
}
return super.use(level, player, interactionHand);
}

@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
if(stack.get(DataComponentz.COORDINATE_COMPONENT) != null){
BlockPos pos=stack.get(DataComponentz.COORDINATE_COMPONENT);
tooltipComponents.add(Component.translatable("tooltip.gate_compass.target").append( ": x:" + pos.getX() +", y:" + pos.getY()+ ", z:" +pos.getZ()).withStyle(ChatFormatting.GRAY));
}
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.martianz.beyondtheclouds.util;

import net.martianz.beyondtheclouds.BeyondTheClouds;
import net.martianz.beyondtheclouds.component.DataComponentz;
import net.martianz.beyondtheclouds.item.Itemz;
import net.minecraft.client.renderer.item.CompassItemPropertyFunction;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.resources.ResourceLocation;

public class ItemPropertiez {

public static void addItemProperties(){
ItemProperties.register(Itemz.GATE_COMPASS.get(), ResourceLocation.fromNamespaceAndPath(BeyondTheClouds.MODID, "angle"),
new CompassItemPropertyFunction((clientLevel, stack, entity) -> {
BlockPos pos = new BlockPos(1, 1, 1);
if(stack.get(DataComponentz.COORDINATE_COMPONENT) != null){
pos = stack.get(DataComponentz.COORDINATE_COMPONENT);
}
return GlobalPos.of(clientLevel.dimension(), pos);
})
);
}

}
5 changes: 5 additions & 0 deletions src/main/resources/assets/beyondtheclouds/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"creativetab.beyondtheclouds.cloudrealm_tab": "Beyond The Clouds: Cloud Realm",
"tooltip.gate_compass.target": "Gate Location",
"item.beyondtheclouds.gate_compass": "Gate Compass"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_16"
},
"overrides": [
{
"predicate": { "beyondtheclouds:angle": 0.000000 }, "model": "beyondtheclouds:item/gate_compass" },
{ "predicate": { "beyondtheclouds:angle": 0.015625 }, "model": "beyondtheclouds:item/gate_compass_17" },
{ "predicate": { "beyondtheclouds:angle": 0.046875 }, "model": "beyondtheclouds:item/gate_compass_18" },
{ "predicate": { "beyondtheclouds:angle": 0.078125 }, "model": "beyondtheclouds:item/gate_compass_19" },
{ "predicate": { "beyondtheclouds:angle": 0.109375 }, "model": "beyondtheclouds:item/gate_compass_20" },
{ "predicate": { "beyondtheclouds:angle": 0.140625 }, "model": "beyondtheclouds:item/gate_compass_21" },
{ "predicate": { "beyondtheclouds:angle": 0.171875 }, "model": "beyondtheclouds:item/gate_compass_22" },
{ "predicate": { "beyondtheclouds:angle": 0.203125 }, "model": "beyondtheclouds:item/gate_compass_23" },
{ "predicate": { "beyondtheclouds:angle": 0.234375 }, "model": "beyondtheclouds:item/gate_compass_24" },
{ "predicate": { "beyondtheclouds:angle": 0.265625 }, "model": "beyondtheclouds:item/gate_compass_25" },
{ "predicate": { "beyondtheclouds:angle": 0.296875 }, "model": "beyondtheclouds:item/gate_compass_26" },
{ "predicate": { "beyondtheclouds:angle": 0.328125 }, "model": "beyondtheclouds:item/gate_compass_27" },
{ "predicate": { "beyondtheclouds:angle": 0.359375 }, "model": "beyondtheclouds:item/gate_compass_28" },
{ "predicate": { "beyondtheclouds:angle": 0.390625 }, "model": "beyondtheclouds:item/gate_compass_29" },
{ "predicate": { "beyondtheclouds:angle": 0.421875 }, "model": "beyondtheclouds:item/gate_compass_30" },
{ "predicate": { "beyondtheclouds:angle": 0.453125 }, "model": "beyondtheclouds:item/gate_compass_31" },
{ "predicate": { "beyondtheclouds:angle": 0.484375 }, "model": "beyondtheclouds:item/gate_compass_00" },
{ "predicate": { "beyondtheclouds:angle": 0.515625 }, "model": "beyondtheclouds:item/gate_compass_01" },
{ "predicate": { "beyondtheclouds:angle": 0.546875 }, "model": "beyondtheclouds:item/gate_compass_02" },
{ "predicate": { "beyondtheclouds:angle": 0.578125 }, "model": "beyondtheclouds:item/gate_compass_03" },
{ "predicate": { "beyondtheclouds:angle": 0.609375 }, "model": "beyondtheclouds:item/gate_compass_04" },
{ "predicate": { "beyondtheclouds:angle": 0.640625 }, "model": "beyondtheclouds:item/gate_compass_05" },
{ "predicate": { "beyondtheclouds:angle": 0.671875 }, "model": "beyondtheclouds:item/gate_compass_06" },
{ "predicate": { "beyondtheclouds:angle": 0.703125 }, "model": "beyondtheclouds:item/gate_compass_07" },
{ "predicate": { "beyondtheclouds:angle": 0.734375 }, "model": "beyondtheclouds:item/gate_compass_08" },
{ "predicate": { "beyondtheclouds:angle": 0.765625 }, "model": "beyondtheclouds:item/gate_compass_09" },
{ "predicate": { "beyondtheclouds:angle": 0.796875 }, "model": "beyondtheclouds:item/gate_compass_10" },
{ "predicate": { "beyondtheclouds:angle": 0.828125 }, "model": "beyondtheclouds:item/gate_compass_11" },
{ "predicate": { "beyondtheclouds:angle": 0.859375 }, "model": "beyondtheclouds:item/gate_compass_12" },
{ "predicate": { "beyondtheclouds:angle": 0.890625 }, "model": "beyondtheclouds:item/gate_compass_13" },
{ "predicate": { "beyondtheclouds:angle": 0.921875 }, "model": "beyondtheclouds:item/gate_compass_14" },
{ "predicate": { "beyondtheclouds:angle": 0.953125 }, "model": "beyondtheclouds:item/gate_compass_15" },
{ "predicate": { "beyondtheclouds:angle": 0.984375 }, "model": "beyondtheclouds:item/gate_compass" }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_00"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_01"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_02"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_03"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_04"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_05"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_06"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_07"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_08"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_09"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_10"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_11"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_12"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_13"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_14"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_15"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_17"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_18"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "beyondtheclouds:item/gate_compass_19"
}
}
Loading

0 comments on commit 57ff787

Please sign in to comment.