From e6e20831bcf04626690bd6168c36bf827cdf5561 Mon Sep 17 00:00:00 2001 From: LtxPgm Date: Fri, 27 Sep 2024 22:27:06 -0500 Subject: [PATCH] Adjusted spawning logic to use new tag. Tweaked specular PBR for crystals. --- .../changed/entity/ChangedEntity.java | 23 ++++++++++++++-- .../entity/beast/AbstractAquaticEntity.java | 26 ++++++++++++++---- .../entity/beast/AbstractCaveEntity.java | 2 ++ .../entity/beast/AbstractLatexShark.java | 18 ------------ .../changed/init/ChangedEntities.java | 3 +- .../blocks/beifeng_crystal_bottom_s.png | Bin 128 -> 141 bytes .../blocks/beifeng_crystal_small_s.png | Bin 144 -> 157 bytes .../textures/blocks/beifeng_crystal_top_s.png | Bin 129 -> 142 bytes .../textures/blocks/dark_dragon_crystal_s.png | Bin 159 -> 172 bytes .../textures/blocks/latex_crystal_s.png | Bin 138 -> 151 bytes 10 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/main/java/net/ltxprogrammer/changed/entity/ChangedEntity.java b/src/main/java/net/ltxprogrammer/changed/entity/ChangedEntity.java index 217c22792..d582f5392 100644 --- a/src/main/java/net/ltxprogrammer/changed/entity/ChangedEntity.java +++ b/src/main/java/net/ltxprogrammer/changed/entity/ChangedEntity.java @@ -25,6 +25,7 @@ import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.tags.BlockTags; import net.minecraft.util.Mth; import net.minecraft.world.Difficulty; import net.minecraft.world.InteractionHand; @@ -393,13 +394,31 @@ public static boolean isDarkEnoughToSpawn(ServerLevelAccessor world, BlockPos po } } + protected static boolean checkSpawnBlock(ServerLevelAccessor world, MobSpawnType reason, BlockPos pos) { + if (reason != MobSpawnType.NATURAL) + return true; + int index = 3; + do { + final BlockPos thisPos = pos; + BlockState state = world.getBlockState(thisPos); + pos = thisPos.below(); + if (state.is(ChangedTags.Blocks.LATEX_SPAWNABLE_ON)) + return true; + if (state.isAir() || !state.isCollisionShapeFullBlock(world, thisPos)) + continue; + return false; + } while (index-- > 0); + + return false; + } + public static boolean checkEntitySpawnRules(EntityType entityType, ServerLevelAccessor world, MobSpawnType reason, BlockPos pos, Random random) { - /*if (!isDarkEnoughToSpawn(world, pos, random)) - return false;*/ if (pos.getY() < world.getSeaLevel() - 10) return false; if (random.nextFloat() < 0.75f) return false; + if (!checkSpawnBlock(world, reason, pos)) + return false; return Monster.checkAnyLightMonsterSpawnRules(entityType, world, reason, pos, random); } diff --git a/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractAquaticEntity.java b/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractAquaticEntity.java index e02948b68..4ac52cd92 100644 --- a/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractAquaticEntity.java +++ b/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractAquaticEntity.java @@ -5,6 +5,7 @@ import net.ltxprogrammer.changed.entity.TransfurMode; import net.ltxprogrammer.changed.util.Color3; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; @@ -23,6 +24,8 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeMod; @@ -35,14 +38,27 @@ public abstract class AbstractAquaticEntity extends ChangedEntity implements Aqu protected final WaterBoundPathNavigation waterNavigation; protected final GroundPathNavigation groundNavigation; + private static boolean isDeepEnoughToSpawn(LevelAccessor p_32367_, BlockPos p_32368_) { + return p_32368_.getY() < p_32367_.getSeaLevel() - 5; + } + public static boolean checkEntitySpawnRules(EntityType entityType, ServerLevelAccessor world, MobSpawnType reason, BlockPos pos, Random random) { - /*if (!isDarkEnoughToSpawn(world, pos, random)) - return false;*/ if (!world.canSeeSkyFromBelowWater(pos)) return false; - if (random.nextFloat() < 0.75f) + if (random.nextFloat() < 0.75F) + return false; + + if (!world.getFluidState(pos.below()).is(FluidTags.WATER)) { return false; - return Monster.checkAnyLightMonsterSpawnRules(entityType, world, reason, pos, random); + } else { + Holder holder = world.getBiome(pos); + boolean flag = world.getDifficulty() != Difficulty.PEACEFUL && (reason == MobSpawnType.SPAWNER || world.getFluidState(pos).is(FluidTags.WATER)); + if (!holder.is(Biomes.RIVER) && !holder.is(Biomes.FROZEN_RIVER)) { + return random.nextInt(40) == 0 && isDeepEnoughToSpawn(world, pos) && flag; + } else { + return random.nextInt(15) == 0 && flag; + } + } } @Override @@ -180,7 +196,7 @@ public void tick() { aquaticEntity.updateSwimming(); LivingEntity livingentity = this.aquaticEntity.getTarget(); - if (this.aquaticEntity.isInWater()) { + if (this.aquaticEntity.isEyeInFluid(FluidTags.WATER)) { if (livingentity != null && livingentity.getY() > this.aquaticEntity.getY()) { double dx = livingentity.getX() - this.aquaticEntity.getX(); double dz = livingentity.getZ() - this.aquaticEntity.getZ(); diff --git a/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractCaveEntity.java b/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractCaveEntity.java index 96e537f1d..da132a4c6 100644 --- a/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractCaveEntity.java +++ b/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractCaveEntity.java @@ -24,6 +24,8 @@ public static boolean checkEntitySpawnRules(EntityType return false; if (random.nextFloat() < 0.75f) return false; + if (!checkSpawnBlock(world, reason, pos)) + return false; return Monster.checkAnyLightMonsterSpawnRules(entityType, world, reason, pos, random); } } diff --git a/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractLatexShark.java b/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractLatexShark.java index f146a56aa..7ed0c7361 100644 --- a/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractLatexShark.java +++ b/src/main/java/net/ltxprogrammer/changed/entity/beast/AbstractLatexShark.java @@ -29,24 +29,6 @@ public AbstractLatexShark(EntityType p_19870_, Lev super(p_19870_, p_19871_); } - private static boolean isDeepEnoughToSpawn(LevelAccessor p_32367_, BlockPos p_32368_) { - return p_32368_.getY() < p_32367_.getSeaLevel() - 5; - } - - public static boolean checkAquaticLatexSpawnRules(EntityType p_32350_, ServerLevelAccessor p_32351_, MobSpawnType p_32352_, BlockPos p_32353_, Random p_32354_) { - if (!p_32351_.getFluidState(p_32353_.below()).is(FluidTags.WATER)) { - return false; - } else { - Holder holder = p_32351_.getBiome(p_32353_); - boolean flag = p_32351_.getDifficulty() != Difficulty.PEACEFUL && isDarkEnoughToSpawn(p_32351_, p_32353_, p_32354_) && (p_32352_ == MobSpawnType.SPAWNER || p_32351_.getFluidState(p_32353_).is(FluidTags.WATER)); - if (!holder.is(Biomes.RIVER) && !holder.is(Biomes.FROZEN_RIVER)) { - return p_32354_.nextInt(40) == 0 && isDeepEnoughToSpawn(p_32351_, p_32353_) && flag; - } else { - return p_32354_.nextInt(15) == 0 && flag; - } - } - } - @Override public LatexType getLatexType() { return LatexType.NEUTRAL; diff --git a/src/main/java/net/ltxprogrammer/changed/init/ChangedEntities.java b/src/main/java/net/ltxprogrammer/changed/init/ChangedEntities.java index 32493a595..75ebbe126 100644 --- a/src/main/java/net/ltxprogrammer/changed/init/ChangedEntities.java +++ b/src/main/java/net/ltxprogrammer/changed/init/ChangedEntities.java @@ -22,6 +22,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.dimension.DimensionType; import net.minecraftforge.common.ForgeSpawnEggItem; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; @@ -469,7 +470,7 @@ public static void addSpawners(BiomeLoadingEvent event) { // Inject spawns into ChangedBiomeInterface.addSpawn(spawns, ChangedMobCategories.CHANGED, GREEN_LIZARD, 10, 1, 2, 0.7, 0.15); } - if (event.getCategory() == Biome.BiomeCategory.BEACH) { + if (event.getCategory() == Biome.BiomeCategory.BEACH && !event.getName().equals(Biomes.STONY_SHORE.getRegistryName())) { ChangedBiomeInterface.addSpawn(spawns, ChangedMobCategories.CHANGED, LATEX_OTTER, 100, 1, 3, 0.7, 0.15); } diff --git a/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/beifeng_crystal_bottom_s.png b/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/beifeng_crystal_bottom_s.png index 48fdbbcba7d9f22528cb02753af2bf852e87f722..c2d5d9fc5f028512e8efaaabd5125dc9a437ffaf 100644 GIT binary patch delta 112 zcmV-$0FVEG0gVBWBxwP2Qb$4nuFf3k0000-Nklyt6Sq&tCw|WY1I~ z1V~b=4DIp(6HvXtRRi7|INNOl0^0iNV~ETWtqusV4F*Am8-nMVCer`_002ovPDHLk FV1m$pCujfw diff --git a/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/beifeng_crystal_small_s.png b/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/beifeng_crystal_small_s.png index 79ff7258bc554533632bc645ef11c8bd51505cfc..e9d00a70d18b3f95f676c170bdfb9afdd1cc389d 100644 GIT binary patch delta 52 zcmbQhIG1sP3KwH>kh>GZx^prwCn}1uNB{ZHFK%&gqMe<{4Ko8tHl_!s7=Xaj)z4*} HQ$iB}%Ht6p delta 41 wcmbQsIDv73%0xq9_V^$F<@FK{O!T%B5%Mq=6q_^qF#`~Iy85}Sb4q9e03xvsaR2}S diff --git a/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/beifeng_crystal_top_s.png b/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/beifeng_crystal_top_s.png index f69f42cdd1bb378aca8ec62e2ee38c27cb59dd93..3ab22b9d44de108fac6d1f284ca739ac0e7c0123 100644 GIT binary patch delta 68 zcmZo<>|>muqRLnt=CfXQ^ YeEKKVu(qRh9Z(sAr>mdKI;Vst0C95~yZ`_I delta 55 zcmeBUY-F6EBH`ib;uvDlo17qV<-z~f|Nl8xCaSm@FJ_$RX(&?rT6)8#+NK5uAnmj3q(0FOR!fmkf$I*69Naw^oJd1I$=NP? k;%x$Z?zVxYL^Q~fyeF71e<*wjZ~y=R07*qoM6N<$g3+lsWdHyG diff --git a/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/latex_crystal_s.png b/src/main/resources/resourcepacks/changed_pbr/assets/changed/textures/blocks/latex_crystal_s.png index a5adde956eeeee858f34ac3b95ca24d033c93f36..593b11592fe04a4e98882e35cf8b39b15ceaba6e 100644 GIT binary patch delta 52 zcmeBToX$8wg^RH`$lZxy-8q?;6BR|+??3uqzvG$kL>nuS5O)2*F6r+&3_#%N>gTe~ HDWM4f>s%5a delta 55 zcmbQv*u^+OMIzAC#WBR9H#tFqm6>0{^XiBHhyMRBILkKC(@NyyL8FIL7|;J@00K`} KKbLh*2~7Y&4;6v{