Skip to content

Commit

Permalink
Fixed structure advancements
Browse files Browse the repository at this point in the history
Couple of other fixes
  • Loading branch information
GirafiStudios committed May 9, 2023
1 parent 1d5ce7e commit 908a739
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import static net.minecraftforge.common.Tags.Items.*;

public class KilnTileEntity extends KilnBaseTileEntity { //TODO Partial rewrite needed, changes in vanilla
public class KilnTileEntity extends KilnBaseTileEntity { //TODO Might freeze up world?
public int burnTime;
public int recipesUsed;
public int cookTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.annotation.Nullable;
import java.util.Optional;

public class DesertRabbitEntity extends Rabbit { //TODO Test. Have partially implemented old way of defining rabbit type. Rabbits are now using a custom variant, which we probably shouldn´t extend (Although test to make sure)
public class DesertRabbitEntity extends Rabbit {
private static final EntityDataAccessor<Integer> DATA_TYPE_ID = SynchedEntityData.defineId(DesertRabbitEntity.class, EntityDataSerializers.INT);

public DesertRabbitEntity(EntityType<? extends DesertRabbitEntity> entityType, Level level) {
Expand Down Expand Up @@ -67,6 +67,7 @@ public void setAtumRabbitType(int id) {
this.entityData.set(DATA_TYPE_ID, id);
}

@Override
@Nullable
public SpawnGroupData finalizeSpawn(@Nonnull ServerLevelAccessor serverLevelAccessor, @Nonnull DifficultyInstance difficultyInstance, @Nonnull MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData, @Nullable CompoundTag nbt) {
int i = this.getRandomAtumRabbitType(serverLevelAccessor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.teammetallurgy.atum.init.AtumLootTables;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
Expand All @@ -15,10 +16,8 @@
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.goal.*;
import net.minecraft.world.entity.ai.goal.target.NonTameRandomTargetGoal;
import net.minecraft.world.entity.animal.Cat;
Expand All @@ -29,15 +28,17 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;

public class ServalEntity extends Cat { //TODO Test. Same problem as with Desert Rabbits
public class ServalEntity extends Cat {
private static final EntityDataAccessor<Integer> DATA_TYPE_ID = SynchedEntityData.defineId(ServalEntity.class, EntityDataSerializers.INT);
private static final Ingredient BREEDING_ITEMS = Ingredient.of(AtumItems.SKELETAL_FISH.get());
private CatTemptGoal temptGoal;
Expand Down Expand Up @@ -93,12 +94,14 @@ public int getAtumCatType() {
}

public void setAtumCatType(int type) {
if (type < 0 || type > SERVAL_TEXTURE_BY_ID.size()) {
type = this.random.nextInt(SERVAL_TEXTURE_BY_ID.size());
}
this.entityData.set(DATA_TYPE_ID, type);
}

public void setRandomServalType() {
int type = this.random.nextInt(SERVAL_TEXTURE_BY_ID.size());
this.setAtumCatType(type);
}

@Override
protected void defineSynchedData() {
super.defineSynchedData();
Expand All @@ -113,6 +116,14 @@ public void tick() {
}
}

@Override
@Nullable
public SpawnGroupData finalizeSpawn(@Nonnull ServerLevelAccessor serverLevelAccessor, @Nonnull DifficultyInstance difficultyInstance, @Nonnull MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData, @Nullable CompoundTag nbt) {
this.setRandomServalType();

return super.finalizeSpawn(serverLevelAccessor, difficultyInstance, spawnType, spawnGroupData, nbt);
}

@Override
public Cat getBreedOffspring(@Nonnull ServerLevel serverLevel, @Nonnull AgeableMob ageableEntity) {
ServalEntity serval = AtumEntities.SERVAL.get().create(serverLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.StructureTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class AtumEffects {
public static final DeferredRegister<MobEffect> MOB_EFFECT_DEFERRED = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, Atum.MOD_ID);
public static final RegistryObject<MobEffect> MARKED_FOR_DEATH = register("marked_for_death", new MarkedForDeathEffect()); //TODO Fix, crashes
public static final RegistryObject<MobEffect> MARKED_FOR_DEATH = register("marked_for_death", new MarkedForDeathEffect());

public static RegistryObject<MobEffect> register(String name, MobEffect effect) {
MinecraftForge.EVENT_BUS.register(effect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.teammetallurgy.atum.entity.stone.StonewardenEntity;
import com.teammetallurgy.atum.entity.undead.*;
import com.teammetallurgy.atum.entity.villager.AtumVillagerEntity;
import com.teammetallurgy.atum.world.DimensionHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/com/teammetallurgy/atum/misc/AtumConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,15 @@ public static class Sandstorm {
}
}

public static class WorldGen { //TODO. Some of these probably need to go
public static class WorldGen {
public static final String WORLDGEN = "world gen";
public final ForgeConfigSpec.DoubleValue mineshaftProbability;
public final ForgeConfigSpec.IntValue ruinsAmount;
public final ForgeConfigSpec.IntValue fossilsChance;
public final ForgeConfigSpec.BooleanValue sandLayerEdge;

WorldGen(ForgeConfigSpec.Builder builder) {
builder.push(WORLDGEN);
this.mineshaftProbability = builder.comment("Probability of mineshafts generating. Set to 0 to disable. Default value same as vanilla overworld")
.translation("atum.config.mineshaft_probability")
.defineInRange("Minecraft probability", 0.007D, 0.0D, 1.0D);
this.ruinsAmount = builder.comment("Specify the amount of ruin variants structures/ruins. Allows for additional ruin structures with a resourcepack")
.translation("atum.config.ruins_amount")
.defineInRange("Ruins Amount", 17, 1, 999);
this.fossilsChance = builder.defineInRange("Fossils chance, set to 0 to disable", 64, 0, 255);
this.sandLayerEdge = builder.comment("Should Sand Layers generate along all edges?")
.translation("atum.config.sand_layer_enabled")
.define("Enable Sand Layer along edges", true);
builder.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.teammetallurgy.atum.world;

import com.google.common.collect.Lists;
import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.blocks.SandLayersBlock;
import com.teammetallurgy.atum.init.AtumBiomes;
Expand All @@ -22,7 +21,6 @@
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;
import java.util.Optional;

@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.teammetallurgy.atum.init.AtumBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import javax.annotation.Nonnull;

public class SandLayerFeature extends Feature<NoneFeatureConfiguration> { //TODO Fix
public class SandLayerFeature extends Feature<NoneFeatureConfiguration> {

public SandLayerFeature(Codec<NoneFeatureConfiguration> config) {
super(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"conditions": {
"player": {
"location": {
"feature": "atum:pyramid"
"structure": "atum:pyramid"
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/main/resources/data/atum/advancements/core/ruinedit.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
"conditions": {
"player": {
"location": {
"player": {
"location": {
"feature": "atum:ruin"
}
}
"structure": "atum:ruin"
}
}
}
Expand Down

0 comments on commit 908a739

Please sign in to comment.