Skip to content

Commit

Permalink
1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lykrast committed Apr 8, 2024
1 parent 1b25ab8 commit d02f2cc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
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.4

minecraft_version=1.19
forge_version=41.1.0
minecraft_version=1.20.1
forge_version=47.1.3
42 changes: 33 additions & 9 deletions src/main/java/lykrast/glassential/Glassential.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package lykrast.glassential;

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

import org.apache.logging.log4j.LogManager;
Expand All @@ -10,10 +12,15 @@
import lykrast.glassential.blocks.RedstoneGlassBlock;
import lykrast.glassential.blocks.TooltipGlassBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
Expand All @@ -23,6 +30,7 @@
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent;
import net.minecraftforge.registries.RegistryObject;

@Mod(Glassential.MODID)
Expand All @@ -36,24 +44,40 @@ public Glassential() {
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(bus);
ITEMS.register(bus);
bus.addListener(Glassential::makeCreativeTab);
}

private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
private static List<RegistryObject<Item>> itemsForCreative = new ArrayList<>();
private static RegistryObject<Item> stackForIcon;

public static void makeCreativeTab(RegisterEvent event) {
event.register(Registries.CREATIVE_MODE_TAB, helper -> {
helper.register(ResourceKey.create(Registries.CREATIVE_MODE_TAB, new ResourceLocation(MODID, "glassential")),
CreativeModeTab.builder()
.title(Component.translatable("itemGroup.glassential.items"))
.icon(() -> new ItemStack(stackForIcon.get()))
.displayItems((parameters, output) -> itemsForCreative.forEach(i -> output.accept(i.get())))
.build());
});
}

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);
makeBlock("glass_light", () -> new TooltipGlassBlock(glassProp().lightLevel((b) -> 15), "tooltip.glassential.light"));
makeBlock("glass_redstone", () -> new RedstoneGlassBlock(glassProp()));
makeBlock("glass_ghostly", () -> new TooltipGlassBlock(glassProp().noCollission(), "tooltip.glassential.ghostly"));
makeBlock("glass_ethereal", () -> new EtherealGlassBlock(glassProp().noCollission(), false));
makeBlock("glass_ethereal_reverse", () -> new EtherealGlassBlock(glassProp().noCollission(), true));
makeBlock("glass_dark_ethereal", () -> new DarkEtherealGlassBlock(glassProp().noCollission(), false));
makeBlock("glass_dark_ethereal_reverse", () -> new DarkEtherealGlassBlock(glassProp().noCollission(), true));
}

private static RegistryObject<Block> makeBlock(String name, Supplier<Block> block, CreativeModeTab creativeTab) {
private static RegistryObject<Block> makeBlock(String name, Supplier<Block> block) {
RegistryObject<Block> regged = BLOCKS.register(name, block);
ITEMS.register(name, () -> new BlockItem(regged.get(), (new Item.Properties()).tab(creativeTab)));
itemsForCreative.add(ITEMS.register(name, () -> new BlockItem(regged.get(), (new Item.Properties()))));
//too lazy to do it smart
if (name.equals("glass_ethereal_reverse")) stackForIcon = itemsForCreative.get(itemsForCreative.size()-1);
return regged;
}

Expand Down

0 comments on commit d02f2cc

Please sign in to comment.