From 8e5e451d4c5e5bb0de1ffdccc4a43c38181de9d1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Aug 2021 20:01:19 +0700 Subject: [PATCH] add android station block? --- .../mc/otm/OverdriveThatMatters.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 64a4e9384..c35d89cc8 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -4,8 +4,14 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; 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.material.Material; +import net.minecraft.world.level.material.MaterialColor; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.AttachCapabilitiesEvent; @@ -27,12 +33,17 @@ import ru.dbotthepony.mc.otm.capability.IAndroidCapability; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file -@Mod("overdrive_that_matters") -public class OverdriveThatMatters -{ +@Mod(OverdriveThatMatters.MOD_ID) +public class OverdriveThatMatters { // Directly reference a log4j logger. + public static final String MOD_ID = "overdrive_that_matters"; public static final Logger LOGGER = LogManager.getLogger(); + public static Block ANDROID_STATION = new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE).requiresCorrectToolForDrops().strength(3F, 6.0F)).setRegistryName(OverdriveThatMatters.MOD_ID, "android_station"); + public static Item ANDROID_STATION_ITEM = new BlockItem(ANDROID_STATION, new Item.Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)).setRegistryName(OverdriveThatMatters.MOD_ID, "android_station"); + + // public static final Block STONE = register("stone", new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE).requiresCorrectToolForDrops().strength(1.5F, 6.0F))); + public OverdriveThatMatters() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); @@ -45,26 +56,24 @@ public class OverdriveThatMatters MinecraftForge.EVENT_BUS.register(this); } - private void setup(final FMLCommonSetupEvent event) - { + private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } - private void enqueueIMC(final InterModEnqueueEvent event) - { + private void enqueueIMC(final InterModEnqueueEvent event) { // some example code to dispatch IMC to another mod InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); } - private void processIMC(final InterModProcessEvent event) - { + private void processIMC(final InterModProcessEvent event) { // some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). map(m->m.messageSupplier().get()). collect(Collectors.toList())); } + // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { @@ -72,7 +81,7 @@ public class OverdriveThatMatters LOGGER.info("HELLO from server starting"); } - private final ResourceLocation android_cap_location = new ResourceLocation("overdrive_that_matters", "android_capability"); + private final ResourceLocation android_cap_location = new ResourceLocation(OverdriveThatMatters.MOD_ID, "android_capability"); @SubscribeEvent public void onAttachCapabilityEvent(AttachCapabilitiesEvent event) { @@ -108,6 +117,14 @@ public class OverdriveThatMatters public static void onBlocksRegistry(final RegistryEvent.Register blockRegistryEvent) { // register a new block here LOGGER.info("HELLO from Register Block"); + blockRegistryEvent.getRegistry().register(ANDROID_STATION); + } + + @SubscribeEvent + public static void onItemRegistry(final RegistryEvent.Register blockRegistryEvent) { + // register a new block here + LOGGER.info("HELLO from Register Item"); + blockRegistryEvent.getRegistry().register(ANDROID_STATION_ITEM); } } }