add android station block?

This commit is contained in:
DBotThePony 2021-08-07 20:01:19 +07:00
parent 91834d9f5e
commit 8e5e451d4c
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -4,8 +4,14 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; 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.Block;
import net.minecraft.world.level.block.Blocks; 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.MinecraftForge;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent;
@ -27,12 +33,17 @@ import ru.dbotthepony.mc.otm.capability.IAndroidCapability;
import java.util.stream.Collectors; import java.util.stream.Collectors;
// The value here should match an entry in the META-INF/mods.toml file // The value here should match an entry in the META-INF/mods.toml file
@Mod("overdrive_that_matters") @Mod(OverdriveThatMatters.MOD_ID)
public class OverdriveThatMatters public class OverdriveThatMatters {
{
// Directly reference a log4j logger. // Directly reference a log4j logger.
public static final String MOD_ID = "overdrive_that_matters";
public static final Logger LOGGER = LogManager.getLogger(); 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() { public OverdriveThatMatters() {
// Register the setup method for modloading // Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
@ -45,26 +56,24 @@ public class OverdriveThatMatters
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
private void setup(final FMLCommonSetupEvent event) private void setup(final FMLCommonSetupEvent event) {
{
// some preinit code // some preinit code
LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("HELLO FROM PREINIT");
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); 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 // some example code to dispatch IMC to another mod
InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); 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 // some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream(). LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.messageSupplier().get()). map(m->m.messageSupplier().get()).
collect(Collectors.toList())); collect(Collectors.toList()));
} }
// You can use SubscribeEvent and let the Event Bus discover methods to call // You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent @SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) { public void onServerStarting(FMLServerStartingEvent event) {
@ -72,7 +81,7 @@ public class OverdriveThatMatters
LOGGER.info("HELLO from server starting"); 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 @SubscribeEvent
public void onAttachCapabilityEvent(AttachCapabilitiesEvent<Entity> event) { public void onAttachCapabilityEvent(AttachCapabilitiesEvent<Entity> event) {
@ -108,6 +117,14 @@ public class OverdriveThatMatters
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
// register a new block here // register a new block here
LOGGER.info("HELLO from Register Block"); LOGGER.info("HELLO from Register Block");
blockRegistryEvent.getRegistry().register(ANDROID_STATION);
}
@SubscribeEvent
public static void onItemRegistry(final RegistryEvent.Register<Item> blockRegistryEvent) {
// register a new block here
LOGGER.info("HELLO from Register Item");
blockRegistryEvent.getRegistry().register(ANDROID_STATION_ITEM);
} }
} }
} }