Server and client biome fixes
This commit is contained in:
parent
38a5f66a01
commit
16656508a9
3 changed files with 33 additions and 9 deletions
|
@ -33,6 +33,7 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.LocalDifficulty;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
|
@ -192,8 +193,9 @@ public class EntityEndSlime extends SlimeEntity {
|
|||
float yaw = EntityEndSlime.this.getHeadYaw();
|
||||
float speed = EntityEndSlime.this.getMovementSpeed();
|
||||
if (speed > 0.1) {
|
||||
Vec3d dir = Vec3d.fromPolar(0, yaw);
|
||||
BlockPos pos = EntityEndSlime.this.getBlockPos().add(dir.getX() * speed * 4, 0, dir.getZ() * speed * 4);
|
||||
float dx = MathHelper.sin(-yaw * 0.017453292F - 3.1415927F);
|
||||
float dz = MathHelper.cos(-yaw * 0.017453292F - 3.1415927F);
|
||||
BlockPos pos = EntityEndSlime.this.getBlockPos().add(dx * speed * 4, 0, dz * speed * 4);
|
||||
int down = BlocksHelper.downRay(EntityEndSlime.this.world, pos, 16);
|
||||
return down < 5;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.entity.effect.StatusEffects;
|
|||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biome.Category;
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
|
@ -47,7 +48,7 @@ public class BackgroundRendererMixin {
|
|||
if (lerp > 1) lerp = 1;
|
||||
|
||||
FluidState fluidState = camera.getSubmergedFluidState();
|
||||
if (fluidState.isEmpty() && world.getDimension().hasEnderDragonFight()) {
|
||||
if (fluidState.isEmpty() && world.getRegistryKey().equals(World.END)) {
|
||||
Entity entity = camera.getFocusedEntity();
|
||||
boolean skip = false;
|
||||
if (entity instanceof LivingEntity) {
|
||||
|
@ -72,7 +73,7 @@ public class BackgroundRendererMixin {
|
|||
Biome biome = entity.world.getBiome(entity.getBlockPos());
|
||||
FluidState fluidState = camera.getSubmergedFluidState();
|
||||
if (biome.getCategory() == Category.THEEND && fluidState.isEmpty()) {
|
||||
EndBiome endBiome = BiomeRegistry.getFromBiome(biome);
|
||||
EndBiome endBiome = BiomeRegistry.getRenderBiome(biome);
|
||||
|
||||
if (fogDensity == 0) {
|
||||
fogDensity = endBiome.getFogDensity();
|
||||
|
|
|
@ -3,9 +3,11 @@ package ru.betterend.registry;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
@ -26,6 +28,7 @@ public class BiomeRegistry {
|
|||
private static final Map<EndBiome, RegistryKey<Biome>> KEYS = Maps.newHashMap();
|
||||
private static final HashMap<Identifier, EndBiome> ID_MAP = Maps.newHashMap();
|
||||
private static final HashMap<Biome, EndBiome> MUTABLE = Maps.newHashMap();
|
||||
private static final HashMap<Biome, EndBiome> CLIENT = Maps.newHashMap();
|
||||
|
||||
public static final BiomePicker LAND_BIOMES = new BiomePicker();
|
||||
public static final BiomePicker VOID_BIOMES = new BiomePicker();
|
||||
|
@ -70,6 +73,8 @@ public class BiomeRegistry {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
CLIENT.clear();
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(RegistryKey<Biome> key, BiomeType type, float genChance) {
|
||||
|
@ -94,6 +99,12 @@ public class BiomeRegistry {
|
|||
return endBiome;
|
||||
}
|
||||
|
||||
public static EndBiome registerSubBiome(EndBiome biome, EndBiome parent, float genChance) {
|
||||
parent.addSubBiome(biome);
|
||||
makeLink(biome);
|
||||
return biome;
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(EndBiome biome, BiomeType type) {
|
||||
registerBiomeDirect(biome);
|
||||
addToPicker(biome, type);
|
||||
|
@ -124,11 +135,21 @@ public class BiomeRegistry {
|
|||
}
|
||||
|
||||
public static EndBiome getFromBiome(Biome biome) {
|
||||
EndBiome endBiome = MUTABLE.get(biome);
|
||||
return ID_MAP.getOrDefault(biomeRegistry.getId(biome), END);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static EndBiome getRenderBiome(Biome biome) {
|
||||
EndBiome endBiome = CLIENT.get(biome);
|
||||
if (endBiome == null) {
|
||||
endBiome = ID_MAP.getOrDefault(biomeRegistry.getId(biome), END);
|
||||
MUTABLE.put(biome, END);
|
||||
return END;
|
||||
Identifier id = MinecraftClient.getInstance().world.getRegistryManager().get(Registry.BIOME_KEY).getId(biome);
|
||||
if (id == null) {
|
||||
endBiome = END;
|
||||
}
|
||||
else {
|
||||
endBiome = ID_MAP.getOrDefault(id, END);
|
||||
}
|
||||
CLIENT.put(biome, endBiome);
|
||||
}
|
||||
return endBiome;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue