diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java b/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java index 4bbdbd6..27bd139 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java @@ -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; +// })); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java index 826e51e..124a332 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java @@ -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; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java index 5466784..88d7bd6 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java @@ -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 GOAT_HORN_SOUND_VARIANTS = IntStream.range(0, 8).mapToObj(value -> { + public static final ImmutableList GOAT_HORN_SOUNDS = IntStream.range(0, 8).mapToObj(value -> { return create("item.goat_horn.sound." + value); }).collect(ImmutableList.toImmutableList()); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java index f383be4..7dc3266 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java @@ -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 { /** diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java index 826edc2..0234721 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java @@ -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>> SENSORS = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.NEAREST_ITEMS); protected static final ImmutableList> 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 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 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 getListenableEvents() { - return WBGameEventTags.ALLAY_CAN_LISTEN; - } - } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java new file mode 100644 index 0000000..1569d8e --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java @@ -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 getLastDeathLocation(); + + void setLastDeathLocation(Optional location); +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java new file mode 100644 index 0000000..41830e7 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java @@ -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); + } + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java new file mode 100644 index 0000000..2431b45 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java @@ -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 instruments; + + public GoatHornItem(Properties properties, TagKey instrumentTag) { + super(properties); + this.instruments = instrumentTag; + } + + @Override + public void appendHoverText(ItemStack stack, @Nullable Level level, List components, TooltipFlag tooltipFlag) { + super.appendHoverText(stack, level, components, tooltipFlag); + Optional> 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) { + ItemStack stack = new ItemStack(item); + setInstrument(stack, instrument); + return stack; + } + + public static void setRandomInstrumentFromTag(ItemStack stack, TagKey tag, Random random) { + Optional> 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) { + stack.getOrCreateTag().putString(INSTRUMENT_KEY, instrument.unwrapKey().orElseThrow(() -> { + return new IllegalStateException("Invalid instrument"); + }).location().toString()); + } + + @Override + public void fillItemCategory(CreativeModeTab tab, NonNullList stacks) { + if (this.allowdedIn(tab)) { + for (Holder holder : WBRegistries.INSTRUMENT.registry().getTagOrEmpty(this.instruments)) { +// stacks.add(getStackForInstrument(WBItems.GOAT_HORN.get(), holder)); + } + } + } + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + Optional> 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> instrument = this.getInstrument(stack); + return instrument.map(holder -> holder.value().useDuration()).orElse(0); + } + + private Optional> 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> 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); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java new file mode 100644 index 0000000..82e7907 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java @@ -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 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); + }); +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java new file mode 100644 index 0000000..9adbbbd --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java @@ -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 INSTRUMENTS = CoreRegistry.create(WBRegistries.INSTRUMENT.registry(), WildBackport.MOD_ID); + + public static final Supplier PONDER_GOAT_HORN = create("ponder_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(0)); + public static final Supplier SIGN_GOAT_HORN = create("sign_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(1)); + public static final Supplier SEEK_GOAT_HORN = create("seek_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(2)); + public static final Supplier FEEL_GOAT_HORN = create("feel_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(3)); + public static final Supplier ADMIRE_GOAT_HORN = create("admire_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(4)); + public static final Supplier CALL_GOAT_HORN = create("call_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(5)); + public static final Supplier YEARN_GOAT_HORN = create("yearn_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(6)); + public static final Supplier DREAM_GOAT_HORN = create("dream_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(7)); + + private static Supplier create(String key, SoundEvent soundEvent) { + return INSTRUMENTS.register(key, () -> new Instrument(soundEvent, 140, 256.0F)); + } + +// public static final ResourceKey PONDER_GOAT_HORN = Instruments.of("ponder_goat_horn"); +// public static final ResourceKey SIGN_GOAT_HORN = Instruments.of("sign_goat_horn"); +// public static final ResourceKey SEEK_GOAT_HORN = Instruments.of("seek_goat_horn"); +// public static final ResourceKey FEEL_GOAT_HORN = Instruments.of("feel_goat_horn"); +// public static final ResourceKey ADMIRE_GOAT_HORN = Instruments.of("admire_goat_horn"); +// public static final ResourceKey CALL_GOAT_HORN = Instruments.of("call_goat_horn"); +// public static final ResourceKey YEARN_GOAT_HORN = Instruments.of("yearn_goat_horn"); +// public static final ResourceKey DREAM_GOAT_HORN = Instruments.of("dream_goat_horn"); +// +// private static ResourceKey of(String name) { +// return ResourceKey.create(WBRegistries.INSTRUMENT.key(), new ResourceLocation(name)); +// } +// +// public static Instrument registerAndGetDefault(Registry 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)); +// } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java index 0dfad7c..c7c1aa4 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java @@ -45,10 +45,12 @@ public class WBItems { // Deep Dark public static final Supplier ECHO_SHARD = create("echo_shard", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + public static final Supplier RECOVERY_COMPASS = create("recovery_compass", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS))); // Music public static final Supplier 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 DISC_FRAGMENT_5 = create("disc_fragment_5", () -> new DiscFragmentItem(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); +// public static final Supplier GOAT_HORN = create("goat_horn", () -> new GoatHornItem(new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC), InstrumentTags.GOAT_HORNS)); private static Supplier create(String key, Supplier item) { return ITEMS.register(key, item); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java new file mode 100644 index 0000000..1ed0c84 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java @@ -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> ROOT_PLACER_TYPES = BUILDER.create("worldgen/root_placer_type", registry -> RootPlacerType.MANGROVE_ROOT_PLACER.get()); + public static final SampleRegistry INSTRUMENT = BUILDER.create("instrument", registry -> Instruments.DREAM_GOAT_HORN.get()); +// public static final SampleRegistry INSTRUMENT = BUILDER.create("instrument", Instruments::registerAndGetDefault); +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java index 54ddf71..83c56dc 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java @@ -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

{ - public static final CoreRegistry> PLACERS = CoreRegistry.create(WBRegistries.ROOT_PLACER_TYPES.getSecond(), WildBackport.MOD_ID); + public static final CoreRegistry> PLACERS = CoreRegistry.create(WBRegistries.ROOT_PLACER_TYPES.registry(), WildBackport.MOD_ID); public static final Supplier> MANGROVE_ROOT_PLACER = PLACERS.register("mangrove_root_placer", () -> new RootPlacerType<>(MangroveRootPlacer.CODEC)); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBRegistries.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBRegistries.java deleted file mode 100644 index 71b541e..0000000 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBRegistries.java +++ /dev/null @@ -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>>, Registry>> ROOT_PLACER_TYPES = create("worldgen/root_placer_type", registry -> RootPlacerType.MANGROVE_ROOT_PLACER.get()); - - private static Pair>, Registry> create(String key, Registry.RegistryBootstrap bootstrap) { - ResourceKey> resource = ResourceKey.createRegistryKey(new ResourceLocation(WildBackport.MOD_ID, key)); - Registry registry = Registry.registerSimple(resource, bootstrap); - return Pair.of(resource, registry); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java new file mode 100644 index 0000000..d7054b8 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java @@ -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> ANCIENT_CITY = create("ancient_city", ) + + private static > Holder> create(String key, ConfiguredStructureFeature feature) { + return BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, ResourceKey.create(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, new ResourceLocation(WildBackport.MOD_ID, key)), feature); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java index 4684cdf..89f139f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java @@ -60,8 +60,7 @@ public class WBWorldGeneration { } // Mangrove Swamp - - public static final Holder> MANGROVE = config("mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder( + public static final Holder> 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> TALL_MANGROVE = config("tall_mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder( + public static final Holder> 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 MANGROVE_CHECKED = place("mangrove_checked", MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())); - public static final Holder TALL_MANGROVE_CHECKED = place("tall_mangrove_checked", TALL_MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())); - - public static final Holder> 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 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> 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 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 MANGROVE_CHECKED = create("mangrove_checked", MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())); + public static final Holder TALL_MANGROVE_CHECKED = create("tall_mangrove_checked", TALL_MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())); + public static final Holder> 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 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> 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 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> 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 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> 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 SCULK_PATCH_ANCIENT_CITY = place("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY_CONFIG); - - public static final Holder> 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 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> 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 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> 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 SCULK_PATCH_ANCIENT_CITY_PLACED = create("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY); + public static final Holder> 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 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 > Holder> config(String key, F feature, FC configuration) { + public static > Holder> create(String key, F feature, FC configuration) { return BuiltinRegistries.registerExact(BuiltinRegistries.CONFIGURED_FEATURE, WildBackport.MOD_ID + ":" + key, new ConfiguredFeature<>(feature, configuration)); } - public static Holder place(String key, Holder> 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 create(String key, Holder> feature, PlacementModifier... modifiers) { + return BuiltinRegistries.registerExact(BuiltinRegistries.PLACED_FEATURE, WildBackport.MOD_ID + ":" + key, new PlacedFeature(Holder.hackyErase(feature), List.copyOf(List.of(modifiers)))); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java new file mode 100644 index 0000000..58e0fa4 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java @@ -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 TAGS = TagBuilder.create(WBRegistries.INSTRUMENT.registry(), WildBackport.MOD_ID); + + public static final TagKey REGULAR_GOAT_HORNS = TAGS.create("regular_goat_horns"); + public static final TagKey SCREAMING_GOAT_HORNS = TAGS.create("screaming_goat_horns"); + public static final TagKey GOAT_HORNS = TAGS.create("goat_horns"); +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java index 3571a17..28e6f95 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java @@ -7,20 +7,20 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; public class WBBlockTags { - public static final TagBuilder TAGS = TagBuilder.create(Registry.BLOCK, WildBackport.MOD_ID); + public static final TagBuilder BUILDER = TagBuilder.create(Registry.BLOCK, WildBackport.MOD_ID); // Mangrove Swamp - public static final TagKey CONVERTABLE_TO_MUD = TAGS.create("convertable_to_mud"); - public static final TagKey FROG_PREFER_JUMP_TO = TAGS.create("frog_prefer_jump_to"); - //TODO - public static final TagKey FROGS_SPAWNABLE_ON = TAGS.create("frogs_spawnable_on"); - public static final TagKey MANGROVE_LOGS_CAN_GROW_THROUGH = TAGS.create("mangrove_logs_can_grow_through"); - public static final TagKey MANGROVE_ROOTS_CAN_GROW_THROUGH = TAGS.create("mangrove_roots_can_grow_through"); + public static final TagKey CONVERTABLE_TO_MUD = BUILDER.create("convertable_to_mud"); + public static final TagKey FROG_PREFER_JUMP_TO = BUILDER.create("frog_prefer_jump_to"); + public static final TagKey FROGS_SPAWNABLE_ON = BUILDER.create("frogs_spawnable_on"); + public static final TagKey MANGROVE_LOGS_CAN_GROW_THROUGH = BUILDER.create("mangrove_logs_can_grow_through"); + public static final TagKey MANGROVE_ROOTS_CAN_GROW_THROUGH = BUILDER.create("mangrove_roots_can_grow_through"); // Deep Dark - public static final TagKey SCULK_REPLACEABLE = TAGS.create("sculk_replaceable"); - public static final TagKey SCULK_REPLACEABLE_WORLD_GEN = TAGS.create("sculk_replaceable_world_gen"); + public static final TagKey SCULK_REPLACEABLE = BUILDER.create("sculk_replaceable"); + public static final TagKey SCULK_REPLACEABLE_WORLD_GEN = BUILDER.create("sculk_replaceable_world_gen"); + public static final TagKey ANCIENT_CITY_REPLACEABLE = BUILDER.create("ancient_city_replaceable"); // Compatibility - public static final TagKey MUD = TAGS.create("mud"); + public static final TagKey MUD = BUILDER.create("mud"); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java index 9b287dc..852b1e8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java @@ -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) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java index c01bc9c..dc07aec 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java @@ -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 CODEC = WBRegistries.ROOT_PLACER_TYPES.getSecond().byNameCodec().dispatch(RootPlacer::getType, RootPlacerType::codec); + public static final Codec CODEC = WBRegistries.ROOT_PLACER_TYPES.registry().byNameCodec().dispatch(RootPlacer::getType, RootPlacerType::codec); protected final IntProvider trunkOffsetY; protected final BlockStateProvider rootProvider; protected final Optional aboveRootPlacement; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java new file mode 100644 index 0000000..0a48e33 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java @@ -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 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(); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/events/StructureGeneration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java similarity index 96% rename from common/src/main/java/com/cursedcauldron/wildbackport/common/events/StructureGeneration.java rename to common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java index 865c54b..53f41d0 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/events/StructureGeneration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java @@ -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; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java new file mode 100644 index 0000000..696c1b3 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java @@ -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)); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java new file mode 100644 index 0000000..204a754 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java @@ -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 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 BLOCK_TAG_ROT = Registry.register(Registry.STRUCTURE_PROCESSOR, new ResourceLocation("block_rot"), () -> CODEC); + private final Optional> rottableBlocks; + private final float integrity; + + public BlockTagRotProcessor(TagKey rottableBlocks, float integrity) { + this(Optional.of(Registry.BLOCK.getOrCreateTag(rottableBlocks)), integrity); + } + + public BlockTagRotProcessor(Optional> 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; + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java new file mode 100644 index 0000000..a700bd7 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java @@ -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 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 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 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 create(String key, ImmutableList processors) { + return BuiltinRegistries.register(BuiltinRegistries.PROCESSOR_LIST, new ResourceLocation(WildBackport.MOD_ID, key), new StructureProcessorList(processors)); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java index eed3994..d095149 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java @@ -33,7 +33,7 @@ public abstract class CoreRegistry { this.bootstrap(); } - public abstract void bootstrap(); + protected abstract void bootstrap(); public static class DefaultRegistry extends CoreRegistry { public DefaultRegistry(Registry registry, String modId) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java index ac5553f..cacf2a7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java @@ -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; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java new file mode 100644 index 0000000..c2f7b15 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java @@ -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 SampleRegistry create(String key, Registry.RegistryBootstrap bootstrap) { + ResourceKey> resource = ResourceKey.createRegistryKey(new ResourceLocation(this.modId, key)); + return new SampleRegistry<>(resource, Registry.registerSimple(resource, bootstrap)); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/SampleRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/SampleRegistry.java new file mode 100644 index 0000000..7ca46b1 --- /dev/null +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/SampleRegistry.java @@ -0,0 +1,6 @@ +package com.cursedcauldron.wildbackport.core.api; + +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; + +public record SampleRegistry(ResourceKey> key, Registry registry) {} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java index dc6979f..1e7db80 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java @@ -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(); } } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java index 1a9cf5c..eb2f2b7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java @@ -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(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/GoToWantedItemMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/GoToWantedItemMixin.java deleted file mode 100644 index 9744075..0000000 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/GoToWantedItemMixin.java +++ /dev/null @@ -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 { - @Inject(method = "checkExtraStartConditions", at = @At("TAIL"), cancellable = true) - private void wb$checkExtraConditions(ServerLevel level, E entity, CallbackInfoReturnable 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); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java index 88efe65..7346bfe 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java @@ -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 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 getLastDeathLocation() { + return this.lastDeathLocation; + } + + @Override + public void setLastDeathLocation(Optional location) { + this.lastDeathLocation = location; + } } \ No newline at end of file diff --git a/common/src/main/resources/data/wildbackport/tags/instruments/goat_horns.json b/common/src/main/resources/data/wildbackport/tags/instruments/goat_horns.json new file mode 100644 index 0000000..5578b8c --- /dev/null +++ b/common/src/main/resources/data/wildbackport/tags/instruments/goat_horns.json @@ -0,0 +1,6 @@ +{ + "values": [ + "#wildbackport:regular_goat_horns", + "#wildbackport:screaming_goat_horns" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/data/wildbackport/tags/instruments/regular_goat_horns.json b/common/src/main/resources/data/wildbackport/tags/instruments/regular_goat_horns.json new file mode 100644 index 0000000..13be49d --- /dev/null +++ b/common/src/main/resources/data/wildbackport/tags/instruments/regular_goat_horns.json @@ -0,0 +1,8 @@ +{ + "values": [ + "wildbackport:ponder_goat_horn", + "wildbackport:sing_goat_horn", + "wildbackport:seek_goat_horn", + "wildbackport:feel_goat_horn" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/data/wildbackport/tags/instruments/screaming_goat_horns.json b/common/src/main/resources/data/wildbackport/tags/instruments/screaming_goat_horns.json new file mode 100644 index 0000000..577fbbf --- /dev/null +++ b/common/src/main/resources/data/wildbackport/tags/instruments/screaming_goat_horns.json @@ -0,0 +1,8 @@ +{ + "values": [ + "wildbackport:admire_goat_horn", + "wildbackport:call_goat_horn", + "wildbackport:yearn_goat_horn", + "wildbackport:dream_goat_horn" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/wildbackport-common.mixins.json b/common/src/main/resources/wildbackport-common.mixins.json index ce9c12f..098f6b3 100644 --- a/common/src/main/resources/wildbackport-common.mixins.json +++ b/common/src/main/resources/wildbackport-common.mixins.json @@ -34,7 +34,6 @@ "access.WoodTypeAccessor", "common.BlockEntityTypeMixin", "common.FlyNodeEvaluatorMixin", - "common.GoToWantedItemMixin", "common.LivingEntityMixin", "common.MobEffectMixin", "common.MobEffectMixin$MobEffectInstanceMixin", diff --git a/common/src/main/resources/wildbackport.accesswidener b/common/src/main/resources/wildbackport.accesswidener index 795cf51..aa33197 100644 --- a/common/src/main/resources/wildbackport.accesswidener +++ b/common/src/main/resources/wildbackport.accesswidener @@ -23,3 +23,5 @@ transitive-accessible class net/minecraft/client/renderer/RenderStateShard$Shade transitive-accessible method net/minecraft/client/particle/HugeExplosionParticle (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 \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/EnvironmentImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/EnvironmentImpl.java index c491b50..e855b92 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/EnvironmentImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/EnvironmentImpl.java @@ -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); + } } \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index c7efbf0..a9000dd 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -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" + } + } } -} +} \ No newline at end of file diff --git a/fabric/src/main/resources/icon.png b/fabric/src/main/resources/icon.png new file mode 100644 index 0000000..056fe9c Binary files /dev/null and b/fabric/src/main/resources/icon.png differ diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EnvironmentImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EnvironmentImpl.java index 08f3c2b..0e2f286 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EnvironmentImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EnvironmentImpl.java @@ -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); + } } \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index f0261af..fed0087 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -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" diff --git a/forge/src/main/resources/icon.png b/forge/src/main/resources/icon.png new file mode 100644 index 0000000..056fe9c Binary files /dev/null and b/forge/src/main/resources/icon.png differ diff --git a/gradle.properties b/gradle.properties index 807b0c3..2a14066 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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