mirror of
https://github.com/GTNewHorizons/Tainted-Magic.git
synced 2026-11-21 04:22:21 +00:00
Cleanup & bug fixes
This commit is contained in:
1 parent
54f79497e0
commit
a3bf5a1b55
11 files changed
+167
-283
No files matched your search
@@ -0,0 +1,9 @@
|
||||
package taintedmagic.api;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IEquipmentItemRenderer
|
||||
{
|
||||
abstract void render (EntityPlayer p, ItemStack s, float partialTicks);
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package taintedmagic.client;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import taintedmagic.client.handler.EquipmentItemRenderHandler;
|
||||
import taintedmagic.client.handler.HUDHandler;
|
||||
import taintedmagic.client.renderer.RenderEntityDiffusion;
|
||||
import taintedmagic.client.renderer.RenderEntityGlowpet;
|
||||
@@ -19,9 +23,6 @@ import taintedmagic.common.entities.EntityHomingShard;
|
||||
import taintedmagic.common.entities.EntityTaintBubble;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.client.renderers.entity.RenderEldritchOrb;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
@@ -30,9 +31,9 @@ public class ClientProxy extends CommonProxy
|
||||
public void registerClientHandlers ()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new HUDHandler());
|
||||
FMLCommonHandler.instance().bus().register(new HUDHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new EquipmentItemRenderHandler());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerRenderers ()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package taintedmagic.client.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import taintedmagic.api.IEquipmentItemRenderer;
|
||||
import taintedmagic.common.helper.TaintedMagicHelper;
|
||||
import taintedmagic.common.items.tools.ItemKatana;
|
||||
|
||||
public class EquipmentItemRenderHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onPlayerRender (RenderPlayerEvent.Specials.Post event)
|
||||
{
|
||||
EntityPlayer p = event.entityPlayer;
|
||||
if (p.getActivePotionEffect(Potion.invisibility) != null) return;
|
||||
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
List<Item> rendering = new ArrayList<Item>();
|
||||
for (int i = 0; i < 36; i++)
|
||||
{
|
||||
ItemStack s = inv[i];
|
||||
if (s != null && s.getItem() instanceof IEquipmentItemRenderer && !rendering.contains(s.getItem()))
|
||||
{
|
||||
((IEquipmentItemRenderer) s.getItem()).render(p, s, event.partialRenderTick);
|
||||
rendering.add(s.getItem());
|
||||
}
|
||||
if (i == 36) rendering.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package taintedmagic.common;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import taintedmagic.client.handler.EquipmentItemRenderHandler;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraftforge.common.util.EnumHelper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import taintedmagic.client.handler.EquipmentItemRenderHandler;
|
||||
import taintedmagic.common.handler.ConfigHandler;
|
||||
import taintedmagic.common.handler.TaintedMagicEventHandler;
|
||||
import taintedmagic.common.handler.UpdateHandler;
|
||||
@@ -81,7 +82,7 @@ public class TaintedMagic
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(taintedMagicEvents);
|
||||
FMLCommonHandler.instance().bus().register(taintedMagicEvents);
|
||||
|
||||
|
||||
proxy.registerRenderers();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,16 @@ package taintedmagic.common.handler;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -22,6 +26,8 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import taintedmagic.api.IBloodlust;
|
||||
import taintedmagic.api.IEquipmentItemRenderer;
|
||||
import taintedmagic.common.helper.TaintedMagicHelper;
|
||||
import taintedmagic.common.items.wand.foci.FocusUpgrades;
|
||||
import taintedmagic.common.items.wand.foci.ItemFocusMageMace;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
@@ -33,21 +39,17 @@ import thaumcraft.api.wands.StaffRod;
|
||||
import thaumcraft.api.wands.WandRod;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.items.equipment.ItemCrimsonSword;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import thaumcraft.common.lib.network.PacketHandler;
|
||||
import thaumcraft.common.lib.network.playerdata.PacketResearchComplete;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
||||
|
||||
public class TaintedMagicEventHandler
|
||||
{
|
||||
Random randy = new Random();
|
||||
|
||||
@SubscribeEvent
|
||||
public void livingTick (LivingEvent.LivingUpdateEvent event)
|
||||
public void playerTick (LivingEvent.LivingUpdateEvent event)
|
||||
{
|
||||
if (event.entity instanceof EntityPlayer)
|
||||
{
|
||||
@@ -66,7 +68,7 @@ public class TaintedMagicEventHandler
|
||||
}
|
||||
|
||||
/*
|
||||
* Used to upate the attack dmg for the Mage's Mace focus
|
||||
* Used to upate the attack dmg for the Mage'slot Mace focus
|
||||
*/
|
||||
public void updateAttackDamage (EntityPlayer p)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package taintedmagic.common.helper;
|
||||
|
||||
import baubles.api.BaublesApi;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.network.PacketHandler;
|
||||
import taintedmagic.common.network.PacketSyncInv;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.codechicken.lib.vec.Vector3;
|
||||
import thaumcraft.common.items.baubles.ItemAmuletVis;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import baubles.api.BaublesApi;
|
||||
|
||||
public class TaintedMagicHelper
|
||||
{
|
||||
@@ -44,18 +41,6 @@ public class TaintedMagicHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void syncSlotToClients (EntityPlayer p)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TaintedMagic.proxy.getClientWorld() == null) PacketHandler.INSTANCE.sendToAll(new PacketSyncInv(p));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 getDistanceBetween (Entity e, Entity target)
|
||||
{
|
||||
Vector3 fromPosition = new Vector3(e.posX, e.posY, e.posZ);
|
||||
|
||||
@@ -3,11 +3,18 @@ package taintedmagic.common.items;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,26 +24,17 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import taintedmagic.api.IEquipmentItemRenderer;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.helper.TaintedMagicHelper;
|
||||
import taintedmagic.common.items.tools.ItemKatana;
|
||||
import taintedmagic.common.network.PacketHandler;
|
||||
import taintedmagic.common.network.PacketSyncInv;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
import thaumcraft.codechicken.lib.vec.Vector3;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemFlyteCharm extends Item implements IWarpingGear
|
||||
public class ItemFlyteCharm extends Item implements IWarpingGear, IEquipmentItemRenderer
|
||||
{
|
||||
boolean isFlying = false;
|
||||
boolean synced = false;
|
||||
@@ -103,26 +101,17 @@ public class ItemFlyteCharm extends Item implements IWarpingGear
|
||||
|
||||
ItemStack s = null;
|
||||
|
||||
for (int i = 0; i < p.inventory.mainInventory.length; i++)
|
||||
InventoryPlayer inv = p.inventory;
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
if (p.inventory.mainInventory[i] != null && p.inventory.mainInventory[i].getItem() instanceof ItemFlyteCharm)
|
||||
ItemStack stackInSlot = inv.getStackInSlot(i);
|
||||
if (stackInSlot != null && stackInSlot.getItem() instanceof ItemKatana)
|
||||
{
|
||||
if (!this.synced)
|
||||
{
|
||||
// sync slot to other players
|
||||
TaintedMagicHelper.syncSlotToClients(p.inventory.player);
|
||||
this.synced = true;
|
||||
}
|
||||
s = p.inventory.mainInventory[i];
|
||||
s = stackInSlot;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.synced)
|
||||
{
|
||||
TaintedMagicHelper.syncSlotToClients(p.inventory.player);
|
||||
this.synced = false;
|
||||
}
|
||||
s = null;
|
||||
}
|
||||
}
|
||||
@@ -224,64 +213,46 @@ public class ItemFlyteCharm extends Item implements IWarpingGear
|
||||
return 5;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly (Side.CLIENT)
|
||||
public void renderPlayer (RenderPlayerEvent.Specials.Post event)
|
||||
@Override
|
||||
public void render (EntityPlayer p, ItemStack s, float pT)
|
||||
{
|
||||
EntityPlayer p = event.entityPlayer;
|
||||
if (p.getActivePotionEffect(Potion.invisibility) != null) return;
|
||||
GL11.glPushMatrix();
|
||||
|
||||
ItemStack s = null;
|
||||
for (int i = 0; i < p.inventory.getSizeInventory(); i++)
|
||||
{
|
||||
if (p.inventory.getStackInSlot(i) != null && p.inventory.getStackInSlot(i).getItem() instanceof ItemFlyteCharm)
|
||||
{
|
||||
s = p.inventory.getStackInSlot(i);
|
||||
break;
|
||||
}
|
||||
else s = null;
|
||||
}
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, (p != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - p.getDefaultEyeHeight() + (p.isSneaking() ? 0.0625 : 0), 0);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glRotatef(45, -1, 0, -1);
|
||||
GL11.glTranslatef(0.0F, -0.5F, -0.2F);
|
||||
|
||||
GL11.glTranslated(0, (p != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - p.getDefaultEyeHeight() + (p.isSneaking() ? 0.0625 : 0), 0);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
|
||||
GL11.glRotatef(45, -1, 0, -1);
|
||||
GL11.glTranslatef(0.0F, -0.5F, -0.2F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.8F);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
Tessellator t = Tessellator.instance;
|
||||
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.8F);
|
||||
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
||||
GL11.glRotatef(p.ticksExisted + pT, 0F, 1F, 0F);
|
||||
|
||||
Tessellator t = Tessellator.instance;
|
||||
UtilsFX.bindTexture(circle);
|
||||
|
||||
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
||||
GL11.glRotatef(p.ticksExisted + event.partialRenderTick, 0F, 1F, 0F);
|
||||
t.startDrawingQuads();
|
||||
t.addVertexWithUV(-1, 0, -1, 0, 0);
|
||||
t.addVertexWithUV(-1, 0, 1, 0, 1);
|
||||
t.addVertexWithUV(1, 0, 1, 1, 1);
|
||||
t.addVertexWithUV(1, 0, -1, 1, 0);
|
||||
t.draw();
|
||||
|
||||
UtilsFX.bindTexture(circle);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
t.startDrawingQuads();
|
||||
t.addVertexWithUV(-1, 0, -1, 0, 0);
|
||||
t.addVertexWithUV(-1, 0, 1, 0, 1);
|
||||
t.addVertexWithUV(1, 0, 1, 1, 1);
|
||||
t.addVertexWithUV(1, 0, -1, 1, 0);
|
||||
t.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,13 @@ package taintedmagic.common.items.tools;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
@@ -28,28 +35,20 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import taintedmagic.api.IEquipmentItemRenderer;
|
||||
import taintedmagic.client.model.ModelKatana;
|
||||
import taintedmagic.client.model.ModelSaya;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.entities.EntityTaintBubble;
|
||||
import taintedmagic.common.helper.TaintedMagicHelper;
|
||||
import taintedmagic.common.items.ItemFlyteCharm;
|
||||
import taintedmagic.common.network.PacketHandler;
|
||||
import taintedmagic.common.network.PacketKatanaAttack;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.entities.projectile.EntityExplosiveOrb;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemKatana extends Item implements IWarpingGear, IRepairable
|
||||
public class ItemKatana extends Item implements IWarpingGear, IRepairable, IEquipmentItemRenderer
|
||||
{
|
||||
public static final int SUBTYPES = 3;
|
||||
|
||||
@@ -70,39 +69,6 @@ public class ItemKatana extends Item implements IWarpingGear, IRepairable
|
||||
this.setUnlocalizedName("ItemKatana");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerTick (LivingEvent.LivingUpdateEvent event)
|
||||
{
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer p = (EntityPlayer) event.entityLiving;
|
||||
for (int i = 0; i < p.inventory.mainInventory.length; i++)
|
||||
{
|
||||
if (p.inventory.mainInventory[i] != null && p.inventory.mainInventory[i].getItem() instanceof ItemKatana)
|
||||
{
|
||||
if (!this.synced)
|
||||
{
|
||||
// sync slot to other players
|
||||
TaintedMagicHelper.syncSlotToClients(p.inventory.player);
|
||||
this.synced = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.synced)
|
||||
{
|
||||
TaintedMagicHelper.syncSlotToClients(p.inventory.player);
|
||||
this.synced = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -320,68 +286,6 @@ public class ItemKatana extends Item implements IWarpingGear, IRepairable
|
||||
else return false;
|
||||
}
|
||||
|
||||
@SideOnly (Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onPlayerRender (RenderPlayerEvent.Specials.Post event)
|
||||
{
|
||||
EntityPlayer p = event.entityPlayer;
|
||||
if (p.getActivePotionEffect(Potion.invisibility) != null) return;
|
||||
|
||||
ItemStack s = null;
|
||||
for (int i = 0; i < p.inventory.getSizeInventory(); i++)
|
||||
{
|
||||
if (p.inventory.getStackInSlot(i) != null && p.inventory.getStackInSlot(i).getItem() instanceof ItemKatana)
|
||||
{
|
||||
s = p.inventory.getStackInSlot(i);
|
||||
break;
|
||||
}
|
||||
else s = null;
|
||||
}
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
int light = p.getBrightnessForRender(0);
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(55, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(-0.6F, 2.25F, 1.25F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture(s));
|
||||
saya.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (p.getHeldItem() == null || p.getHeldItem() != s)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(55, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(-0.6F, 2.25F, 1.25F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture(s));
|
||||
katana.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly (Side.CLIENT)
|
||||
public static void renderHUD (ScaledResolution r, EntityPlayer p, float pT)
|
||||
{
|
||||
@@ -492,4 +396,48 @@ public class ItemKatana extends Item implements IWarpingGear, IRepairable
|
||||
{
|
||||
return s.getItemDamage() == 0 ? 0 : s.getItemDamage() == 1 ? 3 : 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render (EntityPlayer p, ItemStack s, float pT)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
int light = p.getBrightnessForRender(0);
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(55, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(-0.6F, 2.25F, 1.25F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture(s));
|
||||
saya.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (p.getHeldItem() == null || p.getHeldItem() != s)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(55, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(-0.6F, 2.25F, 1.25F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture(s));
|
||||
katana.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package taintedmagic.common.network;
|
||||
|
||||
import taintedmagic.common.lib.LibInfo;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import taintedmagic.common.lib.LibInfo;
|
||||
|
||||
public class PacketHandler
|
||||
{
|
||||
@@ -13,6 +13,5 @@ public class PacketHandler
|
||||
{
|
||||
int idx = 0;
|
||||
INSTANCE.registerMessage(PacketKatanaAttack.class, PacketKatanaAttack.class, idx++, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketSyncInv.class, PacketSyncInv.class, idx++, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package taintedmagic.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.World;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketSyncInv implements IMessage, IMessageHandler<PacketSyncInv, IMessage>
|
||||
{
|
||||
int playerID;
|
||||
ItemStack[] inv = null;
|
||||
|
||||
public PacketSyncInv ()
|
||||
{
|
||||
}
|
||||
|
||||
public PacketSyncInv (EntityPlayer p)
|
||||
{
|
||||
this.playerID = p.getEntityId();
|
||||
this.inv = p.inventory.mainInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage (PacketSyncInv message, MessageContext ctx)
|
||||
{
|
||||
World w = TaintedMagic.proxy.getClientWorld();
|
||||
if (w == null) return null;
|
||||
|
||||
Entity p = w.getEntityByID(message.playerID);
|
||||
if (p != null && p instanceof EntityPlayer) ((EntityPlayer) p).inventory.mainInventory = message.inv;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes (ByteBuf buf)
|
||||
{
|
||||
playerID = buf.readInt();
|
||||
PacketBuffer pb = new PacketBuffer(buf);
|
||||
try
|
||||
{
|
||||
ItemStack[] s = new ItemStack[36];
|
||||
for (int i = 0; i < 36; i++)
|
||||
s[i] = pb.readItemStackFromBuffer();
|
||||
inv = s;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes (ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(playerID);
|
||||
PacketBuffer pb = new PacketBuffer(buf);
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < 36; i++)
|
||||
pb.writeItemStackToBuffer(inv[i]);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user