Work more on migrations to 1.21

This commit is contained in:
zontreck 2025-02-23 01:02:03 -07:00
parent 922f89d14c
commit ddc7fa9952
16 changed files with 480 additions and 212 deletions

View file

@ -3,7 +3,6 @@ package com.zontreck;
import com.zontreck.block.DeprecatedModBlocks;
import com.zontreck.block.ModBlocks;
import com.zontreck.client.TimeBoostEntityRenderer;
import com.zontreck.commands.CommandRegistry;
import com.zontreck.configs.client.AEClientConfig;
import com.zontreck.configs.server.AEServerConfig;
import com.zontreck.effects.ModEffects;
@ -13,29 +12,25 @@ import com.zontreck.entities.ModEntities;
import com.zontreck.items.DeprecatedModItems;
import com.zontreck.items.ModItems;
import com.zontreck.libzontreck.config.ServerConfig;
import com.zontreck.libzontreck.util.SNbtIo;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.data.structures.NbtToSnbt;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.StringTag;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.EventBusSubscriber.Bus;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import java.nio.file.Path;
import java.time.Instant;
import java.util.Random;
import java.util.logging.LogManager;
import org.apache.logging.log4j.Logger;
import com.zontreck.items.CreativeModeTabs;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.common.NeoForgeMod;
@Mod(AriasEssentials.MOD_ID)
public final class AriasEssentials {
@ -43,13 +38,12 @@ public final class AriasEssentials {
public static final String MOD_ID = "ariasessentials";
public static final Random random = new Random(Instant.now().getEpochSecond());
public AriasEssentials() {
public AriasEssentials(IEventBus bus) {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like registries and resources) may still be
// uninitialized.
// Proceed with mild caution.
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
LOGGER.info("/!\\ Loading Aria's Essentials Configuration Files /!\\");
AEServerConfig.loadFromFile();
AEClientConfig.loadFromFile();
@ -57,6 +51,7 @@ public final class AriasEssentials {
LOGGER.info("/!\\ DONE LOADING AECONFIG /!\\");
ModItems.ITEMS.register(bus);
CreativeModeTabs.register(bus);
ModEntities.register(bus);
ModEffects.register(bus);
ModPotions.register(bus);
@ -67,7 +62,7 @@ public final class AriasEssentials {
}
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@EventBusSubscriber(bus = Bus.MOD, value = Dist.CLIENT)
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent ev) {

View file

@ -2,14 +2,13 @@ package com.zontreck.block;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
@Deprecated
public class DeprecatedBlock extends Block
{
public DeprecatedBlock(){
super(BlockBehaviour.Properties.copy(Blocks.STONE).instabreak());
super(BlockBehaviour.Properties.of().instabreak());
}
}

View file

@ -1,17 +1,17 @@
package com.zontreck.block;
import java.util.List;
import com.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import java.util.List;
@Deprecated
public class DeprecatedBlockItem extends BlockItem
{
@ -20,8 +20,12 @@ public class DeprecatedBlockItem extends BlockItem
super(a, new Item.Properties().fireResistant());
}
public DeprecatedBlockItem(Object obj) {
super((Block)obj, new Item.Properties().fireResistant());
}
@Override
public boolean isFoil(ItemStack p_41453_) {
public boolean isFoil(ItemStack stack) {
return true;
}
@ -34,12 +38,14 @@ public class DeprecatedBlockItem extends BlockItem
public boolean isPiglinCurrency(ItemStack stack) {
return true;
}
@Override
public void appendHoverText(ItemStack p_41421_, Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
p_41423_.add(ChatHelpers.macro("!Dark_Red!This block is deprecated"));
p_41423_.add(ChatHelpers.macro("!Dark_Green!It would appear this block smells faintly of gold. Maybe piglins will accept it?"));
p_41423_.add(ChatHelpers.macro("!Dark_Red!This block is scheduled for removal in a future version. You should use it before it is too late."));
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents,
TooltipFlag tooltipFlag) {
tooltipComponents.add(ChatHelpers.macro("!Dark_Red!This block is deprecated"));
tooltipComponents.add(ChatHelpers.macro("!Dark_Green!It would appear this block smells faintly of gold. Maybe piglins will accept it?"));
tooltipComponents.add(ChatHelpers.macro("!Dark_Red!This block is scheduled for removal in a future version. You should use it before it is too late."));
}
}

View file

@ -3,25 +3,25 @@ package com.zontreck.block;
import com.zontreck.AriasEssentials;
import com.zontreck.items.CreativeModeTabs;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredRegister;
@Deprecated
public class DeprecatedModBlocks
{
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, AriasEssentials.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registries.BLOCK, AriasEssentials.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(Registries.ITEM, AriasEssentials.MOD_ID);
public static void register(IEventBus bus){
@ -39,11 +39,11 @@ public class DeprecatedModBlocks
private static BlockBehaviour.Properties standardBehavior()
{
return BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(7F).destroyTime(6);
return BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(7F).destroyTime(6);
}
private static BlockBehaviour.Properties stoneLikeBehavior()
{
return BlockBehaviour.Properties.copy(Blocks.COBBLESTONE);
return BlockBehaviour.Properties.of();
}
private static BlockBehaviour.Properties explosionResistance()
@ -71,11 +71,11 @@ public class DeprecatedModBlocks
private static BlockBehaviour.Properties stone = stoneLikeBehavior();
private static BlockBehaviour.Properties poolLightClean = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 15);
private static BlockBehaviour.Properties poolLightDirty = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 12);
private static BlockBehaviour.Properties poolLightFilthy = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 4);
private static BlockBehaviour.Properties poolLightClean = BlockBehaviour.Properties.ofFullCopy(Blocks.GLASS).lightLevel((X) -> 15);
private static BlockBehaviour.Properties poolLightDirty = BlockBehaviour.Properties.ofFullCopy(Blocks.GLASS).lightLevel((X) -> 12);
private static BlockBehaviour.Properties poolLightFilthy = BlockBehaviour.Properties.ofFullCopy(Blocks.GLASS).lightLevel((X) -> 4);
public static RegistryObject<Block> registerDeprecated(RegistryObject<Block> blk)
public static DeferredBlock registerDeprecated(DeferredBlock blk)
{
CreativeModeTabs.addToAETab(ITEMS.register(blk.getId().getPath(), ()->new DeprecatedBlockItem(blk.get())));

View file

@ -3,7 +3,9 @@ package com.zontreck.block;
import com.zontreck.AriasEssentials;
import com.zontreck.items.CreativeModeTabs;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
@ -13,15 +15,14 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.ArrayList;
import java.util.List;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredBlock;
public class ModBlocks {
private static BlockBehaviour.StatePredicate shulkerState = (p_152653_, p_152654_, p_152655_) -> {
@ -35,8 +36,8 @@ public class ModBlocks {
};
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, AriasEssentials.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registries.BLOCK, AriasEssentials.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(Registries.ITEM, AriasEssentials.MOD_ID);
private static boolean never(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
return false;
@ -58,7 +59,7 @@ public class ModBlocks {
private static BlockBehaviour.Properties standardBehavior()
{
return BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(7F).destroyTime(6).isValidSpawn(ModBlocks::neverSpawn);
return BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(7F).destroyTime(6).isValidSpawn(ModBlocks::neverSpawn);
}
private static BlockBehaviour.Properties gratingBlock()
{
@ -70,7 +71,7 @@ public class ModBlocks {
private static BlockBehaviour.Properties stoneLikeBehavior()
{
return BlockBehaviour.Properties.copy(Blocks.COBBLESTONE).isValidSpawn(ModBlocks::neverSpawn);
return BlockBehaviour.Properties.of().isValidSpawn(ModBlocks::neverSpawn);
}
private static BlockBehaviour.Properties explosionResistance()
@ -100,45 +101,45 @@ public class ModBlocks {
private static BlockBehaviour.Properties gratingBlock = gratingBlock();
private static BlockBehaviour.Properties poolLightClean = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 15);
private static BlockBehaviour.Properties poolLightDirty = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 12);
private static BlockBehaviour.Properties poolLightFilthy = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 4);
private static BlockBehaviour.Properties poolLightClean = BlockBehaviour.Properties.ofFullCopy(Blocks.GLASS).lightLevel((X) -> 15);
private static BlockBehaviour.Properties poolLightDirty = BlockBehaviour.Properties.ofFullCopy(Blocks.GLASS).lightLevel((X) -> 12);
private static BlockBehaviour.Properties poolLightFilthy = BlockBehaviour.Properties.ofFullCopy(Blocks.GLASS).lightLevel((X) -> 4);
public static RegistryObject<Block> registerWithItem(RegistryObject<Block> blk, Item.Properties props)
public static DeferredBlock registerWithItem(DeferredBlock blk, Item.Properties props)
{
CreativeModeTabs.addToAETab(ITEMS.register(blk.getId().getPath(), ()->new BlockItem(blk.get(), props.tab(CreativeModeTabs.AETAB))));
CreativeModeTabs.addToAETab(ITEMS.register(blk.getId().getPath(), ()->new BlockItem(((Block)blk.get()), props.tab(CreativeModeTabs.AETAB))));
return blk;
}
public static List<RegistryObject<Block>> registerPoolTile(String color) {
public static List<DeferredBlock> registerPoolTile(String color) {
String baseNick = color.length()>1 ? color+"_pool_tile" : "pool_tile";
List<RegistryObject<Block>> ret = new ArrayList<>();
final RegistryObject<Block> tile1 = registerWithItem(BLOCKS.register(baseNick, ()->new Block(stone)), new Item.Properties());
List<DeferredBlock> ret = new ArrayList<>();
final DeferredBlock tile1 = registerWithItem(BLOCKS.register(baseNick, ()->new Block(stone)), new Item.Properties());
final RegistryObject<Block> POOL_TILE_STAIRS = registerWithItem(BLOCKS.register(baseNick + "_stairs", ()->new StairBlock(tile1.get()::defaultBlockState, stone)), new Item.Properties());
final DeferredBlock POOL_TILE_STAIRS = registerWithItem(BLOCKS.register(baseNick + "_stairs", ()->new StairBlock(tile1.get()::defaultBlockState, stone)), new Item.Properties());
final RegistryObject<Block> POOL_TILE_SLAB = registerWithItem(BLOCKS.register(baseNick+"_slab", ()->new SlabBlock(stone)), new Item.Properties());
final DeferredBlock POOL_TILE_SLAB = registerWithItem(BLOCKS.register(baseNick+"_slab", ()->new SlabBlock(stone)), new Item.Properties());
final RegistryObject<Block> POOL_TILE_WALL = registerWithItem(BLOCKS.register(baseNick + "_wall", ()->new WallBlock(stone)), new Item.Properties());
final DeferredBlock POOL_TILE_WALL = registerWithItem(BLOCKS.register(baseNick + "_wall", ()->new WallBlock(stone)), new Item.Properties());
final RegistryObject<Block> POOL_LIGHT = registerWithItem(BLOCKS.register(baseNick + "_light", ()->new Block(poolLightClean)), new Item.Properties());
final DeferredBlock POOL_LIGHT = registerWithItem(BLOCKS.register(baseNick + "_light", ()->new Block(poolLightClean)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE = registerWithItem(BLOCKS.register("dirty_" + baseNick, ()->new Block(stone)), new Item.Properties());
final DeferredBlock DIRTY_POOL_TILE = registerWithItem(BLOCKS.register("dirty_" + baseNick, ()->new Block(stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_stairs", ()->new StairBlock(DIRTY_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
final DeferredBlock DIRTY_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_stairs", ()->new StairBlock(DIRTY_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_slab", ()-> new SlabBlock(stone)), new Item.Properties());
final DeferredBlock DIRTY_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_slab", ()-> new SlabBlock(stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_wall", ()->new WallBlock(stone)), new Item.Properties());
final DeferredBlock DIRTY_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_wall", ()->new WallBlock(stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_light", ()->new Block(poolLightDirty)), new Item.Properties());
final DeferredBlock DIRTY_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_light", ()->new Block(poolLightDirty)), new Item.Properties());
final RegistryObject<Block> FILTHY_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_" + baseNick + "_light", ()->new Block(poolLightFilthy)), new Item.Properties());
final DeferredBlock FILTHY_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_" + baseNick + "_light", ()->new Block(poolLightFilthy)), new Item.Properties());
ret.add(tile1);
@ -157,7 +158,7 @@ public class ModBlocks {
public static final RegistryObject<Block> DARK_RED_WOOL = registerWithItem(BLOCKS.register("dark_red_wool", ()->new Block(BlockBehaviour.Properties.copy(Blocks.RED_WOOL))), new Item.Properties());
public static final DeferredBlock DARK_RED_WOOL = registerWithItem(BLOCKS.register("dark_red_wool", ()->new Block(BlockBehaviour.Properties.copy(Blocks.RED_WOOL))), new Item.Properties());
public static final RegistryObject<Block> DARK_RED_CARPET = registerWithItem(BLOCKS.register("dark_red_carpet", ()->new CarpetBlock(BlockBehaviour.Properties.copy(Blocks.RED_CARPET))), new Item.Properties());

View file

@ -1,6 +1,8 @@
package com.zontreck.block;
import com.mojang.serialization.MapCodec;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
@ -24,4 +26,10 @@ public class RotatableBlock extends HorizontalDirectionalBlock
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection());
}
@Override
protected MapCodec<? extends HorizontalDirectionalBlock> codec() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'codec'");
}
}

View file

@ -0,0 +1,113 @@
package com.zontreck.client;
import java.util.List;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.MultiBufferSource;
public record BlockFaceTextRenderer(Font font, Vector3f vector3f) {
public static BlockFaceTextRenderer create(Font font) {
return new BlockFaceTextRenderer(font, new Vector3f());
}
public static BlockFaceTextRenderer create() {
return create(Minecraft.getInstance().font);
}
public IDrawText of(PoseStack poseStack, MultiBufferSource multiBufferSource) {
return ((face, text, dropShadows, packedLightCoords, color, backgroundcolor, x, y, z, offsetX, offsetY) -> {
drawText(font, poseStack, multiBufferSource, text, face.of(vector3f, x, y, z), face.axis(), packedLightCoords, dropShadows, color, backgroundcolor, offsetX, offsetY);
});
}
private static void drawText(Font font, PoseStack matrixStack, MultiBufferSource source, String text, Vector3f translateVector, Quaternionf rotate, int pPackedLightCoords, boolean dropShadows, int color, int backgroundColor, float oX, float oY) {
matrixStack.pushPose();
matrixStack.translate(translateVector.x(), translateVector.y(), translateVector.z());
matrixStack.scale(0.02F, -0.02F, 0.02F);
matrixStack.mulPose(rotate);
font.drawInBatch(
text, // Text
oX, // pX
oY, // pY
color, // pColor
dropShadows, // pDropShadow
matrixStack.last().pose(), // matrix4f
source, // MultiBufferSource
Font.DisplayMode.NORMAL, // DisplayMode
backgroundColor, // Background Color
pPackedLightCoords // pPackedLightsCoords
);
matrixStack.popPose();
}
public enum Face {
FRONT((v, x, y, z) -> {
return v.set(-x, y, z);
}, Axis.YP.rotationDegrees(0)),
BACK((v, x, y, z) -> {
return v.set(x, y, -z);
}, Axis.YP.rotationDegrees(180F)),
RIGHT((v, x, y, z) -> {
return v.set(z, y, x);
}, Axis.YP.rotationDegrees(90F)),
LEFT((v, x, y, z) -> {
return v.set(-z, y, -x);
}, Axis.YP.rotationDegrees(-90F)),
TOP((v, x, y, z) -> {
return v.set(-x, z, -y);
}, Axis.XP.rotationDegrees(90F)),
BOTTON((v, x, y, z) -> {
return v.set(-x, -z, y);
}, Axis.XP.rotationDegrees(-90F));
private static final List<Face> FACES = List.of(values());
public static List<Face> valuesList() {
return FACES;
}
private final QuadFunction<Vector3f, Float, Float, Float, Vector3f> function;
private final Quaternionf rotate;
Face(QuadFunction<Vector3f, Float, Float, Float, Vector3f> function, Quaternionf rotate) {
this.function = function;
this.rotate = rotate;
}
public Vector3f of(Vector3f vector3f, float x, float y, float z) {
return function.apply(vector3f, x, y, z);
}
public Quaternionf axis() {
return rotate;
}
}
@FunctionalInterface
public interface QuadFunction<T, U, V, W, R> {
R apply(T t, U u, V v, W w);
}
@FunctionalInterface
public interface IDrawText {
void render(Face face, String text, boolean dropShadows, int packedLightCoords, int color, int backgroundcolor, float x, float y, float z, float offsetX, float offsetY);
default void render(List<Face> faces, String text, int packedLightCoords, int color, float x, float y, float z) {
faces.forEach(face -> render(face, text, false, packedLightCoords, color, 0, x, y, z, 0, 0));
}
default void render(List<Face> faces, String text, boolean dropShadows, int packedLightCoords, int color, int backgroundcolor, float x, float y, float z, float offsetX, float offsetY) {
faces.forEach(face -> render(face, text, dropShadows, packedLightCoords, color, backgroundcolor, x, y, z, offsetX, offsetY));
}
default void render(List<Face> faces, String text, boolean dropShadows, int packedLightCoords, int color, int backgroundcolor, float x, float y, float z) {
faces.forEach(face -> render(face, text, dropShadows, packedLightCoords, color, backgroundcolor, x, y, z, 0, 0));
}
}
}

View file

@ -1,12 +1,9 @@
package com.zontreck.client;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import com.zontreck.AriasEssentials;
import com.zontreck.entities.TimeBoostEntity;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
@ -14,6 +11,8 @@ import net.minecraft.resources.ResourceLocation;
public class TimeBoostEntityRenderer extends EntityRenderer<TimeBoostEntity> {
private static final BlockFaceTextRenderer textRenderer = BlockFaceTextRenderer.create();
public TimeBoostEntityRenderer(EntityRendererProvider.Context erp) {
super(erp);
}
@ -21,30 +20,21 @@ public class TimeBoostEntityRenderer extends EntityRenderer<TimeBoostEntity> {
@Override
public void render(TimeBoostEntity entity, float entityYaw, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int packedLightIn) {
public void render(TimeBoostEntity entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferSource, int packedLightIn) {
String timeRate = "x" + 2 * entity.getTimeRate();
float paddingLeftRight = 2 * entity.getTimeRate() < 10 ? 0.11F : 0.19F;
drawText(matrixStack, timeRate, new Vector3f(-paddingLeftRight, 0.064F, 0.51F), Vector3f.YP.rotationDegrees(0), ChatFormatting.WHITE.getColor()); // Front
drawText(matrixStack, timeRate, new Vector3f(paddingLeftRight, 0.064F, -0.51F), Vector3f.YP.rotationDegrees(180F), ChatFormatting.WHITE.getColor()); // Back
drawText(matrixStack, timeRate, new Vector3f(0.51F, 0.064F, paddingLeftRight), Vector3f.YP.rotationDegrees(90F), ChatFormatting.WHITE.getColor()); // Right
drawText(matrixStack, timeRate, new Vector3f(-0.51F, 0.064F, -paddingLeftRight), Vector3f.YP.rotationDegrees(-90F), ChatFormatting.WHITE.getColor()); // Left
drawText(matrixStack, timeRate, new Vector3f(-paddingLeftRight, 0.51F, -0.064F), Vector3f.XP.rotationDegrees(90F), ChatFormatting.WHITE.getColor()); // Top
drawText(matrixStack, timeRate, new Vector3f(-paddingLeftRight, -0.51F, 0.064F), Vector3f.XP.rotationDegrees(-90F), ChatFormatting.WHITE.getColor()); // Bottom
int remainingTimeSeconds = entity.getRemainingTime() / 20;
String timeRemaining = remainingTimeSeconds + "s";
var rendererText = textRenderer.of(poseStack, bufferSource);
rendererText.render(BlockFaceTextRenderer.Face.valuesList(), timeRate, packedLightIn, 16777215, paddingLeftRight, 0.064F, 0.51F); // Render Time Rate
rendererText.render(BlockFaceTextRenderer.Face.valuesList(), timeRemaining, packedLightIn, remainingTimeSeconds > 10 ? 16777215 : 16711680, paddingLeftRight, 0.264F, 0.51F); // Render Time Remaining, goes reed when < 10 seconds, otherwise white text.
}
@Override
public ResourceLocation getTextureLocation(TimeBoostEntity entity) {
return null;
}
private void drawText(PoseStack matrixStack, String text, Vector3f translateVector, Quaternion rotate, int color) {
matrixStack.pushPose();
matrixStack.translate(translateVector.x(), translateVector.y(), translateVector.z());
matrixStack.scale(0.02F, -0.02F, 0.02F);
matrixStack.mulPose(rotate);
Font fontRenderer = Minecraft.getInstance().gui.getFont();
fontRenderer.draw(matrixStack, text, 0, 0, color);
matrixStack.popPose();
return ResourceLocation.fromNamespaceAndPath(AriasEssentials.MOD_ID, "accelerate");
}
}

View file

@ -7,24 +7,42 @@ import java.util.function.Supplier;
import com.zontreck.AriasEssentials;
import com.zontreck.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
@Mod.EventBusSubscriber(modid = AriasEssentials.MOD_ID, value = Dist.CLIENT)
@EventBusSubscriber(modid=AriasEssentials.MOD_ID, value = Dist.CLIENT)
public class CreativeModeTabs {
public static CreativeModeTab AETAB = new CreativeModeTab("ariasessentials") {
@Override
public ItemStack makeIcon() {
return new ItemStack(ModBlocks.BLUE_POOL_TILES.get(0).get().asItem());
}
};
public static final List<Supplier<? extends ItemLike>> AE_TAB_ITEMS = new ArrayList<Supplier<? extends ItemLike>>();
public static DeferredRegister REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, AriasEssentials.MOD_ID);
@SuppressWarnings("unchecked")
public static DeferredHolder<CreativeModeTab, CreativeModeTab> AETAB = REGISTRY.register("ariasessentials", ()->
CreativeModeTab.builder()
.icon(()->((Item)ModItems.TIAB.get()).getDefaultInstance())
.displayItems((par, build) -> AE_TAB_ITEMS.forEach(it->build.accept(it.get())))
.build());
public static <T extends Item> RegistryObject<T> addToAETab(RegistryObject<T> item)
public static <T extends Item> DeferredItem addToAETab(DeferredItem item)
{
AE_TAB_ITEMS.add(item);
return item;
}
public static void register(IEventBus bus) {
REGISTRY.register(bus);
}
}

View file

@ -1,20 +1,20 @@
package com.zontreck.items;
import java.util.List;
import com.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import java.util.List;
public class DeprecatedItem extends Item
{
public DeprecatedItem()
{
super(new Properties().fireResistant().tab(CreativeModeTabs.AETAB));
super(new Properties().fireResistant());
}
@Override
@ -31,12 +31,14 @@ public class DeprecatedItem extends Item
public boolean isPiglinCurrency(ItemStack stack) {
return true;
}
@Override
public void appendHoverText(ItemStack p_41421_, Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
p_41423_.add(ChatHelpers.macro("!Dark_Red!This item is deprecated"));
p_41423_.add(ChatHelpers.macro("!Dark_Green!It would appear this item smells faintly of gold. Maybe piglins will accept it?"));
p_41423_.add(ChatHelpers.macro("!Dark_Red!This item is scheduled for removal in a future version. You should use it before it is too late."));
}
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents,
TooltipFlag tooltipFlag) {
tooltipComponents.add(ChatHelpers.macro("!Dark_Red!This item is deprecated"));
tooltipComponents.add(ChatHelpers.macro("!Dark_Green!It would appear this item smells faintly of gold. Maybe piglins will accept it?"));
tooltipComponents.add(ChatHelpers.macro("!Dark_Red!This item is scheduled for removal in a future version. You should use it before it is too late."));
}
}

View file

@ -1,61 +1,61 @@
package com.zontreck.items;
import com.zontreck.items.impl.TimeBottle;
import net.minecraft.world.item.SimpleFoiledItem;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.world.item.Item;
import com.zontreck.AriasEssentials;
import net.minecraftforge.registries.RegistryObject;
import com.zontreck.items.impl.TimeBottle;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.Item;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
public class ModItems {
public static DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
public static DeferredRegister<Item> ITEMS = DeferredRegister.create(Registries.ITEM, AriasEssentials.MOD_ID);
public static RegistryObject<Item> TIAB = ITEMS.register("tiab", ()->new TimeBottle());
public static DeferredItem TIAB = ITEMS.register("tiab", ()->new TimeBottle());
public static final RegistryObject<Item> IHAN_CRYSTAL = CreativeModeTabs.addToAETab(ITEMS.register("ihan_crystal", () -> new IhanCrystal()));
public static final DeferredItem IHAN_CRYSTAL = CreativeModeTabs.addToAETab(ITEMS.register("ihan_crystal", () -> new IhanCrystal()));
public static final RegistryObject<Item> ETERNIUM_RAW_ORE = CreativeModeTabs.addToAETab(ITEMS.register("eternium_ore", () -> new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem ETERNIUM_RAW_ORE = CreativeModeTabs.addToAETab(ITEMS.register("eternium_ore", () -> new Item(new Item.Properties())));
public static final RegistryObject<Item> ETERNIUM_INGOT = CreativeModeTabs.addToAETab(ITEMS.register("eternium_ingot", ()-> new SimpleFoiledItem(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem ETERNIUM_INGOT = CreativeModeTabs.addToAETab(ITEMS.register("eternium_ingot", ()-> new SimpleFoiledItem(new Item.Properties())));
public static final RegistryObject<Item> ETERNIUM_ROD = CreativeModeTabs.addToAETab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64).tab(CreativeModeTabs.AETAB))));
public static final DeferredItem ETERNIUM_ROD = CreativeModeTabs.addToAETab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
public static final RegistryObject<Item> MIAB = CreativeModeTabs.addToAETab(ITEMS.register("mob_capture_ball", ()->new MobCaptureBallItem()));
public static final DeferredItem MIAB = CreativeModeTabs.addToAETab(ITEMS.register("mob_capture_ball", ()->new MobCaptureBallItem()));
public static final RegistryObject<Item> EMPTY_SPAWN_EGG = CreativeModeTabs.addToAETab(ITEMS.register("empty_spawn_egg", () -> new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem EMPTY_SPAWN_EGG = CreativeModeTabs.addToAETab(ITEMS.register("empty_spawn_egg", () -> new Item(new Item.Properties())));
public static final RegistryObject<Item> GENERIC_DEPRECATED_ITEM = CreativeModeTabs.addToAETab(ITEMS.register("deprecated", ()->new DeprecatedItem()));
public static final DeferredItem GENERIC_DEPRECATED_ITEM = CreativeModeTabs.addToAETab(ITEMS.register("deprecated", ()->new DeprecatedItem()));
public static final RegistryObject<Item> WHITE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("white_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem WHITE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("white_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> BLUE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("blue_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem BLUE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("blue_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> LIGHT_BLUE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("light_blue_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem LIGHT_BLUE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("light_blue_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> CYAN_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("cyan_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem CYAN_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("cyan_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> DARK_RED_DYE = CreativeModeTabs.addToAETab(ITEMS.register("dark_red_dye", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem DARK_RED_DYE = CreativeModeTabs.addToAETab(ITEMS.register("dark_red_dye", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> RED_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("red_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem RED_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("red_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> DARK_RED_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("dark_red_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem DARK_RED_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("dark_red_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> GREEN_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("green_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem GREEN_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("green_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> LIME_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("lime_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem LIME_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("lime_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> PARTIAL_ITEM = CreativeModeTabs.addToAETab(ITEMS.register("partial_item", PartialItem::new));
public static final DeferredItem PARTIAL_ITEM = CreativeModeTabs.addToAETab(ITEMS.register("partial_item", PartialItem::new));
public static final RegistryObject<Item> MAGMA_POWDER = CreativeModeTabs.addToAETab(ITEMS.register("magma_powder", ()-> new MagmaPowder(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem MAGMA_POWDER = CreativeModeTabs.addToAETab(ITEMS.register("magma_powder", ()-> new MagmaPowder(new Item.Properties())));
public static final RegistryObject<Item> METAL_BAR = CreativeModeTabs.addToAETab(ITEMS.register("metal_bar", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
public static final DeferredItem METAL_BAR = CreativeModeTabs.addToAETab(ITEMS.register("metal_bar", ()->new Item(new Item.Properties())));
}