This commit is contained in:
paulevsGitch 2021-04-19 21:38:14 +03:00
parent 3ec2edd6d5
commit 3f8da599ec
5 changed files with 56 additions and 67 deletions

View file

@ -1,31 +1,30 @@
package ru.betterend.config; package ru.betterend.config;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
public class Configs { public class Configs {
public static final PathConfig ENTITY_CONFIG = new PathConfig("entities"); public static final PathConfig ENTITY_CONFIG = new PathConfig("entities");
public static final PathConfig BLOCK_CONFIG = new PathConfig("blocks"); public static final PathConfig BLOCK_CONFIG = new PathConfig("blocks");
public static final PathConfig ITEM_CONFIG = new PathConfig("items"); public static final PathConfig ITEM_CONFIG = new PathConfig("items");
public static final IdConfig BIOME_CONFIG = new EntryConfig("biomes"); public static final IdConfig BIOME_CONFIG = new EntryConfig("biomes");
public static final PathConfig GENERATOR_CONFIG = new PathConfig("generator"); public static final PathConfig GENERATOR_CONFIG = new PathConfig("generator");
public static final PathConfig RECIPE_CONFIG = new PathConfig("recipes"); public static final PathConfig RECIPE_CONFIG = new PathConfig("recipes");
public static final PortalsConfig PORTALS_CONFIG = new PortalsConfig("portals");
@Environment(value = EnvType.CLIENT)
@Environment(value = EnvType.CLIENT) public static final PathConfig CLENT_CONFIG = new PathConfig("client");
public static final PathConfig CLENT_CONFIG = new PathConfig("client");
public static void saveConfigs() {
public static void saveConfigs() { ENTITY_CONFIG.saveChanges();
ENTITY_CONFIG.saveChanges(); BLOCK_CONFIG.saveChanges();
BLOCK_CONFIG.saveChanges(); BIOME_CONFIG.saveChanges();
BIOME_CONFIG.saveChanges(); ITEM_CONFIG.saveChanges();
ITEM_CONFIG.saveChanges(); GENERATOR_CONFIG.saveChanges();
GENERATOR_CONFIG.saveChanges(); RECIPE_CONFIG.saveChanges();
RECIPE_CONFIG.saveChanges();
if (BetterEnd.isClient()) {
if (BetterEnd.isClient()) { CLENT_CONFIG.saveChanges();
CLENT_CONFIG.saveChanges(); }
} }
} }
}

View file

@ -1,19 +0,0 @@
package ru.betterend.config;
import com.google.gson.JsonObject;
public class PortalsConfig {
private final ConfigWriter writer;
private final JsonObject configObject;
public PortalsConfig(String path) {
this.writer = new ConfigWriter(path);
this.configObject = writer.load();
}
public void saveChanges() {
writer.save();
}
}

View file

@ -49,15 +49,20 @@ public class CubozoaEntity extends AbstractSchoolingFish {
@Override @Override
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) { public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) {
SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag); SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag);
if (entityTag != null) {
if (entityTag.contains("variant")) if (EndBiomes.getFromBiome(world.getBiome(blockPosition())) == EndBiomes.SULPHUR_SPRINGS) {
this.entityData.set(VARIANT, entityTag.getByte("variant"));
if (entityTag.contains("scale"))
this.entityData.set(SCALE, entityTag.getByte("scale"));
}
else if (EndBiomes.getFromBiome(world.getBiome(blockPosition())) == EndBiomes.SULPHUR_SPRINGS) {
this.entityData.set(VARIANT, (byte) 1); this.entityData.set(VARIANT, (byte) 1);
} }
if (entityTag != null) {
if (entityTag.contains("Variant")) {
this.entityData.set(VARIANT, entityTag.getByte("Variant"));
}
if (entityTag.contains("Scale")) {
this.entityData.set(SCALE, entityTag.getByte("Scale"));
}
}
this.refreshDimensions(); this.refreshDimensions();
return data; return data;
} }
@ -91,8 +96,8 @@ public class CubozoaEntity extends AbstractSchoolingFish {
protected ItemStack getBucketItemStack() { protected ItemStack getBucketItemStack() {
ItemStack bucket = EndItems.BUCKET_CUBOZOA.getDefaultInstance(); ItemStack bucket = EndItems.BUCKET_CUBOZOA.getDefaultInstance();
CompoundTag tag = bucket.getOrCreateTag(); CompoundTag tag = bucket.getOrCreateTag();
tag.putByte("variant", entityData.get(VARIANT)); tag.putByte("Variant", entityData.get(VARIANT));
tag.putByte("scale", entityData.get(SCALE)); tag.putByte("Scale", entityData.get(SCALE));
return bucket; return bucket;
} }

View file

@ -43,15 +43,20 @@ public class EndFishEntity extends AbstractSchoolingFish {
@Override @Override
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) { public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag) {
SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag); SpawnGroupData data = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityTag);
if (entityTag != null) {
if (entityTag.contains("variant")) if (EndBiomes.getFromBiome(world.getBiome(blockPosition())) == EndBiomes.SULPHUR_SPRINGS) {
this.entityData.set(VARIANT, entityTag.getByte("variant"));
if (entityTag.contains("scale"))
this.entityData.set(SCALE, entityTag.getByte("scale"));
}
else if (EndBiomes.getFromBiome(world.getBiome(blockPosition())) == EndBiomes.SULPHUR_SPRINGS) {
this.entityData.set(VARIANT, (byte) (random.nextInt(VARIANTS_SULPHUR) + VARIANTS_NORMAL)); this.entityData.set(VARIANT, (byte) (random.nextInt(VARIANTS_SULPHUR) + VARIANTS_NORMAL));
} }
if (entityTag != null) {
if (entityTag.contains("Variant")) {
this.entityData.set(VARIANT, entityTag.getByte("variant"));
}
if (entityTag.contains("Scale")) {
this.entityData.set(SCALE, entityTag.getByte("scale"));
}
}
this.refreshDimensions(); this.refreshDimensions();
return data; return data;
} }

View file

@ -45,7 +45,6 @@ public class ServerLevelMixin {
lastWorld = session.getLevelId(); lastWorld = session.getLevelId();
@SuppressWarnings("resource")
ServerLevel world = ServerLevel.class.cast(this); ServerLevel world = ServerLevel.class.cast(this);
File dir = session.getDimensionPath(world.dimension()); File dir = session.getDimensionPath(world.dimension());
if (!new File(dir, "level.dat").exists()) { if (!new File(dir, "level.dat").exists()) {