diff --git a/build.gradle b/build.gradle index ce7a3b8..2d22003 100644 --- a/build.gradle +++ b/build.gradle @@ -105,6 +105,7 @@ dependencies { // Add in JEI and TOP to assist debugging during development runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${top_version}") + compileOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${top_version}:api") annotationProcessor 'org.spongepowered:mixin:0.8.2:processor' } diff --git a/src/main/java/fathertoast/specialmobs/client/renderer/entity/NinjaSkeletonRenderer.java b/src/main/java/fathertoast/specialmobs/client/renderer/entity/NinjaSkeletonRenderer.java index 2097998..ec8a401 100644 --- a/src/main/java/fathertoast/specialmobs/client/renderer/entity/NinjaSkeletonRenderer.java +++ b/src/main/java/fathertoast/specialmobs/client/renderer/entity/NinjaSkeletonRenderer.java @@ -55,7 +55,7 @@ public class NinjaSkeletonRenderer extends SkeletonRenderer { matrixStack.pushPose(); matrixStack.translate( -0.5D, 0.0D, -0.5D ); - this.blockRenderer.renderBlock( Blocks.LECTERN.defaultBlockState(), matrixStack, buffer, i, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE ); + this.blockRenderer.renderBlock( state, matrixStack, buffer, i, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE ); matrixStack.popPose(); } diff --git a/src/main/java/fathertoast/specialmobs/common/compat/top/NinjaEntityDisplayOverride.java b/src/main/java/fathertoast/specialmobs/common/compat/top/NinjaEntityDisplayOverride.java new file mode 100644 index 0000000..9e7a930 --- /dev/null +++ b/src/main/java/fathertoast/specialmobs/common/compat/top/NinjaEntityDisplayOverride.java @@ -0,0 +1,42 @@ +package fathertoast.specialmobs.common.compat.top; + +import fathertoast.specialmobs.common.entity.ai.INinja; +import mcjty.theoneprobe.api.*; +import net.minecraft.block.Block; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.World; + +import java.util.Objects; + +public class NinjaEntityDisplayOverride implements IEntityDisplayOverride { + + + + @Override + public boolean overrideStandardInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, PlayerEntity playerEntity, World world, Entity entity, IProbeHitEntityData iProbeHitEntityData) { + if (entity instanceof INinja) { + INinja ninja = (INinja) entity; + + if (ninja.getDisguiseBlock() != null) { + Block block = ninja.getDisguiseBlock().getBlock(); + + iProbeInfo.horizontal().item(new ItemStack(block.asItem())); + iProbeInfo.horizontal().text(CompoundText.create().text(new StringTextComponent(translateBlockName(block))), iProbeInfo.defaultTextStyle()); + + return true; + } + } + return false; + } + + /** Returns the localized name of a block */ + private String translateBlockName(Block block) { + ResourceLocation resourceLocation = block.getRegistryName(); + return I18n.get("block." + Objects.requireNonNull(resourceLocation).getNamespace() + "." + resourceLocation.getPath()); + } +} diff --git a/src/main/java/fathertoast/specialmobs/common/compat/top/SMProbeConfig.java b/src/main/java/fathertoast/specialmobs/common/compat/top/SMProbeConfig.java new file mode 100644 index 0000000..4553d68 --- /dev/null +++ b/src/main/java/fathertoast/specialmobs/common/compat/top/SMProbeConfig.java @@ -0,0 +1,30 @@ +package fathertoast.specialmobs.common.compat.top; + +import fathertoast.specialmobs.common.entity.ai.INinja; +import mcjty.theoneprobe.api.IProbeConfig; +import mcjty.theoneprobe.api.IProbeConfigProvider; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeHitEntityData; +import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +public class SMProbeConfig implements IProbeConfigProvider { + + @Override + public void getProbeConfig(IProbeConfig probeConfig, PlayerEntity playerEntity, World world, Entity entity, IProbeHitEntityData iProbeHitEntityData) { + if (entity instanceof INinja) { + INinja ninja = (INinja) entity; + + if (ninja.getDisguiseBlock() != null) { + probeConfig.showMobHealth(IProbeConfig.ConfigMode.NOT); + } + } + } + + @Override + public void getProbeConfig(IProbeConfig probeConfig, PlayerEntity playerEntity, World world, BlockState blockState, IProbeHitData iProbeHitData) { + + } +} diff --git a/src/main/java/fathertoast/specialmobs/common/compat/top/SMTheOneProbe.java b/src/main/java/fathertoast/specialmobs/common/compat/top/SMTheOneProbe.java new file mode 100644 index 0000000..092cd57 --- /dev/null +++ b/src/main/java/fathertoast/specialmobs/common/compat/top/SMTheOneProbe.java @@ -0,0 +1,24 @@ +package fathertoast.specialmobs.common.compat.top; + +import mcjty.theoneprobe.api.ITheOneProbe; + +import javax.annotation.Nullable; +import java.util.function.Function; + +public class SMTheOneProbe implements Function { + + @Nullable + public static ITheOneProbe TOP; + + @Override + public Void apply(ITheOneProbe probe) { + TOP = probe; + setup(probe); + return null; + } + + private void setup(ITheOneProbe probe) { + probe.registerEntityDisplayOverride(new NinjaEntityDisplayOverride()); + probe.registerProbeConfigProvider(new SMProbeConfig()); + } +} diff --git a/src/main/java/fathertoast/specialmobs/common/core/SpecialMobs.java b/src/main/java/fathertoast/specialmobs/common/core/SpecialMobs.java index df1d6f6..0c521fc 100644 --- a/src/main/java/fathertoast/specialmobs/common/core/SpecialMobs.java +++ b/src/main/java/fathertoast/specialmobs/common/core/SpecialMobs.java @@ -1,6 +1,7 @@ package fathertoast.specialmobs.common.core; import fathertoast.specialmobs.common.bestiary.MobFamily; +import fathertoast.specialmobs.common.compat.top.SMTheOneProbe; import fathertoast.specialmobs.common.config.Config; import fathertoast.specialmobs.common.core.register.SMEntities; import fathertoast.specialmobs.common.core.register.SMItems; @@ -8,7 +9,10 @@ import fathertoast.specialmobs.common.event.BiomeEvents; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.InterModComms; +import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.ForgeRegistryEntry; import org.apache.logging.log4j.LogManager; @@ -110,12 +114,19 @@ public class SpecialMobs { IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); eventBus.addListener( SMEntities::createAttributes ); + eventBus.addListener( this::sendIMCMessages ); SMEntities.REGISTRY.register( eventBus ); SMItems.REGISTRY.register( eventBus ); MobFamily.initBestiary(); } + + public void sendIMCMessages(InterModEnqueueEvent event) { + if (ModList.get().isLoaded("theoneprobe")) { + InterModComms.sendTo("theoneprobe", "getTheOneProbe", SMTheOneProbe::new); + } + } /** @return A ResourceLocation with the mod's namespace. */ public static ResourceLocation resourceLoc( String path ) { return new ResourceLocation( MOD_ID, path ); } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 7fe98c8..add580e 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -24,20 +24,27 @@ Source: https://github.com/FatherToast/ Discussion: https://discord.gg/GFTzTdX ''' -[[dependencies.deadlyworld]] +[[dependencies.specialmobs]] modId = "forge" mandatory = true versionRange = "[36.2.17,)" ordering = "NONE" side = "BOTH" -[[dependencies.deadlyworld]] +[[dependencies.specialmobs]] modId = "minecraft" mandatory = true versionRange = "[1.16.5,1.17)" ordering = "NONE" side = "BOTH" +[[dependencies.specialmobs]] +modId = "theoneprobe" +mandatory = false +versionRange = "[1.16,)" +ordering = "BEFORE" +side = "BOTH" + # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ #updateJSONURL="https://change.me.example.invalid/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI