Enderlook Posted August 6, 2018 Share Posted August 6, 2018 (edited) I'm trying to make a custom Frost Walker that instead of turn water into ice it will turn lava sources into obsidian and lava flows into cobblestone. Also, I want that after some time, that cobblestone and obsidian turns into lava again like in Frost walker. My problems are two: It isn't able to turn lava flows. It only works in sources (Pseudo-fixed below). It doesn't turn back blocks after a while. Here is my code: @SubscribeEvent public static void stonewalker(LivingUpdateEvent event) { int level = EnchantmentHelper.getMaxEnchantmentLevel(ENCHANTMENT_STONE_WALKER, event.getEntityLiving()); if(level > 0) { Entity entity = event.getEntity(); EntityLivingBase entityLiving = event.getEntityLiving(); World world = entity.world; if(!world.isRemote && entityLiving.onGround) { int r = level + 2; BlockPos pos = entity.getPosition(); for (int x = -r; x <= r; x++) { for (int z = -r; z <= r; z++) { BlockPos blockpos = pos.add(x,-1,z); if(blockpos.distanceSq(pos.getX(), pos.getY(), pos.getZ()) > r*r) { continue; } IBlockState iblockstate = world.getBlockState(blockpos); if (iblockstate.getMaterial() == Material.LAVA && (iblockstate.getBlock() == Blocks.LAVA || iblockstate.getBlock() == Blocks.FLOWING_LAVA) && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && world.mayPlace(Blocks.OBSIDIAN, blockpos, false, EnumFacing.DOWN, (Entity)null)) { world.setBlockState(blockpos, Blocks.OBSIDIAN.getDefaultState()); world.scheduleUpdate(blockpos.toImmutable(), Blocks.OBSIDIAN, MathHelper.getInt(entityLiving.getRNG(), 60, 120)); } } } } } }; I think the problems may be in the last if block statement. This: `iblockstate.getMaterial() == Material.LAVA && (iblockstate.getBlock() == Blocks.LAVA || iblockstate.getBlock() == Blocks.FLOWING_LAVA) && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && world.mayPlace(Blocks.COBBLESTONE, blockpos, false, EnumFacing.DOWN, (Entity)null)`. I'm not sure how works this part `((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()`. I noted that if I delete that part, it's able to turn lava flows, but I was wondering why Minecraft has that in Frost Walker enchantment. Also, I think this line make the timer: `world.scheduleUpdate(blockpos.toImmutable(), Blocks.OBSIDIAN, MathHelper.getInt(entityLiving.getRNG(), 60, 120));` but I am not sure how to ask to "world" turn back the block after the time expires. The first problem can be fixed in this way: if (iblockstate.getMaterial() == Material.LAVA && (iblockstate.getBlock() == Blocks.LAVA || iblockstate.getBlock() == Blocks.FLOWING_LAVA) && world.mayPlace(Blocks.OBSIDIAN, blockpos, false, EnumFacing.DOWN, (Entity)null)) { if (((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0) { world.setBlockState(blockpos, Blocks.OBSIDIAN.getDefaultState()); world.scheduleUpdate(blockpos.toImmutable(), Blocks.OBSIDIAN, MathHelper.getInt(entityLiving.getRNG(), 60, 120)); } else { world.setBlockState(blockpos, Blocks.COBBLESTONE.getDefaultState()); world.scheduleUpdate(blockpos.toImmutable(), Blocks.COBBLESTONE, MathHelper.getInt(entityLiving.getRNG(), 60, 120)); } } Not sure the second one. Edited August 6, 2018 by Enderlook Quote Link to comment Share on other sites More sharing options...
Cadiboo Posted August 6, 2018 Share Posted August 6, 2018 I believe vanilla turns back blocks by not placing actual ice, but placing special ice that turns back by itself. Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 (edited) 12 minutes ago, Cadiboo said: I believe vanilla turns back blocks by not placing actual ice, but placing special ice that turns back by itself. You have right: https://minecraft.gamepedia.com/Frosted_Ice So, what is the purpose of?: world.scheduleUpdate(blockpos.toImmutable(), Blocks.COBBLESTONE, MathHelper.getInt(entityLiving.getRNG(), 60, 120)); Edited August 6, 2018 by Enderlook Quote Link to comment Share on other sites More sharing options...
Draco18s Posted August 6, 2018 Share Posted August 6, 2018 26 minutes ago, Enderlook said: I'm not sure how works this part `((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()`. liquid level 0 = source block. Frost Walker only turns source blocks into things. 26 minutes ago, Enderlook said: but I am not sure how to ask to "world" turn back the block after the time expires. As Cadiboo says, Frost Walker doesn't make ice, it uses a separate block. https://minecraft.gamepedia.com/Frosted_Ice Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Cadiboo Posted August 6, 2018 Share Posted August 6, 2018 (edited) 4 minutes ago, Enderlook said: You have right: https://minecraft.gamepedia.com/Frosted_Ice So, what is the purpose of?: world.scheduleUpdate(blockpos.toImmutable(), Blocks.COBBLESTONE, MathHelper.getInt(entityLiving.getRNG(), 60, 120)); Telling the block that it should update. This does nothing for normal blocks, however for the Frosted ice it probably (I assume) will trigger a possible melt Edited August 6, 2018 by Cadiboo Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
Cadiboo Posted August 6, 2018 Share Posted August 6, 2018 Just now, Cadiboo said: Telling the block that it should update. This does nothing for normal blocks, however for the Frosted ice it will trigger a possible melt You could make blocks that extend frosted ice and just set their blockstates to point to the vanilla block models (cobble, obsidian) Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 1 minute ago, Cadiboo said: Telling the block that it should update. This does nothing for normal blocks, however for the Frosted ice it will trigger a possible melt Oh, that is interesting! Quote Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 Any idea of where can I get the source code of Frosted Ice? I would like to see it but I can't find it. Quote Link to comment Share on other sites More sharing options...
Cadiboo Posted August 6, 2018 Share Posted August 6, 2018 2 minutes ago, Enderlook said: Any idea of where can I get the source code of Frosted Ice? I would like to see it but I can't find it. Use your IDE to look for it, it’s probably under net.minecraft.block Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 (edited) 33 minutes ago, Cadiboo said: Use your IDE to look for it, it’s probably under net.minecraft.block Oh, I was looking in blocks. That is why I haven't found it! Edited August 6, 2018 by DaemonUmbra Removed Copyrighted Code Quote Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 I've made a custom block, called `petrify_obsidian` (just a basic block) in order to spawn it with my "stone_walker". But each time I try to use my enchantment it crashes the game, and if I replace it with normal obsidian, it doesn't. What am I doing wrong? I just changed `Blocks.OBSIDIAN` to `ModBlocks.PETRIFY_OBSIDIAN_BLOCK`. I think the problem may be with the way I register it, but not sure. @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ModBlocks { @ObjectHolder(ExtraCraft.MOD_ID + ":petrify_obsidian_block") public static final BlockPetrifyObsidian BLOCK_PETRIFY_OBSIDIAN = null; private static CBlockBasic[] BLOCK_BASIC; public static void init() { BLOCK_BASIC = new CBlockBasic[] { new BlockPetrifyObsidian() }; } @SideOnly(Side.CLIENT) public static void initializeBlockModels() { for (CBlockBasic block : BLOCK_BASIC) { block.initializeModel(); } }; @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); registry.registerAll(BLOCK_BASIC); }; @SubscribeEvent public static void registerItemBlocks(final RegistryEvent.Register<Item> event) { for (CBlockBasic block : BLOCK_BASIC) { block.registerItemBlock(event); } } } Init is called on: @Mod(modid = ExtraCraft.MOD_ID, name = ExtraCraft.NAME, version = ExtraCraft.VERSION) @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ExtraCraft implements IProxy { // [...] @Override @EventHandler public void preInitializationEvent(FMLPreInitializationEvent event) { ModBlocks.init(); } // [...] } I think that the registration of my enchantment event is being done before my block initialization (null exception), but I don't know how to change the order. Description: Ticking player java.lang.NullPointerException: Ticking player at net.minecraft.world.World.mayPlace(World.java:3435) at net.enderlook.extracraft.init.ModEnchantments.stonewalker(ModEnchantments.java:69) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_8_ModEnchantments_stonewalker_LivingUpdateEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:566) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2312) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272) at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Unknown Source) What can I do? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 3 minutes ago, Enderlook said: I've made a custom block, called `petrify_obsidian` (just a basic block) in order to spawn it with my "stone_walker". But each time I try to use my enchantment it crashes the game, and if I replace it with normal obsidian, it doesn't. What am I doing wrong? I just changed `Blocks.OBSIDIAN` to `ModBlocks.PETRIFY_OBSIDIAN_BLOCK`. I think the problem may be with the way I register it, but not sure. @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ModBlocks { @ObjectHolder(ExtraCraft.MOD_ID + ":petrify_obsidian_block") public static final BlockPetrifyObsidian BLOCK_PETRIFY_OBSIDIAN = null; private static CBlockBasic[] BLOCK_BASIC; public static void init() { BLOCK_BASIC = new CBlockBasic[] { new BlockPetrifyObsidian() }; } @SideOnly(Side.CLIENT) public static void initializeBlockModels() { for (CBlockBasic block : BLOCK_BASIC) { block.initializeModel(); } }; @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); registry.registerAll(BLOCK_BASIC); }; @SubscribeEvent public static void registerItemBlocks(final RegistryEvent.Register<Item> event) { for (CBlockBasic block : BLOCK_BASIC) { block.registerItemBlock(event); } } } Init is called on: @Mod(modid = ExtraCraft.MOD_ID, name = ExtraCraft.NAME, version = ExtraCraft.VERSION) @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ExtraCraft implements IProxy { // [...] @Override @EventHandler public void preInitializationEvent(FMLPreInitializationEvent event) { ModBlocks.init(); } // [...] } I think that the registration of my enchantment event is being done before my block initialization (null exception), but I don't know how to change the order. Description: Ticking player java.lang.NullPointerException: Ticking player at net.minecraft.world.World.mayPlace(World.java:3435) at net.enderlook.extracraft.init.ModEnchantments.stonewalker(ModEnchantments.java:69) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_8_ModEnchantments_stonewalker_LivingUpdateEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:566) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2312) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272) at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Unknown Source) What can I do? Something is null on line 69 of ModEnchantments Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 2 hours ago, Animefan8888 said: Something is null on line 69 of ModEnchantments I know, the line 69 is: if (iblockstate.getMaterial() == Material.LAVA && (iblockstate.getBlock() == Blocks.LAVA || iblockstate.getBlock() == Blocks.FLOWING_LAVA) && world.mayPlace(ModBlocks.BLOCK_PETRIFY_OBSIDIAN, blockpos, false, EnumFacing.DOWN, (Entity)null)) { I'm quite sure the null may be `ModBlocks.BLOCK_PETRIFY_OBSIDIAN`, that is why I'm asking how can I fix it. That block is initialized automatically by Minecraft: @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ModBlocks { // [...] @ObjectHolder(ExtraCraft.MOD_ID + ":petrify_obsidian_block") public static final BlockPetrifyObsidian BLOCK_PETRIFY_OBSIDIAN = null; // [...] } And also the enchantment is initialized by Minecraft: @EventBusSubscriber(modid=ExtraCraft.MOD_ID) public class ModEnchantments { // [...] @SubscribeEvent public static void stonewalker(LivingUpdateEvent event) { // [...] } } So I don't know how to fix it. Quote Link to comment Share on other sites More sharing options...
Draco18s Posted August 6, 2018 Share Posted August 6, 2018 Use the debugger to verify that that is what is null. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 (edited) 14 minutes ago, Enderlook said: I'm quite sure the null may be `ModBlocks.BLOCK_PETRIFY_OBSIDIAN I'm sure that it is the null instance that you are using as an entity that is null. Try using the player. Edited August 6, 2018 by Animefan8888 Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 31 minutes ago, Animefan8888 said: I'm sure that it is the null instance that you are using as an entity that is null. Try using the player. I'm not sure what you mean with "try using the player", but note that if I replace my block ModBlocks.PETRIFY_OBSIDIAN_BLOCK to Blocks.OBSIDIAN (I mean, a vanilla block) it works fine. That is why I think it may be a problem with the block. 39 minutes ago, Draco18s said: Use the debugger to verify that that is what is null. I'm sorry but I don't know how to use that IDE's tools, so I'll do my best. I've set a breakpoint in that line and open debug mode. It says: event LivingEvent$LivingUpdateEvent (id=419) level 1 entity EntityPlayerMP (id=424) entityLiving EntityPlayerMP (id=424) world WorldServer (id=431) r 3 pos BlockPos (id=436) x -1 z -2 blockpos BlockPos (id=697) iblockstate BlockStateContainer$StateImplementation (id=440) It seems that there isn't any null in that variables. But... If I add this line before the breakpoint: BlockPetrifyObsidian a = ModBlocks.BLOCK_PETRIFY_OBSIDIAN; I can see: getMaterial() returned MaterialLogic (id=462) event LivingEvent$LivingUpdateEvent (id=418) level 1 entity EntityPlayerMP (id=423) entityLiving EntityPlayerMP (id=423) world WorldServer (id=430) r 3 pos BlockPos (id=435) x -2 z -2 blockpos BlockPos (id=438) iblockstate BlockStateContainer$StateImplementation (id=439) a null That "a" ---> my custom block, is null. So, if both things (the block and the event) are registered automatically with "@SubscribeEvent", how can I ask Minecraft/Forge to initialize first the block and then the event? Or I don't know, whatever it must be done. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 23 minutes ago, Enderlook said: So, if both things (the block and the event) are registered automatically with "@SubscribeEvent", how can I ask Minecraft/Forge to initialize first the block and then the event? Or I don't know, whatever it must be done. The yes it is obviously your block, and the problem may be that the string in your @ObjectHolder annotation doesn't match its registry name? 1 Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Enderlook Posted August 6, 2018 Author Share Posted August 6, 2018 17 minutes ago, Animefan8888 said: The yes it is obviously your block, and the problem may be that the string in your @ObjectHolder annotation doesn't match its registry name? You have right, the registry name was different from the @ObjectHolder, I didn't know that. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.