Skip to content

Commit

Permalink
fixed spawner processor replacing
Browse files Browse the repository at this point in the history
  • Loading branch information
TelepathicGrunt committed Jul 23, 2022
1 parent 25ea176 commit 2a22a52
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### **(V.6.1.4 Changes) (1.19.0 Minecraft)**

#### RS Spawners:
Fixed bug where removing all mobs for an RS Spawner will cause air pockets to spawn in place of the spawner in
Ocean Mineshafts and Ocean Dungeons. Also causes Pig Spawners to spawn in End Dungeons.
Now, removing all mobs will remove the spawner block properly without placing air pockets or Pig Spawners
for Ocean Mineshafts, Ocean Dungeons, and End Dungeons.

#### Mod Compat:
Added some William Wythers' Overhauled Overworld biomes to RS's biome tags to improve compat.
Also, update to v3.0.3 or newer William Wythers' Overhauled Overworld have maximum compat with RS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,6 @@ private boolean isValidNonSolidBlock(NbtDungeonConfig config, BlockState state)
return state.isAir();
}

/**
* Makes the given block entity now have the correct spawner mob
*/
private void SetMobSpawnerEntity(RandomSource random, NbtDungeonConfig config, SpawnerBlockEntity blockEntity) {
EntityType<?> entity = RepurposedStructures.mobSpawnerManager.getSpawnerMob(config.rsSpawnerResourcelocation, random);
if(entity != null) {
blockEntity.getSpawner().setEntityId(entity);
}
else{
RepurposedStructures.LOGGER.warn("EntityType in a dungeon does not exist in registry! : {}", config.rsSpawnerResourcelocation);
}
}

/**
* Makes the targeted slab block now a full block.
*/
Expand Down Expand Up @@ -311,13 +298,16 @@ else if(GeneralUtils.isFullCube(world, mutable, neighboringState) && !(neighbori
RandomizableContainerBlockEntity.setLootTable(world, random, mutable, config.chestResourcelocation);
mutable.move(Direction.DOWN);
if(lootBlock.getBlock() == Blocks.SHULKER_BOX && world.getBlockEntity(mutable) == null) {
world.setBlock(mutable, Blocks.SPAWNER.defaultBlockState(), 2);
BlockEntity blockEntity = world.getBlockEntity(mutable);
if (blockEntity instanceof SpawnerBlockEntity) {
SetMobSpawnerEntity(random, config, (SpawnerBlockEntity) blockEntity);
EntityType<?> entity = RepurposedStructures.mobSpawnerManager.getSpawnerMob(config.rsSpawnerResourcelocation, random);
if (entity != null) {
world.setBlock(mutable, Blocks.SPAWNER.defaultBlockState(), 2);
BlockEntity blockEntity = world.getBlockEntity(mutable);
if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity) {
spawnerBlockEntity.getSpawner().setEntityId(entity);
}
}
}
else{
else {
SolidifyBlock(world, mutable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SpawnerBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.LegacyRandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
Expand All @@ -36,7 +37,8 @@ public class SpawnerRandomizingProcessor extends StructureProcessor {
Codec.intRange(0, Integer.MAX_VALUE).fieldOf("min_spawn_delay").orElse(200).forGetter(spawnerRandomizingProcessor -> spawnerRandomizingProcessor.minSpawnDelay),
Codec.intRange(0, Integer.MAX_VALUE).fieldOf("required_player_range").orElse(16).forGetter(spawnerRandomizingProcessor -> spawnerRandomizingProcessor.requiredPlayerRange),
Codec.intRange(0, Integer.MAX_VALUE).fieldOf("spawn_count").orElse(4).forGetter(spawnerRandomizingProcessor -> spawnerRandomizingProcessor.spawnCount),
Codec.intRange(0, Integer.MAX_VALUE).fieldOf("spawn_range").orElse(4).forGetter(spawnerRandomizingProcessor -> spawnerRandomizingProcessor.spawnRange)
Codec.intRange(0, Integer.MAX_VALUE).fieldOf("spawn_range").orElse(4).forGetter(spawnerRandomizingProcessor -> spawnerRandomizingProcessor.spawnRange),
BlockState.CODEC.fieldOf("spawner_replacement_block").orElse(Blocks.AIR.defaultBlockState()).forGetter(spawnerRandomizingProcessor -> spawnerRandomizingProcessor.replacementState)
).apply(instance, instance.stable(SpawnerRandomizingProcessor::new)));

public final ResourceLocation rsSpawnerResourcelocation;
Expand All @@ -49,6 +51,7 @@ public class SpawnerRandomizingProcessor extends StructureProcessor {
public final int requiredPlayerRange;
public final int spawnCount;
public final int spawnRange;
public final BlockState replacementState;

private SpawnerRandomizingProcessor(ResourceLocation rsSpawnerResourcelocation,
Optional<InclusiveRange<Integer>> validBlockLightLevel,
Expand All @@ -59,7 +62,9 @@ private SpawnerRandomizingProcessor(ResourceLocation rsSpawnerResourcelocation,
int minSpawnDelay,
int requiredPlayerRange,
int spawnCount,
int spawnRange) {
int spawnRange,
BlockState replacementState)
{
this.rsSpawnerResourcelocation = rsSpawnerResourcelocation;
this.validBlockLightLevel = validBlockLightLevel;
this.validSkyLightLevel = validSkyLightLevel;
Expand All @@ -70,6 +75,7 @@ private SpawnerRandomizingProcessor(ResourceLocation rsSpawnerResourcelocation,
this.requiredPlayerRange = requiredPlayerRange;
this.spawnCount = spawnCount;
this.spawnRange = spawnRange;
this.replacementState = replacementState;
}

@Override
Expand All @@ -81,7 +87,7 @@ public StructureTemplate.StructureBlockInfo processBlock(LevelReader worldView,
CompoundTag spawnerNBT = SetMobSpawnerEntity(random, structureBlockInfoWorld.nbt);

if(spawnerNBT == null) {
return new StructureTemplate.StructureBlockInfo(worldPos, Blocks.AIR.defaultBlockState(), null);
return new StructureTemplate.StructureBlockInfo(worldPos, replacementState, null);
}
else {
return new StructureTemplate.StructureBlockInfo(worldPos, structureBlockInfoWorld.state, spawnerNBT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
},
{
"processor_type": "repurposed_structures:spawner_randomizing_processor",
"rs_spawner_resourcelocation": "repurposed_structures:dungeons/end"
"rs_spawner_resourcelocation": "repurposed_structures:dungeons/end",
"spawner_replacement_block": {
"Name": "minecraft:end_stone_bricks"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:snow_block"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
"valid_block_light_level": {
"min_inclusive": 0,
"max_inclusive": 7
},
"spawner_replacement_block": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
}
},
{
Expand Down

0 comments on commit 2a22a52

Please sign in to comment.