summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorLance5057 <Lance5057@gmail.com>2015-03-11 17:35:41 -0500
committerLance5057 <Lance5057@gmail.com>2015-03-11 17:35:41 -0500
commitf67a4599861ccf1efd0707413cb6b69e63e49f75 (patch)
tree81451a0c94e6298d3135893a184e030545bc02fa /src/main
parentfad218d842cac7a9b8bf4d57020c79c690c17183 (diff)
Flipping in Crest Mount works.
Sorta glitchy still.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java4
-rw-r--r--src/main/java/gmail/Lance5057/gui/Gui_CrestMount.java28
-rw-r--r--src/main/java/gmail/Lance5057/network/Handler_CrestMount.java24
-rw-r--r--src/main/java/gmail/Lance5057/network/Message_CrestMount.java55
-rw-r--r--src/main/java/gmail/Lance5057/network/PacketHandler.java14
-rw-r--r--src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java15
6 files changed, 112 insertions, 28 deletions
diff --git a/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java b/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java
index 47dae73..3c3c1c6 100644
--- a/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java
+++ b/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java
@@ -10,6 +10,7 @@ import gmail.Lance5057.blocks.QueensGoldBlock;
import gmail.Lance5057.items.AeonSteelIngot;
import gmail.Lance5057.items.DogbeariumIngot;
import gmail.Lance5057.items.QueensGoldIngot;
+import gmail.Lance5057.network.PacketHandler;
import gmail.Lance5057.proxy.CommonProxy;
import gmail.Lance5057.tileentities.TileEntity_CrestMount;
import net.minecraft.block.Block;
@@ -59,7 +60,7 @@ public Item getTabIconItem() { return Items.arrow; }
};
-public static SimpleNetworkWrapper network;
+public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID);
public static Item item_AeonSteelIngot;
public static Block block_AeonSteelBlock;
@@ -95,6 +96,7 @@ public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent e)
{
+ PacketHandler.init();
//Renderers
proxy.registerRenderers();
diff --git a/src/main/java/gmail/Lance5057/gui/Gui_CrestMount.java b/src/main/java/gmail/Lance5057/gui/Gui_CrestMount.java
index 4824a39..72b876b 100644
--- a/src/main/java/gmail/Lance5057/gui/Gui_CrestMount.java
+++ b/src/main/java/gmail/Lance5057/gui/Gui_CrestMount.java
@@ -1,6 +1,8 @@
package gmail.Lance5057.gui;
+import gmail.Lance5057.com.mod_TinkersDefense;
import gmail.Lance5057.containers.Container_CrestMount;
+import gmail.Lance5057.network.Message_CrestMount;
import gmail.Lance5057.tileentities.TileEntity_CrestMount;
import javax.swing.plaf.basic.BasicComboBoxUI.KeyHandler;
@@ -21,16 +23,11 @@ import org.lwjgl.opengl.GL12;
public class Gui_CrestMount extends GuiContainer
{
-/** x and y size of the inventory window in pixels. Defined as float, passed as int
-* These are used for drawing the player model. */
private float xSize_lo;
private float ySize_lo;
-/** ResourceLocation takes 2 parameters: ModId, path to texture at the location:
-* "src/minecraft/assets/modid/" */
private static final ResourceLocation iconLocation = new ResourceLocation("tinkersdefense", "textures/gui/crest_mount.png");
-/** The inventory to render on screen */
private final TileEntity_CrestMount inventory;
public Gui_CrestMount(InventoryPlayer invPlayer, TileEntity_CrestMount te_crest)
@@ -45,11 +42,10 @@ this.inventory = te_crest;
public void initGui()
{
super.initGui();
- //ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
- this.buttonList.add(new GuiButton(1,this.guiLeft + 61, this.guiTop + 10, 16, 16,"Flip"));
- this.buttonList.add(new GuiButton(2,this.guiLeft + 16, this.guiTop + 16, 16, 16,"Flip"));
- this.buttonList.add(new GuiButton(3,this.guiLeft + 16, this.guiTop + 32, 16, 16,"Flip"));
- this.buttonList.add(new GuiButton(4,this.guiLeft + 16, this.guiTop + 48, 16, 16,"Flip"));
+ this.buttonList.add(new GuiButton(1,this.guiLeft + 60, this.guiTop + 10, 18, 18,"Flip"));
+ this.buttonList.add(new GuiButton(2,this.guiLeft + 94, this.guiTop + 10, 18, 18,"Flip"));
+ this.buttonList.add(new GuiButton(3,this.guiLeft + 78, this.guiTop + 10, 18, 18,"Flip"));
+ this.buttonList.add(new GuiButton(4,this.guiLeft + 77, this.guiTop + 64, 18, 18,"Flip"));
}
@Override
@@ -64,15 +60,11 @@ protected void actionPerformed(GuiButton button)
else
inventory.flip[i-1]=false;
- inventory.getWorldObj().markBlockForUpdate(inventory.xCoord, inventory.yCoord, inventory.zCoord);
- inventory.markDirty();
+ mod_TinkersDefense.INSTANCE.sendToServer(new Message_CrestMount(inventory.xCoord, inventory.yCoord, inventory.zCoord, inventory.flip));
}
}
}
-/**
-* Draws the screen and all the components in it.
-*/
public void drawScreen(int par1, int par2, float par3)
{
super.drawScreen(par1, par2, par3);
@@ -80,17 +72,11 @@ this.xSize_lo = (float)par1;
this.ySize_lo = (float)par2;
}
-/**
-* Draw the foreground layer for the GuiContainer (everything in front of the items)
-*/
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
}
-/**
-* Draw the background layer for the GuiContainer (everything behind the items)
-*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
diff --git a/src/main/java/gmail/Lance5057/network/Handler_CrestMount.java b/src/main/java/gmail/Lance5057/network/Handler_CrestMount.java
new file mode 100644
index 0000000..fa1a89c
--- /dev/null
+++ b/src/main/java/gmail/Lance5057/network/Handler_CrestMount.java
@@ -0,0 +1,24 @@
+package gmail.Lance5057.network;
+
+import ibxm.Player;
+import gmail.Lance5057.tileentities.TileEntity_CrestMount;
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+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 Handler_CrestMount implements IMessageHandler<Message_CrestMount, IMessage>
+{
+ @Override
+ public IMessage onMessage(Message_CrestMount message, MessageContext ctx)
+ {
+ TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
+ if (te instanceof TileEntity_CrestMount) {
+ ((TileEntity_CrestMount) te).flip = message.flip;
+ }
+ return null;
+ }
+}
+
diff --git a/src/main/java/gmail/Lance5057/network/Message_CrestMount.java b/src/main/java/gmail/Lance5057/network/Message_CrestMount.java
new file mode 100644
index 0000000..6034726
--- /dev/null
+++ b/src/main/java/gmail/Lance5057/network/Message_CrestMount.java
@@ -0,0 +1,55 @@
+package gmail.Lance5057.network;
+
+import gmail.Lance5057.tileentities.TileEntity_CrestMount;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.client.Minecraft;
+import net.minecraft.tileentity.TileEntity;
+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 Message_CrestMount implements IMessage
+{
+ public int x, y, z;
+ public boolean[] flip = new boolean[4];
+
+ public Message_CrestMount()
+ {
+
+ }
+
+ public Message_CrestMount(int x, int y, int z, boolean[] flip)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ System.arraycopy(flip, 0, this.flip, 0, flip.length);
+
+ }
+
+
+
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ this.x = buf.readInt();
+ this.y = buf.readInt();
+ this.z = buf.readInt();
+ for(int i = 0; i<flip.length; i++)
+ {
+ this.flip[i] = buf.readBoolean();
+ }
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ buf.writeInt(x);
+ buf.writeInt(y);
+ buf.writeInt(z);
+ for(int i = 0; i<flip.length; i++)
+ {
+ buf.writeBoolean(flip[i]);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gmail/Lance5057/network/PacketHandler.java b/src/main/java/gmail/Lance5057/network/PacketHandler.java
new file mode 100644
index 0000000..002d779
--- /dev/null
+++ b/src/main/java/gmail/Lance5057/network/PacketHandler.java
@@ -0,0 +1,14 @@
+package gmail.Lance5057.network;
+
+import gmail.Lance5057.com.mod_TinkersDefense;
+import cpw.mods.fml.relauncher.Side;
+
+public class PacketHandler {
+ private static int id = 0;
+
+ public static void init()
+ {
+ mod_TinkersDefense.INSTANCE.registerMessage(Handler_CrestMount.class, Message_CrestMount.class,id++,Side.SERVER);
+
+ }
+}
diff --git a/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java b/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java
index 8e96516..d8384ed 100644
--- a/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java
+++ b/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java
@@ -23,17 +23,20 @@ public class TileEntity_CrestMount extends TileEntity implements IInventory
{
super();
inventory = new ItemStack[invSize];
+ flip = new boolean[4];
}
@Override
public void updateEntity()
{
super.updateEntity();
- if (worldObj.isRemote)
- {
-
-
- }
+// if (!worldObj.isRemote)
+// {
+
+ getWorldObj().markBlockForUpdate(xCoord, yCoord, zCoord);
+ markDirty();
+//
+// }
}
@Override
@@ -159,7 +162,7 @@ public class TileEntity_CrestMount extends TileEntity implements IInventory
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
- flip = new boolean[4];
+
flip[0] = compound.getBoolean("flip_1");
flip[1] = compound.getBoolean("flip_2");
flip[2] = compound.getBoolean("flip_3");