Jump to content

kriNon

Members
  • Posts

    24
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

kriNon's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. As in subscribe to the event and then cancel the event, preventing section of galacticraft code from running?
  2. So in space (dimension 3) when the player is in Freefall (floating not near any blocks) then the player is unable to move using A or D (only able to move forwards or backwards), as well as speed and acceleration works differently. I might need to make my mod depend on Galacticraft, and then modify movement too based on which state the player is in. Their movement mechanics are a little complicated in space, but they can be seen here: https://github.com/micdoodle8/Galacticraft/blob/master/src/main/java/micdoodle8/mods/galacticraft/core/entities/player/FreefallHandler.java
  3. Okay, so I tested it and it works perfectly! Thanks! Sadly, I've now realized that despite the mod working correctly, it doesn't do what I needed it to. I'll go into a bit more detail, but it looks like i'm going to have to try a different method. So, the purpose of my mod was to give the player creative flight in that specific dimension (dimension 3) because the mod that creates the dimension (galacticraft) has different movement mechanics in creative mode to survival mode in that dimension. I had assumed that the different mechanics were caused by a isFlying check, however it turns out that it is actually an isCreative check. Is there any good way of editing a class in another mod, without compiling a custom version of that mod? Kind of like patching the class upon runtime? Thanks a lot for your help!
  4. What I meant was, if we ignore the if statement for dimension. Just to simplify the code (incremental testing), flight does occur in the first one, but not the second. Neither does anything with the if statement for the dimension.
  5. So just for simplicity, ignoring the second if statement. This works: if (event.player instanceof EntityPlayer) { if (!event.player.getEntityWorld().isRemote) { return; } event.player.capabilities.isFlying = true; } But this does nothing: if (event.player instanceof EntityPlayer) { if (event.player.getEntityWorld().isRemote) { return; } event.player.capabilities.isFlying = true; } No crash. The crash did occur with other mods, but I rechecked it and it is no longer an issue (no idea why, maybe I changed the code somewhere and forgot), but the crash is no longer happening under any circumstance.
  6. Yeah doing that does nothing, I suspect that event.player.capabilities.isFlying = true; needs to be done on the client, not the server.
  7. Alright, so after compiling the code again it no longer causes crashes however the crash I was getting was this: https://pastebin.com/yNgNKfdU I'm not quite sure what I did to fix the crashes, but nonetheless the code works fine without the if(event.player.dimension == 3){} (albeit flight occurs in all dimensions) However with the if statement flight will never occur (not even in dimension 3)
  8. Hey all, So I'm working on what is pretty much my first mod, and I am aiming for some very simple functionality. What I want to do is make it so that if the player is in dimension 3 the mod will set event.player.capabilities.isFlying = true. Here's the code for the class that I'm working on: package kriNon.mods.ModpackMod; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ITickable; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; public class DimensionFlight { @SubscribeEvent public void onPlayerTickEvent(TickEvent.PlayerTickEvent event) { if (event.player instanceof EntityPlayer) { if (!event.player.getEntityWorld().isRemote) { return; } if(event.player.dimension == 3){ event.player.capabilities.isFlying = true; } } } } Now the issue I'm having is that the third if statement (the one that checks if the player dimension == 3) will crash the game. I believe I may be going wrong because the client side does not know what dimension it is in (i believe this might be handled only on the server side). How would I best be able to combat this problem? A simple solution would be ideal so that I may better understand it! Thanks!
  9. So I did some more testing, and it seems that the errors are caused when calling the function updateAddresses(). Any idea what could be wrong with it? I've tried making a simplified version of the class so that I can test basic functionality. So I have a "private RegistryInformation r" Where the class RegistryInformation is defined as: class RegistryInformation { HashSet<Integer> addresses; int maxAddress; public void init() { addresses = new HashSet<Integer>(); maxAddress = 0; } public void updateAddresses() { if(addresses.contains(maxAddress)) { // New address added, look up while(addresses.contains(maxAddress)) maxAddress++; } else { // Old address removed, look down while(!addresses.contains(maxAddress)) maxAddress--; maxAddress++; } } } And upon calling r.updateAddresses() it will cause errors. The class in it's entirety is here: package kriNon.endernet.lib; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.util.HashMap; import java.util.HashSet; import kriNon.endernet.Endernet; public class EnderRegistry { class RegistryInformation { HashSet<Integer> addresses; int maxAddress; public void init() { addresses = new HashSet<Integer>(); maxAddress = 0; } public void updateAddresses() { if(addresses.contains(maxAddress)) { // New address added, look up while(addresses.contains(maxAddress)) maxAddress++; } else { // Old address removed, look down while(!addresses.contains(maxAddress)) maxAddress--; maxAddress++; } } } public static EnderRegistry instance; private RegistryInformation r; private final HashMap<Integer, Object> objects = new HashMap<Integer, Object>(); private final File file; public EnderRegistry(File file) { this.file = file; try { r = (RegistryInformation)(Endernet.gson.fromJson(new FileReader(file), RegistryInformation.class)); } catch(FileNotFoundException e) { r = new RegistryInformation(); r.init(); } } public int register(Object o) { r.updateAddresses(); int address = r.maxAddress; r.addresses.add(address); objects.put(address, o); r.updateAddresses(); return address; } }
  10. Yeah, I had posted it earlier but here it is: https://github.com/kriNon/Endernet1.10.2/tree/Testing_EnderRegistry Thanks!
  11. Alright, so after some further testing I've removed the section of code which was checking if the TileEntityEnderTransmitter has a ea value, and if not was registering one. This is because inside the readFromNBT part of the tile entity, it would register the tileentity with a ea value. This has fixed the crashing upon breaking or placing the Ender Transmitter blocks. However, upon placing the blocks, they still do not receive an ea value, and upon loading the world, and breaking the blocks I get errors: [15:34:17] [server thread/ERROR]: Failed to load data for block entity ender_transmitter java.lang.NullPointerException at kriNon.endernet.lib.EnderRegistry.set(EnderRegistry.java:73) ~[EnderRegistry.class:?] at kriNon.endernet.tileentities.TileEntityEnderTransmitter.readFromNBT(TileEntityEnderTransmitter.java:245) ~[TileEntityEnderTransmitter.class:?] at net.minecraft.tileentity.TileEntity.create(TileEntity.java:137) [TileEntity.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:515) [AnvilChunkLoader.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:96) [ChunkIOProvider.class:?] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) [ChunkIOExecutor.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:121) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:92) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:138) [ChunkProviderServer.class:?] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) [integratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91] [15:34:17] [server thread/ERROR] [FML]: A TileEntity ender_transmitter(kriNon.endernet.tileentities.TileEntityEnderTransmitter) has thrown an exception during loading, its state cannot be restored. Report this to the mod author java.lang.NullPointerException at kriNon.endernet.lib.EnderRegistry.set(EnderRegistry.java:73) ~[EnderRegistry.class:?] at kriNon.endernet.tileentities.TileEntityEnderTransmitter.readFromNBT(TileEntityEnderTransmitter.java:245) ~[TileEntityEnderTransmitter.class:?] at net.minecraft.tileentity.TileEntity.create(TileEntity.java:137) [TileEntity.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:515) [AnvilChunkLoader.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:96) [ChunkIOProvider.class:?] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) [ChunkIOExecutor.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:121) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:92) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:138) [ChunkProviderServer.class:?] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) [integratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91] [15:34:51] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_91] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_91] at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91] Caused by: java.lang.NullPointerException at kriNon.endernet.lib.EnderRegistry.unregister(EnderRegistry.java:62) ~[EnderRegistry.class:?] at kriNon.endernet.blocks.BlockEnderTransmitter.breakBlock(BlockEnderTransmitter.java:70) ~[blockEnderTransmitter.class:?] at net.minecraft.world.chunk.Chunk.setBlockState(Chunk.java:610) ~[Chunk.class:?] at net.minecraft.world.World.setBlockState(World.java:384) ~[World.class:?] at net.minecraft.block.Block.removedByPlayer(Block.java:1324) ~[block.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:298) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:292) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:339) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.onBlockClicked(PlayerInteractionManager.java:175) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:658) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_91] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_91] at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?] ... 5 more
  12. So after some further testing I've determined that both when placing and breaking the block, the error occurs with lines 53 and 64 respectively, both of which are calling the function updateAddresses() in the nested class RegistryInformation. public void updateAddresses() { if(addresses.contains(maxAddress)) { // New address added, look up while(addresses.contains(maxAddress)) maxAddress++; } else { // Old address removed, look down while(!addresses.contains(maxAddress)) maxAddress--; maxAddress++; } } When loading a world with the blocks already placed I also get this error: [11:53:00] [server thread/ERROR]: Failed to load data for block entity ender_transmitter java.lang.NullPointerException at kriNon.endernet.lib.EnderRegistry.set(EnderRegistry.java:73) ~[EnderRegistry.class:?] at kriNon.endernet.tileentities.TileEntityEnderTransmitter.readFromNBT(TileEntityEnderTransmitter.java:248) ~[TileEntityEnderTransmitter.class:?] at net.minecraft.tileentity.TileEntity.create(TileEntity.java:137) [TileEntity.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:515) [AnvilChunkLoader.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:96) [ChunkIOProvider.class:?] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) [ChunkIOExecutor.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:121) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:92) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:138) [ChunkProviderServer.class:?] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) [integratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91] [11:53:00] [server thread/ERROR] [FML]: A TileEntity ender_transmitter(kriNon.endernet.tileentities.TileEntityEnderTransmitter) has thrown an exception during loading, its state cannot be restored. Report this to the mod author java.lang.NullPointerException at kriNon.endernet.lib.EnderRegistry.set(EnderRegistry.java:73) ~[EnderRegistry.class:?] at kriNon.endernet.tileentities.TileEntityEnderTransmitter.readFromNBT(TileEntityEnderTransmitter.java:248) ~[TileEntityEnderTransmitter.class:?] at net.minecraft.tileentity.TileEntity.create(TileEntity.java:137) [TileEntity.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:515) [AnvilChunkLoader.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:96) [ChunkIOProvider.class:?] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) [ChunkIOExecutor.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:121) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:92) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:138) [ChunkProviderServer.class:?] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) [integratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
  13. r.updateAddresses(); which calls: public void updateAddresses() { if(addresses.contains(maxAddress)) { // New address added, look up while(addresses.contains(maxAddress)) maxAddress++; } else { // Old address removed, look down while(!addresses.contains(maxAddress)) maxAddress--; maxAddress++; } }
  14. Yes When I try that I get this error: http://pastebin.com/fyUJSmW3
  15. Sorry, do you mean that I should be using FMLServerAboutToStartEvent instead of FMLServerStartingEvent in my main class?
×
×
  • Create New...

Important Information

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