Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ allprojects {
// adds some useful annotations for miscellaneous uses. does not add any dependencies, though people without the lib will be missing some useful context hints.
"implementationOnly"("org.jetbrains:annotations:23.0.0")

modLocalRuntime("com.github.calmilamsy:ModMenu:${project.properties["modmenu_version"]}") {
modLocalRuntime("net.glasslauncher.mods:ModMenu:${project.properties["modmenu_version"]}") {
isTransitive = false
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ fabric.loom.multiProjectOptimisation=true
# Test properties
gcapi_version = 1.3.1
hmi_version = 5.1.1
modmenu_version = v1.8.5-beta.3
modmenu_version = 1.8.5-beta.9
mojangfix_version = 0.5.2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public enum Blocks {

TEST_BLOCK("test_block", "testBlock", id -> new TemplateBlock(id, Material.CLAY).setHardness(1)),
TEST_BLOCK("test_block", "testBlock", id -> new TemplateBlock(id, Material.STONE).setHardness(1)),
TEST_ANIMATED_BLOCK("test_animated_block", "testAnimatedBlock", id -> new ModdedMetaBlock(id, Material.NETHER_PORTAL)),
CUSTOM_MODEL_BLOCK("farlands_block", "farlands_block", id -> new ModdedModelBlock(id, Material.SOIL).setHardness(1)),
FREEZER("freezer", "freezer", id -> new BlockFreezer(id).setHardness(2.5F).setSoundGroup(TemplateBlock.DEFAULT_SOUND_GROUP)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.modificationstation.sltest.gui.hud;

import net.mine_diver.unsafeevents.listener.EventListener;
import net.modificationstation.stationapi.api.client.event.gui.hud.HudTextLine;
import net.modificationstation.stationapi.api.client.event.gui.hud.HudTextRenderEvent;

import java.util.Random;

public class TestHudText {
private static final int[] COLORS = {0x5BCEFA, 0xF5A9B8, 0xFFFFFF, 0xF5A9B8};
private final Random random = new Random();
private int frames;
private int color;
private int verColor;

@EventListener
public void renderHudText(HudTextRenderEvent event) {
if (frames % 7 == 0) verColor = random.nextInt(0xFFFFFF + 1);
event.setVersion(new HudTextLine(
"Statint api 2rd ediction ;)" + (event.debug ? "(" + event.minecraft.debugText + ")" : ""),
verColor)
);
if (frames > 0 && frames % 15 == 0) {
color = color + 1 < COLORS.length? color + 1 : 0;
}
event.right.add(new HudTextLine("gaming", COLORS[color]));
if (event.debug) {
event.left.add(new HudTextLine("This Texts only Shows In de Bugge ?!??! :0"));
event.right.add(new HudTextLine("this text has a rly big offsets", 0xFF0000, 40));
}
frames++;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import net.modificationstation.sltest.block.Blocks;
import net.modificationstation.sltest.block.VariationBlock;
import net.modificationstation.stationapi.api.event.registry.ItemRegistryEvent;
import net.modificationstation.stationapi.api.item.tool.MiningLevelManager;
import net.modificationstation.stationapi.api.item.tool.ToolMaterialFactory;
import net.modificationstation.stationapi.api.registry.BlockRegistry;
import net.modificationstation.stationapi.api.registry.ItemRegistry;
import net.modificationstation.stationapi.api.registry.Registry;
import net.modificationstation.stationapi.api.tag.TagKey;
import net.modificationstation.stationapi.api.template.item.BlockStateItem;

import static net.modificationstation.sltest.SLTest.NAMESPACE;
Expand All @@ -17,8 +20,13 @@ public class ItemListener {

@EventListener
public void registerItems(ItemRegistryEvent event) {
MiningLevelManager.LevelNode moddedNode = new MiningLevelManager.LevelNode(TagKey.of(BlockRegistry.KEY, NAMESPACE.id("needs_tool_level_modded")));
MiningLevelManager.GRAPH.putEdge(ToolMaterial.STONE.getMiningLevelNode(), moddedNode);
MiningLevelManager.GRAPH.putEdge(moddedNode, ToolMaterial.IRON.getMiningLevelNode());
MiningLevelManager.invalidateCache();

testItem = new ModdedItem(NAMESPACE.id("test_item")).setTranslationKey(NAMESPACE, "testItem"); //8475
testMaterial = ToolMaterialFactory.create("testMaterial", 3, Integer.MAX_VALUE, Float.MAX_VALUE, Integer.MAX_VALUE - 2);
testMaterial = ToolMaterialFactory.create("testMaterial", 3, Integer.MAX_VALUE, Float.MAX_VALUE, Integer.MAX_VALUE - 2).miningLevelNode(moddedNode);
testPickaxe = new ModdedPickaxeItem(NAMESPACE.id("test_pickaxe"), testMaterial).setTranslationKey(NAMESPACE, "testPickaxe"); //8476
testNBTItem = new NBTItem(NAMESPACE.id("nbt_item")).setTranslationKey(NAMESPACE, "nbt_item"); //8477
testModelItem = new ModelItem(NAMESPACE.id("model_item")).setMaxCount(1).setTranslationKey(NAMESPACE, "idkSomething");
Expand All @@ -30,6 +38,8 @@ public void registerItems(ItemRegistryEvent event) {
testShears = new TestShearsItem(NAMESPACE.id("test_shears")).setTranslationKey(NAMESPACE, "test_shears");
pacifistSword = new PacifistSwordItem(NAMESPACE.id("pacifist_sword")).setTranslationKey(NAMESPACE, "pacifist_sword");
dullPickaxe = new DullPickaxeItem(NAMESPACE.id("dull_pickaxe")).setTranslationKey(NAMESPACE, "dull_pickaxe");


}

public static Item testItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"sltest:test_block"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"sltest:test_block"
]
}
3 changes: 2 additions & 1 deletion src/test/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"net.modificationstation.sltest.datafixer.DataFixerListener",
"net.modificationstation.sltest.worldgen.TestWorldgenListener",
"net.modificationstation.sltest.bonemeal.BonemealListener",
"net.modificationstation.sltest.dispenser.DispenserListener"
"net.modificationstation.sltest.dispenser.DispenserListener",
"net.modificationstation.sltest.gui.hud.TestHudText"
],
"stationapi:event_bus_client": [
"net.modificationstation.sltest.gui.GuiListener",
Expand Down
1 change: 1 addition & 0 deletions station-flattening-v0/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = getSubprojectVersion(project, "1.0.0")

addModuleDependencies(project,
"station-api-base",
"station-gui-api-v0",
"station-maths-v0",
"station-registry-api-v0",
"station-networking-v0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.modificationstation.stationapi.impl.client.gui.hud;

import net.fabricmc.loader.api.FabricLoader;
import net.mine_diver.unsafeevents.listener.EventListener;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.hit.HitResultType;
import net.modificationstation.stationapi.api.StationAPI;
import net.modificationstation.stationapi.api.block.BlockState;
import net.modificationstation.stationapi.api.client.event.gui.hud.HudTextRenderEvent;
import net.modificationstation.stationapi.api.client.event.gui.hud.HudTextLine;
import net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint;
import net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy;
import net.modificationstation.stationapi.api.state.property.Property;
import net.modificationstation.stationapi.api.tag.TagKey;

import java.util.Collection;
import java.util.Collections;

import static net.modificationstation.stationapi.api.client.event.gui.hud.HudTextLine.GRAY;
import static net.modificationstation.stationapi.api.client.event.gui.hud.HudTextLine.WHITE;

@Entrypoint(eventBus = @EventBusPolicy(registerInstance = false))
public class StationFlatteningHudText {
@EventListener(phase = StationAPI.INTERNAL_PHASE)
private static void renderHudText(HudTextRenderEvent event) {
if (!event.debug) return;
HitResult hit = event.minecraft.field_2823;
if (hit == null || hit.type != HitResultType.BLOCK) return;
BlockState state = event.minecraft.world.getBlockState(hit.blockX, hit.blockY, hit.blockZ);
Collections.addAll(event.right,
new HudTextLine("Block: " + state.getBlock().getTranslatedName(), WHITE, 20),
new HudTextLine("Meta: " + event.minecraft.world.getBlockMeta(hit.blockX, hit.blockY, hit.blockZ))
);
Collection<Property<?>> properties = state.getProperties();
if (!properties.isEmpty()) {
event.right.add(new HudTextLine("Properties:"));
event.right.addAll(properties.stream().map(prop ->
new HudTextLine(prop.getName() + ": " + state.get(prop), GRAY)
).toList());
}

Collection<TagKey<Block>> tags = state.streamTags().toList();
if (!tags.isEmpty()) {
event.right.add(new HudTextLine("Tags:"));
event.right.addAll(tags.stream().map(tag -> new HudTextLine("#" + tag.id(), GRAY)).toList());
}

if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
BlockEntity entity = event.minecraft.world.method_1777(hit.blockX, hit.blockY, hit.blockZ);
if (entity != null) {
String className = entity.getClass().getName();
String text = "Tile Entity: " + className.substring(className.lastIndexOf('.') + 1);
event.right.add(new HudTextLine(text, WHITE, 20));
}
}
}
}

This file was deleted.

3 changes: 2 additions & 1 deletion station-flattening-v0/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"net.modificationstation.stationapi.api.block.States",
"net.modificationstation.stationapi.impl.block.PlacementStateImpl",
"net.modificationstation.stationapi.impl.world.WorldDataVersionImpl",
"net.modificationstation.stationapi.impl.block.BlockInteractionImpl"
"net.modificationstation.stationapi.impl.block.BlockInteractionImpl",
"net.modificationstation.stationapi.impl.client.gui.hud.StationFlatteningHudText"
],
"main": [
"net.modificationstation.stationapi.impl.packet.StationFlatteningNetworkingImpl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"client": [
"client.BlockRenderManagerMixin",
"client.ClientWorldMixin",
"client.InGameHudMixin",
"client.InteractionManagerMixin",
"client.MinecraftMixin",
"client.MultiplayerChunkCacheMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.modificationstation.stationapi.api.client.event.gui.hud;

import lombok.AllArgsConstructor;

/**
* Text and info for rendering custom HUD text lines.
*/
@AllArgsConstructor
public final class HudTextLine {
public static final int WHITE = 0xFFFFFF;
public static final int GRAY = 0xE0E0E0;

public String text;
/**
* @see net.glasslauncher.mods.api.gcapi.api.CharacterUtils#getIntFromColour(Color)
*/
public int color;
/**
* Y offset from the last rendered line.
*/
public int yOffset;

public HudTextLine(String text) {
this(text, WHITE);
}
public HudTextLine(String text, int color) {
this(text, color, 10);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.modificationstation.stationapi.api.client.event.gui.hud;

import lombok.Getter;
import lombok.experimental.SuperBuilder;
import net.mine_diver.unsafeevents.Event;
import net.mine_diver.unsafeevents.event.EventPhases;
import net.minecraft.client.Minecraft;
import net.modificationstation.stationapi.api.StationAPI;

import java.util.ArrayList;
import java.util.List;

/**
* Fires while rendering in-game (debug) HUD text.
*/
@SuperBuilder
@EventPhases({StationAPI.INTERNAL_PHASE, EventPhases.DEFAULT_PHASE})
public class HudTextRenderEvent extends Event {
/**
* Whether the F3 debug HUD is enabled.
* @see net.minecraft.client.option.GameOptions#debugHud
*/
public final boolean debug;
public final Minecraft minecraft;
public final List<HudTextLine> left = new ArrayList<>(), right = new ArrayList<>();
@Getter private HudTextLine version;

/**
* Set by highest priority listener.
*/
public void setVersion(HudTextLine line) {
if (version == null) version = line;
}
}
Loading