Skip to content

Commit

Permalink
Finally got 1.19 to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Lykrast committed Jun 12, 2022
1 parent eeedb2f commit aacf1d0
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 85 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ archivesBaseName = "glassential-forge"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'official', version: '1.18.2'
mappings channel: 'official', version: '1.19'

// Default run configurations.
runs {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ org.gradle.daemon=false

mod_version = 1.2.3

minecraft_version=1.18.2
forge_version=40.1.0
minecraft_version=1.19
forge_version=41.0.17
75 changes: 35 additions & 40 deletions src/main/java/lykrast/glassential/Glassential.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
package lykrast.glassential;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import lykrast.glassential.blocks.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.client.renderer.RenderType;
import lykrast.glassential.blocks.DarkEtherealGlassBlock;
import lykrast.glassential.blocks.EtherealGlassBlock;
import lykrast.glassential.blocks.RedstoneGlassBlock;
import lykrast.glassential.blocks.TooltipGlassBlock;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.BlockGetter;
import net.minecraftforge.event.RegistryEvent;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

@Mod(Glassential.MODID)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = Glassential.MODID)
Expand All @@ -32,43 +37,33 @@ public class Glassential {
public static final Logger LOGGER = LogManager.getLogger();

public Glassential() {
// Config will have to go here one day
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(bus);
ITEMS.register(bus);
}

private static List<Block> blocks;
private static List<Item> blockitems;

@SubscribeEvent
public static void registerBlocks(final RegistryEvent.Register<Block> event) {
blocks = new ArrayList<>();
blockitems = new ArrayList<>();
event.getRegistry().registerAll(makeBlock("glass_dark_ethereal", new DarkEtherealGlassBlock(glassProp().noCollission(), false), CreativeModeTab.TAB_BUILDING_BLOCKS),
makeBlock("glass_dark_ethereal_reverse", new DarkEtherealGlassBlock(glassProp().noCollission(), true), CreativeModeTab.TAB_BUILDING_BLOCKS),
makeBlock("glass_ethereal", new EtherealGlassBlock(glassProp().noCollission(), false), CreativeModeTab.TAB_BUILDING_BLOCKS),
makeBlock("glass_ethereal_reverse", new EtherealGlassBlock(glassProp().noCollission(), true), CreativeModeTab.TAB_BUILDING_BLOCKS),
makeBlock("glass_ghostly", new TooltipGlassBlock(glassProp().noCollission(), "tooltip.glassential.ghostly"), CreativeModeTab.TAB_BUILDING_BLOCKS),
makeBlock("glass_light", new TooltipGlassBlock(glassProp().lightLevel((b) -> 15), "tooltip.glassential.light"), CreativeModeTab.TAB_BUILDING_BLOCKS),
makeBlock("glass_redstone", new RedstoneGlassBlock(glassProp()), CreativeModeTab.TAB_REDSTONE));
}

@SubscribeEvent
public static void registerItems(final RegistryEvent.Register<Item> event) {
IForgeRegistry<Item> reg = event.getRegistry();
blockitems.forEach(reg::register);
blockitems = null;
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);

static {
makeBlock("glass_dark_ethereal", () -> new DarkEtherealGlassBlock(glassProp().noCollission(), false), CreativeModeTab.TAB_BUILDING_BLOCKS);
makeBlock("glass_dark_ethereal_reverse", () -> new DarkEtherealGlassBlock(glassProp().noCollission(), true), CreativeModeTab.TAB_BUILDING_BLOCKS);
makeBlock("glass_ethereal", () -> new EtherealGlassBlock(glassProp().noCollission(), false), CreativeModeTab.TAB_BUILDING_BLOCKS);
makeBlock("glass_ethereal_reverse", () -> new EtherealGlassBlock(glassProp().noCollission(), true), CreativeModeTab.TAB_BUILDING_BLOCKS);
makeBlock("glass_ghostly", () -> new TooltipGlassBlock(glassProp().noCollission(), "tooltip.glassential.ghostly"), CreativeModeTab.TAB_BUILDING_BLOCKS);
makeBlock("glass_light", () -> new TooltipGlassBlock(glassProp().lightLevel((b) -> 15), "tooltip.glassential.light"), CreativeModeTab.TAB_BUILDING_BLOCKS);
makeBlock("glass_redstone", () -> new RedstoneGlassBlock(glassProp()), CreativeModeTab.TAB_REDSTONE);
}

@SubscribeEvent
public static void clientStuff(final FMLClientSetupEvent event) {
blocks.forEach(b -> ItemBlockRenderTypes.setRenderLayer(b, RenderType.translucent()));
blocks = null;
BLOCKS.getEntries().forEach(b -> ItemBlockRenderTypes.setRenderLayer(b.get(), RenderType.translucent()));
}

private static Block makeBlock(String name, Block block, CreativeModeTab creativeTab) {
block.setRegistryName(MODID, name);
blocks.add(block);
blockitems.add(new BlockItem(block, ((new Item.Properties()).tab(creativeTab))).setRegistryName(MODID, name));
return block;
private static RegistryObject<Block> makeBlock(String name, Supplier<Block> block, CreativeModeTab creativeTab) {
RegistryObject<Block> regged = BLOCKS.register(name, block);
ITEMS.register(name, () -> new BlockItem(regged.get(), (new Item.Properties()).tab(creativeTab)));
return regged;
}

private static Block.Properties glassProp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

import javax.annotation.Nullable;

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -31,6 +30,6 @@ public int getLightBlock(BlockState state, BlockGetter world, BlockPos pos) {
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add((new TranslatableComponent("tooltip.glassential.dark")).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("tooltip.glassential.dark").withStyle(ChatFormatting.GRAY));
}
}
15 changes: 7 additions & 8 deletions src/main/java/lykrast/glassential/blocks/DarkGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

import javax.annotation.Nullable;

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -32,6 +31,6 @@ public int getLightBlock(BlockState state, BlockGetter world, BlockPos pos) {
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add((new TranslatableComponent("tooltip.glassential.dark")).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("tooltip.glassential.dark").withStyle(ChatFormatting.GRAY));
}
}
23 changes: 11 additions & 12 deletions src/main/java/lykrast/glassential/blocks/EtherealGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@

import javax.annotation.Nullable;

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -41,6 +40,6 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPo
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add((new TranslatableComponent(collidePlayers ? "tooltip.glassential.ethereal_reverse" : "tooltip.glassential.ethereal")).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable(collidePlayers ? "tooltip.glassential.ethereal_reverse" : "tooltip.glassential.ethereal").withStyle(ChatFormatting.GRAY));
}
}
17 changes: 8 additions & 9 deletions src/main/java/lykrast/glassential/blocks/RedstoneGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

import javax.annotation.Nullable;

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.Direction;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -38,6 +37,6 @@ public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Directio
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add((new TranslatableComponent("tooltip.glassential.redstone")).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("tooltip.glassential.redstone").withStyle(ChatFormatting.GRAY));
}
}
11 changes: 5 additions & 6 deletions src/main/java/lykrast/glassential/blocks/TooltipGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

import javax.annotation.Nullable;

import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -27,7 +26,7 @@ public TooltipGlassBlock(Properties properties, String tooltip) {
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add((new TranslatableComponent(this.tooltip)).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable(this.tooltip).withStyle(ChatFormatting.GRAY));
}

}

0 comments on commit aacf1d0

Please sign in to comment.