diff --git a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityFireDragon.java b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityFireDragon.java index c13b776..582ca90 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityFireDragon.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityFireDragon.java @@ -45,11 +45,7 @@ public class EntityFireDragon extends EntityDragonBase { public static final Identifier MALE_LOOT = Identifier.of(IceAndFire.MOD_ID, "entities/dragon/fire_dragon_male"); public static final Identifier SKELETON_LOOT = Identifier.of(IceAndFire.MOD_ID, "entities/dragon/fire_dragon_skeleton"); - public EntityFireDragon(World worldIn) { - this(IafEntities.FIRE_DRAGON.get(), worldIn); - } - - public EntityFireDragon(EntityType t, World worldIn) { + public EntityFireDragon(EntityType t, World worldIn) { super(t, worldIn, DragonType.FIRE, 1, 1 + IafCommonConfig.INSTANCE.dragon.attackDamage.getValue(), IafCommonConfig.INSTANCE.dragon.maxHealth.getValue() * 0.04, IafCommonConfig.INSTANCE.dragon.maxHealth.getValue(), 0.15F, 0.4F); this.setPathfindingPenalty(PathNodeType.DAMAGE_FIRE, 0.0F); this.setPathfindingPenalty(PathNodeType.LAVA, 8.0F); diff --git a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityIceDragon.java b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityIceDragon.java index 24b2003..74b4f2c 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityIceDragon.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityIceDragon.java @@ -46,11 +46,7 @@ public class EntityIceDragon extends EntityDragonBase { public static final Identifier MALE_LOOT = Identifier.of(IceAndFire.MOD_ID, "entities/dragon/ice_dragon_male"); public static final Identifier SKELETON_LOOT = Identifier.of(IceAndFire.MOD_ID, "entities/dragon/ice_dragon_skeleton"); - public EntityIceDragon(World worldIn) { - this(IafEntities.ICE_DRAGON.get(), worldIn); - } - - public EntityIceDragon(EntityType t, World worldIn) { + public EntityIceDragon(EntityType t, World worldIn) { super(t, worldIn, DragonType.ICE, 1, 1 + IafCommonConfig.INSTANCE.dragon.attackDamage.getValue(), IafCommonConfig.INSTANCE.dragon.maxHealth.getValue() * 0.04, IafCommonConfig.INSTANCE.dragon.maxHealth.getValue(), 0.15F, 0.4F); ANIMATION_SPEAK = Animation.create(20); ANIMATION_BITE = Animation.create(35); diff --git a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityLightningDragon.java b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityLightningDragon.java index bd983cf..79c7421 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityLightningDragon.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityLightningDragon.java @@ -49,11 +49,7 @@ public class EntityLightningDragon extends EntityDragonBase { private static final TrackedData LIGHTNING_TARGET_Y = DataTracker.registerData(EntityLightningDragon.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData LIGHTNING_TARGET_Z = DataTracker.registerData(EntityLightningDragon.class, TrackedDataHandlerRegistry.FLOAT); - public EntityLightningDragon(World worldIn) { - this(IafEntities.LIGHTNING_DRAGON.get(), worldIn); - } - - public EntityLightningDragon(EntityType t, World worldIn) { + public EntityLightningDragon(EntityType t, World worldIn) { super(t, worldIn, DragonType.LIGHTNING, 1, 1 + IafCommonConfig.INSTANCE.dragon.attackDamage.getValue(), IafCommonConfig.INSTANCE.dragon.maxHealth.getValue() * 0.04, IafCommonConfig.INSTANCE.dragon.maxHealth.getValue(), 0.15F, 0.4F); this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, 0.0F); this.setPathfindingPenalty(PathNodeType.LAVA, 8.0F); diff --git a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityMobSkull.java b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityMobSkull.java index 0787b49..6775d34 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityMobSkull.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/entity/EntityMobSkull.java @@ -24,7 +24,6 @@ import net.minecraft.world.World; public class EntityMobSkull extends AnimalEntity implements IBlacklistedFromStatues, IDeadMob { - private static final TrackedData SKULL_DIRECTION = DataTracker.registerData(EntityMobSkull.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData SKULL_ENUM = DataTracker.registerData(EntityMobSkull.class, TrackedDataHandlerRegistry.INTEGER); diff --git a/common/src/main/java/com/iafenvoy/iceandfire/entity/block/BlockEntityEggInIce.java b/common/src/main/java/com/iafenvoy/iceandfire/entity/block/BlockEntityEggInIce.java index 0d05326..0619b3d 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/entity/block/BlockEntityEggInIce.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/entity/block/BlockEntityEggInIce.java @@ -34,7 +34,8 @@ public static void tickEgg(World level, BlockPos pos, BlockState state, BlockEnt entityEggInIce.age++; if (entityEggInIce.age >= IafCommonConfig.INSTANCE.dragon.eggBornTime.getValue() && entityEggInIce.type != null && !entityEggInIce.spawned) if (!level.isClient) { - EntityIceDragon dragon = new EntityIceDragon(level); + EntityIceDragon dragon = IafEntities.ICE_DRAGON.get().create(level); + assert dragon != null; dragon.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5); dragon.setVariant(entityEggInIce.type.name()); dragon.setGender(ThreadLocalRandom.current().nextBoolean()); diff --git a/common/src/main/java/com/iafenvoy/iceandfire/registry/IafRenderers.java b/common/src/main/java/com/iafenvoy/iceandfire/registry/IafRenderers.java index 1730000..0937520 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/registry/IafRenderers.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/registry/IafRenderers.java @@ -15,7 +15,6 @@ import com.iafenvoy.iceandfire.render.model.animator.FireDragonTabulaModelAnimator; import com.iafenvoy.iceandfire.render.model.animator.IceDragonTabulaModelAnimator; import com.iafenvoy.iceandfire.render.model.animator.LightningTabulaDragonAnimator; -import com.iafenvoy.iceandfire.render.model.animator.SeaSerpentTabulaModelAnimator; import com.iafenvoy.uranus.client.model.util.TabulaModelHandlerHelper; import com.iafenvoy.uranus.client.render.DynamicItemRenderer; import com.iafenvoy.uranus.client.render.armor.IArmorRendererBase; @@ -39,14 +38,14 @@ public final class IafRenderers { public static final Identifier SEA_SERPENT = Identifier.of(IceAndFire.MOD_ID, "seaserpent/seaserpent_base"); public static void registerEntityRenderers() { - EntityRendererRegistry.register(IafEntities.FIRE_DRAGON, x -> new RenderDragonBase(x, TabulaModelHandlerHelper.getModel(FIRE_DRAGON, new MemorizeSupplier<>(FireDragonTabulaModelAnimator::new)), 0)); - EntityRendererRegistry.register(IafEntities.ICE_DRAGON, manager -> new RenderDragonBase(manager, TabulaModelHandlerHelper.getModel(ICE_DRAGON, new MemorizeSupplier<>(IceDragonTabulaModelAnimator::new)), 1)); + EntityRendererRegistry.register(IafEntities.FIRE_DRAGON, x -> new RenderDragonBase(x, TabulaModelHandlerHelper.getModel(FIRE_DRAGON, new MemorizeSupplier<>(FireDragonTabulaModelAnimator::new)))); + EntityRendererRegistry.register(IafEntities.ICE_DRAGON, manager -> new RenderDragonBase(manager, TabulaModelHandlerHelper.getModel(ICE_DRAGON, new MemorizeSupplier<>(IceDragonTabulaModelAnimator::new)))); EntityRendererRegistry.register(IafEntities.LIGHTNING_DRAGON, manager -> new RenderLightningDragon(manager, TabulaModelHandlerHelper.getModel(LIGHTNING_DRAGON, new MemorizeSupplier<>(LightningTabulaDragonAnimator::new)), 2)); EntityRendererRegistry.register(IafEntities.DRAGON_EGG, RenderDragonEgg::new); EntityRendererRegistry.register(IafEntities.DRAGON_ARROW, RenderDragonArrow::new); EntityRendererRegistry.register(IafEntities.DRAGON_SKULL, RenderDragonSkull::new); - EntityRendererRegistry.register(IafEntities.FIRE_DRAGON_CHARGE, manager -> new RenderDragonFireCharge(manager, true)); - EntityRendererRegistry.register(IafEntities.ICE_DRAGON_CHARGE, manager -> new RenderDragonFireCharge(manager, false)); + EntityRendererRegistry.register(IafEntities.FIRE_DRAGON_CHARGE, manager -> new RenderDragonCharge(manager, true)); + EntityRendererRegistry.register(IafEntities.ICE_DRAGON_CHARGE, manager -> new RenderDragonCharge(manager, false)); EntityRendererRegistry.register(IafEntities.LIGHTNING_DRAGON_CHARGE, RenderDragonLightningCharge::new); EntityRendererRegistry.register(IafEntities.HIPPOGRYPH_EGG, FlyingItemEntityRenderer::new); EntityRendererRegistry.register(IafEntities.HIPPOGRYPH, RenderHippogryph::new); @@ -73,13 +72,13 @@ public static void registerEntityRenderers() { EntityRendererRegistry.register(IafEntities.MYRMEX_SWARMER, manager -> new RenderMyrmexBase<>(manager, new ModelMyrmexRoyal(), 0.25F)); EntityRendererRegistry.register(IafEntities.AMPHITHERE, RenderAmphithere::new); EntityRendererRegistry.register(IafEntities.AMPHITHERE_ARROW, RenderAmphithereArrow::new); - EntityRendererRegistry.register(IafEntities.SEA_SERPENT, manager -> new RenderSeaSerpent(manager, TabulaModelHandlerHelper.getModel(SEA_SERPENT, SeaSerpentTabulaModelAnimator::new))); + EntityRendererRegistry.register(IafEntities.SEA_SERPENT, RenderSeaSerpent::new); EntityRendererRegistry.register(IafEntities.SEA_SERPENT_BUBBLES, RenderNothing::new); EntityRendererRegistry.register(IafEntities.SEA_SERPENT_ARROW, RenderSeaSerpentArrow::new); EntityRendererRegistry.register(IafEntities.CHAIN_TIE, RenderChainTie::new); EntityRendererRegistry.register(IafEntities.PIXIE_CHARGE, RenderNothing::new); EntityRendererRegistry.register(IafEntities.TIDE_TRIDENT, RenderTideTrident::new); - EntityRendererRegistry.register(IafEntities.MOB_SKULL, manager -> new RenderMobSkull(manager, TabulaModelHandlerHelper.getModel(SEA_SERPENT, SeaSerpentTabulaModelAnimator::new))); + EntityRendererRegistry.register(IafEntities.MOB_SKULL, RenderMobSkull::new); EntityRendererRegistry.register(IafEntities.DREAD_SCUTTLER, RenderDreadScuttler::new); EntityRendererRegistry.register(IafEntities.DREAD_GHOUL, RenderDreadGhoul::new); EntityRendererRegistry.register(IafEntities.DREAD_BEAST, RenderDreadBeast::new); diff --git a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonBase.java b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonBase.java index 51c708a..afbd310 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonBase.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonBase.java @@ -11,13 +11,13 @@ import net.minecraft.util.math.RotationAxis; public class RenderDragonBase extends MobEntityRenderer> { - public RenderDragonBase(EntityRendererFactory.Context context, TabulaModel model, int dragonType) { + public RenderDragonBase(EntityRendererFactory.Context context, TabulaModel model) { super(context, model, 0.15F); this.addFeature(new LayerDragonMaleOverlay(this)); this.addFeature(new LayerDragonEyes(this)); this.addFeature(new LayerDragonRider(this, false)); this.addFeature(new LayerDragonBanner(this)); - this.addFeature(new LayerDragonArmor(this, dragonType)); + this.addFeature(new LayerDragonArmor(this)); } @Override diff --git a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonFireCharge.java b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonCharge.java similarity index 90% rename from common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonFireCharge.java rename to common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonCharge.java index 085a08f..365d3c3 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonFireCharge.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderDragonCharge.java @@ -13,10 +13,10 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.RotationAxis; -public class RenderDragonFireCharge extends EntityRenderer { +public class RenderDragonCharge extends EntityRenderer { public final boolean isFire; - public RenderDragonFireCharge(EntityRendererFactory.Context context, boolean isFire) { + public RenderDragonCharge(EntityRendererFactory.Context context, boolean isFire) { super(context); this.isFire = isFire; } diff --git a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderLightningDragon.java b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderLightningDragon.java index 14cc7d8..f3eb522 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderLightningDragon.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderLightningDragon.java @@ -17,7 +17,7 @@ public class RenderLightningDragon extends RenderDragonBase { private final LightningRender lightningRender = new LightningRender(); public RenderLightningDragon(EntityRendererFactory.Context context, TabulaModel modelSupplier, int dragonType) { - super(context, modelSupplier, dragonType); + super(context, modelSupplier); } private static float getBoundedScale(float scale) { diff --git a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderMobSkull.java b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderMobSkull.java index 2d54770..15e9a17 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderMobSkull.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/RenderMobSkull.java @@ -4,9 +4,13 @@ import com.iafenvoy.iceandfire.IceAndFire; import com.iafenvoy.iceandfire.data.IafSkullType; import com.iafenvoy.iceandfire.entity.EntityMobSkull; +import com.iafenvoy.iceandfire.entity.EntitySeaSerpent; +import com.iafenvoy.iceandfire.registry.IafRenderers; import com.iafenvoy.iceandfire.render.model.*; +import com.iafenvoy.iceandfire.render.model.animator.SeaSerpentTabulaModelAnimator; import com.iafenvoy.uranus.client.model.TabulaModel; import com.iafenvoy.uranus.client.model.basic.BasicModelPart; +import com.iafenvoy.uranus.client.model.util.TabulaModelHandlerHelper; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; @@ -29,9 +33,9 @@ public class RenderMobSkull extends EntityRenderer { private final ModelTroll trollModel; private final ModelAmphithere amphithereModel; private final ModelHydraHead hydraModel; - private final TabulaModel seaSerpentModel; + private final TabulaModel seaSerpentModel; - public RenderMobSkull(EntityRendererFactory.Context context, TabulaModel seaSerpentModel) { + public RenderMobSkull(EntityRendererFactory.Context context) { super(context); this.hippogryphModel = new ModelHippogryph(); this.cyclopsModel = new ModelCyclops(); @@ -39,7 +43,7 @@ public RenderMobSkull(EntityRendererFactory.Context context, TabulaModel> { - public RenderSeaSerpent(EntityRendererFactory.Context context, AdvancedEntityModel model) { - super(context, model, 1.6F); + public RenderSeaSerpent(EntityRendererFactory.Context context) { + super(context, TabulaModelHandlerHelper.getModel(IafRenderers.SEA_SERPENT, SeaSerpentTabulaModelAnimator::new), 1.6F); this.features.add(new LayerSeaSerpentAncient(this)); } diff --git a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/layer/LayerDragonArmor.java b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/layer/LayerDragonArmor.java index 450b962..e697835 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/render/entity/layer/LayerDragonArmor.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/render/entity/layer/LayerDragonArmor.java @@ -20,7 +20,7 @@ public class LayerDragonArmor extends FeatureRenderer> { private static final List ARMOR_SLOTS = List.of(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET); - public LayerDragonArmor(MobEntityRenderer> renderIn, int type) { + public LayerDragonArmor(MobEntityRenderer> renderIn) { super(renderIn); } diff --git a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GorgonTempleStructure.java b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GorgonTempleStructure.java index 8b4d474..a3438f2 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GorgonTempleStructure.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GorgonTempleStructure.java @@ -21,14 +21,14 @@ public class GorgonTempleStructure extends IafJigsawStructure { public static final Codec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(configCodecBuilder(instance), StructurePool.REGISTRY_CODEC.fieldOf("start_pool").forGetter(structure -> structure.startPool), - Identifier.CODEC.optionalFieldOf("start_jigsaw_name", null).forGetter(structure -> structure.startJigsawName), + Identifier.CODEC.optionalFieldOf("start_jigsaw_name").forGetter(structure -> structure.startJigsawName), Codec.intRange(0, 30).fieldOf("size").forGetter(structure -> structure.size), HeightProvider.CODEC.fieldOf("start_height").forGetter(structure -> structure.startHeight), - Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap", null).forGetter(structure -> structure.projectStartToHeightmap), + Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap").forGetter(structure -> structure.projectStartToHeightmap), Codec.intRange(1, 128).fieldOf("max_distance_from_center").forGetter(structure -> structure.maxDistanceFromCenter) ).apply(instance, GorgonTempleStructure::new)).codec(); - public GorgonTempleStructure(Config config, RegistryEntry startPool, Identifier startJigsawName, int size, HeightProvider startHeight, Heightmap.Type projectStartToHeightmap, int maxDistanceFromCenter) { + public GorgonTempleStructure(Config config, RegistryEntry startPool, Optional startJigsawName, int size, HeightProvider startHeight, Optional projectStartToHeightmap, int maxDistanceFromCenter) { super(config, startPool, startJigsawName, size, startHeight, projectStartToHeightmap, maxDistanceFromCenter); } @@ -41,11 +41,11 @@ protected Optional getStructurePosition(Context pContext) { return StructurePoolBasedGenerator.generate( pContext, // Used for JigsawPlacement to get all the proper behaviors done. this.startPool, // The starting pool to use to create the structure layout from - Optional.ofNullable(this.startJigsawName), // Can be used to only spawn from one Jigsaw block. But we don't need to worry about this. + this.startJigsawName, // Can be used to only spawn from one Jigsaw block. But we don't need to worry about this. this.size, // How deep a branch of pieces can go away from center piece. (5 means branches cannot be longer than 5 pieces from center piece) blockpos, // Where to spawn the structure. false, // "useExpansionHack" This is for legacy villages to generate properly. You should keep this false always. - Optional.ofNullable(this.projectStartToHeightmap), // Adds the terrain height's y value to the passed in blockpos's y value. (This uses WORLD_SURFACE_WG heightmap which stops at top water too) + this.projectStartToHeightmap, // Adds the terrain height's y value to the passed in blockpos's y value. (This uses WORLD_SURFACE_WG heightmap which stops at top water too) // Here, blockpos's y value is 60 which means the structure spawn 60 blocks above terrain height. // Set this to false for structure to be place only at the passed in blockpos's Y value instead. // Definitely keep this false when placing structures in the nether as otherwise, heightmap placing will put the structure on the Bedrock roof. diff --git a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GraveyardStructure.java b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GraveyardStructure.java index 55265ca..9bef05e 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GraveyardStructure.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/GraveyardStructure.java @@ -19,14 +19,14 @@ public class GraveyardStructure extends IafJigsawStructure { public static final Codec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(GraveyardStructure.configCodecBuilder(instance), StructurePool.REGISTRY_CODEC.fieldOf("start_pool").forGetter(structure -> structure.startPool), - Identifier.CODEC.optionalFieldOf("start_jigsaw_name", null).forGetter(structure -> structure.startJigsawName), + Identifier.CODEC.optionalFieldOf("start_jigsaw_name").forGetter(structure -> structure.startJigsawName), Codec.intRange(0, 30).fieldOf("size").forGetter(structure -> structure.size), HeightProvider.CODEC.fieldOf("start_height").forGetter(structure -> structure.startHeight), - Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap", null).forGetter(structure -> structure.projectStartToHeightmap), + Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap").forGetter(structure -> structure.projectStartToHeightmap), Codec.intRange(1, 128).fieldOf("max_distance_from_center").forGetter(structure -> structure.maxDistanceFromCenter) ).apply(instance, GraveyardStructure::new)).codec(); - public GraveyardStructure(Config config, RegistryEntry startPool, Identifier startJigsawName, int size, HeightProvider startHeight, Heightmap.Type projectStartToHeightmap, int maxDistanceFromCenter) { + public GraveyardStructure(Config config, RegistryEntry startPool, Optional startJigsawName, int size, HeightProvider startHeight, Optional projectStartToHeightmap, int maxDistanceFromCenter) { super(config, startPool, startJigsawName, size, startHeight, projectStartToHeightmap, maxDistanceFromCenter); } @@ -38,11 +38,11 @@ protected Optional getStructurePosition(Context pContext) { return StructurePoolBasedGenerator.generate( pContext, // Used for JigsawPlacement to get all the proper behaviors done. this.startPool, // The starting pool to use to create the structure layout from - Optional.ofNullable(this.startJigsawName), // Can be used to only spawn from one Jigsaw block. But we don't need to worry about this. + this.startJigsawName, // Can be used to only spawn from one Jigsaw block. But we don't need to worry about this. this.size, // How deep a branch of pieces can go away from center piece. (5 means branches cannot be longer than 5 pieces from center piece) blockpos, // Where to spawn the structure. false, // "useExpansionHack" This is for legacy villages to generate properly. You should keep this false always. - Optional.ofNullable(this.projectStartToHeightmap), // Adds the terrain height's y value to the passed in blockpos's y value. (This uses WORLD_SURFACE_WG heightmap which stops at top water too) + this.projectStartToHeightmap, // Adds the terrain height's y value to the passed in blockpos's y value. (This uses WORLD_SURFACE_WG heightmap which stops at top water too) // Here, blockpos's y value is 60 which means the structure spawn 60 blocks above terrain height. // Set this to false for structure to be place only at the passed in blockpos's Y value instead. // Definitely keep this false when placing structures in the nether as otherwise, heightmap placing will put the structure on the Bedrock roof. diff --git a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/IafJigsawStructure.java b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/IafJigsawStructure.java index 2f11238..6d57fea 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/IafJigsawStructure.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/IafJigsawStructure.java @@ -6,19 +6,18 @@ import net.minecraft.world.Heightmap; import net.minecraft.world.gen.heightprovider.HeightProvider; import net.minecraft.world.gen.structure.Structure; -import org.jetbrains.annotations.Nullable; + +import java.util.Optional; public abstract class IafJigsawStructure extends Structure { protected final RegistryEntry startPool; - @Nullable - protected final Identifier startJigsawName; + protected final Optional startJigsawName; protected final int size; protected final HeightProvider startHeight; - @Nullable - protected final Heightmap.Type projectStartToHeightmap; + protected final Optional projectStartToHeightmap; protected final int maxDistanceFromCenter; - public IafJigsawStructure(Config config, RegistryEntry startPool, @Nullable Identifier startJigsawName, int size, HeightProvider startHeight, Heightmap.@Nullable Type projectStartToHeightmap, int maxDistanceFromCenter) { + public IafJigsawStructure(Config config, RegistryEntry startPool, Optional startJigsawName, int size, HeightProvider startHeight, Optional projectStartToHeightmap, int maxDistanceFromCenter) { super(config); this.startPool = startPool; this.startJigsawName = startJigsawName; diff --git a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/MausoleumStructure.java b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/MausoleumStructure.java index 70ea18c..338c843 100644 --- a/common/src/main/java/com/iafenvoy/iceandfire/world/structure/MausoleumStructure.java +++ b/common/src/main/java/com/iafenvoy/iceandfire/world/structure/MausoleumStructure.java @@ -21,14 +21,14 @@ public class MausoleumStructure extends IafJigsawStructure { public static final Codec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(configCodecBuilder(instance), StructurePool.REGISTRY_CODEC.fieldOf("start_pool").forGetter(structure -> structure.startPool), - Identifier.CODEC.optionalFieldOf("start_jigsaw_name", null).forGetter(structure -> structure.startJigsawName), + Identifier.CODEC.optionalFieldOf("start_jigsaw_name").forGetter(structure -> structure.startJigsawName), Codec.intRange(0, 30).fieldOf("size").forGetter(structure -> structure.size), HeightProvider.CODEC.fieldOf("start_height").forGetter(structure -> structure.startHeight), - Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap", null).forGetter(structure -> structure.projectStartToHeightmap), + Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap").forGetter(structure -> structure.projectStartToHeightmap), Codec.intRange(1, 128).fieldOf("max_distance_from_center").forGetter(structure -> structure.maxDistanceFromCenter) ).apply(instance, MausoleumStructure::new)).codec(); - public MausoleumStructure(Config config, RegistryEntry startPool, Identifier startJigsawName, int size, HeightProvider startHeight, Heightmap.Type projectStartToHeightmap, int maxDistanceFromCenter) { + public MausoleumStructure(Config config, RegistryEntry startPool, Optional startJigsawName, int size, HeightProvider startHeight, Optional projectStartToHeightmap, int maxDistanceFromCenter) { super(config, startPool, startJigsawName, size, startHeight, projectStartToHeightmap, maxDistanceFromCenter); } @@ -42,11 +42,11 @@ protected Optional getStructurePosition(Context pContext) { return StructurePoolBasedGenerator.generate( pContext, // Used for JigsawPlacement to get all the proper behaviors done. this.startPool, // The starting pool to use to create the structure layout from - Optional.ofNullable(this.startJigsawName), // Can be used to only spawn from one Jigsaw block. But we don't need to worry about this. + this.startJigsawName, // Can be used to only spawn from one Jigsaw block. But we don't need to worry about this. this.size, // How deep a branch of pieces can go away from center piece. (5 means branches cannot be longer than 5 pieces from center piece) blockpos, // Where to spawn the structure. false, // "useExpansionHack" This is for legacy villages to generate properly. You should keep this false always. - Optional.ofNullable(this.projectStartToHeightmap), // Adds the terrain height's y value to the passed in blockpos's y value. (This uses WORLD_SURFACE_WG heightmap which stops at top water too) + this.projectStartToHeightmap, // Adds the terrain height's y value to the passed in blockpos's y value. (This uses WORLD_SURFACE_WG heightmap which stops at top water too) // Here, blockpos's y value is 60 which means the structure spawn 60 blocks above terrain height. // Set this to false for structure to be place only at the passed in blockpos's Y value instead. // Definitely keep this false when placing structures in the nether as otherwise, heightmap placing will put the structure on the Bedrock roof. diff --git a/gradle.properties b/gradle.properties index 0a1ae5b..e8ff5e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true # Mod properties -mod_version = 0.8.4 +mod_version = 0.8.5 maven_group = com.iafenvoy.iceandfire archives_name = IceAndFireCE enabled_platforms = fabric,forge