restructuring (blocks & tabs in own file)
This commit is contained in:
parent
e66100b781
commit
41a939cc48
@ -5,13 +5,8 @@ import com.jenny.compressedtnt.blocks.*;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
@ -23,7 +18,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -36,57 +30,13 @@ public class Compressedtnt {
|
||||
// Directly reference a slf4j logger
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
|
||||
|
||||
public static final RegistryObject<strongerTNTBlock> TNT_8 = BLOCKS.register("tnt_8", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 8.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_8_ITEM = ITEMS.register("tnt_8", () -> new BlockItem(TNT_8.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_16 = BLOCKS.register("tnt_16", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 16.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_16_ITEM = ITEMS.register("tnt_16", () -> new BlockItem(TNT_16.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_32 = BLOCKS.register("tnt_32", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_32_ITEM = ITEMS.register("tnt_32", () -> new BlockItem(TNT_32.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_64 = BLOCKS.register("tnt_64", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 64.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_64_ITEM = ITEMS.register("tnt_64", () -> new BlockItem(TNT_64.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_128 = BLOCKS.register("tnt_128", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 128.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_128_ITEM = ITEMS.register("tnt_128", () -> new BlockItem(TNT_128.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_CLUSTER_2 = BLOCKS.register("tnt_cluster_2", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 2, 10));
|
||||
public static final RegistryObject<Item> TNT_CLUSTER__2ITEM = ITEMS.register("tnt_cluster_2", () -> new BlockItem(TNT_CLUSTER_2.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_CLUSTER_4 = BLOCKS.register("tnt_cluster_4", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 4, 10));
|
||||
public static final RegistryObject<Item> TNT_CLUSTER_4_ITEM = ITEMS.register("tnt_cluster_4", () -> new BlockItem(TNT_CLUSTER_4.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_CLUSTER_8 = BLOCKS.register("tnt_cluster_8", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 8, 10));
|
||||
public static final RegistryObject<Item> TNT_CLUSTER_8_ITEM = ITEMS.register("tnt_cluster_8", () -> new BlockItem(TNT_CLUSTER_8.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register("compressedtnt", () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> TNT_8_ITEM.get().getDefaultInstance()).displayItems((parameters, output) -> {
|
||||
output.accept(TNT_8.get());
|
||||
output.accept(TNT_16.get());
|
||||
output.accept(TNT_32.get());
|
||||
output.accept(TNT_64.get());
|
||||
output.accept(TNT_128.get());
|
||||
output.accept(TNT_CLUSTER_2.get());
|
||||
output.accept(TNT_CLUSTER_4.get());
|
||||
output.accept(TNT_CLUSTER_8.get());
|
||||
}).title(Component.literal("Compressed TNT")).build());
|
||||
|
||||
public Compressedtnt() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
// Register the Deferred Register to the mod event bus so blocks get registered
|
||||
BLOCKS.register(modEventBus);
|
||||
// Register the Deferred Register to the mod event bus so items get registered
|
||||
ITEMS.register(modEventBus);
|
||||
// Register the Deferred Register to the mod event bus so tabs get registered
|
||||
CREATIVE_MODE_TABS.register(modEventBus);
|
||||
new blocks().register(modEventBus);
|
||||
new creativeTab().register(modEventBus);
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
47
src/main/java/com/jenny/compressedtnt/blocks/blocks.java
Normal file
47
src/main/java/com/jenny/compressedtnt/blocks/blocks.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.jenny.compressedtnt.blocks;
|
||||
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import static com.jenny.compressedtnt.Compressedtnt.MODID;
|
||||
|
||||
public class blocks {
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static final RegistryObject<strongerTNTBlock> TNT_8 = BLOCKS.register("tnt_8", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 8.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_8_ITEM = ITEMS.register("tnt_8", () -> new BlockItem(TNT_8.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_16 = BLOCKS.register("tnt_16", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 16.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_16_ITEM = ITEMS.register("tnt_16", () -> new BlockItem(TNT_16.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_32 = BLOCKS.register("tnt_32", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_32_ITEM = ITEMS.register("tnt_32", () -> new BlockItem(TNT_32.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_64 = BLOCKS.register("tnt_64", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 64.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_64_ITEM = ITEMS.register("tnt_64", () -> new BlockItem(TNT_64.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_128 = BLOCKS.register("tnt_128", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 128.0f, 80));
|
||||
public static final RegistryObject<Item> TNT_128_ITEM = ITEMS.register("tnt_128", () -> new BlockItem(TNT_128.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_CLUSTER_2 = BLOCKS.register("tnt_cluster_2", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 2, 10));
|
||||
public static final RegistryObject<Item> TNT_CLUSTER__2ITEM = ITEMS.register("tnt_cluster_2", () -> new BlockItem(TNT_CLUSTER_2.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_CLUSTER_4 = BLOCKS.register("tnt_cluster_4", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 4, 10));
|
||||
public static final RegistryObject<Item> TNT_CLUSTER_4_ITEM = ITEMS.register("tnt_cluster_4", () -> new BlockItem(TNT_CLUSTER_4.get(), new Item.Properties()));
|
||||
|
||||
public static final RegistryObject<Block> TNT_CLUSTER_8 = BLOCKS.register("tnt_cluster_8", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 8, 10));
|
||||
public static final RegistryObject<Item> TNT_CLUSTER_8_ITEM = ITEMS.register("tnt_cluster_8", () -> new BlockItem(TNT_CLUSTER_8.get(), new Item.Properties()));
|
||||
|
||||
public void register(IEventBus bus) {
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
}
|
||||
}
|
31
src/main/java/com/jenny/compressedtnt/creativeTab.java
Normal file
31
src/main/java/com/jenny/compressedtnt/creativeTab.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.jenny.compressedtnt;
|
||||
|
||||
import com.jenny.compressedtnt.blocks.blocks;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import static com.jenny.compressedtnt.Compressedtnt.MODID;
|
||||
|
||||
public class creativeTab {
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
|
||||
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register("compressedtnt", () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> blocks.TNT_8_ITEM.get().getDefaultInstance()).displayItems((parameters, output) -> {
|
||||
output.accept(blocks.TNT_8.get());
|
||||
output.accept(blocks.TNT_16.get());
|
||||
output.accept(blocks.TNT_32.get());
|
||||
output.accept(blocks.TNT_64.get());
|
||||
output.accept(blocks.TNT_128.get());
|
||||
output.accept(blocks.TNT_CLUSTER_2.get());
|
||||
output.accept(blocks.TNT_CLUSTER_4.get());
|
||||
output.accept(blocks.TNT_CLUSTER_8.get());
|
||||
}).title(Component.literal("Compressed TNT")).build());
|
||||
|
||||
public void register(IEventBus bus) {
|
||||
CREATIVE_MODE_TABS.register(bus);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.jenny.compressedtnt.datagen;
|
||||
|
||||
import com.jenny.compressedtnt.Compressedtnt;
|
||||
import com.jenny.compressedtnt.blocks.blocks;
|
||||
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@ -20,14 +21,14 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
|
||||
@Override
|
||||
protected void registerStatesAndModels() {
|
||||
sideTopBottom(Compressedtnt.TNT_8.get());
|
||||
sideTopBottom(Compressedtnt.TNT_16.get());
|
||||
sideTopBottom(Compressedtnt.TNT_32.get());
|
||||
sideTopBottom(Compressedtnt.TNT_64.get());
|
||||
sideTopBottom(Compressedtnt.TNT_128.get());
|
||||
sideTopBottom(Compressedtnt.TNT_CLUSTER_2.get());
|
||||
sideTopBottom(Compressedtnt.TNT_CLUSTER_4.get());
|
||||
sideTopBottom(Compressedtnt.TNT_CLUSTER_8.get());
|
||||
sideTopBottom(blocks.TNT_8.get());
|
||||
sideTopBottom(blocks.TNT_16.get());
|
||||
sideTopBottom(blocks.TNT_32.get());
|
||||
sideTopBottom(blocks.TNT_64.get());
|
||||
sideTopBottom(blocks.TNT_128.get());
|
||||
sideTopBottom(blocks.TNT_CLUSTER_2.get());
|
||||
sideTopBottom(blocks.TNT_CLUSTER_4.get());
|
||||
sideTopBottom(blocks.TNT_CLUSTER_8.get());
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user