Added player and world to getNBTData for entities.

This commit is contained in:
Thomas Guimbretiere committed 2014-12-17 01:20:37 +01:00
1 parent 5978494340
commit 146e30cbda
4 files changed
+21 -5

No files matched your search

@@ -3,6 +3,7 @@ package mcp.mobius.waila.addons.stevescarts;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -85,7 +86,7 @@ public class HUDMinecartModular implements IWailaEntityProvider {
}
@Override
public NBTTagCompound getNBTData(Entity te, NBTTagCompound tag) {
public NBTTagCompound getNBTData(EntityPlayerMP player, Entity te, NBTTagCompound tag, World world) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -3,6 +3,7 @@ package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -22,5 +23,5 @@ public interface IWailaEntityProvider {
* NBTTagCompound tag argument is the current NBT tag passed along by the various providers (first provider will be empty).
* You HAVE TO return it if you registered as a provider, even if you are not doing anything to it (similar to the tooltip lists).
* */
NBTTagCompound getNBTData(Entity ent, NBTTagCompound tag);
NBTTagCompound getNBTData(EntityPlayerMP player, Entity ent, NBTTagCompound tag, World world);
}
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
@@ -98,7 +99,7 @@ public class HUDHandlerEntities implements IWailaEntityProvider {
}
@Override
public NBTTagCompound getNBTData(Entity te, NBTTagCompound tag) {
public NBTTagCompound getNBTData(EntityPlayerMP player, Entity te, NBTTagCompound tag, World world) {
return tag;
}
@@ -1,16 +1,20 @@
package mcp.mobius.waila.network;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.NBTUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -72,9 +76,18 @@ public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x
try{
NBTTagCompound tag = new NBTTagCompound();
EntityPlayerMP player = ((NetHandlerPlayServer) ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).playerEntity;
if (ModuleRegistrar.instance().hasNBTEntityProviders(entity)){
for (IWailaEntityProvider provider : ModuleRegistrar.instance().getNBTEntityProviders(entity))
tag = provider.getNBTData(entity, tag);
for (IWailaEntityProvider provider : ModuleRegistrar.instance().getNBTEntityProviders(entity)){
try{
tag = provider.getNBTData(player, entity, tag, world);
} catch (AbstractMethodError ame){
Method getNBTData = provider.getClass().getMethod("getNBTData", Entity.class, NBTTagCompound.class);
tag = (NBTTagCompound)getNBTData.invoke(provider, entity, tag);
}
}
} else {
entity.writeToNBT(tag);
tag = NBTUtil.createTag(tag, msg.keys);