Jump to content

mrcobalt124

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by mrcobalt124

  1. Yeah I figured that out cool. Another thing, is there a way I can get control of some code when an entity is touching my block? I'm trying to make a conveyor belt, don't be mistaken by the Mud Block name, that's just a block i'm messing around with.
  2. Hm, overriding onBlockClicked still lets me break the block, and doesn't trigger the function. Should I be testing in survival mode?
  3. I am trying to make a specific class for one of my blocks but for some reason the overridden methods are not called, however the constructor is called and gets added to the registry as it still shows up in game. public class MudBlock extends Block { public MudBlock(Properties properties) { super(properties); FunMod.log.info("Mud Block created!"); } @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { FunMod.log.info("Entity collided with a Mud Block!"); } @Override public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { FunMod.log.info("Block was clicked on!"); } } That is the class I create. I register it like this: @Mod.EventBusSubscriber(modid = FunMod.MOD_ID, bus = Bus.MOD) @ObjectHolder(FunMod.MOD_ID) public class BlockInit { /* Blocks to be registered */ public static MudBlock mud_block = null; private static void register_block(final RegistryEvent.Register<Block> event, Block block, String name) { block.setRegistryName(name); event.getRegistry().register(block); } private static void register_block_item(final RegistryEvent.Register<Item> event, Block block, Item.Properties properties, String name) { event.getRegistry().register(new BlockItem(block, properties).setRegistryName(name)); } @SubscribeEvent public static void register_blocks(final RegistryEvent.Register<Block> event) { /* Create block objects */ mud_block = new MudBlock(Block.Properties.create(Material.SAND).hardnessAndResistance(10f, 0f).harvestTool(ToolType.SHOVEL).slipperiness(5f).sound(SoundType.GROUND)); /* Register blocks */ FunMod.log.info("Registering blocks."); register_block(event, mud_block, "mud_block"); FunMod.log.info("Done."); } @SubscribeEvent public static void register_block_items(final RegistryEvent.Register<Item> event) { /* Register block items */ register_block_item(event, mud_block, new Item.Properties().maxStackSize(64).group(ItemGroup.BUILDING_BLOCKS), "mud_block"); } } Does anyone see anything I am doing wrong? Also I'm using 1.15.2 EDIT: Sometimes the onEntityCollision works, but not all the time. It seems to only trigger when an Entity is actually inside one of the blocks and not just touching it.
×
×
  • Create New...

Important Information

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