Skip to content

Commit

Permalink
added ancient paintings
Browse files Browse the repository at this point in the history
  • Loading branch information
NewJumper committed May 12, 2024
1 parent 1ff2d5d commit 68f3877
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 4 deletions.
@@ -1,2 +1,2 @@
// 1.20.1 2024-04-03T16:31:59.8068017 Languages: en_us
5c069c5699d7744b9335b43474580a66c22666e2 assets/deeperdarker/lang/en_us.json
// 1.20.1 2024-05-12T13:17:34.6173826 Languages: en_us
569b4e328a6e96d049c25028a661562ac09a4161 assets/deeperdarker/lang/en_us.json
14 changes: 14 additions & 0 deletions src/generated/resources/assets/deeperdarker/lang/en_us.json
Expand Up @@ -230,6 +230,20 @@
"key.categories.deeperdarker": "Deeper and Darker",
"key.deeperdarker.boost": "Boost Soul Elytra",
"key.deeperdarker.transmit": "Use Sculk Transmitter",
"painting.deeperdarker.abstraction.author": "Pedro Ricardo",
"painting.deeperdarker.abstraction.title": "Abstraction",
"painting.deeperdarker.adventure.author": "Pedro Ricardo",
"painting.deeperdarker.adventure.title": "Adventure",
"painting.deeperdarker.carrot.author": "Pedro Ricardo",
"painting.deeperdarker.carrot.title": "Carrot",
"painting.deeperdarker.clouds.author": "Pedro Ricardo",
"painting.deeperdarker.clouds.title": "Clouds",
"painting.deeperdarker.echoer.author": "Pedro Ricardo",
"painting.deeperdarker.echoer.title": "Echoer",
"painting.deeperdarker.millipede.author": "Pedro Ricardo",
"painting.deeperdarker.millipede.title": "Millipede",
"painting.deeperdarker.ooze.author": "Pedro Ricardo",
"painting.deeperdarker.ooze.title": "Ooze",
"subtitles.ambient.otherside.additions": "Warden dreams",
"subtitles.ambient.portal.groan": "The Otherside forebodes",
"subtitles.entity.shattered.ambient": "Shattered growls",
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/kyanite/deeperdarker/DeeperDarker.java
Expand Up @@ -97,6 +97,7 @@ public DeeperDarker() {
DDBlocks.BLOCKS.register(eventBus);
DDBlockEntities.BLOCK_ENTITIES.register(eventBus);
DDEntities.ENTITIES.register(eventBus);
AncientPaintingVariants.PAINTINGS.register(eventBus);
DDEffects.EFFECTS.register(eventBus);
DDPotions.POTIONS.register(eventBus);
DDEnchantments.ENCHANTMENTS.register(eventBus);
Expand Down
@@ -0,0 +1,19 @@
package com.kyanite.deeperdarker.content;

import com.kyanite.deeperdarker.DeeperDarker;
import net.minecraft.world.entity.decoration.PaintingVariant;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class AncientPaintingVariants {
public static final DeferredRegister<PaintingVariant> PAINTINGS = DeferredRegister.create(ForgeRegistries.PAINTING_VARIANTS, DeeperDarker.MOD_ID);

public static final RegistryObject<PaintingVariant> ABSTRACTION = PAINTINGS.register("abstraction", () -> new PaintingVariant(32, 32));
public static final RegistryObject<PaintingVariant> ADVENTURE = PAINTINGS.register("adventure", () -> new PaintingVariant(64, 16));
public static final RegistryObject<PaintingVariant> CARROT = PAINTINGS.register("carrot", () -> new PaintingVariant(32, 16));
public static final RegistryObject<PaintingVariant> CLOUDS = PAINTINGS.register("clouds", () -> new PaintingVariant(64, 16));
public static final RegistryObject<PaintingVariant> ECHOER = PAINTINGS.register("echoer", () -> new PaintingVariant(16, 16));
public static final RegistryObject<PaintingVariant> MILLIPEDE = PAINTINGS.register("millipede", () -> new PaintingVariant(32, 32));
public static final RegistryObject<PaintingVariant> OOZE = PAINTINGS.register("ooze", () -> new PaintingVariant(16, 16));
}
Expand Up @@ -84,6 +84,21 @@ protected void addTranslations() {
add("enchantment." + DeeperDarker.MOD_ID + "." + DDEnchantments.CATALYSIS.getId().getPath() + ".desc", "Spreads sculk when mobs are killed.");
add("enchantment." + DeeperDarker.MOD_ID + "." + DDEnchantments.SCULK_SMITE.getId().getPath() + ".desc", "Increases damage against sculk mobs such as Shattered and the Warden.");

add("painting." + DeeperDarker.MOD_ID + ".abstraction.title", "Abstraction");
add("painting." + DeeperDarker.MOD_ID + ".abstraction.author", "Pedro Ricardo");
add("painting." + DeeperDarker.MOD_ID + ".adventure.title", "Adventure");
add("painting." + DeeperDarker.MOD_ID + ".adventure.author", "Pedro Ricardo");
add("painting." + DeeperDarker.MOD_ID + ".carrot.title", "Carrot");
add("painting." + DeeperDarker.MOD_ID + ".carrot.author", "Pedro Ricardo");
add("painting." + DeeperDarker.MOD_ID + ".clouds.title", "Clouds");
add("painting." + DeeperDarker.MOD_ID + ".clouds.author", "Pedro Ricardo");
add("painting." + DeeperDarker.MOD_ID + ".echoer.title", "Echoer");
add("painting." + DeeperDarker.MOD_ID + ".echoer.author", "Pedro Ricardo");
add("painting." + DeeperDarker.MOD_ID + ".millipede.title", "Millipede");
add("painting." + DeeperDarker.MOD_ID + ".millipede.author", "Pedro Ricardo");
add("painting." + DeeperDarker.MOD_ID + ".ooze.title", "Ooze");
add("painting." + DeeperDarker.MOD_ID + ".ooze.author", "Pedro Ricardo");

add("subtitles.ambient.otherside.additions", "Warden dreams");
add("subtitles.ambient.portal.groan", "The Otherside forebodes");
add("subtitles.entity.snapper.ambient", "Sculk Snapper breathes");
Expand Down
@@ -0,0 +1,52 @@
package com.kyanite.deeperdarker.mixin;

import com.kyanite.deeperdarker.util.DDTags;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.HangingEntity;
import net.minecraft.world.entity.decoration.Painting;
import net.minecraft.world.item.HangingEntityItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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.List;

@Mixin(HangingEntityItem.class)
public abstract class HangingEntityItemMixin {
private static final Component TOOLTIP_RANDOM_VARIANT = Component.translatable("painting.random").withStyle(ChatFormatting.GRAY);
@Shadow
private EntityType<? extends HangingEntity> type;

@Inject(method = "appendHoverText", at = @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack stack, Level level, List<Component> tooltips, TooltipFlag isAdvanced, CallbackInfo ci) {
if(this.type == EntityType.PAINTING) {
CompoundTag tag = stack.getTag();
if(tag != null && tag.contains("EntityTag", 10)) {
CompoundTag entityTag = tag.getCompound("EntityTag");
if(Painting.loadVariant(entityTag).get().is(DDTags.Misc.ANCIENT_PAINTING)) {
Painting.loadVariant(entityTag).ifPresentOrElse((variantHolder) -> {

variantHolder.unwrapKey().ifPresent((variant) -> {
tooltips.add(Component.translatable(variant.location().toLanguageKey("painting", "title")).withStyle(ChatFormatting.YELLOW));
tooltips.add(Component.translatable(variant.location().toLanguageKey("painting", "author")).withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.OBFUSCATED));
});
tooltips.add(Component.translatable("painting.dimensions", Mth.positiveCeilDiv(variantHolder.value().getWidth(), 16), Mth.positiveCeilDiv(variantHolder.value().getHeight(), 16)));
}, () -> tooltips.add(TOOLTIP_RANDOM_VARIANT));

ci.cancel();
}
} else if(isAdvanced.isCreative()) {
tooltips.add(TOOLTIP_RANDOM_VARIANT);
}
}
}
}
54 changes: 54 additions & 0 deletions src/main/java/com/kyanite/deeperdarker/mixin/PaintingMixin.java
@@ -0,0 +1,54 @@
package com.kyanite.deeperdarker.mixin;

import com.kyanite.deeperdarker.util.DDTags;
import net.minecraft.core.Holder;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.HangingEntity;
import net.minecraft.world.entity.decoration.Painting;
import net.minecraft.world.entity.decoration.PaintingVariant;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Painting.class)
public abstract class PaintingMixin extends HangingEntity {
protected PaintingMixin(EntityType<? extends HangingEntity> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
}

@Shadow
public abstract Holder<PaintingVariant> getVariant();

@Inject(method = "dropItem", at = @At("HEAD"), cancellable = true)
public void dropItem(Entity entity, CallbackInfo cir) {
if(getVariant().is(DDTags.Misc.ANCIENT_PAINTING) && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.playSound(SoundEvents.PAINTING_BREAK, 1, 1);
if(entity instanceof Player player && player.getAbilities().instabuild) return;

ItemEntity itemEntity = this.spawnAtLocation(Items.PAINTING);
CompoundTag tag = itemEntity.getItem().getOrCreateTagElement("EntityTag");
Painting.storeVariant(tag, getVariant());
cir.cancel();
}
}

@Inject(method = "getPickResult", at = @At("RETURN"))
public void getPickResult(CallbackInfoReturnable<ItemStack> cir) {
if(getVariant().is(DDTags.Misc.ANCIENT_PAINTING)) {
CompoundTag tag = cir.getReturnValue().getOrCreateTagElement("EntityTag");
Painting.storeVariant(tag, getVariant());
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/kyanite/deeperdarker/util/DDTags.java
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.decoration.PaintingVariant;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -43,7 +44,8 @@ private static TagKey<Item> tag(String name) {
}
}

public static class Biomes {
public static class Misc {
public static final TagKey<Biome> HAS_ANCIENT_TEMPLE = TagKey.create(Registries.BIOME, new ResourceLocation(DeeperDarker.MOD_ID, "has_structure/ancient_temple"));
public static final TagKey<PaintingVariant> ANCIENT_PAINTING = TagKey.create(Registries.PAINTING_VARIANT, new ResourceLocation(DeeperDarker.MOD_ID, "ancient_painting"));
}
}
Expand Up @@ -26,7 +26,7 @@ public static void bootstrap(BootstapContext<Structure> context) {
HolderGetter<Biome> biomes = context.lookup(Registries.BIOME);
HolderGetter<StructureTemplatePool> pools = context.lookup(Registries.TEMPLATE_POOL);

context.register(ANCIENT_TEMPLE, new JigsawStructure(structure(biomes.getOrThrow(DDTags.Biomes.HAS_ANCIENT_TEMPLE)), pools.getOrThrow(DDPools.ANCIENT_TEMPLE), 7, ConstantHeight.of(VerticalAnchor.absolute(18)), false));
context.register(ANCIENT_TEMPLE, new JigsawStructure(structure(biomes.getOrThrow(DDTags.Misc.HAS_ANCIENT_TEMPLE)), pools.getOrThrow(DDPools.ANCIENT_TEMPLE), 7, ConstantHeight.of(VerticalAnchor.absolute(18)), false));
}

private static Structure.StructureSettings structure(HolderSet<Biome> biomes) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,11 @@
{
"values": [
"deeperdarker:abstraction",
"deeperdarker:adventure",
"deeperdarker:carrot",
"deeperdarker:clouds",
"deeperdarker:echoer",
"deeperdarker:millipede",
"deeperdarker:ooze"
]
}
2 changes: 2 additions & 0 deletions src/main/resources/mixins.deeperdarker.json
Expand Up @@ -6,6 +6,8 @@
"refmap": "mixins.deeperdarker.refmap.json",
"mixins": [
"ContainerMenuMixin",
"HangingEntityItemMixin",
"PaintingMixin",
"PhantomMixin",
"PhantomRendererMixin",
"VibrationListenerMixin",
Expand Down

0 comments on commit 68f3877

Please sign in to comment.