kyrptonaught / customportalapi

Developer Api for creating custom portals to any dimension
MIT License
63 stars 22 forks source link

Custom Portal Block not working properly for flat portals. #37

Closed frikinjay closed 3 years ago

frikinjay commented 3 years ago

Not sure if its been implemented properly yet for flat portals but when going into the portal for the first time it generates a weird portal on the other end and if you go through that portal the game crashes with this. (Using the most recent commit of both The Aether and CustomPortalAPI)

https://user-images.githubusercontent.com/88995340/140008934-49afb839-7b29-480b-b5f1-ad1f14a0605e.mp4



java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
    at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
    at net.kyrptonaught.customportalapi.portal.linking.PortalLinkingStorage.getDestination(PortalLinkingStorage.java:50)
    at net.kyrptonaught.customportalapi.util.CustomTeleporter.customTPTarget(CustomTeleporter.java:56)
    at net.kyrptonaught.customportalapi.util.CustomTeleporter.TPToDim(CustomTeleporter.java:39)
    at net.kyrptonaught.customportalapi.CustomPortalBlock.onEntityCollision(CustomPortalBlock.java:108)
    at net.minecraft.block.AbstractBlock$AbstractBlockState.onEntityCollision(AbstractBlock.java:926)
    at net.minecraft.entity.Entity.checkBlockCollision(Entity.java:1035)
    at net.minecraft.entity.Entity.tryCheckBlockCollision(Entity.java:739)
    at net.minecraft.entity.Entity.move(Entity.java:712)
    at net.minecraft.entity.LivingEntity.applyMovementInput(LivingEntity.java:2244)
    at net.minecraft.entity.LivingEntity.travel(LivingEntity.java:2189)
    at net.minecraft.entity.player.PlayerEntity.travel(PlayerEntity.java:1591)
    at net.minecraft.entity.LivingEntity.tickMovement(LivingEntity.java:2640)
    at net.minecraft.entity.player.PlayerEntity.tickMovement(PlayerEntity.java:559)
    at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2346)
    at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:274)
    at net.minecraft.server.network.ServerPlayerEntity.playerTick(ServerPlayerEntity.java:466)
    at net.minecraft.server.network.ServerPlayNetworkHandler.tick(ServerPlayNetworkHandler.java:212)
    at net.minecraft.network.ClientConnection.tick(ClientConnection.java:238)
    at net.minecraft.server.ServerNetworkIo.tick(ServerNetworkIo.java:183)
    at net.minecraft.server.MinecraftServer.tickWorlds(MinecraftServer.java:902)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:831)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:96)
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:697)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:270)
    at java.base/java.lang.Thread.run(Thread.java:831)
kyrptonaught commented 3 years ago

Well this is an odd one. Did you register another portal to the aether? Can you post the relevant code?

kyrptonaught commented 3 years ago

I think this is caused by custom portal block used by the aether. It has a hard link to the glowstone block as the frame. You'd have to create a new portal block or just use the default. I guess I never thought of having portal of different types linking to the same dim

frikinjay commented 3 years ago

Yeah i basically used Aether's portal block directly as the custom portal block. I think i might have a hint as well, it doesnt look like its hardcoded in the class where it extends CustomPortalBlock


CustomPortalBuilder.beginPortal()
                .customPortalBlock((AetherPortalBlock) BLUE_PORTAL)
                .frameBlock(Blocks.SHROOMLIGHT)
                .lightWithWater()
                .destDimID(new Identifier("the_aether:the_aether"))
                .tintColor(50,133,168)
                .flatPortal()
                .registerPortal();
kyrptonaught commented 3 years ago

See here https://github.com/devs-immortal/The-Aether/blob/00d3512cb0f8a95b027183a0a85466bb19015813/src/main/java/net/id/aether/blocks/AetherPortalBlock.java#L50

This is it hardcoded to always return a gowstone block as it's frame. his helps with performance. You can not supply a customPortalBlock to the builder and it will just use the default one. Which should work fine

frikinjay commented 3 years ago

I originally had the default one but I was hoping to use Aether's for the proximity sound triggers, particles, other effects etc. I might have to just recreate a class without the glowstone requirement and use that with the AetherBlocks BLUE_PORTAL

frikinjay commented 3 years ago

Seems to work fine without the override image

Do you want me to close the issue? This is intended right?

kyrptonaught commented 3 years ago

Yes, it technically is intended behavior. Just very odd when used like this

frikinjay commented 3 years ago

Ah i see no worries. Thanks for the help!