WIP ninja TOP compat

This commit is contained in:
Sarinsa 2022-06-28 22:51:45 +02:00 committed by Sarinsa
parent 9a8d1cdedb
commit 9b8dde210a
7 changed files with 118 additions and 3 deletions

View file

@ -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'
}

View file

@ -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();
}

View file

@ -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());
}
}

View file

@ -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) {
}
}

View file

@ -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<ITheOneProbe, Void> {
@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());
}
}

View file

@ -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 ); }

View file

@ -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