From 92162949e8597cdaa5d30bf181c5effd8d05e23e Mon Sep 17 00:00:00 2001 From: rearth Date: Thu, 12 Dec 2024 21:25:14 +0100 Subject: [PATCH] Add spawner blacklist --- .../tags/block/mineable/pickaxe.json | 184 +++++++++--------- .../tags/entity_type/spawner_blacklist.json | 5 + .../arcane/SpawnerControllerBlockEntity.java | 9 + .../java/rearth/oritech/init/TagContent.java | 4 + docs/arcane/mob_spawning.mdx | 4 + .../fabricgen/OritechDataGenerator.java | 1 + .../fabricgen/datagen/EntityTagGenerator.java | 21 ++ 7 files changed, 136 insertions(+), 92 deletions(-) create mode 100644 common/src/main/generated/data/oritech/tags/entity_type/spawner_blacklist.json create mode 100644 fabricdatagen/src/main/java/rearth/oritech/fabricgen/datagen/EntityTagGenerator.java diff --git a/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json b/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json index 1fa1aee79..bd3cdffd8 100644 --- a/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json +++ b/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json @@ -1,112 +1,112 @@ { "values": [ - "oritech:biosteel_block", - "oritech:particle_collector_block", - "oritech:industrial_glass_block", - "oritech:machine_core_6", - "oritech:quarry_addon", - "oritech:machine_core_2", - "oritech:metal_beam_block", - "oritech:steam_engine_block", - "oritech:reactor_condenser", - "oritech:machine_hunter_addon", - "oritech:nickel_block", - "oritech:placer_block", - "oritech:machine_core_4", - "oritech:powered_furnace_block", - "oritech:nickel_plating_slab", - "oritech:biomass_block", - "oritech:reactor_double_rod", - "oritech:machine_capacitor_addon", - "oritech:machine_efficiency_addon", - "oritech:machine_plating_block", + "oritech:ceiling_light_hanging", "oritech:pump_block", - "oritech:machine_core_7", - "oritech:plastic_block", "oritech:machine_redstone_addon", - "oritech:foundry_block", - "oritech:pipe_booster_block", - "oritech:raw_nickel_block", - "oritech:reactor_energy_port", - "oritech:machine_plating_pressure_plate", - "oritech:duratium_block", - "oritech:drone_port_block", - "oritech:fertilizer_block", - "oritech:large_storage_block", - "oritech:accelerator_sensor", - "oritech:adamant_block", - "oritech:iron_plating_block", + "oritech:machine_core_3", + "oritech:item_filter_block", + "oritech:big_solar_panel_block", + "oritech:reactor_double_rod", + "oritech:machine_core_4", + "oritech:iron_plating_pressure_plate", "oritech:deep_drill_block", - "oritech:machine_acceptor_addon", - "oritech:enchanter_block", - "oritech:spawner_controller_block", - "oritech:fragment_forge_block", - "oritech:machine_fluid_addon", - "oritech:energy_pipe", - "oritech:machine_speed_addon", - "oritech:creative_storage_block", - "oritech:ceiling_light_hanging", - "oritech:machine_plating_stairs", - "oritech:accelerator_controller", - "oritech:machine_plating_slab", - "oritech:bio_generator_block", - "oritech:superconductor", - "oritech:machine_core_1", - "oritech:crop_filter_addon", - "oritech:machine_extender", - "oritech:reactor_absorber_port", - "oritech:reactor_fuel_port", "oritech:steel_block", + "oritech:tech_button", + "oritech:item_pipe", + "oritech:machine_inventory_proxy_addon", + "oritech:biosteel_block", + "oritech:machine_speed_addon", + "oritech:machine_frame_block", + "oritech:machine_core_5", + "oritech:ceiling_light", + "oritech:machine_plating_block", "oritech:raw_platinum_block", - "oritech:reactor_reflector", - "oritech:enchantment_catalyst_block", - "oritech:basic_generator_block", - "oritech:fluid_pipe", - "oritech:reactor_quad_rod", - "oritech:accelerator_ring", - "oritech:spawner_cage_block", - "oritech:fuel_generator_block", + "oritech:laser_arm_block", + "oritech:crop_filter_addon", + "oritech:reactor_heat_pipe", + "oritech:duratium_block", "oritech:platinum_block", - "oritech:machine_inventory_proxy_addon", - "oritech:reactor_wall", + "oritech:centrifuge_block", + "oritech:energite_block", + "oritech:fluxite_block", + "oritech:iron_plating_stairs", + "oritech:raw_nickel_block", "oritech:tech_door", - "oritech:destroyer_block", - "oritech:machine_core_3", - "oritech:reactor_rod", "oritech:silicon_block", - "oritech:accelerator_motor", - "oritech:nickel_plating_stairs", - "oritech:reactor_vent", - "oritech:tech_button", - "oritech:ceiling_light", - "oritech:item_filter_block", - "oritech:fluxite_block", - "oritech:atomic_forge_block", "oritech:machine_yield_addon", - "oritech:iron_plating_pressure_plate", - "oritech:big_solar_panel_block", - "oritech:reactor_heat_pipe", - "oritech:iron_plating_slab", - "oritech:iron_plating_stairs", - "oritech:pulverizer_block", - "oritech:centrifuge_block", - "oritech:electrum_block", + "oritech:fluid_pipe", + "oritech:reactor_quad_rod", + "oritech:enchantment_catalyst_block", + "oritech:reactor_energy_port", "oritech:nickel_plating_pressure_plate", - "oritech:tech_lever", + "oritech:pipe_booster_block", + "oritech:reactor_wall", + "oritech:capacitor_addon_extender", + "oritech:machine_core_2", + "oritech:treefeller_block", + "oritech:iron_plating_slab", + "oritech:large_storage_block", + "oritech:machine_plating_slab", + "oritech:machine_fluid_addon", + "oritech:accelerator_controller", + "oritech:particle_collector_block", + "oritech:reactor_absorber_port", + "oritech:machine_hunter_addon", "oritech:assembler_block", - "oritech:machine_frame_block", - "oritech:energite_block", + "oritech:powered_furnace_block", + "oritech:plastic_block", + "oritech:accelerator_sensor", + "oritech:electrum_block", + "oritech:destroyer_block", + "oritech:fuel_generator_block", + "oritech:biomass_block", + "oritech:bio_generator_block", + "oritech:placer_block", + "oritech:spawner_controller_block", + "oritech:iron_plating_block", + "oritech:nickel_plating_slab", + "oritech:fertilizer_block", "oritech:lava_generator_block", - "oritech:steam_boiler_addon", - "oritech:item_pipe", - "oritech:machine_core_5", - "oritech:reactor_controller", "oritech:charger_block", - "oritech:treefeller_block", - "oritech:capacitor_addon_extender", "oritech:nickel_plating_block", - "oritech:laser_arm_block", + "oritech:superconductor", + "oritech:creative_storage_block", + "oritech:steam_engine_block", + "oritech:enchanter_block", + "oritech:accelerator_motor", + "oritech:basic_generator_block", + "oritech:steam_boiler_addon", + "oritech:reactor_reflector", + "oritech:nickel_block", + "oritech:spawner_cage_block", "oritech:black_hole_block", + "oritech:nickel_plating_stairs", + "oritech:industrial_glass_block", + "oritech:quarry_addon", + "oritech:adamant_block", + "oritech:atomic_forge_block", + "oritech:machine_capacitor_addon", + "oritech:reactor_condenser", + "oritech:machine_core_7", + "oritech:machine_efficiency_addon", + "oritech:machine_plating_stairs", + "oritech:machine_acceptor_addon", + "oritech:reactor_vent", + "oritech:machine_extender", + "oritech:metal_beam_block", + "oritech:machine_core_1", + "oritech:reactor_controller", + "oritech:reactor_fuel_port", + "oritech:machine_plating_pressure_plate", + "oritech:accelerator_ring", + "oritech:energy_pipe", + "oritech:reactor_rod", + "oritech:fragment_forge_block", + "oritech:pulverizer_block", + "oritech:foundry_block", + "oritech:machine_core_6", + "oritech:drone_port_block", + "oritech:tech_lever", "oritech:energy_pipe_connection", "oritech:fluid_pipe_connection", "oritech:item_pipe_connection", diff --git a/common/src/main/generated/data/oritech/tags/entity_type/spawner_blacklist.json b/common/src/main/generated/data/oritech/tags/entity_type/spawner_blacklist.json new file mode 100644 index 000000000..50003ea6b --- /dev/null +++ b/common/src/main/generated/data/oritech/tags/entity_type/spawner_blacklist.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:ender_dragon" + ] +} \ No newline at end of file diff --git a/common/src/main/java/rearth/oritech/block/entity/arcane/SpawnerControllerBlockEntity.java b/common/src/main/java/rearth/oritech/block/entity/arcane/SpawnerControllerBlockEntity.java index 213752f6f..b51de81e4 100644 --- a/common/src/main/java/rearth/oritech/block/entity/arcane/SpawnerControllerBlockEntity.java +++ b/common/src/main/java/rearth/oritech/block/entity/arcane/SpawnerControllerBlockEntity.java @@ -22,6 +22,7 @@ import rearth.oritech.client.init.ParticleContent; import rearth.oritech.init.BlockContent; import rearth.oritech.init.BlockEntitiesContent; +import rearth.oritech.init.TagContent; import rearth.oritech.network.NetworkContent; public class SpawnerControllerBlockEntity extends BaseSoulCollectionEntity implements BlockEntityTicker { @@ -201,7 +202,15 @@ public void onEntitySteppedOn(Entity entity) { if (spawnedMob != null) return; if (entity instanceof MobEntity mobEntity) { + + if (mobEntity.getType().arch$holder().isIn(TagContent.SPAWNER_BLACKLIST)) { + Oritech.LOGGER.debug("Ignored blacklisted entity for spawner: " + mobEntity.getType().arch$registryName()); + return; + } + spawnedMob = mobEntity.getType(); + + networkDirty = true; maxSouls = getSoulCost((int) mobEntity.getMaxHealth()); diff --git a/common/src/main/java/rearth/oritech/init/TagContent.java b/common/src/main/java/rearth/oritech/init/TagContent.java index 4292dd20b..bfe96d47a 100644 --- a/common/src/main/java/rearth/oritech/init/TagContent.java +++ b/common/src/main/java/rearth/oritech/init/TagContent.java @@ -1,6 +1,7 @@ package rearth.oritech.init; import net.minecraft.block.Block; +import net.minecraft.entity.EntityType; import net.minecraft.item.Item; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; @@ -72,4 +73,7 @@ public class TagContent { public static final TagKey RAW_BLUE_DYE = TagKey.of(RegistryKeys.ITEM, Identifier.of("c", "raw_materials/dyes/blue")); public static final TagKey RAW_MAGENTA_DYE = TagKey.of(RegistryKeys.ITEM, Identifier.of("c", "raw_materials/dyes/magenta")); public static final TagKey RAW_PINK_DYE = TagKey.of(RegistryKeys.ITEM, Identifier.of("c", "raw_materials/dyes/pink")); + + // spawner blacklist + public static final TagKey> SPAWNER_BLACKLIST = TagKey.of(RegistryKeys.ENTITY_TYPE, Oritech.id("spawner_blacklist")); } diff --git a/docs/arcane/mob_spawning.mdx b/docs/arcane/mob_spawning.mdx index 035d5bb19..3c12e8ea2 100644 --- a/docs/arcane/mob_spawning.mdx +++ b/docs/arcane/mob_spawning.mdx @@ -15,3 +15,7 @@ Mobs will only spawn if an empty surface is available nearby. When a mob type is set (or when right-clicked if invalid), the spawner highlights the required size of the spawner cage below. You can also right-click the spawner to get information on the current operational state. + + + The spawner will not cage any mob types that match the "oritech:spawner_blacklist" tag. + \ No newline at end of file diff --git a/fabricdatagen/src/main/java/rearth/oritech/fabricgen/OritechDataGenerator.java b/fabricdatagen/src/main/java/rearth/oritech/fabricgen/OritechDataGenerator.java index 501792fac..f9bb35fa4 100644 --- a/fabricdatagen/src/main/java/rearth/oritech/fabricgen/OritechDataGenerator.java +++ b/fabricdatagen/src/main/java/rearth/oritech/fabricgen/OritechDataGenerator.java @@ -16,5 +16,6 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { pack.addProvider(ItemTagGenerator::new); pack.addProvider(RecipeGenerator::new); pack.addProvider(AdvancementGenerator::new); + pack.addProvider(EntityTagGenerator::new); } } diff --git a/fabricdatagen/src/main/java/rearth/oritech/fabricgen/datagen/EntityTagGenerator.java b/fabricdatagen/src/main/java/rearth/oritech/fabricgen/datagen/EntityTagGenerator.java new file mode 100644 index 000000000..4351b5cf0 --- /dev/null +++ b/fabricdatagen/src/main/java/rearth/oritech/fabricgen/datagen/EntityTagGenerator.java @@ -0,0 +1,21 @@ +package rearth.oritech.fabricgen.datagen; + +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.minecraft.entity.EntityType; +import net.minecraft.registry.RegistryWrapper; +import rearth.oritech.init.TagContent; + +import java.util.concurrent.CompletableFuture; + +public class EntityTagGenerator extends FabricTagProvider.EntityTypeTagProvider { + public EntityTagGenerator(FabricDataOutput output, CompletableFuture completableFuture) { + super(output, completableFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + getOrCreateTagBuilder(TagContent.SPAWNER_BLACKLIST) + .add(EntityType.ENDER_DRAGON); // this should never actually be loaded, but it's here as a failsafe + } +}