This commit is contained in:
ItsBlackGear 2022-09-14 16:56:36 -03:00
parent c2799b923f
commit 5de0af64bc
45 changed files with 658 additions and 150 deletions

View file

@ -2,6 +2,9 @@ package com.cursedcauldron.wildbackport;
import com.cursedcauldron.wildbackport.client.registry.WBParticleTypes;
import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents;
import com.cursedcauldron.wildbackport.common.entities.access.Recovery;
import com.cursedcauldron.wildbackport.common.items.CompassItemPropertyFunction;
import com.cursedcauldron.wildbackport.common.registry.Instruments;
import com.cursedcauldron.wildbackport.common.registry.WBBiomes;
import com.cursedcauldron.wildbackport.common.registry.WBBlockEntities;
import com.cursedcauldron.wildbackport.common.registry.WBBlocks;
@ -19,12 +22,16 @@ import com.cursedcauldron.wildbackport.common.registry.entity.WBActivities;
import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes;
import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules;
import com.cursedcauldron.wildbackport.common.registry.entity.WBSensorTypes;
import com.cursedcauldron.wildbackport.common.tag.InstrumentTags;
import com.cursedcauldron.wildbackport.common.tag.WBBiomeTags;
import com.cursedcauldron.wildbackport.common.tag.WBBlockTags;
import com.cursedcauldron.wildbackport.common.tag.WBEntityTypeTags;
import com.cursedcauldron.wildbackport.common.tag.WBGameEventTags;
import com.cursedcauldron.wildbackport.common.tag.WBItemTags;
import com.mojang.logging.LogUtils;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import org.slf4j.Logger;
//<>
@ -43,6 +50,7 @@ public class WildBackport {
WBEntityTypes.ENTITIES.register();
WBGameEvents.EVENTS.register();
WBFeatures.FEATURES.register();
Instruments.INSTRUMENTS.register();
WBItems.ITEMS.register();
WBMemoryModules.MEMORIES.register();
WBMobEffects.EFFECTS.register();
@ -58,9 +66,14 @@ public class WildBackport {
// Tags
WBBiomeTags.TAGS.bootstrap();
WBBlockTags.TAGS.bootstrap();
WBBlockTags.BUILDER.bootstrap();
WBEntityTypeTags.TAGS.bootstrap();
WBGameEventTags.TAGS.bootstrap();
WBItemTags.TAGS.bootstrap();
InstrumentTags.TAGS.bootstrap();
// ItemProperties.register(WBItems.RECOVERY_COMPASS.get(), new ResourceLocation("angle"), new CompassItemPropertyFunction((level, stack, entity) -> {
// return entity instanceof Player player ? Recovery.of(player).getLastDeathLocation().orElse(null) : null;
// }));
}
}

View file

@ -16,7 +16,10 @@ import com.cursedcauldron.wildbackport.client.render.model.ChestBoatModel;
import com.cursedcauldron.wildbackport.client.render.model.FrogModel;
import com.cursedcauldron.wildbackport.client.render.model.TadpoleModel;
import com.cursedcauldron.wildbackport.client.render.model.WardenModel;
import com.cursedcauldron.wildbackport.common.entities.access.Recovery;
import com.cursedcauldron.wildbackport.common.items.CompassItemPropertyFunction;
import com.cursedcauldron.wildbackport.common.registry.WBBlocks;
import com.cursedcauldron.wildbackport.common.registry.WBItems;
import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes;
import com.cursedcauldron.wildbackport.core.api.ColorRegistry;
import com.cursedcauldron.wildbackport.core.api.ParticleRegistry;
@ -25,6 +28,9 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.level.FoliageColor;

View file

@ -79,7 +79,7 @@ public class WBSoundEvents {
// Items
public static final SoundEvent BUCKED_EMPTY_TADPOLE = create("item.bucket.empty_tadpole");
public static final SoundEvent BUCKED_FILL_TADPOLE = create("item.bucket.fill_tadpole");
public static final ImmutableList<SoundEvent> GOAT_HORN_SOUND_VARIANTS = IntStream.range(0, 8).mapToObj(value -> {
public static final ImmutableList<SoundEvent> GOAT_HORN_SOUNDS = IntStream.range(0, 8).mapToObj(value -> {
return create("item.goat_horn.sound." + value);
}).collect(ImmutableList.toImmutableList());

View file

@ -4,13 +4,17 @@ import com.cursedcauldron.wildbackport.common.entities.Allay;
import com.cursedcauldron.wildbackport.common.entities.Frog;
import com.cursedcauldron.wildbackport.common.entities.Tadpole;
import com.cursedcauldron.wildbackport.common.entities.Warden;
import com.cursedcauldron.wildbackport.common.events.StructureGeneration;
import com.cursedcauldron.wildbackport.common.registry.WBBlocks;
import com.cursedcauldron.wildbackport.common.entities.access.Recovery;
import com.cursedcauldron.wildbackport.common.items.CompassItemPropertyFunction;
import com.cursedcauldron.wildbackport.common.registry.WBItems;
import com.cursedcauldron.wildbackport.common.worldgen.structure.StructureGeneration;
import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration;
import com.cursedcauldron.wildbackport.core.api.MobRegistry;
import com.cursedcauldron.wildbackport.core.api.worldgen.BiomeModifier;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
public class CommonSetup {
/**

View file

@ -2,27 +2,20 @@ package com.cursedcauldron.wildbackport.common.entities;
import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents;
import com.cursedcauldron.wildbackport.common.entities.brain.AllayBrain;
import com.cursedcauldron.wildbackport.common.entities.warden.MobPositionSource;
import com.cursedcauldron.wildbackport.common.entities.warden.VibrationHandler;
import com.cursedcauldron.wildbackport.common.registry.WBGameEvents;
import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules;
import com.cursedcauldron.wildbackport.common.tag.WBGameEventTags;
import com.google.common.collect.ImmutableList;
import com.mojang.serialization.Dynamic;
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.TagKey;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
@ -49,9 +42,6 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.gameevent.GameEventListener;
import net.minecraft.world.level.gameevent.GameEventListenerRegistrar;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
@ -66,8 +56,6 @@ public class Allay extends PathfinderMob implements InventoryCarrier {
protected static final ImmutableList<? extends SensorType<? extends Sensor<? super Allay>>> SENSORS = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.NEAREST_ITEMS);
protected static final ImmutableList<MemoryModuleType<?>> MEMORIES = ImmutableList.of(MemoryModuleType.PATH, MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.HURT_BY, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, WBMemoryModules.LIKED_PLAYER.get(), WBMemoryModules.LIKED_NOTEBLOCK.get(), WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get(), WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get());
public static final ImmutableList<Float> THROW_SOUND_PITCHES = ImmutableList.of(0.5625F, 0.625F, 0.75F, 0.9375F, 1.0F, 1.0F, 1.125F, 1.25F, 1.5F, 1.875F, 2.0F, 2.25F, 2.5F, 3.0F, 3.75F, 4.0F);
private final VibrationHandler listener = new VibrationHandler(new MobPositionSource(this, this.getEyeHeight()), 16, new VibrationListenerCallback());
private final GameEventListenerRegistrar registrar = new GameEventListenerRegistrar(this.listener);
private final SimpleContainer inventory = new SimpleContainer(1);
private float holdingTicks;
private float holdingTicksOld;
@ -209,8 +197,6 @@ public class Allay extends PathfinderMob implements InventoryCarrier {
} else {
this.holdingTicks = Mth.clamp(this.holdingTicks - 1.0F, 0.0F, 5.0F);
}
} else {
this.listener.tick(this.level);
}
}
@ -298,11 +284,6 @@ public class Allay extends PathfinderMob implements InventoryCarrier {
return !this.isOnGround();
}
@Override @Nullable
public GameEventListenerRegistrar getGameEventListenerRegistrar() {
return this.registrar;
}
public float getHoldingItemAnimationProgress(float animationProgress) {
return Mth.lerp(animationProgress, this.holdingTicksOld, this.holdingTicks) / 5.0F;
}
@ -350,27 +331,4 @@ public class Allay extends PathfinderMob implements InventoryCarrier {
public Vec3 getLeashOffset() {
return new Vec3(0.0D, this.getEyeHeight() * 0.6D, this.getBbWidth() * 0.1D);
}
//TODO: check why the allay is not detecting note blocks
class VibrationListenerCallback implements VibrationHandler.VibrationConfig {
@Override
public boolean shouldListen(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity) {
if (Allay.this.getLevel() != level || Allay.this.isRemoved() || Allay.this.isNoAi()) {
return false;
} else {
Optional<GlobalPos> position = Allay.this.getBrain().getMemory(WBMemoryModules.LIKED_NOTEBLOCK.get());
return position.isEmpty() || position.get().dimension().equals(level.dimension()) && position.get().pos().equals(pos);
}
}
@Override
public void onSignalReceive(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity, @Nullable Entity source, float distance) {
if (event == WBGameEvents.NOTE_BLOCK_PLAY.get()) AllayBrain.rememberNoteBlock(Allay.this, new BlockPos(pos));
}
@Override
public TagKey<GameEvent> getListenableEvents() {
return WBGameEventTags.ALLAY_CAN_LISTEN;
}
}
}

View file

@ -0,0 +1,16 @@
package com.cursedcauldron.wildbackport.common.entities.access;
import net.minecraft.core.GlobalPos;
import net.minecraft.world.entity.player.Player;
import java.util.Optional;
public interface Recovery {
static Recovery of(Player player) {
return (Recovery)player;
}
Optional<GlobalPos> getLastDeathLocation();
void setLastDeathLocation(Optional<GlobalPos> location);
}

View file

@ -0,0 +1,112 @@
package com.cursedcauldron.wildbackport.common.items;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nullable;
public class CompassItemPropertyFunction implements ClampedItemPropertyFunction {
private final CompassItemPropertyFunction.CompassWobble wobble = new CompassItemPropertyFunction.CompassWobble();
private final CompassItemPropertyFunction.CompassWobble wobbleRandom = new CompassItemPropertyFunction.CompassWobble();
public final CompassItemPropertyFunction.CompassTarget compassTarget;
public CompassItemPropertyFunction(CompassItemPropertyFunction.CompassTarget target) {
this.compassTarget = target;
}
public float unclampedCall(ItemStack p_234960_, @Nullable ClientLevel p_234961_, @Nullable LivingEntity p_234962_, int p_234963_) {
Entity entity = p_234962_ != null ? p_234962_ : p_234960_.getEntityRepresentation();
if (entity == null) {
return 0.0F;
} else {
p_234961_ = this.tryFetchLevelIfMissing(entity, p_234961_);
return p_234961_ == null ? 0.0F : this.getCompassRotation(p_234960_, p_234961_, p_234963_, entity);
}
}
private float getCompassRotation(ItemStack p_234955_, ClientLevel p_234956_, int p_234957_, Entity p_234958_) {
GlobalPos globalpos = this.compassTarget.getPos(p_234956_, p_234955_, p_234958_);
long i = p_234956_.getGameTime();
return !this.isValidCompassTargetPos(p_234958_, globalpos) ? this.getRandomlySpinningRotation(p_234957_, i) : this.getRotationTowardsCompassTarget(p_234958_, i, globalpos.pos());
}
private float getRandomlySpinningRotation(int p_234937_, long p_234938_) {
if (this.wobbleRandom.shouldUpdate(p_234938_)) {
this.wobbleRandom.update(p_234938_, Math.random());
}
double d0 = this.wobbleRandom.rotation + (double)((float)this.hash(p_234937_) / 2.14748365E9F);
return Mth.positiveModulo((float)d0, 1.0F);
}
private float getRotationTowardsCompassTarget(Entity p_234942_, long p_234943_, BlockPos p_234944_) {
double d0 = this.getAngleFromEntityToPos(p_234942_, p_234944_);
double d1 = this.getWrappedVisualRotationY(p_234942_);
if (p_234942_ instanceof Player player) {
if (player.isLocalPlayer()) {
if (this.wobble.shouldUpdate(p_234943_)) {
this.wobble.update(p_234943_, 0.5D - (d1 - 0.25D));
}
double d3 = d0 + this.wobble.rotation;
return Mth.positiveModulo((float)d3, 1.0F);
}
}
double d2 = 0.5D - (d1 - 0.25D - d0);
return Mth.positiveModulo((float)d2, 1.0F);
}
@javax.annotation.Nullable
private ClientLevel tryFetchLevelIfMissing(Entity p_234946_, @javax.annotation.Nullable ClientLevel p_234947_) {
return p_234947_ == null && p_234946_.level instanceof ClientLevel ? (ClientLevel)p_234946_.level : p_234947_;
}
private boolean isValidCompassTargetPos(Entity p_234952_, @javax.annotation.Nullable GlobalPos p_234953_) {
return p_234953_ != null && p_234953_.dimension() == p_234952_.level.dimension() && !(p_234953_.pos().distToCenterSqr(p_234952_.position()) < (double)1.0E-5F);
}
private double getAngleFromEntityToPos(Entity p_234949_, BlockPos p_234950_) {
Vec3 vec3 = Vec3.atCenterOf(p_234950_);
return Math.atan2(vec3.z() - p_234949_.getZ(), vec3.x() - p_234949_.getX()) / (double)((float)Math.PI * 2F);
}
private double getWrappedVisualRotationY(Entity entity) {
return Mth.positiveModulo(entity.getYRot() / 360.0F, 1.0D);
}
private int hash(int p_234935_) {
return p_234935_ * 1327217883;
}
public interface CompassTarget {
@Nullable GlobalPos getPos(ClientLevel level, ItemStack stack, Entity entity);
}
static class CompassWobble {
double rotation;
private double deltaRotation;
private long lastUpdateTick;
boolean shouldUpdate(long updateTick) {
return this.lastUpdateTick != updateTick;
}
void update(long updateTick, double rotation) {
this.lastUpdateTick = updateTick;
double d0 = rotation - this.rotation;
d0 = Mth.positiveModulo(d0 + 0.5D, 1.0D) - 0.5D;
this.deltaRotation += d0 * 0.1D;
this.deltaRotation *= 0.8D;
this.rotation = Mth.positiveModulo(this.rotation + this.deltaRotation, 1.0D);
}
}
}

View file

@ -0,0 +1,122 @@
package com.cursedcauldron.wildbackport.common.items;
import com.cursedcauldron.wildbackport.common.registry.WBGameEvents;
import com.cursedcauldron.wildbackport.common.registry.WBItems;
import com.cursedcauldron.wildbackport.common.registry.WBRegistries;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.core.Holder;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Random;
public class GoatHornItem extends Item {
private static final String INSTRUMENT_KEY = "instrument";
private TagKey<Instrument> instruments;
public GoatHornItem(Properties properties, TagKey<Instrument> instrumentTag) {
super(properties);
this.instruments = instrumentTag;
}
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> components, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, level, components, tooltipFlag);
Optional<ResourceKey<Instrument>> instrument = this.getInstrument(stack).flatMap(Holder::unwrapKey);
if (instrument.isPresent()) {
MutableComponent component = new TranslatableComponent(Util.makeDescriptionId(INSTRUMENT_KEY, instrument.get().location()));
components.add(component.withStyle(ChatFormatting.GRAY));
}
}
public static ItemStack getStackForInstrument(Item item, Holder<Instrument> instrument) {
ItemStack stack = new ItemStack(item);
setInstrument(stack, instrument);
return stack;
}
public static void setRandomInstrumentFromTag(ItemStack stack, TagKey<Instrument> tag, Random random) {
Optional<Holder<Instrument>> instrument = WBRegistries.INSTRUMENT.registry().getTag(tag).flatMap(holders -> holders.getRandomElement(random));
instrument.ifPresent(holder -> setInstrument(stack, holder));
}
private static void setInstrument(ItemStack stack, Holder<Instrument> instrument) {
stack.getOrCreateTag().putString(INSTRUMENT_KEY, instrument.unwrapKey().orElseThrow(() -> {
return new IllegalStateException("Invalid instrument");
}).location().toString());
}
@Override
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> stacks) {
if (this.allowdedIn(tab)) {
for (Holder<Instrument> holder : WBRegistries.INSTRUMENT.registry().getTagOrEmpty(this.instruments)) {
// stacks.add(getStackForInstrument(WBItems.GOAT_HORN.get(), holder));
}
}
}
@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
Optional<Holder<Instrument>> holder = this.getInstrument(stack);
if (holder.isPresent()) {
Instrument instrument = holder.get().value();
player.startUsingItem(hand);
playSound(level, player, instrument);
player.getCooldowns().addCooldown(this, instrument.useDuration());
return InteractionResultHolder.consume(stack);
} else {
return InteractionResultHolder.fail(stack);
}
}
@Override
public int getUseDuration(ItemStack stack) {
Optional<Holder<Instrument>> instrument = this.getInstrument(stack);
return instrument.map(holder -> holder.value().useDuration()).orElse(0);
}
private Optional<Holder<Instrument>> getInstrument(ItemStack stack) {
CompoundTag tag = stack.getTag();
if (tag != null) {
ResourceLocation location = ResourceLocation.tryParse(tag.getString("instrument"));
if (location != null) {
return WBRegistries.INSTRUMENT.registry().getHolder(ResourceKey.create(WBRegistries.INSTRUMENT.key(), location));
}
}
Iterator<Holder<Instrument>> instruments = WBRegistries.INSTRUMENT.registry().getTagOrEmpty(this.instruments).iterator();
return instruments.hasNext() ? Optional.of(instruments.next()) : Optional.empty();
}
@Override
public UseAnim getUseAnimation(ItemStack stack) {
return UseAnim.SPYGLASS;
}
private static void playSound(Level level, Player player, Instrument instrument) {
level.playSound(player, player, instrument.soundEvent(), SoundSource.RECORDS, instrument.range() / 16.0F, 1.0F);
level.gameEvent(WBGameEvents.INSTRUMENT_PLAY.get(), player);
}
}

View file

@ -0,0 +1,12 @@
package com.cursedcauldron.wildbackport.common.items;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.ExtraCodecs;
public record Instrument(SoundEvent soundEvent, int useDuration, float range) {
public static final Codec<Instrument> CODEC = RecordCodecBuilder.create(instance -> {
return instance.group(SoundEvent.CODEC.fieldOf("sound_event").forGetter(Instrument::soundEvent), ExtraCodecs.POSITIVE_INT.fieldOf("use_duration").forGetter(Instrument::useDuration), ExtraCodecs.POSITIVE_FLOAT.fieldOf("range").forGetter(Instrument::range)).apply(instance, Instrument::new);
});
}

View file

@ -0,0 +1,50 @@
package com.cursedcauldron.wildbackport.common.registry;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents;
import com.cursedcauldron.wildbackport.common.items.Instrument;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import net.minecraft.sounds.SoundEvent;
import java.util.function.Supplier;
public class Instruments {
public static final CoreRegistry<Instrument> INSTRUMENTS = CoreRegistry.create(WBRegistries.INSTRUMENT.registry(), WildBackport.MOD_ID);
public static final Supplier<Instrument> PONDER_GOAT_HORN = create("ponder_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(0));
public static final Supplier<Instrument> SIGN_GOAT_HORN = create("sign_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(1));
public static final Supplier<Instrument> SEEK_GOAT_HORN = create("seek_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(2));
public static final Supplier<Instrument> FEEL_GOAT_HORN = create("feel_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(3));
public static final Supplier<Instrument> ADMIRE_GOAT_HORN = create("admire_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(4));
public static final Supplier<Instrument> CALL_GOAT_HORN = create("call_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(5));
public static final Supplier<Instrument> YEARN_GOAT_HORN = create("yearn_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(6));
public static final Supplier<Instrument> DREAM_GOAT_HORN = create("dream_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(7));
private static Supplier<Instrument> create(String key, SoundEvent soundEvent) {
return INSTRUMENTS.register(key, () -> new Instrument(soundEvent, 140, 256.0F));
}
// public static final ResourceKey<Instrument> PONDER_GOAT_HORN = Instruments.of("ponder_goat_horn");
// public static final ResourceKey<Instrument> SIGN_GOAT_HORN = Instruments.of("sign_goat_horn");
// public static final ResourceKey<Instrument> SEEK_GOAT_HORN = Instruments.of("seek_goat_horn");
// public static final ResourceKey<Instrument> FEEL_GOAT_HORN = Instruments.of("feel_goat_horn");
// public static final ResourceKey<Instrument> ADMIRE_GOAT_HORN = Instruments.of("admire_goat_horn");
// public static final ResourceKey<Instrument> CALL_GOAT_HORN = Instruments.of("call_goat_horn");
// public static final ResourceKey<Instrument> YEARN_GOAT_HORN = Instruments.of("yearn_goat_horn");
// public static final ResourceKey<Instrument> DREAM_GOAT_HORN = Instruments.of("dream_goat_horn");
//
// private static ResourceKey<Instrument> of(String name) {
// return ResourceKey.create(WBRegistries.INSTRUMENT.key(), new ResourceLocation(name));
// }
//
// public static Instrument registerAndGetDefault(Registry<Instrument> registry) {
// Registry.register(registry, PONDER_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(0), 140, 256.0F));
// Registry.register(registry, SIGN_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(1), 140, 256.0F));
// Registry.register(registry, SEEK_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(2), 140, 256.0F));
// Registry.register(registry, FEEL_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(3), 140, 256.0F));
// Registry.register(registry, ADMIRE_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(4), 140, 256.0F));
// Registry.register(registry, CALL_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(5), 140, 256.0F));
// Registry.register(registry, YEARN_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(6), 140, 256.0F));
// return Registry.register(registry, DREAM_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(7), 140, 256.0F));
// }
}

View file

@ -45,10 +45,12 @@ public class WBItems {
// Deep Dark
public static final Supplier<Item> ECHO_SHARD = create("echo_shard", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
public static final Supplier<Item> RECOVERY_COMPASS = create("recovery_compass", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS)));
// Music
public static final Supplier<Item> MUSIC_DISC_5 = create("music_disc_5", () -> RecordItemAccessor.createRecordItem(15, WBSoundEvents.MUSIC_DISC_5, new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE)));
public static final Supplier<Item> DISC_FRAGMENT_5 = create("disc_fragment_5", () -> new DiscFragmentItem(new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
// public static final Supplier<Item> GOAT_HORN = create("goat_horn", () -> new GoatHornItem(new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC), InstrumentTags.GOAT_HORNS));
private static <T extends Item> Supplier<T> create(String key, Supplier<T> item) {
return ITEMS.register(key, item);

View file

@ -0,0 +1,18 @@
package com.cursedcauldron.wildbackport.common.registry;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.items.Instrument;
import com.cursedcauldron.wildbackport.common.registry.Instruments;
import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType;
import com.cursedcauldron.wildbackport.core.api.RegistryBuilder;
import com.cursedcauldron.wildbackport.core.api.SampleRegistry;
//<>
public class WBRegistries {
public static final RegistryBuilder BUILDER = RegistryBuilder.create(WildBackport.MOD_ID);
public static final SampleRegistry<RootPlacerType<?>> ROOT_PLACER_TYPES = BUILDER.create("worldgen/root_placer_type", registry -> RootPlacerType.MANGROVE_ROOT_PLACER.get());
public static final SampleRegistry<Instrument> INSTRUMENT = BUILDER.create("instrument", registry -> Instruments.DREAM_GOAT_HORN.get());
// public static final SampleRegistry<Instrument> INSTRUMENT = BUILDER.create("instrument", Instruments::registerAndGetDefault);
}

View file

@ -1,6 +1,7 @@
package com.cursedcauldron.wildbackport.common.registry.worldgen;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.registry.WBRegistries;
import com.cursedcauldron.wildbackport.common.worldgen.placers.MangroveRootPlacer;
import com.cursedcauldron.wildbackport.common.worldgen.placers.RootPlacer;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
@ -9,7 +10,7 @@ import com.mojang.serialization.Codec;
import java.util.function.Supplier;
public class RootPlacerType<P extends RootPlacer> {
public static final CoreRegistry<RootPlacerType<?>> PLACERS = CoreRegistry.create(WBRegistries.ROOT_PLACER_TYPES.getSecond(), WildBackport.MOD_ID);
public static final CoreRegistry<RootPlacerType<?>> PLACERS = CoreRegistry.create(WBRegistries.ROOT_PLACER_TYPES.registry(), WildBackport.MOD_ID);
public static final Supplier<RootPlacerType<MangroveRootPlacer>> MANGROVE_ROOT_PLACER = PLACERS.register("mangrove_root_placer", () -> new RootPlacerType<>(MangroveRootPlacer.CODEC));

View file

@ -1,19 +0,0 @@
package com.cursedcauldron.wildbackport.common.registry.worldgen;
import com.cursedcauldron.wildbackport.WildBackport;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
//<>
public class WBRegistries {
public static final Pair<ResourceKey<Registry<RootPlacerType<?>>>, Registry<RootPlacerType<?>>> ROOT_PLACER_TYPES = create("worldgen/root_placer_type", registry -> RootPlacerType.MANGROVE_ROOT_PLACER.get());
private static <T> Pair<ResourceKey<Registry<T>>, Registry<T>> create(String key, Registry.RegistryBootstrap<T> bootstrap) {
ResourceKey<Registry<T>> resource = ResourceKey.createRegistryKey(new ResourceLocation(WildBackport.MOD_ID, key));
Registry<T> registry = Registry.registerSimple(resource, bootstrap);
return Pair.of(resource, registry);
}
}

View file

@ -0,0 +1,19 @@
package com.cursedcauldron.wildbackport.common.registry.worldgen;
import com.cursedcauldron.wildbackport.WildBackport;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
public class WBStructures {
// public static final Holder<ConfiguredStructureFeature<?, ?>> ANCIENT_CITY = create("ancient_city", )
private static <FC extends FeatureConfiguration, F extends StructureFeature<FC>> Holder<ConfiguredStructureFeature<?, ?>> create(String key, ConfiguredStructureFeature<FC, F> feature) {
return BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, ResourceKey.create(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, new ResourceLocation(WildBackport.MOD_ID, key)), feature);
}
}

View file

@ -60,8 +60,7 @@ public class WBWorldGeneration {
}
// Mangrove Swamp
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> MANGROVE = config("mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder(
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> MANGROVE = create("mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder(
BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()),
new UpwardBranchingTrunk(2, 1, 4, UniformInt.of(1, 4), 0.5F, UniformInt.of(0, 1), Registry.BLOCK.getOrCreateTag(WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH)),
BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()),
@ -73,8 +72,7 @@ public class WBWorldGeneration {
new AttachedToLeavesDecorator(0.14F, 1, 0, new RandomizedIntStateProvider(BlockStateProvider.simple(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState().setValue(MangrovePropaguleBlock.HANGING, true)), MangrovePropaguleBlock.AGE, UniformInt.of(0, 4)), 2, List.of(Direction.DOWN)),
new BeehiveDecorator(0.01F)
)).ignoreVines().build());
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> TALL_MANGROVE = config("tall_mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder(
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> TALL_MANGROVE = create("tall_mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder(
BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()),
new UpwardBranchingTrunk(4, 1, 9, UniformInt.of(1, 6), 0.5F, UniformInt.of(0, 1), Registry.BLOCK.getOrCreateTag(WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH)),
BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()),
@ -86,42 +84,28 @@ public class WBWorldGeneration {
new AttachedToLeavesDecorator(0.14F, 1, 0, new RandomizedIntStateProvider(BlockStateProvider.simple(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState().setValue(MangrovePropaguleBlock.HANGING, true)), MangrovePropaguleBlock.AGE, UniformInt.of(0, 4)), 2, List.of(Direction.DOWN)),
new BeehiveDecorator(0.01F)
)).ignoreVines().build());
public static final Holder<PlacedFeature> MANGROVE_CHECKED = place("mangrove_checked", MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get()));
public static final Holder<PlacedFeature> TALL_MANGROVE_CHECKED = place("tall_mangrove_checked", TALL_MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get()));
public static final Holder<ConfiguredFeature<RandomFeatureConfiguration, ?>> MANGROVE_VEGETATION = config("mangrove_vegetation", Feature.RANDOM_SELECTOR, new RandomFeatureConfiguration(List.of(
new WeightedPlacedFeature(TALL_MANGROVE_CHECKED, 0.85F)),
MANGROVE_CHECKED
));
public static final Holder<PlacedFeature> TREES_MANGROVE = place("trees_mangrove", MANGROVE_VEGETATION, CountPlacement.of(25), InSquarePlacement.spread(), SurfaceWaterDepthFilter.forMaxDepth(5), PlacementUtils.HEIGHTMAP_OCEAN_FLOOR, BiomeFilter.biome(), BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState(), BlockPos.ZERO)));
public static final Holder<ConfiguredFeature<GrassDiskConfiguration, ?>> DISK_GRASS_CONFIG = config("disk_grass", WBFeatures.DISK.get(), new GrassDiskConfiguration(
new PredicatedStateProvider(BlockStateProvider.simple(Blocks.DIRT), List.of(new PredicatedStateProvider.Rule(BlockPredicate.not(BlockPredicate.allOf(BlockPredicate.solid(Direction.UP.getNormal()), BlockPredicate.matchesFluid(Fluids.WATER, Direction.UP.getNormal()))), BlockStateProvider.simple(Blocks.GRASS_BLOCK)))),
BlockPredicate.matchesBlocks(List.of(Blocks.DIRT, WBBlocks.MUD.get())),
UniformInt.of(2, 6),
2
));
public static final Holder<PlacedFeature> DISK_GRASS = place("disk_grass", DISK_GRASS_CONFIG, CountPlacement.of(1), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_TOP_SOLID, RandomOffsetPlacement.vertical(ConstantInt.of(-1)), BlockPredicateFilter.forPredicate(BlockPredicate.matchesBlock(WBBlocks.MUD.get(), Vec3i.ZERO)), BiomeFilter.biome());
public static final Holder<PlacedFeature> MANGROVE_CHECKED = create("mangrove_checked", MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get()));
public static final Holder<PlacedFeature> TALL_MANGROVE_CHECKED = create("tall_mangrove_checked", TALL_MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get()));
public static final Holder<ConfiguredFeature<RandomFeatureConfiguration, ?>> MANGROVE_VEGETATION = create("mangrove_vegetation", Feature.RANDOM_SELECTOR, new RandomFeatureConfiguration(List.of(new WeightedPlacedFeature(TALL_MANGROVE_CHECKED, 0.85F)), MANGROVE_CHECKED));
public static final Holder<PlacedFeature> TREES_MANGROVE_PLACED = create("trees_mangrove", MANGROVE_VEGETATION, CountPlacement.of(25), InSquarePlacement.spread(), SurfaceWaterDepthFilter.forMaxDepth(5), PlacementUtils.HEIGHTMAP_OCEAN_FLOOR, BiomeFilter.biome(), BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState(), BlockPos.ZERO)));
public static final Holder<ConfiguredFeature<GrassDiskConfiguration, ?>> DISK_GRASS = create("disk_grass", WBFeatures.DISK.get(), new GrassDiskConfiguration(new PredicatedStateProvider(BlockStateProvider.simple(Blocks.DIRT), List.of(new PredicatedStateProvider.Rule(BlockPredicate.not(BlockPredicate.allOf(BlockPredicate.solid(Direction.UP.getNormal()), BlockPredicate.matchesFluid(Fluids.WATER, Direction.UP.getNormal()))), BlockStateProvider.simple(Blocks.GRASS_BLOCK)))), BlockPredicate.matchesBlocks(List.of(Blocks.DIRT, WBBlocks.MUD.get())), UniformInt.of(2, 6), 2));
public static final Holder<PlacedFeature> DISK_GRASS_PLACED = create("disk_grass", DISK_GRASS, CountPlacement.of(1), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_TOP_SOLID, RandomOffsetPlacement.vertical(ConstantInt.of(-1)), BlockPredicateFilter.forPredicate(BlockPredicate.matchesBlock(WBBlocks.MUD.get(), Vec3i.ZERO)), BiomeFilter.biome());
// Deep Dark
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>> SCULK_PATCH_DEEP_DARK_CONFIG = config("sculk_patch_deep_dark", WBFeatures.SCULK_PATCH.get(), new SculkPatchConfiguration(10, 32, 64, 0, 1, ConstantInt.of(0), 0.5F));
public static final Holder<PlacedFeature> SCULK_PATCH_DEEP_DARK = place("sculk_patch_deep_dark", SCULK_PATCH_DEEP_DARK_CONFIG, CountPlacement.of(ConstantInt.of(256)), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome());
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>> SCULK_PATCH_ANCIENT_CITY_CONFIG = config("sculk_patch_ancient_city", WBFeatures.SCULK_PATCH.get(), new SculkPatchConfiguration(10, 32, 64, 0, 1, UniformInt.of(1, 3), 0.5F));
public static final Holder<PlacedFeature> SCULK_PATCH_ANCIENT_CITY = place("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY_CONFIG);
public static final Holder<ConfiguredFeature<GlowLichenConfiguration, ?>> SCULK_VEIN_CONFIG = config("sculk_vein", WBFeatures.SCULK_GROWTH.get(), new GlowLichenConfiguration(20, true, true, true, 1.0F, HolderSet.direct(Block::builtInRegistryHolder, Blocks.STONE, Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.DRIPSTONE_BLOCK, Blocks.CALCITE, Blocks.TUFF, Blocks.DEEPSLATE)));
public static final Holder<PlacedFeature> SCULK_VEIN = place("sculk_vein", SCULK_VEIN_CONFIG, CountPlacement.of(UniformInt.of(204, 250)), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome());
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>> SCULK_PATCH_DEEP_DARK = create("sculk_patch_deep_dark", WBFeatures.SCULK_PATCH.get(), new SculkPatchConfiguration(10, 32, 64, 0, 1, ConstantInt.of(0), 0.5F));
public static final Holder<PlacedFeature> SCULK_PATCH_DEEP_DARK_PLACED = create("sculk_patch_deep_dark", SCULK_PATCH_DEEP_DARK, CountPlacement.of(ConstantInt.of(256)), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome());
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>> SCULK_PATCH_ANCIENT_CITY = create("sculk_patch_ancient_city", WBFeatures.SCULK_PATCH.get(), new SculkPatchConfiguration(10, 32, 64, 0, 1, UniformInt.of(1, 3), 0.5F));
public static final Holder<PlacedFeature> SCULK_PATCH_ANCIENT_CITY_PLACED = create("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY);
public static final Holder<ConfiguredFeature<GlowLichenConfiguration, ?>> SCULK_VEIN = create("sculk_vein", WBFeatures.SCULK_GROWTH.get(), new GlowLichenConfiguration(20, true, true, true, 1.0F, HolderSet.direct(Block::builtInRegistryHolder, Blocks.STONE, Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.DRIPSTONE_BLOCK, Blocks.CALCITE, Blocks.TUFF, Blocks.DEEPSLATE)));
public static final Holder<PlacedFeature> SCULK_VEIN_PLACED = create("sculk_vein", SCULK_VEIN, CountPlacement.of(UniformInt.of(204, 250)), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome());
// Registry
public static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<ConfiguredFeature<FC, ?>> config(String key, F feature, FC configuration) {
public static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<ConfiguredFeature<FC, ?>> create(String key, F feature, FC configuration) {
return BuiltinRegistries.registerExact(BuiltinRegistries.CONFIGURED_FEATURE, WildBackport.MOD_ID + ":" + key, new ConfiguredFeature<>(feature, configuration));
}
public static Holder<PlacedFeature> place(String key, Holder<? extends ConfiguredFeature<?, ?>> feature, PlacementModifier... placements) {
return BuiltinRegistries.registerExact(BuiltinRegistries.PLACED_FEATURE, WildBackport.MOD_ID + ":" + key, new PlacedFeature(Holder.hackyErase(feature), List.copyOf(List.of(placements))));
public static Holder<PlacedFeature> create(String key, Holder<? extends ConfiguredFeature<?, ?>> feature, PlacementModifier... modifiers) {
return BuiltinRegistries.registerExact(BuiltinRegistries.PLACED_FEATURE, WildBackport.MOD_ID + ":" + key, new PlacedFeature(Holder.hackyErase(feature), List.copyOf(List.of(modifiers))));
}
}

View file

@ -0,0 +1,15 @@
package com.cursedcauldron.wildbackport.common.tag;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.items.Instrument;
import com.cursedcauldron.wildbackport.common.registry.WBRegistries;
import com.cursedcauldron.wildbackport.core.api.TagBuilder;
import net.minecraft.tags.TagKey;
public class InstrumentTags {
public static final TagBuilder<Instrument> TAGS = TagBuilder.create(WBRegistries.INSTRUMENT.registry(), WildBackport.MOD_ID);
public static final TagKey<Instrument> REGULAR_GOAT_HORNS = TAGS.create("regular_goat_horns");
public static final TagKey<Instrument> SCREAMING_GOAT_HORNS = TAGS.create("screaming_goat_horns");
public static final TagKey<Instrument> GOAT_HORNS = TAGS.create("goat_horns");
}

View file

@ -7,20 +7,20 @@ import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
public class WBBlockTags {
public static final TagBuilder<Block> TAGS = TagBuilder.create(Registry.BLOCK, WildBackport.MOD_ID);
public static final TagBuilder<Block> BUILDER = TagBuilder.create(Registry.BLOCK, WildBackport.MOD_ID);
// Mangrove Swamp
public static final TagKey<Block> CONVERTABLE_TO_MUD = TAGS.create("convertable_to_mud");
public static final TagKey<Block> FROG_PREFER_JUMP_TO = TAGS.create("frog_prefer_jump_to");
//TODO
public static final TagKey<Block> FROGS_SPAWNABLE_ON = TAGS.create("frogs_spawnable_on");
public static final TagKey<Block> MANGROVE_LOGS_CAN_GROW_THROUGH = TAGS.create("mangrove_logs_can_grow_through");
public static final TagKey<Block> MANGROVE_ROOTS_CAN_GROW_THROUGH = TAGS.create("mangrove_roots_can_grow_through");
public static final TagKey<Block> CONVERTABLE_TO_MUD = BUILDER.create("convertable_to_mud");
public static final TagKey<Block> FROG_PREFER_JUMP_TO = BUILDER.create("frog_prefer_jump_to");
public static final TagKey<Block> FROGS_SPAWNABLE_ON = BUILDER.create("frogs_spawnable_on");
public static final TagKey<Block> MANGROVE_LOGS_CAN_GROW_THROUGH = BUILDER.create("mangrove_logs_can_grow_through");
public static final TagKey<Block> MANGROVE_ROOTS_CAN_GROW_THROUGH = BUILDER.create("mangrove_roots_can_grow_through");
// Deep Dark
public static final TagKey<Block> SCULK_REPLACEABLE = TAGS.create("sculk_replaceable");
public static final TagKey<Block> SCULK_REPLACEABLE_WORLD_GEN = TAGS.create("sculk_replaceable_world_gen");
public static final TagKey<Block> SCULK_REPLACEABLE = BUILDER.create("sculk_replaceable");
public static final TagKey<Block> SCULK_REPLACEABLE_WORLD_GEN = BUILDER.create("sculk_replaceable_world_gen");
public static final TagKey<Block> ANCIENT_CITY_REPLACEABLE = BUILDER.create("ancient_city_replaceable");
// Compatibility
public static final TagKey<Block> MUD = TAGS.create("mud");
public static final TagKey<Block> MUD = BUILDER.create("mud");
}

View file

@ -22,16 +22,16 @@ public class WorldGenerator {
}
public static void mangroveSwamp(BiomeWriter writer) {
writer.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, WBWorldGeneration.DISK_GRASS);
writer.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, WBWorldGeneration.TREES_MANGROVE);
writer.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, WBWorldGeneration.DISK_GRASS_PLACED);
writer.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, WBWorldGeneration.TREES_MANGROVE_PLACED);
writer.addSpawn(MobCategory.MONSTER, EntityType.SLIME, 1, 1, 1);
writer.addSpawn(MobCategory.WATER_AMBIENT, EntityType.TROPICAL_FISH, 25, 8, 8);
}
public static void deepDark(BiomeWriter writer) {
writer.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, WBWorldGeneration.SCULK_VEIN);
writer.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, WBWorldGeneration.SCULK_PATCH_DEEP_DARK);
writer.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, WBWorldGeneration.SCULK_VEIN_PLACED);
writer.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, WBWorldGeneration.SCULK_PATCH_DEEP_DARK_PLACED);
}
public static void addFrogs(BiomeWriter writer) {

View file

@ -1,7 +1,7 @@
package com.cursedcauldron.wildbackport.common.worldgen.placers;
import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBRegistries;
import com.cursedcauldron.wildbackport.common.registry.WBRegistries;
import com.cursedcauldron.wildbackport.common.worldgen.decorator.AboveRootPlacement;
import com.cursedcauldron.wildbackport.common.worldgen.features.RootedTreeConfig;
import com.mojang.datafixers.Products;
@ -22,7 +22,7 @@ import java.util.Random;
import java.util.function.BiConsumer;
public abstract class RootPlacer {
public static final Codec<RootPlacer> CODEC = WBRegistries.ROOT_PLACER_TYPES.getSecond().byNameCodec().dispatch(RootPlacer::getType, RootPlacerType::codec);
public static final Codec<RootPlacer> CODEC = WBRegistries.ROOT_PLACER_TYPES.registry().byNameCodec().dispatch(RootPlacer::getType, RootPlacerType::codec);
protected final IntProvider trunkOffsetY;
protected final BlockStateProvider rootProvider;
protected final Optional<AboveRootPlacement> aboveRootPlacement;

View file

@ -0,0 +1,20 @@
package com.cursedcauldron.wildbackport.common.worldgen.structure;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.worldgen.structure.pools.AncientCityStructurePools;
import com.cursedcauldron.wildbackport.common.worldgen.structure.processors.WBProcessorLists;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.Pools;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
public class AncientCityStructurePieces {
public static final Holder<StructureTemplatePool> START = Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/city_center"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/city_center/city_center_1", WBProcessorLists.ANCIENT_CITY_START_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/city_center_2", WBProcessorLists.ANCIENT_CITY_START_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/city_center_3", WBProcessorLists.ANCIENT_CITY_START_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID));
public static void bootstrap() {
AncientCityStructurePools.bootstrap();
}
}

View file

@ -1,4 +1,4 @@
package com.cursedcauldron.wildbackport.common.events;
package com.cursedcauldron.wildbackport.common.worldgen.structure;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.core.mixin.access.StructureTemplatePoolAccessor;

View file

@ -0,0 +1,22 @@
package com.cursedcauldron.wildbackport.common.worldgen.structure.pools;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration;
import com.cursedcauldron.wildbackport.common.worldgen.structure.processors.WBProcessorLists;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import net.minecraft.data.worldgen.Pools;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
public class AncientCityStructurePools {
public static void bootstrap() {
Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/structures"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.empty(), 7), Pair.of(StructurePoolElement.single("ancient_city/structures/barracks", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/chamber_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/chamber_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/chamber_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/sauna_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/small_statue", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/large_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 2), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_4", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 2), Pair.of(StructurePoolElement.list(ImmutableList.of(StructurePoolElement.single("ancient_city/structures/camp_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), StructurePoolElement.single("ancient_city/structures/camp_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), StructurePoolElement.single("ancient_city/structures/camp_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION))), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/medium_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/medium_ruin_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/small_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/small_ruin_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/large_pillar_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/medium_pillar_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.list(ImmutableList.of(StructurePoolElement.single("ancient_city/structures/ice_box_1"))), 1)), StructureTemplatePool.Projection.RIGID));
Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/sculk"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.feature(WBWorldGeneration.SCULK_PATCH_ANCIENT_CITY_PLACED), 6), Pair.of(StructurePoolElement.empty(), 1)), StructureTemplatePool.Projection.RIGID));
Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/walls"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/walls/intact_corner_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_intersection_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_lshape_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_3", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_4", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_passage_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 3), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_corner_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_corner_wall_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 2), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 2), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_3", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 3), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_4", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 3)), StructureTemplatePool.Projection.RIGID));
Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/walls/no_corners"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_3", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_4", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_5", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_bridge", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID));
Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/city_center/walls"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_left_corner", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_right_corner_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_right_corner_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/left", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/right", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/top", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/top_right_corner", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/top_left_corner", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID));
Pools.register(new StructureTemplatePool(new ResourceLocation(WildBackport.MOD_ID, "ancient_city/city/entrance"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_connector", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_4", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_5", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID));
}
}

View file

@ -0,0 +1,51 @@
package com.cursedcauldron.wildbackport.common.worldgen.structure.processors;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryCodecs;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public class BlockTagRotProcessor extends StructureProcessor {
public static final Codec<BlockTagRotProcessor> CODEC = RecordCodecBuilder.create(instance -> {
return instance.group(RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY).optionalFieldOf("rottable_blocks").forGetter(processor -> {
return processor.rottableBlocks;
}), Codec.floatRange(0.0F, 1.0F).fieldOf("integrity").forGetter(processor -> {
return processor.integrity;
})).apply(instance, BlockTagRotProcessor::new);
});
private static final StructureProcessorType<BlockTagRotProcessor> BLOCK_TAG_ROT = Registry.register(Registry.STRUCTURE_PROCESSOR, new ResourceLocation("block_rot"), () -> CODEC);
private final Optional<HolderSet<Block>> rottableBlocks;
private final float integrity;
public BlockTagRotProcessor(TagKey<Block> rottableBlocks, float integrity) {
this(Optional.of(Registry.BLOCK.getOrCreateTag(rottableBlocks)), integrity);
}
public BlockTagRotProcessor(Optional<HolderSet<Block>> rottableBlocks, float integrity) {
this.rottableBlocks = rottableBlocks;
this.integrity = integrity;
}
@Override @Nullable
public StructureTemplate.StructureBlockInfo processBlock(LevelReader level, BlockPos from, BlockPos to, StructureTemplate.StructureBlockInfo pre, StructureTemplate.StructureBlockInfo post, StructurePlaceSettings settings) {
return (this.rottableBlocks.isEmpty() || pre.state.is(this.rottableBlocks.get())) && !(settings.getRandom(post.pos).nextFloat() <= this.integrity) ? null : post;
}
@Override
protected StructureProcessorType<?> getType() {
return BLOCK_TAG_ROT;
}
}

View file

@ -0,0 +1,29 @@
package com.cursedcauldron.wildbackport.common.worldgen.structure.processors;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.tag.WBBlockTags;
import com.google.common.collect.ImmutableList;
import net.minecraft.core.Holder;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.structure.templatesystem.AlwaysTrueTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.ProcessorRule;
import net.minecraft.world.level.levelgen.structure.templatesystem.ProtectedBlockProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.RandomBlockMatchTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
public class WBProcessorLists {
public static final Holder<StructureProcessorList> ANCIENT_CITY_START_DEGRADATION = create("ancient_city_start_degradation", ImmutableList.of(new RuleProcessor(ImmutableList.of(new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()))), new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE)));
public static final Holder<StructureProcessorList> ANCIENT_CITY_GENERIC_DEGRADATION = create("ancient_city_generic_degradation", ImmutableList.of(new BlockTagRotProcessor(WBBlockTags.ANCIENT_CITY_REPLACEABLE, 0.95F), new RuleProcessor(ImmutableList.of(new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()))), new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE)));
public static final Holder<StructureProcessorList> ANCIENT_CITY_WALLS_DEGRADATION = create("ancient_city_walls_degradation", ImmutableList.of(new BlockTagRotProcessor(WBBlockTags.ANCIENT_CITY_REPLACEABLE, 0.95F), new RuleProcessor(ImmutableList.of(new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILE_SLAB, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()))), new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE)));
public static void bootstrap() {}
private static Holder<StructureProcessorList> create(String key, ImmutableList<StructureProcessor> processors) {
return BuiltinRegistries.register(BuiltinRegistries.PROCESSOR_LIST, new ResourceLocation(WildBackport.MOD_ID, key), new StructureProcessorList(processors));
}
}

View file

@ -33,7 +33,7 @@ public abstract class CoreRegistry<T> {
this.bootstrap();
}
public abstract void bootstrap();
protected abstract void bootstrap();
public static class DefaultRegistry<T> extends CoreRegistry<T> {
public DefaultRegistry(Registry<T> registry, String modId) {

View file

@ -3,6 +3,11 @@ package com.cursedcauldron.wildbackport.core.api;
import dev.architectury.injectables.annotations.ExpectPlatform;
public class Environment {
@ExpectPlatform
public static boolean isModLoaded(String modId) {
throw new AssertionError();
}
public static boolean isForge() {
return getPlatform() == Platform.FORGE;
}

View file

@ -0,0 +1,22 @@
package com.cursedcauldron.wildbackport.core.api;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
public class RegistryBuilder {
private final String modId;
public RegistryBuilder(String modId) {
this.modId = modId;
}
public static RegistryBuilder create(String modId) {
return new RegistryBuilder(modId);
}
public <T> SampleRegistry<T> create(String key, Registry.RegistryBootstrap<T> bootstrap) {
ResourceKey<Registry<T>> resource = ResourceKey.createRegistryKey(new ResourceLocation(this.modId, key));
return new SampleRegistry<>(resource, Registry.registerSimple(resource, bootstrap));
}
}

View file

@ -0,0 +1,6 @@
package com.cursedcauldron.wildbackport.core.api;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
public record SampleRegistry<T>(ResourceKey<Registry<T>> key, Registry<T> registry) {}

View file

@ -2,6 +2,7 @@ package com.cursedcauldron.wildbackport.core.mixin.client;
import com.cursedcauldron.wildbackport.common.effects.EffectFactor;
import com.cursedcauldron.wildbackport.common.registry.WBMobEffects;
import com.cursedcauldron.wildbackport.core.api.Environment;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft;
@ -33,7 +34,6 @@ public abstract class LightTextureMixin {
@Shadow @Final private GameRenderer renderer;
private LocalPlayer getPlayer() {
// assert this.minecraft.player != null;
return this.minecraft.player;
}
@ -53,8 +53,10 @@ public abstract class LightTextureMixin {
//TODO simplify
@Inject(method = "updateLightTexture(F)V", at = @At("HEAD"))
private void updateLight(float delta, CallbackInfo ci) {
if (Environment.isModLoaded("lod")) return;
if (this.updateLightTexture) {
this.updateLightTexture = false;
this.minecraft.getProfiler().push("lightTex");
ClientLevel level = this.minecraft.level;
if (level != null) {
float skyDarken = level.getSkyDarken(1.0F);
@ -126,6 +128,7 @@ public abstract class LightTextureMixin {
}
this.lightTexture.upload();
this.minecraft.getProfiler().pop();
}
}
}

View file

@ -73,7 +73,6 @@ public abstract class ModelPartMixin implements Animated, Drawable {
this.translateAndRotate(pose);
for (ModelPart part : this.children.values()) part.render(pose, consumer, light, delta, red, green, blue, alpha);
pose.popPose();
}
}

View file

@ -1,23 +0,0 @@
package com.cursedcauldron.wildbackport.core.mixin.common;
import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.behavior.GoToWantedItem;
import net.minecraft.world.entity.ai.memory.MemoryStatus;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(GoToWantedItem.class)
public class GoToWantedItemMixin<E extends LivingEntity> {
@Inject(method = "checkExtraStartConditions", at = @At("TAIL"), cancellable = true)
private void wb$checkExtraConditions(ServerLevel level, E entity, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(!this.isInPickupCooldown(entity) && cir.getReturnValue());
}
private boolean isInPickupCooldown(E entity) {
return entity.getBrain().checkMemory(WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), MemoryStatus.VALUE_PRESENT);
}
}

View file

@ -2,9 +2,11 @@ package com.cursedcauldron.wildbackport.core.mixin.common;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.entities.Warden;
import com.cursedcauldron.wildbackport.common.entities.access.Recovery;
import com.cursedcauldron.wildbackport.common.entities.access.WardenTracker;
import com.cursedcauldron.wildbackport.common.entities.warden.WardenSpawnTracker;
import com.mojang.serialization.Dynamic;
import net.minecraft.core.GlobalPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
import net.minecraft.world.entity.LivingEntity;
@ -14,12 +16,15 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Optional;
//<>
@Mixin(Player.class)
public class PlayerMixin implements WardenTracker {
public class PlayerMixin implements WardenTracker, Recovery {
private final Player player = Player.class.cast(this);
private WardenSpawnTracker spawnTracker = new WardenSpawnTracker(0, 0, 0);
private Optional<GlobalPos> lastDeathLocation = Optional.empty();
@Inject(method = "tick", at = @At("TAIL"))
private void wb$tick(CallbackInfo ci) {
@ -45,4 +50,14 @@ public class PlayerMixin implements WardenTracker {
public WardenSpawnTracker getWardenSpawnTracker() {
return this.spawnTracker;
}
@Override
public Optional<GlobalPos> getLastDeathLocation() {
return this.lastDeathLocation;
}
@Override
public void setLastDeathLocation(Optional<GlobalPos> location) {
this.lastDeathLocation = location;
}
}

View file

@ -0,0 +1,6 @@
{
"values": [
"#wildbackport:regular_goat_horns",
"#wildbackport:screaming_goat_horns"
]
}

View file

@ -0,0 +1,8 @@
{
"values": [
"wildbackport:ponder_goat_horn",
"wildbackport:sing_goat_horn",
"wildbackport:seek_goat_horn",
"wildbackport:feel_goat_horn"
]
}

View file

@ -0,0 +1,8 @@
{
"values": [
"wildbackport:admire_goat_horn",
"wildbackport:call_goat_horn",
"wildbackport:yearn_goat_horn",
"wildbackport:dream_goat_horn"
]
}

View file

@ -34,7 +34,6 @@
"access.WoodTypeAccessor",
"common.BlockEntityTypeMixin",
"common.FlyNodeEvaluatorMixin",
"common.GoToWantedItemMixin",
"common.LivingEntityMixin",
"common.MobEffectMixin",
"common.MobEffectMixin$MobEffectInstanceMixin",

View file

@ -23,3 +23,5 @@ transitive-accessible class net/minecraft/client/renderer/RenderStateShard$Shade
transitive-accessible method net/minecraft/client/particle/HugeExplosionParticle <init> (Lnet/minecraft/client/multiplayer/ClientLevel;DDDDLnet/minecraft/client/particle/SpriteSet;)V
transitive-accessible method net/minecraft/world/level/block/MultifaceBlock hasFace (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;)Z
transitive-accessible method net/minecraft/core/Registry registerSimple (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/Registry$RegistryBootstrap;)Lnet/minecraft/core/Registry;
transitive-accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)V

View file

@ -1,9 +1,14 @@
package com.cursedcauldron.wildbackport.core.api.fabric;
import com.cursedcauldron.wildbackport.core.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
public class EnvironmentImpl {
public static Environment.Platform getPlatform() {
return Environment.Platform.FABRIC;
}
public static boolean isModLoaded(String modId) {
return FabricLoader.getInstance().isModLoaded(modId);
}
}

View file

@ -3,13 +3,17 @@
"id": "wildbackport",
"version": "${version}",
"name": "TheWildBackport",
"description": "backport features from the wild update",
"description": "Backport features from the wild update",
"authors": [
"BlackGear",
"Orcinus",
"Dopadream"
],
"contact": {},
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/the-wild-backport",
"sources": "https://github.com/ItsBlackGear/TheWildBackport-Master",
"issues": "https://github.com/ItsBlackGear/TheWildBackport-Master/issues"
},
"license": "All-Rights-Reserved",
"icon": "icon.png",
"environment": "*",
@ -32,5 +36,12 @@
"fabricloader": ">=0.14.8",
"minecraft": ">=1.18.2",
"terrablender": ">=1.0.0.59"
},
"custom": {
"modmenu": {
"links": {
"modmenu.discord": "https://discord.gg/fTzK9SP"
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

View file

@ -1,9 +1,14 @@
package com.cursedcauldron.wildbackport.core.api.forge;
import com.cursedcauldron.wildbackport.core.api.Environment;
import net.minecraftforge.fml.ModList;
public class EnvironmentImpl {
public static Environment.Platform getPlatform() {
return Environment.Platform.FORGE;
}
public static boolean isModLoaded(String modId) {
return ModList.get().isLoaded(modId);
}
}

View file

@ -1,14 +1,16 @@
modLoader = "javafml"
loaderVersion = "[40,)"
issueTrackerURL = "https://github.com/ItsBlackGear/TheWildBackport-Master/issues"
license = "All Rights Reserved"
[[mods]]
modId = "wildbackport"
version = "${version}"
displayName = "TheWildBackport"
displayURL = "https://www.curseforge.com/minecraft/mc-mods/the-wild-backport"
logoFile = "icon.png"
authors = "BlackGear, Orcinus, Dopadream"
description = '''backport features from the wild update'''
description = '''Backport features from the wild update'''
[[dependencies.wildbackport]]
modId = "forge"

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

View file

@ -4,7 +4,7 @@ minecraft_version=1.18.2
enabled_platforms=fabric,forge
archives_base_name=wildbackport
mod_version=1.2.2
mod_version=1.2.3
maven_group=com.cursedcauldron
fabric_loader_version=0.14.8