Jump to content

Liahim

Members
  • Posts

    36
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    S-Pb
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Liahim's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. In order not to receive the LayerLightEventListener 256 times, but to receive it only once. Could you point me to where the light data is being retrieved? Perhaps I can somehow intercept this packet or add a mixin call to it. I really need to know this exactly at the time of loading the chunk, since I am making a lightmap. Maybe I should ask the forge team to add a special event for this? Or is it easier for me to add my own ticker for each chunk and retrieve data one tick after loading? 😄
  2. This is exactly what you said. If we look into the Level#getBrightness method, we can see the same thing. default int getBrightness(LightLayer type, BlockPos pos) { return this.getLightEngine().getLayerListener(type).getLightValue(pos); } For example: @SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.side == LogicalSide.CLIENT && event.phase == Phase.START ) { if (event.player.tickCount % 20 == 0) { Level world = event.player.level; LayerLightEventListener sky = world.getLightEngine().getLayerListener(LightLayer.SKY); BlockPos pos = new BlockPos(event.player.blockPosition()); MutableBlockPos mPos = BlockPos.ZERO.mutable(); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { int s = sky.getLightValue(mPos.set(pos).move(x, 0, z)); System.out.println(pos + "_" + s); } } } } } It doesn't matter where and how to do it. I see incorrect data only during the chunk load event. And this happens only at 1.18.x
  3. No, that doesn't work either. @SubscribeEvent public void onChunkLoaded(ChunkEvent.Load event) { if (event.getWorld().isClientSide()) { if (event.getWorld() instanceof Level) { Level world = (Level) event.getWorld(); LayerLightEventListener sky = world.getLightEngine().getLayerListener(LightLayer.SKY); BlockPos pos = new BlockPos(event.getChunk().getPos().getWorldPosition().above(70)); //Tried at different heights MutableBlockPos mPos = BlockPos.ZERO.mutable(); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { int s = sky.getLightValue(mPos.set(pos).move(x, 0, z)); System.out.println(pos + "_" + s); } } } } } Location? I've tried this in a lot of locations. It outputs either zero or 15 (obviously in empty chunk sections) to the console...
  4. I am trying to do this: @OnlyIn(Dist.CLIENT) @SubscribeEvent public void onChunkLoaded(ChunkEvent.Load event) { if (event.getWorld().isClientSide()) { if (event.getWorld() instanceof Level) { Level world = (Level) event.getWorld(); DataLayer sky = world.getLightEngine().getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(event.getChunk().getPos().x, 64 >> 4, event.getChunk().getPos().z)); if (sky != null) System.out.println(sky.get(8, 8, 8)); } } } But I get zero all the time. If I try to do this at any other time after loading the chunk, the result will be correct. In addition, everything worked correctly on version 1.17.x
  5. I fixed it! The point was that I worked with different instances of the cap in this place: public SimpleCapProvider(Capability<C> capa, NonNullSupplier<C> instance) { this.capa = capa; this.instance = instance.get(); this.capOptional = LazyOptional.of(instance); // <----------- } But this is correct: public SimpleCapProvider(Capability<C> capa, NonNullSupplier<C> instance) { this.capa = capa; this.instance = instance.get(); this.capOptional = LazyOptional.of(() -> this.instance); // <----------- }
  6. public class MistCapaHandler extends ItemStackHandler implements IMistCapaHandler { private Player player; private int pollution; private int toxic; public MistCapaHandler() {} // ... @Override public CompoundTag serializeNBT() { CompoundTag nbt = super.serializeNBT(); nbt.putInt("Pollution", this.pollution); nbt.putInt("Toxic", this.toxic); return nbt; } @Override public void deserializeNBT(CompoundTag nbt) { super.deserializeNBT(nbt); this.pollution = nbt.getInt("Pollution"); this.toxic = nbt.getInt("Toxic"); } // ... }
  7. Yes, indeed. You're right. But why can't I save the information? What am I doing wrong?
  8. But capa didn't save during restarting the game. All events are subscribed in my main class. As I wrote in this message All methods work fine and information is saved when I use event.addListener(provider.capOptional::invalidate); But I am getting NullPointerException when going from dimension to dimension when trying to get a cap on the EntityJoinWorldEvent.
  9. But how can I save information when restarting the game? I use this example: https://github.com/VazkiiMods/Botania/blob/0c1138252901ea646f6f97f9427f62ccd258e9d3/src/main/java/vazkii/botania/common/capability/SimpleCapProvider.java#L42 public class SimpleCapProvider<C extends INBTSerializable<CompoundTag>> implements ICapabilityProvider, INBTSerializable<CompoundTag> { private final C instance; private final LazyOptional<C> capOptional; private final Capability<C> capa; public SimpleCapProvider(Capability<C> capa, NonNullSupplier<C> instance) { this.capa = capa; this.instance = instance.get(); this.capOptional = LazyOptional.of(instance); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return capa.orEmpty(cap, capOptional); } @Override public CompoundTag serializeNBT() { return this.instance.serializeNBT(); } @Override public void deserializeNBT(CompoundTag nbt) { this.instance.deserializeNBT(nbt); } public static <C extends INBTSerializable<CompoundTag>> void attach(AttachCapabilitiesEvent<?> event, ResourceLocation key, Capability<C> cap, NonNullSupplier<C> capInstance) { SimpleCapProvider<C> provider = new SimpleCapProvider<>(cap, capInstance); event.addCapability(key, provider); //event.addListener(provider.capOptional::invalidate); //TODO Capa invalidate } } And this is my capa registration public class MistCaps { @CapabilityInject(IMistCapaHandler.class) public static Capability<IMistCapaHandler> CAPABILITY_MIST; @CapabilityInject(ISkillCapaHandler.class) public static Capability<ISkillCapaHandler> CAPABILITY_SKILL; @CapabilityInject(IFoodHandler.class) public static Capability<IFoodHandler> CAPABILITY_FOOD; private static final List<CapaEntry<? extends INBTSerializable<CompoundTag>>> capaList = Lists.newArrayList(); public static void init(RegisterCapabilitiesEvent event) { register(event, "player_capa", IMistCapaHandler.class, () -> CAPABILITY_MIST, MistCapaHandler::new); register(event, "skill_capa", ISkillCapaHandler.class, () -> CAPABILITY_SKILL, SkillCapaHandler::new); register(event, "food_capa", IFoodHandler.class, () -> CAPABILITY_FOOD, FoodCapaHandler::new); Mist.LOGGER.info("Misty caps has been registered!"); } //////////////////////////////////////////////////////// MAGIC //////////////////////////////////////////////////////// private static <C extends INBTSerializable<CompoundTag>> void register(RegisterCapabilitiesEvent event, String name, Class<C> clazz, NonNullSupplier<Capability<C>> capa, NonNullSupplier<C> instance) { event.register(clazz); capaList.add(new CapaEntry<C>(Mist.resLoc(name), capa, instance)); } @SubscribeEvent public void attachCapabilitiesPlayer(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof Player) capaList.forEach(entry -> attach(event, entry)); } @SubscribeEvent public void cloneCapabilitiesEvent(PlayerEvent.Clone event) { capaList.forEach(entry -> clone(event, entry)); } private static <C extends INBTSerializable<CompoundTag>> void attach(AttachCapabilitiesEvent<?> event, CapaEntry<C> entry) { SimpleCapProvider.attach(event, entry.res, entry.capa.get(), entry.instance); if (event.getCapabilities().get(entry.res) == null) { Mist.LOGGER.error("Player didn't attach [" + entry.capa.get().getName() + "] capa"); } else Mist.LOGGER.info("Player has attached [" + entry.capa.get().getName() + "] capa"); } private static <C extends INBTSerializable<CompoundTag>> void clone(PlayerEvent.Clone event, CapaEntry<C> entry) { try { //event.getOriginal().reviveCaps(); C original = event.getOriginal().getCapability(entry.capa.get()).orElseThrow(NullPointerException::new); CompoundTag nbt = original.serializeNBT(); C clone = event.getPlayer().getCapability(entry.capa.get()).orElseThrow(NullPointerException::new); clone.deserializeNBT(nbt); //event.getOriginal().invalidateCaps(); } catch (Exception e) { Mist.LOGGER.error("Could not clone capability [" + entry.capa.get().getName() + "] when player [" + event.getOriginal().getName() + "] changing dimensions"); } } private static class CapaEntry<C extends INBTSerializable<CompoundTag>> { private final ResourceLocation res; private final NonNullSupplier<C> instance; private final NonNullSupplier<Capability<C>> capa; public CapaEntry(ResourceLocation res, NonNullSupplier<Capability<C>> capa, NonNullSupplier<C> instance) { this.res = res; this.instance = instance; this.capa = capa; } } }
  10. The information is saved if I add listeners in AttachCapabilitiesEvent: event.addCapability(key, provider); event.addListener(provider.capOptional::invalidate); However, I get NullPointerException when going from dimension to dimension at this line in EntityJoinWorldEvent. player.getCapability(MistCaps.CAPABILITY_MIST).orElseThrow(() -> new NullPointerException("Player has no mist capability")); If I do not add listeners, then everything works fine when changing the dimension, but the information is not saved when I restart the game. Of course I have tried using reviveCaps(). No result.
  11. Hello! Tell me, did anyone find a solution to this problem? I have the same.
  12. Fixed! On version 1.16.5, before loading the image, you must reset the following parameters: GlStateManager._pixelStore(GL11.GL_UNPACK_SKIP_PIXELS, 0); GlStateManager._pixelStore(GL11.GL_UNPACK_SKIP_ROWS, 0);
  13. Hello! I am unable to load the texture from the IntBuffer. Sequencing: I create a texture with a certain size and write it to the IntBuffer. Then I load it into GL using the method: GL11.glTexSubImage2D() At certain points, the texture size changes... Then, I recreate the IntBuffer, re-bind the texture and load it again. static int offset; static int size; // offset changes at some point // after that I call prepareImage() public static void prepareImage() { size = (offset * 2 + 1) << 4; buf = BufferUtils.createIntBuffer(size * size); TextureUtil.prepareImage(textureId, size, size); ... // create a texture again and write to the buffer upload(0, 0, size, size); } private static void upload(int xOffset, int yOffset, int width, int height) { if (RenderSystem.isOnRenderThreadOrInit()) uploadImage(xOffset, yOffset, width, height); else RenderSystem.recordRenderCall(() -> uploadImage(xOffset, yOffset, width, height)); } private static void uploadImage(int xOffset, int yOffset, int width, int height) { bindTexture(); boolean offset = xOffset > 0 || yOffset > 0; if (offset) { setPosition(xOffset, yOffset); GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, size); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, GL11.GL_RGBA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buf); // crash here if (offset) { setPosition(0, 0); GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); } } private static void setPosition(int x, int y) { buf.position(y * size + x); } Crash doesn't always happen. Sometimes it works and sometimes it doesn't. Also, if I load only a part of the texture with an offset, the loaded piece eventually jumps and turns out to be in a different position each time. As if the parameter GL11.GL_UNPACK_ROW_LENGTH changes every time. A very strange message is displayed in the console: # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005f4749e0, pid=7740, tid=0x0000000000001c38 # # JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [nvoglv64.DLL+0xaf49e0] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # An error report file with more information is saved as: # E:\Mod\1.16.5\run\hs_err_pid7740.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # This is what is in this file: # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005f4749e0, pid=7740, tid=0x0000000000001c38 # # JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [nvoglv64.DLL+0xaf49e0] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # --------------- T H R E A D --------------- Current thread (0x00000000021ec000): JavaThread "Render thread" [_thread_in_native, id=7224, stack(0x0000000002440000,0x0000000002540000)] siginfo: ExceptionCode=0xc0000005, reading address 0x000000003d5b1000 Registers: RAX=0x000000003d5b1020, RBX=0x000000003d5b0c80, RCX=0x000000003d6cbd60, RDX=0x000000003d5b0c80 RSP=0x000000000253d0d8, RBP=0x0000000000000840, RSI=0x0000000000000000, RDI=0x000000003d6cb9c0 R8 =0x0000000000000013, R9 =0x0000000000000000, R10=0x0000000026a7ee94, R11=0x0000000000000002 R12=0x0000000000000000, R13=0x0000000000000000, R14=0x000000000253d330, R15=0x0000000000000000 RIP=0x000000005f4749e0, EFLAGS=0x0000000000010202 Top of Stack: (sp=0x000000000253d0d8) 0x000000000253d0d8: 000000005f474650 000000000000001e 0x000000000253d0e8: 0000000400000000 0000000000000000 0x000000000253d0f8: 0000021000000800 0000000000000001 0x000000000253d108: 000000005f0bbf00 000000003d6cb9c0 0x000000000253d118: 0000000000000210 000000003d5b0c80 0x000000000253d128: 000000005efc2b83 000000001c620000 0x000000000253d138: 0000000000000000 0000000000000000 0x000000000253d148: 000000005efc2953 000000005f48b040 0x000000000253d158: 0000000000000000 000000005efc2b00 0x000000000253d168: 000000005efcc6d4 00000000242f24d0 0x000000000253d178: 000000005ee45c22 000000000253d330 0x000000000253d188: 0000000000000009 000000005efcc680 0x000000000253d198: 000000001c620000 0000000000000001 0x000000000253d1a8: 000000005efcec7d 000000000253d330 0x000000000253d1b8: 0000000000000001 00000000241392e0 0x000000000253d1c8: 0000000000000004 0000005200000052 Instructions: (pc=0x000000005f4749e0) 0x000000005f4749c0: 11 49 c0 0f 11 41 d0 49 83 e8 01 75 d3 c3 4d 85 0x000000005f4749d0: c0 74 3a 48 83 c1 20 48 8d 42 20 0f 1f 44 00 00 0x000000005f4749e0: 0f 10 58 e0 48 8d 49 40 0f 10 50 f0 0f 10 08 0f 0x000000005f4749f0: 10 40 10 48 8d 40 40 0f 11 59 a0 0f 11 51 b0 0f Register to memory mapping: RAX=0x000000003d5b1020 is an unknown value RBX=0x000000003d5b0c80 is an unknown value RCX=0x000000003d6cbd60 is an unknown value RDX=0x000000003d5b0c80 is an unknown value RSP=0x000000000253d0d8 is pointing into the stack for thread: 0x00000000021ec000 RBP=0x0000000000000840 is an unknown value RSI=0x0000000000000000 is an unknown value RDI=0x000000003d6cb9c0 is an unknown value R8 =0x0000000000000013 is an unknown value R9 =0x0000000000000000 is an unknown value R10=0x0000000026a7ee94 is an unknown value R11=0x0000000000000002 is an unknown value R12=0x0000000000000000 is an unknown value R13=0x0000000000000000 is an unknown value R14=0x000000000253d330 is pointing into the stack for thread: 0x00000000021ec000 R15=0x0000000000000000 is an unknown value Stack: [0x0000000002440000,0x0000000002540000], sp=0x000000000253d0d8, free space=1012k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [nvoglv64.DLL+0xaf49e0] Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) J 12933 org.lwjgl.opengl.GL11C.nglTexSubImage2D(IIIIIIIIJ)V (0 bytes) @ 0x0000000003d749bc [0x0000000003d74940+0x7c] J 22607 C1 ru.liahim.mist.client.shader.FogTexture.uploadImage(IIII)V (99 bytes) @ 0x0000000003c5eb94 [0x0000000003c5e760+0x434] j ru.liahim.mist.client.shader.FogTexture.upload(IIII)V+10 j ru.liahim.mist.client.shader.FogTexture.createFogTexture(Lnet/minecraft/world/World;II)V+74 J 24664 C1 ru.liahim.mist.handlers.Fog.prepareFogParameters(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/util/math/vector/Matrix4f;F)V (435 bytes) @ 0x0000000005ff1404 [0x0000000005ff0860+0xba4] J 24343 C1 ru.liahim.mist.handlers.Fog.prepare(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/util/math/vector/Matrix4f;F)V (43 bytes) @ 0x0000000005c6c2bc [0x0000000005c6bba0+0x71c] J 24241 C2 net.minecraft.client.renderer.WorldRenderer.renderLevel(Lcom/mojang/blaze3d/matrix/MatrixStack;FJZLnet/minecraft/client/renderer/ActiveRenderInfo;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/util/math/vector/Matrix4f;)V (2872 bytes) @ 0x0000000006259f84 [0x0000000006259f20+0x64] J 24416 C1 net.minecraft.client.renderer.GameRenderer.renderLevel(FJLcom/mojang/blaze3d/matrix/MatrixStack;)V (614 bytes) @ 0x000000000630762c [0x0000000006302040+0x55ec] J 13341 C1 net.minecraft.client.renderer.GameRenderer.render(FJZ)V (856 bytes) @ 0x000000000495d52c [0x000000000495bfa0+0x158c] J 25014 C2 net.minecraft.client.Minecraft.runTick(Z)V (994 bytes) @ 0x000000000658c314 [0x000000000658aa60+0x18b4] j net.minecraft.client.Minecraft.run()V+68 j net.minecraft.client.main.Main.main([Ljava/lang/String;)V+1379 v ~StubRoutines::call_stub j sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 J 1863 C1 sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (10 bytes) @ 0x0000000002e25c0c [0x0000000002e25b00+0x10c] J 1862 C1 java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (62 bytes) @ 0x0000000002e26874 [0x0000000002e26480+0x3f4] j net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(Lcpw/mods/modlauncher/api/ITransformingClassLoader;[Ljava/lang/String;)Ljava/lang/Void;+65 j net.minecraftforge.userdev.FMLUserdevClientLaunchProvider$$Lambda$453.call()Ljava/lang/Object;+12 j cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch([Ljava/lang/String;Lcpw/mods/modlauncher/api/ITransformingClassLoader;)V+11 j cpw.mods.modlauncher.LaunchServiceHandler.launch(Ljava/lang/String;[Ljava/lang/String;Lcpw/mods/modlauncher/TransformingClassLoader;Lcpw/mods/modlauncher/LaunchPluginHandler;)V+57 j cpw.mods.modlauncher.LaunchServiceHandler.launch(Lcpw/mods/modlauncher/ArgumentHandler;Lcpw/mods/modlauncher/TransformingClassLoader;Lcpw/mods/modlauncher/LaunchPluginHandler;)V+19 j cpw.mods.modlauncher.Launcher.run([Ljava/lang/String;)V+116 j cpw.mods.modlauncher.Launcher.main([Ljava/lang/String;)V+37 j net.minecraftforge.userdev.LaunchTesting.main([Ljava/lang/String;)V+422 v ~StubRoutines::call_stub
  14. Hello! How can I get the seed from common world settings to set it to the custom Biome Provider and Chunk Generator during they initialization? Currently the seed comes from the codec and dimention.json. But I don't need stable seed. I need a random or seed from the world settings. Thanks for answer
×
×
  • Create New...

Important Information

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