Jump to content

CoddingDirtMC

Members
  • Posts

    24
  • Joined

  • Last visited

Posts posted by CoddingDirtMC

  1. Here is the full code:

    package item;
    
    import net.minecraft.core.BlockPos;
    import net.minecraft.world.InteractionResult;
    import net.minecraft.world.item.Item;
    import net.minecraft.world.item.context.UseOnContext;
    import net.minecraft.world.level.block.BaseFireBlock;
    import net.minecraft.world.level.block.state.BlockState;
    import net.minecraft.world.level.gameevent.GameEvent;
    
    public class FFSS extends Item {
    
    	public FFSS(Properties p_41383_) {
    		super(p_41383_);
    	}
    	
    	@Override
    	public InteractionResult useOn(UseOnContext context) {
    		
    		BlockPos pos1 = new BlockPos(context.getClickedPos().getX(), context.getClickedPos().getY() + 1, context.getClickedPos().getZ());
    		BlockPos pos2 = new BlockPos(pos1.getX() + 1, pos1.getY(), pos1.getZ());
    		BlockPos pos3 = new BlockPos(pos1.getX(), pos1.getY(), pos1.getZ() + 1);
    		BlockPos pos4 = new BlockPos(pos1.getX() + 1, pos1.getY(), pos1.getZ() + 1);
    		
    		BlockState bs1 = BaseFireBlock.getState(context.getLevel(), pos1);
    		BlockState bs2 = BaseFireBlock.getState(context.getLevel(), pos2);
    		BlockState bs3 = BaseFireBlock.getState(context.getLevel(), pos3);
    		BlockState bs4 = BaseFireBlock.getState(context.getLevel(), pos4);
    		
    		context.getLevel().setBlock(pos1, bs1, 1);
    		context.getLevel().setBlock(pos2, bs2, 1);
    		context.getLevel().setBlock(pos3, bs3, 1);
    		context.getLevel().setBlock(pos4, bs4, 1);
    		
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos1);
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos2);
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos3);
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos4);
    	    return InteractionResult.sidedSuccess(context.getLevel().isClientSide());
    	}
    }

    And here is the register code:

    package item;
    
    import net.minecraft.world.item.CreativeModeTab;
    import net.minecraft.world.item.Item;
    import net.minecraftforge.registries.DeferredRegister;
    import net.minecraftforge.registries.ForgeRegistries;
    import net.minecraftforge.registries.RegistryObject;
    import com.elliot.juststeel.*;
    public class ItemInit {
    	public static final DeferredRegister<Item> ITEMS = 
                DeferredRegister.create(ForgeRegistries.ITEMS, JustSteel.MODID);
    	public static final RegistryObject<Item> STEELSTEEL = ITEMS.register("steelsteel",
                () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS).stacksTo(1)));
    	public static final RegistryObject<Item> FLINTFLINT = ITEMS.register("flintflint",
    			() -> new FlintFlint(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS).stacksTo(1)));
    	public static final RegistryObject<Item> FLINTFLINTSTEELSTEEL = ITEMS.register("flintflintsteelsteel",
                () -> new FFSS(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS).stacksTo(1)));
    }

    I did look at the FlintAndSteelItem class but most of the difference was sound which I don't really care about.

  2. Hi,

    I am trying to make a my own version of a flint and steel but changed up a bit. It is supposed to spawn 4 fire blocks in a 2 by 2 area but it is only spawning the fire that I am looking at. Can you help me? Here is my code.

    package item;
    
    import net.minecraft.core.BlockPos;
    import net.minecraft.world.InteractionResult;
    import net.minecraft.world.item.Item;
    import net.minecraft.world.item.context.UseOnContext;
    import net.minecraft.world.level.block.BaseFireBlock;
    import net.minecraft.world.level.block.state.BlockState;
    import net.minecraft.world.level.gameevent.GameEvent;
    
    public class FFSS extends Item {
    
    	public FFSS(Properties p_41383_) {
    		super(p_41383_);
    	}
    	
    	@Override
    	public InteractionResult useOn(UseOnContext context) {
    		
    		BlockPos pos1 = new BlockPos(context.getClickedPos().getX(), context.getClickedPos().getY() + 1, context.getClickedPos().getZ());
    		BlockPos pos2 = new BlockPos(pos1.getX() + 1, pos1.getY(), pos1.getZ());
    		BlockPos pos3 = new BlockPos(pos1.getX(), pos1.getY(), pos1.getZ() + 1);
    		BlockPos pos4 = new BlockPos(pos1.getX() + 1, pos1.getY(), pos1.getZ() + 1);
    		
    		BlockState bs1 = BaseFireBlock.getState(context.getLevel(), pos1);
    		BlockState bs2 = BaseFireBlock.getState(context.getLevel(), pos2);
    		BlockState bs3 = BaseFireBlock.getState(context.getLevel(), pos3);
    		BlockState bs4 = BaseFireBlock.getState(context.getLevel(), pos4);
    		
    		context.getLevel().setBlock(pos1, bs1, 1);
    		context.getLevel().setBlock(pos2, bs2, 1);
    		context.getLevel().setBlock(pos3, bs3, 1);
    		context.getLevel().setBlock(pos4, bs4, 1);
    		
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos1);
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos2);
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos3);
    		context.getLevel().gameEvent(context.getPlayer(), GameEvent.BLOCK_PLACE, pos4);
    	    return super.useOn(context);
    	}
    }

     

  3. you're reading my mind I just did that now and it STILL didnt work

    package util;
    
    import init.BlockInit;
    import com.example.eitem.ElliotItems;
    import net.minecraft.client.renderer.ItemBlockRenderTypes;
    import net.minecraft.client.renderer.RenderType;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
    
    @Mod.EventBusSubscriber(modid = ElliotItems.MOD_ID, bus = Bus.MOD, value = Dist.CLIENT)
    public class ClientEventBusSubscriber {
    	@SubscribeEvent
    	public static void clientSetup(FMLClientSetupEvent event) {
    		ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER.get(), RenderType.cutout());
    	}
    }

     

  4. wait my code has a setup method. And my clientSetup seems to be not running. Is the setup method overriding clientSetup?

    Setup method and Constructor:

    public ElliotItems()
        {
            // Register the setup method for modloading
        	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
            modEventBus.addListener(this::setup);
            // Register the enqueueIMC method for modloading
            modEventBus.addListener(this::enqueueIMC);
            // Register the processIMC method for modloading
            modEventBus.addListener(this::processIMC);
            modEventBus.addListener(this::clientSetup);
            BlockInit.BLOCKS.register(modEventBus);
            ItemInit.ITEMS.register(modEventBus);
            // Register ourselves for server and other game events we are interested in
            MinecraftForge.EVENT_BUS.register(this);
        }
    
        private void setup(final FMLCommonSetupEvent event)
        {
            // some preinit code
            LOGGER.info("HELLO FROM PREINIT");
            char[] ca = {'g', 'o', ' ', 'm', 'y'};
            String c = Character.toString(ca[0]).toUpperCase();
            System.out.println(c + " is c");
            char[] newc = c.toCharArray();
            ca[0] = newc[0];
            System.out.println(new String(ca));
            LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
        }

     

     

  5. alr heres my code:

    package com.example.eitem;
    
    import com.mojang.logging.LogUtils;
    
    import init.BlockInit;
    import init.ItemInit;
    import net.minecraft.client.renderer.ItemBlockRenderTypes;
    import net.minecraft.client.renderer.RenderType;
    import net.minecraft.world.level.block.Block;
    import net.minecraft.world.level.block.Blocks;
    import net.minecraftforge.common.MinecraftForge;
    import net.minecraftforge.event.RegistryEvent;
    import net.minecraftforge.eventbus.api.IEventBus;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.InterModComms;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
    import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
    import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
    import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
    import net.minecraftforge.event.server.ServerStartingEvent;
    import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
    import org.slf4j.Logger;
    
    import java.util.stream.Collectors;
    
    // The value here should match an entry in the META-INF/mods.toml file
    @Mod("eitem")
    public class ElliotItems
    {
    	public static final String MOD_ID = "eitem";
    	public static final String VERSION = "1.6.2";
    	public static final String NAME = "Elliot's Item";
        // Directly reference a slf4j logger
        private static final Logger LOGGER = LogUtils.getLogger();
    
        public ElliotItems()
        {
            // Register the setup method for modloading
        	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
            modEventBus.addListener(this::setup);
            // Register the enqueueIMC method for modloading
            modEventBus.addListener(this::enqueueIMC);
            // Register the processIMC method for modloading
            modEventBus.addListener(this::processIMC);
            BlockInit.BLOCKS.register(modEventBus);
            ItemInit.ITEMS.register(modEventBus);
            modEventBus.addListener(this::clientSetup);
            // Register ourselves for server and other game events we are interested in
            MinecraftForge.EVENT_BUS.register(this);
        }
    
        private void setup(final FMLCommonSetupEvent event)
        {
            // some preinit code
            LOGGER.info("HELLO FROM PREINIT");
            char[] ca = {'g', 'o', ' ', 'm', 'y'};
            String c = Character.toString(ca[0]).toUpperCase();
            System.out.println(c + " is c");
            char[] newc = c.toCharArray();
            ca[0] = newc[0];
            System.out.println(new String(ca));
            LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
        }
        private void clientSetup (final FMLClientSetupEvent event) {
            ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout());
        }
        private void enqueueIMC(final InterModEnqueueEvent event)
        {
            // Some example code to dispatch IMC to another mod
            InterModComms.sendTo("eitem", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
        }
    
        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(ServerStartingEvent event)
        {
            // Do something when the server starts
            LOGGER.info("HELLO from server starting");
        }
    
        // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
        // Event bus for receiving Registry Events)
        @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
        public static class RegistryEvents
        {
            @SubscribeEvent
            public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
            {
                // Register a new block here
                LOGGER.info("HELLO from Register Block");
            }
        }
    }

     

  6. My main is:

    package com.example.eitem;
    
    import com.mojang.logging.LogUtils;
    
    import init.BlockInit;
    import init.ItemInit;
    import net.minecraft.client.renderer.ItemBlockRenderTypes;
    import net.minecraft.client.renderer.RenderType;
    import net.minecraft.world.level.block.Block;
    import net.minecraft.world.level.block.Blocks;
    import net.minecraftforge.common.MinecraftForge;
    import net.minecraftforge.event.RegistryEvent;
    import net.minecraftforge.eventbus.api.IEventBus;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.InterModComms;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
    import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
    import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
    import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
    import net.minecraftforge.event.server.ServerStartingEvent;
    import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
    import org.slf4j.Logger;
    
    import java.util.stream.Collectors;
    
    // The value here should match an entry in the META-INF/mods.toml file
    @Mod("eitem")
    public class ElliotItems
    {
    	public static final String MOD_ID = "eitem";
    	public static final String VERSION = "1.6.2";
    	public static final String NAME = "Elliot's Item";
        // Directly reference a slf4j logger
        private static final Logger LOGGER = LogUtils.getLogger();
    
        public ElliotItems()
        {
            // Register the setup method for modloading
        	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
            modEventBus.addListener(this::setup);
            // Register the enqueueIMC method for modloading
            modEventBus.addListener(this::enqueueIMC);
            // Register the processIMC method for modloading
            modEventBus.addListener(this::processIMC);
            BlockInit.BLOCKS.register(modEventBus);
            ItemInit.ITEMS.register(modEventBus);
            modEventBus.addListener(this::clientSetup);
            // Register ourselves for server and other game events we are interested in
            MinecraftForge.EVENT_BUS.register(this);
        }
    
        private void setup(final FMLCommonSetupEvent event)
        {
            // some preinit code
            LOGGER.info("HELLO FROM PREINIT");
            char[] ca = {'g', 'o', ' ', 'm', 'y'};
            String c = Character.toString(ca[0]).toUpperCase();
            System.out.println(c + " is c");
            char[] newc = c.toCharArray();
            ca[0] = newc[0];
            System.out.println(new String(ca));
            ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout());
            LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
        }
        private void clientSetup (final FMLClientSetupEvent event) {
            ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout());
        private void enqueueIMC(final InterModEnqueueEvent event)
        {
            // Some example code to dispatch IMC to another mod
            InterModComms.sendTo("eitem", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
        }
    
        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(ServerStartingEvent event)
        {
            // Do something when the server starts
            LOGGER.info("HELLO from server starting");
        }
    
        // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
        // Event bus for receiving Registry Events)
        @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
        public static class RegistryEvents
        {
            @SubscribeEvent
            public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
            {
                // Register a new block here
                LOGGER.info("HELLO from Register Block");
            }
        }
    }

    there was stuff i was experimenting with so don't worry about it lol

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.