Lambda
Members-
Posts
486 -
Joined
-
Last visited
Everything posted by Lambda
-
Hey there, so I'm trying to find a way to detect 2 quartz blocks and a gold block on top, on each side.. However, I don't know how to get started. I could do EnumFacing.Horizontals , however finding the two blocks above the block that is detected by the forloop is where I'm stuck.. What would be the best way for the TE to detect if there is a 3 high structure (with the top of them being gold blocks) on each side.
-
Okay, so great progress, however, I'm trying to setup a 'default value' of the energy inside the chunk, however, I'm having a hard time doing so, I've tried making another IVoidStorage and VoidStorage classes that closely replicates the Energy ones, but in the constructor have the energy set to the capacity.. However, when doing this it seems the chunks return null when looking for the energy attached to it.. Maybe there is another way than creating another energy handler? Thanks.
-
Okay Thanks!
-
Hey there! So I'm having a bit of an issue with my IDE, it seems like a lot of lambda / diamond expressions are not allowed.. I've tried changing my project settings to match said language level, but it doesn't seem to solve anything... Thanks!
-
Thanks Animefan and Choonster! Its late, so I'm gonna go to bed and then study the code when I wake.. I'll maybe even post about explaining the code, to see if I get all parts correct. Happy New Year Everybody!
-
How can I access the map without accessing the capability?
-
Then how do you recommend I fix it?
-
@SubscribeEvent public void onChuckLoadEvent(ChunkDataEvent.Load event) { if(event.getWorld().hasCapability(CapabilityVoidEnergy.VOID, null)) { CapabilityVoidEnergyData cap = event.getWorld().getCapability(CapabilityVoidEnergy.VOID, null); cap.chunkData.put(event.getChunk().getPos(), cap.getVoidEnergyStored(event.getChunk().getPos())); } }
-
No, seems I get a nullpointer there: ---- Minecraft Crash Report ---- // Who set us up the TNT? Time: 12/31/16 4:23 PM Description: Exception in server tick loop java.lang.NullPointerException: Exception in server tick loop at com.lambda.plentifulutilities.world.CapabilityVoidEnergyData.getVoidEnergyStored(CapabilityVoidEnergyData.java:76) at com.lambda.plentifulutilities.event.CommonSideEvents.onChuckLoadEvent(CommonSideEvents.java:40) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_CommonSideEvents_onChuckLoadEvent_Load.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:98) at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:125) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:96) at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:142) at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:340) at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) at net.minecraft.server.integrated.IntegratedServer.init(IntegratedServer.java:124) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:507) at java.lang.Thread.run(Thread.java:745) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_91, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1303337144 bytes (1242 MB) / 1724383232 bytes (1644 MB) up to 3814195200 bytes (3637 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.38 Powered by Forge 13.20.0.2201 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.0.2201.jar) UCHIJAA forge{13.20.0.2201} [Minecraft Forge] (forgeSrc-1.11.2-13.20.0.2201.jar) UCHIJAA plentifulutilities{${version}} [Plentiful Utilities] (PlentifulUtilities_main) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' at @Override public int getVoidEnergyStored(ChunkPos pos) { return chunkData.get(pos); } Here is the entire class converted, I dont know if it will work public class CapabilityVoidEnergyData implements IVoidStorage { protected int capacity; protected int regen; public Map<ChunkPos, Integer> chunkData = new HashMap<ChunkPos, Integer>(); public CapabilityVoidEnergyData(int capacity, int regen) { this.capacity = capacity; this.regen = regen; } @Override public int receiveVoidEnergy(int receive, ChunkPos pos) { if(canReceiveVoidEnergy(receive, pos)) { this.setVoidStorage(this.getVoidEnergyStored(pos) + receive, pos); return this.getMaxVoidEnergyStored() + receive; }else { return 0; } } @Override public int extractVoidEnergy(int extract, ChunkPos pos) { if(canExtractVoidEnergy(extract, pos)) { this.setVoidStorage(this.getVoidEnergyStored(pos) - extract, pos); return this.getMaxVoidEnergyStored() - extract; }else { return 0; } } public boolean canExtractVoidEnergy(float amount, ChunkPos pos) { if((this.getVoidEnergyStored(pos) - amount) >= 0) { return true; }else { return false; } } public boolean canReceiveVoidEnergy(float amount, ChunkPos pos) { if((this.getVoidEnergyStored(pos) + amount) <= this.getMaxVoidEnergyStored()) { return true; }else { return false; } } public NBTBase writeData() { NBTTagCompound tag = new NBTTagCompound(); return tag; } public void readData(NBTBase nbt) { } @Override public int getVoidEnergyStored(ChunkPos pos) { return chunkData.get(pos); } @Override public int getMaxVoidEnergyStored() { return capacity; } public void setVoidStorage(int amount, ChunkPos pos) { chunkData.put(pos, amount); } @Override public boolean canExtract() { return false; } @Override public boolean canReceive() { return false; } }
-
Havent fired up the client yet, but IDE no.
-
So this: @Override public int getVoidEnergyStored(ChunkPos pos) { return chunkData.get(pos); }
-
You will be getting an Integer. Yes I know that, but what would I put into the get method ( What obj ) A ChunkPos(your key). Did you read that link I sent you? Yes but I dont have access to a chunkPos.. Should include that in the parameters?
-
No, for several reasons. For one, the return of this.getPos() is a ChunkPos, you don't need to construct a new ChunkPos with it. Second, the return of cap.chunkData.get() is your value, which cannot be used as the key to put new data in. cap.chunkData.put(this.getPos(), /*new value*/); If you want to modify the value (not replace it), then cap.chunkData.put(this.getPos(), cap.chunkData.get(this.getPos()) + /*some modifier*/); Thanks for your detailed repose, however this.getPos() is a BlockPos not a ChuckPos, so I'll need to do construct it (this is inside a TE). You will be getting an Integer. Yes I know that, but what would I put into the get method ( What obj )
-
Yes I know, Thats the question, what should I be getting.
-
Okay for something like this: @Override public int getVoidEnergyStored() { return chunkData.get(); } What would I get?
-
Should I be accessing that map somewhere in my capability? Right now I have this: public class CapabilityVoidEnergyData implements IVoidStorage { protected int capacity; protected int voidStorage; protected int regen; public Map<ChunkPos, Integer> chunkData = new HashMap<ChunkPos, Integer>(); public CapabilityVoidEnergyData(int capacity, int voidStorage, int regen) { this.capacity = capacity; this.voidStorage = voidStorage; this.regen = regen; } @Override public void receiveVoidEnergy(int receive) { if(canReceiveVoidEnergy(receive)) { this.setVoidStorage(this.getVoidEnergyStored() + receive); } } @Override public void extractVoidEnergy(int extract) { if(canExtractVoidEnergy(extract)) { this.setVoidStorage(this.getVoidEnergyStored() - extract); } } public boolean canExtractVoidEnergy(float amount) { if((this.getVoidEnergyStored() - amount) >= 0) { return true; }else { return false; } } public boolean canReceiveVoidEnergy(float amount) { if((this.getVoidEnergyStored() + amount) <= this.getMaxVoidEnergyStored()) { return true; }else { return false; } } public NBTBase writeData() { NBTTagCompound tag = new NBTTagCompound(); return tag; } public void readData(NBTBase nbt) { } @Override public int getVoidEnergyStored() { return voidStorage; } @Override public int getMaxVoidEnergyStored() { return capacity; } public void setVoidStorage(int amount) { this.voidStorage = amount; } @Override public boolean canExtract() { return false; } @Override public boolean canReceive() { return false; } } And I'm not accessing the map value anywhere, should I just remove the 'voidenergy' integer, and just return the map value?
-
Okay, so why does modifying the values of the keys have to do with my 'energy'? I know I'm doing something wrong here: cap.chunkData.put(cap.chunkData.get(new ChunkPos(this.getPos()), /* new value */); Is this correct? If I'm getting this right, then when we assigned the map, ChuckPos is our key, which contains our x,y, and the integer part stores the x,y values? Correct?
-
Okay, thanks for that.. How would I get the energy value though... Yes it returns the value, however what would I do with said value?
-
What is the integer that it returns? the x/y value or the integer that I assigned in the Map?
-
Okay, how would I add / remove some 'energy' from a chunk, not all of them, current I have: cap.chunkData.get(new ChunkPos(this.getPos())); cap.receiveVoidEnergy(5); Which obviously doesn't work because I accessing all chunks with cap.receive... So how would I just do it for that chunk?
-
I see to be getting a NullPointer on: cap.chunkData.put(event.getChunk().getPos(), cap.getVoidEnergyStored()); with: ---- Minecraft Crash Report ---- // I'm sorry, Dave. Time: 12/31/16 12:31 PM Description: Exception in server tick loop java.lang.NullPointerException: Exception in server tick loop at com.lambda.plentifulutilities.event.CommonSideEvents.onChuckLoadEvent(CommonSideEvents.java:40) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_CommonSideEvents_onChuckLoadEvent_Load.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:98) at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:125) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:96) at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:142) at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:340) at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) at net.minecraft.server.integrated.IntegratedServer.init(IntegratedServer.java:124) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:507) at java.lang.Thread.run(Thread.java:745) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_91, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1293656720 bytes (1233 MB) / 1717567488 bytes (1638 MB) up to 3814195200 bytes (3637 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.38 Powered by Forge 13.20.0.2201 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.0.2201.jar) UCHIJAA forge{13.20.0.2201} [Minecraft Forge] (forgeSrc-1.11.2-13.20.0.2201.jar) UCHIJAA plentifulutilities{${version}} [Plentiful Utilities] (PlentifulUtilities_main) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Here is the method: @SubscribeEvent public void onChuckLoadEvent(ChunkDataEvent.Load event) { if(event.getWorld().hasCapability(CapabilityVoidEnergy.VOID, null)) { CapabilityVoidEnergyData cap = event.getWorld().getCapability(CapabilityVoidEnergy.VOID, null); cap.chunkData.put(event.getChunk().getPos(), cap.getVoidEnergyStored()); } }
-
I don't know if this is right.. but I gave it my best shot @SubscribeEvent public void onAddCapabilitiesWorld(AttachCapabilitiesEvent<World> w) { w.addCapability(CapabilityVoidEnergyProvider.KEY, new CapabilityVoidEnergyProvider()); } @SubscribeEvent public void onChuckLoadEvent(ChunkDataEvent.Load event) { if(event.getWorld().hasCapability(CapabilityVoidEnergy.VOID, null)) { CapabilityVoidEnergyData cap = event.getWorld().getCapability(CapabilityVoidEnergy.VOID, null); cap.chunkData.put(event.getChunk().getPos(), cap.getVoidEnergyStored()); } } @SubscribeEvent public void onChuckSaveEvent(ChunkDataEvent.Save event) { if(event.getWorld().hasCapability(CapabilityVoidEnergy.VOID, null)) { CapabilityVoidEnergyData cap = event.getWorld().getCapability(CapabilityVoidEnergy.VOID, null); NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("StartChunkX", event.getChunk().getPos().getXStart()); tag.setInteger("EndChunkX", event.getChunk().getPos().getXEnd()); tag.setInteger("StartChunkZ", event.getChunk().getPos().getZStart()); tag.setInteger("EndChunkZ", event.getChunk().getPos().getZEnd()); tag.setInteger("VoidStored", cap.getVoidEnergyStored()); cap.writeData(tag); } } @SubscribeEvent public void onChuckUnloadEvent(ChunkDataEvent.Unload event) { if(event.getWorld().hasCapability(CapabilityVoidEnergy.VOID, null)) { CapabilityVoidEnergyData cap = event.getWorld().getCapability(CapabilityVoidEnergy.VOID, null); cap.chunkData.remove(event.getChunk().getPos()); cap.chunkData.remove(cap.getVoidEnergyStored()); } }
-
Do I have to assign the map? Or does the ChuckPos include all loaded chunks?
-
Well, you know Deep Resonance? How radiation works with the chunks being assigned values? I kinda want that, but a energy value stored to each one.. So I think i need to assign the data to each chunk
-
So do chunks work like gird coords? 0,0 1,0 2,0 0,1? And how would I iterate though all of them to assign the capability to them? And can I expose the capability with World#getChunkFromBlockCoords(BlockPos) , So I could access it though a TE?