Roguelike Dungeons

Roguelike Dungeons

33M Downloads

[BUG] `head.set(editor, cursor)` no check return value, cause `ClassCastException`

CatEricka opened this issue · 0 comments

commented

Mod version:

https://github.com/Greymerk/minecraft-roguelike/releases/tag/v1.8.0

Crash report:

---- Minecraft Crash Report ----

WARNING: coremods are present:
  SpongeCoremod (spongeforge-1.12.2-2838-7.1.9.jar)
  LoadingPlugin (Bloodmoon-MC1.12.2-1.5.3.jar)
Contact their authors BEFORE contacting forge

// Why did you do that?

Time: 20-2-6 下午2:24
Description: Exception ticking world

java.lang.ClassCastException: net.minecraft.tileentity.TileEntityMobSpawner cannot be cast to net.minecraft.tileentity.TileEntityBed
	at greymerk.roguelike.worldgen.blocks.Bed.generate(Bed.java:24)
	at greymerk.roguelike.worldgen.blocks.Bed.generate(Bed.java:44)
	at greymerk.roguelike.dungeon.towers.HouseTower.decor(HouseTower.java:200)
	at greymerk.roguelike.dungeon.towers.HouseTower.generate(HouseTower.java:113)
	at greymerk.roguelike.dungeon.DungeonGenerator.tower(DungeonGenerator.java:132)
	at greymerk.roguelike.dungeon.DungeonGenerator.generate(DungeonGenerator.java:125)
	at greymerk.roguelike.dungeon.Dungeon.generate(Dungeon.java:128)
	at greymerk.roguelike.dungeon.Dungeon.generateNear(Dungeon.java:121)
	at greymerk.roguelike.dungeon.Dungeon.spawnInChunk(Dungeon.java:192)
	at greymerk.roguelike.DungeonGenerator.generate(DungeonGenerator.java:20)
	at net.minecraftforge.fml.common.registry.GameRegistry.redirect$zzd000$forgeImpl$startTimingOnGenerate(GameRegistry.java:574)
	at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:167)
	at net.minecraft.world.chunk.Chunk.func_186034_a(Chunk.java:1020)
	at net.minecraft.world.chunk.Chunk.func_186030_a(Chunk.java:999)
	at net.minecraft.world.gen.ChunkProviderServer.redirect$bap000$impl$populateChunkThroughSponge(ChunkProviderServer.java:2082)
	at net.minecraft.world.gen.ChunkProviderServer.func_186025_d(ChunkProviderServer.java:157)
	at net.minecraft.server.management.PlayerChunkMapEntry.redirect$bai000$forgeImpl$UpdateLoadedChunk(PlayerChunkMapEntry.java:1576)
	at net.minecraft.server.management.PlayerChunkMapEntry.func_187268_a(PlayerChunkMapEntry.java:126)
	at net.minecraft.server.management.PlayerChunkMap.func_72693_b(SourceFile:147)
	at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:227)
	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:756)
	at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397)
	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
	at java.lang.Thread.run(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
	at greymerk.roguelike.worldgen.blocks.Bed.generate(Bed.java:24)
	at greymerk.roguelike.worldgen.blocks.Bed.generate(Bed.java:44)
	at greymerk.roguelike.dungeon.towers.HouseTower.decor(HouseTower.java:200)
	at greymerk.roguelike.dungeon.towers.HouseTower.generate(HouseTower.java:113)
	at greymerk.roguelike.dungeon.DungeonGenerator.tower(DungeonGenerator.java:132)
	at greymerk.roguelike.dungeon.DungeonGenerator.generate(DungeonGenerator.java:125)
	at greymerk.roguelike.dungeon.Dungeon.generate(Dungeon.java:128)
	at greymerk.roguelike.dungeon.Dungeon.generateNear(Dungeon.java:121)
	at greymerk.roguelike.dungeon.Dungeon.spawnInChunk(Dungeon.java:192)
	at greymerk.roguelike.DungeonGenerator.generate(DungeonGenerator.java:20)
	at net.minecraftforge.fml.common.registry.GameRegistry.redirect$zzd000$forgeImpl$startTimingOnGenerate(GameRegistry.java:574)
	at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:167)
	at net.minecraft.world.chunk.Chunk.func_186034_a(Chunk.java:1020)
	at net.minecraft.world.chunk.Chunk.func_186030_a(Chunk.java:999)
	at net.minecraft.world.gen.ChunkProviderServer.redirect$bap000$impl$populateChunkThroughSponge(ChunkProviderServer.java:2082)
	at net.minecraft.world.gen.ChunkProviderServer.func_186025_d(ChunkProviderServer.java:157)
	at net.minecraft.server.management.PlayerChunkMapEntry.redirect$bai000$forgeImpl$UpdateLoadedChunk(PlayerChunkMapEntry.java:1576)
	at net.minecraft.server.management.PlayerChunkMapEntry.func_187268_a(PlayerChunkMapEntry.java:126)
	at net.minecraft.server.management.PlayerChunkMap.func_72693_b(SourceFile:147)
	at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:227)

-- Affected level --
Details:
	Level name: world
	All players: 1 total; [EntityPlayerMP['Player123'/363, l='world', x=728.27, y=70.00, z=2097.97]]
	Chunk stats: ServerChunkCache: 789 Drop: 0
	Level seed: -6575585099303275336
	Level generator: ID 00 - default, ver 1. Features enabled: true
	Level generator options: 
	Level spawn location: World: (72,81,290), Chunk: (at 8,5,2 in 4,18; contains blocks 64,0,288 to 79,255,303), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
	Level time: 8599338 game time, 8546578 day time
	Level dimension: 0
	Level storage version: 0x04ABD - Anvil
	Level weather: Rain time: 153819 (now: false), thunder time: 1324 (now: true)
	Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false

-- Sponge PhaseTracker --
Details:
	Phase Stack: /******************************************************************************************/
/*   - Phase: Generation{Terrain:TERRAIN_GENERATION}                                      */
/*     Context:                                                                           */
/*     - World: WorldServer{Name=world, DimensionId=0, DimensionType=minecraft:overworld} */
/*   - Phase: Generation{Terrain:TERRAIN_GENERATION}                                      */
/*     Context:                                                                           */
/*     - World: WorldServer{Name=world, DimensionId=0, DimensionType=minecraft:overworld} */
/******************************************************************************************/

Stacktrace:
	at net.minecraft.server.MinecraftServer.handler$zje000$onCrashReport(MinecraftServer.java:4718)
	at net.minecraft.server.MinecraftServer.func_71230_b(MinecraftServer.java:889)
	at net.minecraft.server.dedicated.DedicatedServer.func_71230_b(DedicatedServer.java:371)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:554)
	at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows Server 2016 (amd64) version 10.0
	Java Version: 1.8.0_144, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 204574368 bytes (195 MB) / 830423040 bytes (791 MB) up to 4277534720 bytes (4079 MB)
	JVM Flags: 3 total; -Xincgc -Xmx4096M -Xmx4096M
	IntCache: cache: 12, tcache: 94, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2847 26 mods loaded, 26 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	Mods:

	| State  | ID                | Version           | Source                                   | Signature                                |
	|:------ |:----------------- |:----------------- |:---------------------------------------- |:---------------------------------------- |
	| LCHIJA | minecraft         | 1.12.2            | minecraft.jar                            | None                                     |
	| LCHIJA | mcp               | 9.42              | minecraft.jar                            | None                                     |
	| LCHIJA | FML               | 8.0.99.99         | forge-1.12.2-14.23.5.2847-universal.jar  | None                                     |
	| LCHIJA | forge             | 14.23.5.2847      | forge-1.12.2-14.23.5.2847-universal.jar  | None                                     |
	| LCHIJA | spongeapi         | 7.1.0-ea50f0c2    | spongeforge-1.12.2-2838-7.1.9.jar        | None                                     |
	| LCHIJA | sponge            | 1.12.2-7.1.9      | spongeforge-1.12.2-2838-7.1.9.jar        | None                                     |
	| LCHIJA | spongeforge       | 1.12.2-2838-7.1.9 | spongeforge-1.12.2-2838-7.1.9.jar        | None                                     |
	| LCHIJA | baubles           | 1.5.2             | Baubles-1.12-1.5.2.jar                   | None                                     |
	| LCHIJA | bloodmoon         | 1.5.3             | Bloodmoon-MC1.12.2-1.5.3.jar             | d72e0dd57935b3e9476212aea0c0df352dd76291 |
	| LCHIJA | cqrepoured        | 1.4.0A            | ChocolateQuestRepoured-1.12.2-1.4.0A.jar | None                                     |
	| LCHIJA | configmod         | v1.0              | coroutil-1.12.1-1.2.36.jar               | None                                     |
	| LCHIJA | extendedrenderer  | v1.0              | coroutil-1.12.1-1.2.36.jar               | None                                     |
	| LCHIJA | coroutil          | 1.12.1-1.2.36     | coroutil-1.12.1-1.2.36.jar               | None                                     |
	| LCHIJA | dungeontactics    | DT-0.16.6         | DungeonTactics-1.12.2-0.16.6.jar         | None                                     |
	| LCHIJA | enhancedarmaments | 1.3.17            | enhancedarmaments-1.3.17.jar             | None                                     |
	| LCHIJA | gokistats         | 1.2.7             | gokiStats-1.2.7.jar                      | None                                     |
	| LCHIJA | infernalmobs      | 1.7.5             | InfernalMobs-1.12.2.jar                  | None                                     |
	| LCHIJA | jei               | 4.15.0.293        | jei_1.12.2-4.15.0.293.jar                | None                                     |
	| LCHIJA | roguelike         | 1.8.0             | RoguelikeDungeons-1.12.2-1.8.0.jar       | None                                     |
	| LCHIJA | ruins             | 17.2              | Ruins-1.12.2.jar                         | None                                     |
	| LCHIJA | sakura            | V0.0.8.2-MC1.12.2 | Sakura-V0.0.8.2-MC1.12.2.jar             | None                                     |
	| LCHIJA | zombieawareness   | 1.12.1-1.11.10    | zombieawareness1.11.10.jar                  | None                                     |


	Plugins:

	| State  | ID             | Version     | Source                                        | Signature |
	|:------ |:-------------- |:----------- |:--------------------------------------------- |:--------- |
	| LCHIJA | placeholderapi | 4.5.1       | PlaceholderAPI-4.5.1.jar                 | None      |
	| LCHIJA | nucleus        | 1.3.13-S7.0 | Nucleus-1.3.13-S7.0-MC1.12.2-cn-1.6.jar | None      |
	| LCHIJA | flexiblelogin  | 0.8         | FlexibleLogin-sponge4.X.jar                   | None      |
	| LCHIJA | luckperms      | 5.0.70      | LuckPerms-Sponge-5.0.70.jar                   | None      |

	Loaded coremods (and transformers): 
SpongeCoremod (spongeforge-1.12.2-2838-7.1.9.jar)
  org.spongepowered.common.launch.transformer.SpongeSuperclassTransformer
LoadingPlugin (Bloodmoon-MC1.12.2-1.5.3.jar)
  lumien.bloodmoon.asm.ClassTransformer
	Profiler Position: N/A (disabled)
	Player Count: 1 / 20; [EntityPlayerMP['Player123'/363, l='world', x=728.27, y=70.00, z=2097.97]]
	Is Modded: Definitely; Server brand changed to 'fml,forge,sponge'
	Type: Dedicated Server (map_server.txt)

Analysis

From file greymerk/roguelike/worldgen/blocks/Bed.java,

head.set(editor, cursor);
TileEntityBed bed = (TileEntityBed) editor.getTileEntity(cursor);

if head.set(editor, cursor) return false, for example, the coordinate pointed by cursor is Blocks.MOB_SPAWNER or somethings else:

private boolean setBlock(Coord pos, MetaBlock block, int flags, boolean fillAir, boolean replaceSolid){
MetaBlock currentBlock = getBlock(pos);
if(currentBlock.getBlock() == Blocks.CHEST) return false;
if(currentBlock.getBlock() == Blocks.TRAPPED_CHEST) return false;
if(currentBlock.getBlock() == Blocks.MOB_SPAWNER) return false;
//boolean isAir = world.isAirBlock(pos.getBlockPos());
boolean isAir = currentBlock.getBlock() == Blocks.AIR;
if(!fillAir && isAir) return false;
if(!replaceSolid && !isAir) return false;
try{
world.setBlockState(pos.getBlockPos(), block.getState(), flags);
} catch(NullPointerException npe){
//ignore it.
}
Block type = block.getBlock();
Integer count = stats.get(type);
if(count == null){
stats.put(type, 1);
} else {
stats.put(type, count + 1);
}
return true;
}

then return value of editor.getTileEntity(cursor) may not an instance of TileEntityBed, it will cause ClassCastException.