Tablet of Necromancy Handler (#93)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
This commit is contained in:
authored and GitHub committed 2026-06-16 14:23:57 -04:00
1 parent 1f3e772def
commit 6c25bcee2a
11 files changed
+371 -191

No files matched your search

+1 -2
View File
@@ -23,6 +23,5 @@ dependencies {
// For testing purposes
//runtimeOnlyNonPublishable("com.github.GTNewHorizons:Electro-Magic-Tools:1.7.22:dev")
runtimeOnly(rfg.deobf('curse.maven:thaumcraft-nei-plugin-225095:2241913'))
runtimeOnly('com.github.GTNewHorizons:TCNEIAdditions:1.5.13:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:AspectRecipeIndex:1.0.15:dev')
}
+1 -1
View File
@@ -115,7 +115,7 @@ usesMixins = true
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = true
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
@@ -61,6 +61,7 @@ import thaumic.tinkerer.common.block.tile.kami.TileWarpGate;
import thaumic.tinkerer.common.block.tile.tablet.TileAnimationTablet;
import thaumic.tinkerer.common.compat.FumeTool;
import thaumic.tinkerer.common.core.handler.ConfigHandler;
import thaumic.tinkerer.common.core.helper.EnumMobAspect;
import thaumic.tinkerer.common.core.proxy.TTCommonProxy;
import thaumic.tinkerer.common.item.ItemInfusedSeeds;
import thaumic.tinkerer.common.item.ItemMobDisplay;
@@ -219,4 +220,9 @@ public final class TTClientProxy extends TTCommonProxy {
public EntityPlayer getClientPlayer() {
return ClientHelper.clientPlayer();
}
@Override
public String getMobDisplayName(EnumMobAspect aspect) {
return aspect.getEntity(Minecraft.getMinecraft().theWorld).getCommandSenderName();
}
}
@@ -0,0 +1,36 @@
package thaumic.tinkerer.client.nei;
import codechicken.nei.api.IConfigureNEI;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler;
import cpw.mods.fml.common.Loader;
public class NEIConfig implements IConfigureNEI {
@Override
public void loadConfig() {
if (!Loader.isModLoaded("aspectrecipeindex")) return;
AspectRecipeIndexIntegration.register();
}
@Override
public String getName() {
return "Thaumic Tinkerer NEI";
}
@Override
public String getVersion() {
return "1.0";
}
// This needs to be an inner class to prevent a NoClassDefFoundError from class loading when ARI isn't loaded.
private static class AspectRecipeIndexIntegration {
public static void register() {
TemplateRecipeHandler handler = new NEINecromancyHandler();
GuiCraftingRecipe.craftinghandlers.add(handler);
GuiUsageRecipe.usagehandlers.add(handler);
}
}
}
@@ -0,0 +1,139 @@
package thaumic.tinkerer.client.nei;
import java.util.Arrays;
import net.glease.tc4tweak.api.infusionrecipe.RecipeIngredient;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import com.gtnewhorizons.aspectrecipeindex.nei.InfusionRecipeHandler;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.core.helper.EnumMobAspect;
import thaumic.tinkerer.common.item.ItemMobAspect;
import thaumic.tinkerer.common.item.ItemMobDisplay;
public class NEINecromancyHandler extends InfusionRecipeHandler {
public static final String OVERLAY = "thaumictinkerer.necromancy";
@Override
public String getRecipeName() {
return StatCollector.translateToLocal("tile.spawner.name");
}
@Override
public String getOverlayIdentifier() {
return OVERLAY;
}
@Override
public int getRecipeHeight(int recipe) {
return 0;
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(this.getOverlayIdentifier())) {
for (EnumMobAspect value : EnumMobAspect.values()) {
new NecromancyCachedRecipe(value);
}
} else if (outputId.equals("item")) {
this.loadCraftingRecipes((ItemStack) results[0]);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
if (result.getItem() instanceof ItemMobDisplay display) {
EnumMobAspect type = display.getEntityType(result);
for (EnumMobAspect value : EnumMobAspect.values()) {
if (value == type) {
new NecromancyCachedRecipe(value);
break;
}
}
}
loadUsageRecipes(result);
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
if (!(ingredient.getItem() instanceof ItemMobAspect)) {
return;
}
Aspect target = ItemMobAspect.getAspect(ingredient);
if (target == null) return;
for (EnumMobAspect value : EnumMobAspect.values()) {
for (Aspect aspect : value.aspects) {
if (aspect == target) {
new NecromancyCachedRecipe(value);
break;
}
}
}
}
@Override
public void loadUsageRecipes(String inputId, Object... ingredients) {
loadCraftingRecipes(inputId, ingredients);
}
@Override
public void drawBackground(int recipeIndex) {
GL11.glPushMatrix();
GuiDraw.changeTexture(THAUM_OVERLAYS);
GL11.glEnable(GL11.GL_BLEND);
GL11.glScalef(1.75F, 1.75F, 1.0F);
GL11.glTranslatef(-0.5F, -1F, 0);
GuiDraw.drawTexturedModalRect(27, 8, 207, 78, 42, 42); // Runic matrix drawing
GL11.glTranslatef(0.5F, 1F, 0);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@Override
public void drawInstability(int recipeIndex) {}
@Override
public void drawExtras(int recipeIndex) {
drawSeeAllRecipesLabel(2);
}
protected class NecromancyCachedRecipe extends InfusionCachedRecipe {
public NecromancyCachedRecipe(EnumMobAspect enumMobAspect) {
super(0, true);
setIngredients(enumMobAspect.aspects);
setResult(enumMobAspect);
this.aspects = new AspectList();
addIfValid();
}
private void setResult(EnumMobAspect enumMobAspect) {
ItemStack result = new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemMobDisplay.class));
((ItemMobDisplay) result.getItem()).setEntityType(result, enumMobAspect.toString());
this.result = new PositionedStack(result, OUTPUT_X, 39, false);
}
private void setIngredients(Aspect[] aspects) {
if (aspects.length < 3) return;
addSurroundingItems(
Arrays.asList(
RecipeIngredient.item(true, ItemMobAspect.getStackFromAspect(aspects[0])),
RecipeIngredient.item(true, ItemMobAspect.getStackFromAspect(aspects[1])),
RecipeIngredient.item(true, ItemMobAspect.getStackFromAspect(aspects[2]))));
}
@Override
protected int itemOffset() {
return -24;
}
}
}
@@ -4,7 +4,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
@@ -28,67 +27,22 @@ public class RenderMobDisplay implements IItemRenderer {
@Override
public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... objects) {
ItemMobDisplay item = (ItemMobDisplay) itemStack.getItem();
if (!(itemStack.getItem() instanceof ItemMobDisplay item)) return;
EnumMobAspect aspect = item.getEntityType(itemStack);
Entity entity = null;
float f1 = 0.4f;
float verticalOffset = 0.0f;
if (aspect != null) {
entity = EnumMobAspect.getEntityFromCache(aspect, null);
f1 = aspect.getScale();
verticalOffset = aspect.getVerticalOffset();
}
switch (itemRenderType) {
case ENTITY:
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0.2 + verticalOffset, 0.5);
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, -0.4F, 0.0F);
GL11.glScalef(f1, f1, f1);
EntityItem eItem = (EntityItem) objects[1];
if (entity != null) {
entity.worldObj = (Minecraft.getMinecraft() != null) ? Minecraft.getMinecraft().theWorld : null;
if (entity.worldObj != null) {
Render renderer = RenderManager.instance.getEntityRenderObject(entity);
entity.setWorld(eItem.worldObj);
entity.copyLocationAndAnglesFrom(eItem);
if (renderer != null && renderer.getFontRendererFromRenderManager() != null) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
// if (renderWithLighting) RenderUtils.enableLightmap();
renderer.doRender(entity, 0, 0, 0, 0, 0);
GL11.glPopAttrib();
}
}
entity.worldObj = null;
}
GL11.glPopMatrix();
case EQUIPPED:
break;
case EQUIPPED_FIRST_PERSON:
break;
case INVENTORY:
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0.2 + verticalOffset, 0.5);
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, -0.4F, 0.0F);
GL11.glScalef(f1, f1, f1);
if (entity != null) {
entity.worldObj = (Minecraft.getMinecraft() != null) ? Minecraft.getMinecraft().theWorld : null;
if (entity.worldObj != null) {
Render renderer = RenderManager.instance.getEntityRenderObject(entity);
if (renderer != null && renderer.getFontRendererFromRenderManager() != null) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
// if (renderWithLighting) RenderUtils.enableLightmap();
renderer.doRender(entity, 0, 0, 0, 0, 0);
GL11.glPopAttrib();
}
}
entity.worldObj = null;
}
GL11.glPopMatrix();
case FIRST_PERSON_MAP:
break;
if (aspect == null) return;
Entity entity = EnumMobAspect.getEntityFromCache(aspect, Minecraft.getMinecraft().theWorld);
float scale = aspect.getScale();
float offset = aspect.getVerticalOffset();
GL11.glPushMatrix();
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(0, (-entity.height / 2) + offset, 0.0F);
Render renderer = RenderManager.instance.getEntityRenderObject(entity);
if (renderer != null && renderer.getFontRendererFromRenderManager() != null) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
renderer.doRender(entity, 0, 0, 0, 0, 0);
GL11.glPopAttrib();
}
GL11.glPopMatrix();
}
}
@@ -1,7 +1,11 @@
package thaumic.tinkerer.common.core.helper;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.monster.EntityBlaze;
@@ -30,97 +34,107 @@ import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchPage;
import thaumcraft.common.entities.monster.EntityBrainyZombie;
import thaumcraft.common.entities.monster.EntityFireBat;
import thaumcraft.common.entities.monster.EntityWisp;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.block.BlockSummon;
import thaumic.tinkerer.common.item.ItemMobAspect;
import thaumic.tinkerer.common.item.ItemMobDisplay;
import thaumic.tinkerer.common.lib.LibResearch;
public enum EnumMobAspect {
SnowMan(EntitySnowman.class, new Aspect[] { Aspect.WATER, Aspect.WATER, Aspect.MAN }),
Bat(EntityBat.class, new Aspect[] { Aspect.AIR, Aspect.AIR, Aspect.FLIGHT }, 1.9f, -0.3f),
Blaze(EntityBlaze.class, new Aspect[] { Aspect.FIRE, Aspect.FIRE, Aspect.FIRE }),
BrainyZombie(EntityBrainyZombie.class, new Aspect[] { Aspect.MAGIC, Aspect.UNDEAD, Aspect.FLESH }, "Thaumcraft."),
Firebat(EntityFireBat.class, new Aspect[] { Aspect.FLIGHT, Aspect.FIRE, Aspect.MAGIC }, 1.9f, -0.3f),
CaveSpider(EntityCaveSpider.class, new Aspect[] { Aspect.BEAST, Aspect.POISON, Aspect.POISON }),
Chicken(EntityChicken.class, new Aspect[] { Aspect.CROP, Aspect.FLIGHT, Aspect.BEAST }),
Cow(EntityCow.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.BEAST }),
Creeper(EntityCreeper.class, new Aspect[] { Aspect.MAGIC, Aspect.BEAST, Aspect.ELDRITCH }),
Enderman(EntityEnderman.class, new Aspect[] { Aspect.ELDRITCH, Aspect.ELDRITCH, Aspect.MAN }, 0.3f, 0.0f),
Ghast(EntityGhast.class, new Aspect[] { Aspect.FIRE, Aspect.FLIGHT, Aspect.FLIGHT }, 0.1f, 0.2f),
EntityHorse(EntityHorse.class, new Aspect[] { Aspect.BEAST, Aspect.BEAST, Aspect.TRAVEL }),
VillagerGolem(EntityIronGolem.class, new Aspect[] { Aspect.METAL, Aspect.METAL, Aspect.MAN }, 0.3f, 0.0f),
LavaSlime(EntityMagmaCube.class, new Aspect[] { Aspect.FIRE, Aspect.SLIME, Aspect.SLIME }, 0.6f, 0.0f) {
@Override
protected Entity createEntity(World worldObj) {
return setSlimeSize(super.createEntity(worldObj), 1);
}
},
MushroomCow(EntityMooshroom.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.CROP }),
Ozelot(EntityOcelot.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.ELDRITCH }),
// Passive
Chicken(EntityChicken.class, new Aspect[] { Aspect.CROP, Aspect.FLIGHT, Aspect.BEAST }, 1.0f),
Pig(EntityPig.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.TRAVEL }),
PigZombie(EntityPigZombie.class, new Aspect[] { Aspect.UNDEAD, Aspect.FLESH, Aspect.FIRE }),
Sheep(EntitySheep.class, new Aspect[] { Aspect.EARTH, Aspect.CLOTH, Aspect.BEAST }),
Silverfish(EntitySilverfish.class, new Aspect[] { Aspect.METAL, Aspect.METAL, Aspect.EARTH }),
Skeleton(EntitySkeleton.class, new Aspect[] { Aspect.UNDEAD, Aspect.MAN, Aspect.UNDEAD }),
Slime(EntitySlime.class, new Aspect[] { Aspect.SLIME, Aspect.SLIME, Aspect.BEAST }, 0.6f, 0.0f) {
/// Must be before Cow because EntityMooshroom extends EntityCow
MushroomCow(EntityMooshroom.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.CROP }, 0.9f),
Cow(EntityCow.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.BEAST }, 0.9f),
Sheep(EntitySheep.class, new Aspect[] { Aspect.EARTH, Aspect.CLOTH, Aspect.BEAST }, 0.9f),
Ozelot(EntityOcelot.class, new Aspect[] { Aspect.BEAST, Aspect.EARTH, Aspect.ELDRITCH }),
Wolf(EntityWolf.class, new Aspect[] { Aspect.BEAST, Aspect.BEAST, Aspect.BEAST }),
EntityHorse(EntityHorse.class, new Aspect[] { Aspect.BEAST, Aspect.BEAST, Aspect.TRAVEL }, 0.8f),
SnowMan(EntitySnowman.class, new Aspect[] { Aspect.WATER, Aspect.WATER, Aspect.MAN }, 0.8f),
VillagerGolem(EntityIronGolem.class, new Aspect[] { Aspect.METAL, Aspect.METAL, Aspect.MAN }, 0.6f),
Villager(EntityVillager.class, new Aspect[] { Aspect.MAN, Aspect.MAN, Aspect.MAN }, 0.8f),
Squid(EntitySquid.class, new Aspect[] { Aspect.WATER, Aspect.WATER, Aspect.WATER }, 0.6f, 0.75f),
Bat(EntityBat.class, new Aspect[] { Aspect.AIR, Aspect.AIR, Aspect.FLIGHT }, 1.9f),
// Hostiles
Blaze(EntityBlaze.class, new Aspect[] { Aspect.FIRE, Aspect.FIRE, Aspect.FIRE }, 0.8f),
PigZombie(EntityPigZombie.class, new Aspect[] { Aspect.UNDEAD, Aspect.FLESH, Aspect.FIRE }, 0.8f),
/// Must be before Slime because EntityMagmaCube extends EntitySlime
LavaSlime(EntityMagmaCube.class, new Aspect[] { Aspect.FIRE, Aspect.SLIME, Aspect.SLIME }, 1.5f) {
@Override
protected Entity createEntity(World worldObj) {
return setSlimeSize(super.createEntity(worldObj), 1);
}
},
Spider(EntitySpider.class, new Aspect[] { Aspect.BEAST, Aspect.UNDEAD, Aspect.UNDEAD }),
Squid(EntitySquid.class, new Aspect[] { Aspect.WATER, Aspect.WATER, Aspect.WATER }, 0.3f, 0.5f),
Villager(EntityVillager.class, new Aspect[] { Aspect.MAN, Aspect.MAN, Aspect.MAN }),
Wisp(EntityWisp.class, new Aspect[] { Aspect.AIR, Aspect.MAGIC, Aspect.MAGIC }, "Thaumcraft."),
Witch(EntityWitch.class, new Aspect[] { Aspect.MAGIC, Aspect.UNDEAD, Aspect.ELDRITCH }, 0.35f, 0.0f),
Wolf(EntityWolf.class, new Aspect[] { Aspect.BEAST, Aspect.BEAST, Aspect.BEAST }),
Zombie(EntityZombie.class, new Aspect[] { Aspect.FLESH, Aspect.FLESH, Aspect.UNDEAD });
Ghast(EntityGhast.class, new Aspect[] { Aspect.FIRE, Aspect.FLIGHT, Aspect.FLIGHT }, 0.2f, 0.6f),
Firebat(EntityFireBat.class, new Aspect[] { Aspect.FLIGHT, Aspect.FIRE, Aspect.MAGIC }, 1.9f, 0f, "Thaumcraft."),
/// Must be before Zombie because EntityBrainyZombie extends EntityZombie
BrainyZombie(EntityBrainyZombie.class, new Aspect[] { Aspect.MAGIC, Aspect.UNDEAD, Aspect.FLESH }, 0.8f, 0,
"Thaumcraft."),
Zombie(EntityZombie.class, new Aspect[] { Aspect.FLESH, Aspect.FLESH, Aspect.UNDEAD }, 0.8f),
Skeleton(EntitySkeleton.class, new Aspect[] { Aspect.UNDEAD, Aspect.MAN, Aspect.UNDEAD }, 0.8f),
Creeper(EntityCreeper.class, new Aspect[] { Aspect.MAGIC, Aspect.BEAST, Aspect.ELDRITCH }, 0.8f),
Witch(EntityWitch.class, new Aspect[] { Aspect.MAGIC, Aspect.UNDEAD, Aspect.ELDRITCH }, 0.8f),
/// Must be before Spider because EntityCaveSpider extends EntitySpider
CaveSpider(EntityCaveSpider.class, new Aspect[] { Aspect.BEAST, Aspect.POISON, Aspect.POISON }, 0.8f),
Spider(EntitySpider.class, new Aspect[] { Aspect.BEAST, Aspect.UNDEAD, Aspect.UNDEAD }, 0.8f),
Slime(EntitySlime.class, new Aspect[] { Aspect.SLIME, Aspect.SLIME, Aspect.BEAST }, 1.5f) {
public static Map<EnumMobAspect, Entity> entityCache = Maps.newHashMap();
public Aspect[] aspects;
public Class entity;
public String prefix;
private float scale;
private float offset;
@Override
protected Entity createEntity(World worldObj) {
return setSlimeSize(super.createEntity(worldObj), 1);
}
},
Silverfish(EntitySilverfish.class, new Aspect[] { Aspect.METAL, Aspect.METAL, Aspect.EARTH }, 1.2f),
Enderman(EntityEnderman.class, new Aspect[] { Aspect.ELDRITCH, Aspect.ELDRITCH, Aspect.MAN }, 0.7f),
Wisp(EntityWisp.class, new Aspect[] { Aspect.AIR, Aspect.MAGIC, Aspect.MAGIC }, "Thaumcraft.");
EnumMobAspect(Class entity, Aspect[] aspects, float scale, float offset) {
public static final Map<EnumMobAspect, Entity> entityCache = Maps.newHashMap();
public final Aspect[] aspects;
public final Class<? extends Entity> entity;
public final String prefix;
private final float scale;
private final float offset;
private final MethodHandle ctor;
EnumMobAspect(Class<? extends Entity> entity, Aspect[] aspects, float scale, float offset) {
this(entity, aspects, scale, offset, "");
}
EnumMobAspect(Class<? extends Entity> entity, Aspect[] aspects, float scale) {
this(entity, aspects, scale, 0);
}
EnumMobAspect(Class<? extends Entity> entity, Aspect[] aspects, float scale, float offset, String prefix) {
this.aspects = aspects;
this.entity = entity;
this.scale = scale;
this.offset = offset;
}
EnumMobAspect(Class entity, Aspect[] aspects, float scale, float offset, String prefix) {
this(entity, aspects, scale, offset);
this.prefix = prefix;
MethodHandles.Lookup lookup = MethodHandles.lookup();
try {
this.ctor = lookup.findConstructor(entity, MethodType.methodType(void.class, World.class));
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
EnumMobAspect(Class entity, Aspect[] aspects) {
this.aspects = aspects;
this.entity = entity;
this.scale = 1.1f;
this.offset = 0.0f;
EnumMobAspect(Class<? extends Entity> entity, Aspect[] aspects) {
this(entity, aspects, 1.0f);
}
EnumMobAspect(Class entity, Aspect[] aspects, String prefix) {
this(entity, aspects);
this.prefix = prefix;
EnumMobAspect(Class<? extends Entity> entity, Aspect[] aspects, String prefix) {
this(entity, aspects, 1.0f, 0, prefix);
}
public static Entity getEntityFromCache(EnumMobAspect ent, World worldObj) {
@@ -135,7 +149,7 @@ public enum EnumMobAspect {
private static Entity setSlimeSize(Entity entity, int size) {
if (entity instanceof EntitySlime) {
((EntitySlime) entity).setSlimeSize(1);
((EntitySlime) entity).setSlimeSize(size);
}
return entity;
@@ -147,7 +161,7 @@ public enum EnumMobAspect {
public static EnumMobAspect getMobAspectForType(String name) {
if (name.isEmpty()) return null;
Class clazz = (Class) EntityList.stringToClassMapping.get(name);
Class<? extends Entity> clazz = EntityList.stringToClassMapping.get(name);
for (EnumMobAspect e : EnumMobAspect.values()) {
if (e.entity.isAssignableFrom(clazz)) {
return e;
@@ -156,7 +170,7 @@ public enum EnumMobAspect {
return null;
}
public static Aspect[] getAspectsForEntity(Class clazz) {
public static Aspect[] getAspectsForEntity(Class<? extends Entity> clazz) {
for (EnumMobAspect e : EnumMobAspect.values()) {
if (e.entity.isAssignableFrom(clazz)) {
return e.aspects;
@@ -173,7 +187,7 @@ public enum EnumMobAspect {
return scale;
}
public Class getEntityClass() {
public Class<? extends Entity> getEntityClass() {
return entity;
}
@@ -182,29 +196,31 @@ public enum EnumMobAspect {
}
protected Entity createEntity(World worldObj) {
return EntityList.createEntityByName(toString(), worldObj);
}
public ResearchPage GetRecepiePage() {
ItemStack output = new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemMobAspect.class));
((ItemMobDisplay) output.getItem()).setEntityType(output, toString());
ItemStack[] inputs = new ItemStack[this.aspects.length];
int i = 0;
for (Aspect a : this.aspects) {
inputs[i++] = ItemMobAspect.getStackFromAspect(a);
try {
return (Entity) ctor.invoke(worldObj);
} catch (Throwable e) {
throw new RuntimeException(e);
}
InfusionRecipe recepie = new InfusionRecipe(
LibResearch.KEY_SUMMON,
output,
0,
new AspectList(),
new ItemStack(ThaumicTinkerer.registry.getFirstBlockFromClass(BlockSummon.class)),
inputs);
return new ResearchPage(recepie);
}
@Override
public String toString() {
return prefix == null ? super.toString() : prefix + super.toString();
}
static {
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
public static class EventHandler {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
Minecraft mc = Minecraft.getMinecraft();
if (event.world == mc.theWorld) {
entityCache.clear();
}
}
}
}
@@ -11,17 +11,23 @@
*/
package thaumic.tinkerer.common.core.proxy;
import java.util.Arrays;
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import codechicken.nei.event.NEIRegisterHandlerInfosEvent;
import codechicken.nei.recipe.HandlerInfo;
import codechicken.nei.recipe.RecipeCatalysts;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
@@ -30,6 +36,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import dan200.computercraft.api.ComputerCraftAPI;
@@ -50,7 +57,9 @@ import thaumcraft.common.tiles.TileNode;
import thaumcraft.common.tiles.TileSensor;
import thaumcraft.common.tiles.TileTubeFilter;
import thaumcraft.common.tiles.TileWandPedestal;
import thaumic.tinkerer.client.nei.NEINecromancyHandler;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.block.BlockSummon;
import thaumic.tinkerer.common.block.tile.TileFunnel;
import thaumic.tinkerer.common.block.tile.TileRepairer;
import thaumic.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
@@ -68,13 +77,16 @@ import thaumic.tinkerer.common.core.handler.kami.KamiDimensionHandler;
import thaumic.tinkerer.common.core.handler.kami.SoulHeartHandler;
import thaumic.tinkerer.common.core.helper.AspectCropLootManager;
import thaumic.tinkerer.common.core.helper.BonemealEventHandler;
import thaumic.tinkerer.common.core.helper.EnumMobAspect;
import thaumic.tinkerer.common.core.helper.NumericAspectHelper;
import thaumic.tinkerer.common.enchantment.ModEnchantments;
import thaumic.tinkerer.common.enchantment.core.EnchantmentManager;
import thaumic.tinkerer.common.item.ItemBloodSword;
import thaumic.tinkerer.common.item.SpellClothCraftingHandler;
import thaumic.tinkerer.common.item.foci.ItemFocusDeflect;
import thaumic.tinkerer.common.item.kami.wand.CapIchor;
import thaumic.tinkerer.common.item.kami.wand.RodIchorcloth;
import thaumic.tinkerer.common.lib.LibMisc;
import thaumic.tinkerer.common.network.GuiHandler;
import thaumic.tinkerer.common.network.PlayerTracker;
import thaumic.tinkerer.common.network.packet.PacketEnchanterAddEnchant;
@@ -166,6 +178,10 @@ public class TTCommonProxy {
ThaumicTinkerer.log.info("Skipping TC Multipart integration");
}
if (Loader.isModLoaded("NotEnoughItems") && Loader.isModLoaded("aspectrecipeindex")) {
MinecraftForge.EVENT_BUS.register(new NEIEventHandler());
}
EMTCompat.init();
}
@@ -259,4 +275,25 @@ public class TTCommonProxy {
public void shadowSparkle(World world, float x, float y, float z, int size) {
// NO-OP
}
public String getMobDisplayName(EnumMobAspect aspect) {
return aspect.getEntity(MinecraftServer.getServer().getEntityWorld()).getCommandSenderName();
}
public static class NEIEventHandler {
@SubscribeEvent
public void registerHandler(NEIRegisterHandlerInfosEvent event) {
ItemStack necromancyTablet = new ItemStack(
ThaumicTinkerer.registry.getFirstBlockFromClass(BlockSummon.class));
event.registerHandlerInfo(
new HandlerInfo.Builder(NEINecromancyHandler.class, LibMisc.MOD_NAME, LibMisc.MOD_ID).setHeight(88)
.setDisplayStack(necromancyTablet).build());
RecipeCatalysts.putRecipeCatalysts(
NEINecromancyHandler.OVERLAY,
Arrays.asList(
new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemBloodSword.class)),
necromancyTablet));
}
}
}
@@ -88,8 +88,8 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
}
@Override
public Multimap getItemAttributeModifiers() {
Multimap<Object, Object> multimap = HashMultimap.create();
public Multimap<String, AttributeModifier> getItemAttributeModifiers() {
Multimap<String, AttributeModifier> multimap = HashMultimap.create();
multimap.put(
SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
new AttributeModifier(field_111210_e, "Weapon modifier", DAMAGE, 0));
@@ -183,24 +183,21 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
if (event.source.damageType.equals("player")) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem() == ItemBloodSword.this
&& stack.stackTagCompound != null
&& stack.stackTagCompound.getInteger("Activated") == 1) {
Aspect[] aspects = EnumMobAspect.getAspectsForEntity(event.entity);
// ScanResult sr=new ScanResult((byte)2,0,0,event.entity,"");
// AspectList as=ScanManager.getScanAspects(sr,event.entity.worldObj);
// if(as!=null && as.size()!=0){
if (aspects != null) {
event.drops.removeAll(event.drops);
// for(Aspect a:as.getAspects()){
for (Aspect a : aspects) {
addDrops(event, ItemMobAspect.getStackFromAspect(a));
}
}
if (!event.source.damageType.equals("player")) {
return;
}
EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem();
if (stack == null || stack.getItem() != ItemBloodSword.this
|| stack.stackTagCompound == null
|| stack.stackTagCompound.getInteger("Activated") != 1) {
return;
}
Aspect[] aspects = EnumMobAspect.getAspectsForEntity(event.entity);
if (aspects != null) {
event.drops.clear();
for (Aspect a : aspects) {
addDrops(event, ItemMobAspect.getStackFromAspect(a));
}
}
}
@@ -214,8 +211,7 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
boolean handle = handleNext == 0;
if (!handle) handleNext--;
if (event.entityLiving instanceof EntityPlayer && handle) {
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (event.entityLiving instanceof EntityPlayer player && handle) {
ItemStack itemInUse = player.itemInUse;
if (itemInUse != null && itemInUse.getItem() == ItemBloodSword.this) {
@@ -227,8 +223,7 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
if (handle) {
Entity source = event.source.getSourceOfDamage();
if (source != null && source instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase) source;
if (source instanceof EntityLivingBase attacker) {
ItemStack itemInUse = attacker.getHeldItem();
if (itemInUse != null && itemInUse.getItem() == ItemBloodSword.this)
attacker.attackEntityFrom(DamageSource.magic, 2);
@@ -3,15 +3,16 @@ package thaumic.tinkerer.common.item;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.core.helper.EnumMobAspect;
import thaumic.tinkerer.common.core.helper.ItemNBTHelper;
import thaumic.tinkerer.common.lib.LibItemNames;
import thaumic.tinkerer.common.registry.ItemBase;
import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
import thaumic.tinkerer.common.research.IRegisterableResearch;
/**
@@ -23,10 +24,8 @@ public class ItemMobDisplay extends ItemBase {
public ItemMobDisplay() {
super();
setHasSubtypes(true); // This allows the item to be marked as a metadata item.
setMaxDamage(0); // This makes it so your item doesn't have the damage bar at the bottom of its icon, when
// "damaged"
// similar to the Tools.
setHasSubtypes(true);
setMaxDamage(0);
}
@Override
@@ -34,21 +33,11 @@ public class ItemMobDisplay extends ItemBase {
return false;
}
@Override
public boolean shouldRegister() {
return false;
}
@Override
public IRegisterableResearch getResearchItem() {
return null;
}
@Override
public ThaumicTinkererRecipe getRecipeItem() {
return null;
}
public EnumMobAspect getEntityType(ItemStack stack) {
return EnumMobAspect.getMobAspectForType(ItemNBTHelper.getString(stack, TAG_TYPE, ""));
}
@@ -58,11 +47,10 @@ public class ItemMobDisplay extends ItemBase {
}
@Override
public void getSubItems(Item par1Item, CreativeTabs par2CreativeTabs, List list) {
super.getSubItems(par1Item, par2CreativeTabs, list);
public void getSubItems(Item par1Item, CreativeTabs par2CreativeTabs, List<ItemStack> list) {
for (EnumMobAspect aspect : EnumMobAspect.values()) {
Class aspClass = aspect.getEntityClass();
String name = (String) EntityList.classToStringMapping.get(aspClass);
Class<? extends Entity> aspClass = aspect.getEntityClass();
String name = EntityList.classToStringMapping.get(aspClass);
ItemStack item = new ItemStack(this);
this.setEntityType(item, name);
list.add(item);
@@ -73,4 +61,13 @@ public class ItemMobDisplay extends ItemBase {
public String getItemName() {
return LibItemNames.MOB_DISPLAY;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
String mob = ItemNBTHelper.getString(stack, TAG_TYPE, "");
if (mob == null || mob.isEmpty()) return super.getItemStackDisplayName(stack);
EnumMobAspect aspect = EnumMobAspect.getMobAspectForType(mob);
if (aspect == null) return super.getItemStackDisplayName(stack);
return ThaumicTinkerer.proxy.getMobDisplayName(aspect);
}
}
@@ -107,6 +107,7 @@ item.infusedPotion.Ignis.name=Potion of Ignis
item.infusedPotion.Terra.name=Potion of Terra
item.infusedPotion.Aqua.name=Potion of Aqua
item.infusedGrain.name=Imbued Grain
item.mobDisplay.name=Unknown Mob
# KAMI ITEM NAMES
item.kamiResource.name=Kami Resource
item.ichor.name=Ichor