Changed to a non-retarded way of sending a packet for the Demon Aura and created the Demon Will Viewer interface.
This commit is contained in:
parent
98ed17fe21
commit
12094c1153
3 changed files with 60 additions and 14 deletions
|
@ -0,0 +1,12 @@
|
||||||
|
package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public interface IDemonWillViewer
|
||||||
|
{
|
||||||
|
boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player);
|
||||||
|
|
||||||
|
int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player);
|
||||||
|
}
|
|
@ -1,11 +1,6 @@
|
||||||
package WayofTime.bloodmagic.network;
|
package WayofTime.bloodmagic.network;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
@ -13,6 +8,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.proxy.ClientProxy;
|
import WayofTime.bloodmagic.proxy.ClientProxy;
|
||||||
|
|
||||||
public class DemonAuraPacketProcessor implements IMessage, IMessageHandler<DemonAuraPacketProcessor, IMessage>
|
public class DemonAuraPacketProcessor implements IMessage, IMessageHandler<DemonAuraPacketProcessor, IMessage>
|
||||||
|
@ -33,13 +29,9 @@ public class DemonAuraPacketProcessor implements IMessage, IMessageHandler<Demon
|
||||||
public void fromBytes(ByteBuf buffer)
|
public void fromBytes(ByteBuf buffer)
|
||||||
{
|
{
|
||||||
PacketBuffer buff = new PacketBuffer(buffer);
|
PacketBuffer buff = new PacketBuffer(buffer);
|
||||||
try
|
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = buff.readNBTTagCompoundFromBuffer();
|
currentWill.willMap.put(type, buff.readDouble());
|
||||||
currentWill.readFromNBT(tag, "Aura");
|
|
||||||
} catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +39,10 @@ public class DemonAuraPacketProcessor implements IMessage, IMessageHandler<Demon
|
||||||
public void toBytes(ByteBuf buffer)
|
public void toBytes(ByteBuf buffer)
|
||||||
{
|
{
|
||||||
PacketBuffer buff = new PacketBuffer(buffer);
|
PacketBuffer buff = new PacketBuffer(buffer);
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||||
currentWill.writeToNBT(tag, "Aura");
|
{
|
||||||
buff.writeNBTTagCompoundToBuffer(tag);
|
buff.writeDouble(currentWill.willMap.get(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,6 +47,7 @@ import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.BlockStack;
|
import WayofTime.bloodmagic.api.BlockStack;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
||||||
|
import WayofTime.bloodmagic.api.iface.IDemonWillViewer;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||||
import WayofTime.bloodmagic.network.PlayerVelocityPacketProcessor;
|
import WayofTime.bloodmagic.network.PlayerVelocityPacketProcessor;
|
||||||
|
@ -57,6 +58,46 @@ import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
public class Utils
|
public class Utils
|
||||||
{
|
{
|
||||||
|
public static boolean canPlayerSeeDemonWill(EntityPlayer player)
|
||||||
|
{
|
||||||
|
ItemStack[] mainInventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
|
for (ItemStack stack : mainInventory)
|
||||||
|
{
|
||||||
|
if (stack == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.worldObj, stack, player))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDemonWillResolution(EntityPlayer player)
|
||||||
|
{
|
||||||
|
ItemStack[] mainInventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
|
for (ItemStack stack : mainInventory)
|
||||||
|
{
|
||||||
|
if (stack == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.worldObj, stack, player))
|
||||||
|
{
|
||||||
|
return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.worldObj, stack, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public static NBTTagCompound getPersistentDataTag(EntityPlayer player)
|
public static NBTTagCompound getPersistentDataTag(EntityPlayer player)
|
||||||
{
|
{
|
||||||
NBTTagCompound forgeData = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
|
NBTTagCompound forgeData = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue