Added wire coloring, no visuals yet
This commit is contained in:
parent
e3551fcefd
commit
2701b2b39c
6 changed files with 106 additions and 17 deletions
BIN
resources/assets/resonantinduction/textures/blocks/wire.png
Normal file
BIN
resources/assets/resonantinduction/textures/blocks/wire.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -64,7 +64,7 @@ public class PacketHandler implements IPacketHandler
|
||||||
|
|
||||||
if (tileEntity instanceof IPacketReceiver)
|
if (tileEntity instanceof IPacketReceiver)
|
||||||
{
|
{
|
||||||
sendTileEntityPacketToClients(tileEntity, ((IPacketReceiver) tileEntity).getNetworkedData(new ArrayList()).toArray());
|
sendPacketToAllPlayers(tileEntity, ((IPacketReceiver) tileEntity).getNetworkedData(new ArrayList()).toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,12 +140,12 @@ public class PacketHandler implements IPacketHandler
|
||||||
PacketDispatcher.sendPacketToServer(packet);
|
PacketDispatcher.sendPacketToServer(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTileEntityPacketToServer(TileEntity tileEntity, Object... dataValues)
|
public static void sendPacketToServer(TileEntity tileEntity, Object... dataValues)
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToServer(getTileEntityPacket(tileEntity, dataValues));
|
PacketDispatcher.sendPacketToServer(getTileEntityPacket(tileEntity, dataValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTileEntityPacketToClients(TileEntity tileEntity, Object... dataValues)
|
public static void sendPacketToAllPlayers(TileEntity tileEntity, Object... dataValues)
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToAllPlayers(getTileEntityPacket(tileEntity, dataValues));
|
PacketDispatcher.sendPacketToAllPlayers(getTileEntityPacket(tileEntity, dataValues));
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
||||||
|
|
||||||
public void updateClient()
|
public void updateClient()
|
||||||
{
|
{
|
||||||
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
PacketHandler.sendPacketToAllPlayers(this, getNetworkedData(new ArrayList()).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAllClients()
|
public void updateAllClients()
|
||||||
|
@ -134,7 +134,7 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
||||||
for (Vector3 vec : structure.locations)
|
for (Vector3 vec : structure.locations)
|
||||||
{
|
{
|
||||||
TileEntityBattery battery = (TileEntityBattery) vec.getTileEntity(worldObj);
|
TileEntityBattery battery = (TileEntityBattery) vec.getTileEntity(worldObj);
|
||||||
PacketHandler.sendTileEntityPacketToClients(battery, battery.getNetworkedData(new ArrayList()).toArray());
|
PacketHandler.sendPacketToAllPlayers(battery, battery.getNetworkedData(new ArrayList()).toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class GuiMultimeter extends GuiContainer
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PacketHandler.sendTileEntityPacketToServer(this.tileEntity, (byte) 3, Float.parseFloat(this.textFieldLimit.getText()));
|
PacketHandler.sendPacketToServer(this.tileEntity, (byte) 3, Float.parseFloat(this.textFieldLimit.getText()));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ public class GuiMultimeter extends GuiContainer
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button)
|
protected void actionPerformed(GuiButton button)
|
||||||
{
|
{
|
||||||
PacketHandler.sendTileEntityPacketToServer(this.tileEntity, (byte) 2);
|
PacketHandler.sendPacketToServer(this.tileEntity, (byte) 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -33,6 +35,24 @@ public class BlockWire extends BlockConductor
|
||||||
this.setCreativeTab(TabRI.INSTANCE);
|
this.setCreativeTab(TabRI.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||||
|
{
|
||||||
|
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||||
|
TileEntityWire tileEntity = (TileEntityWire) t;
|
||||||
|
|
||||||
|
if (entityPlayer.getCurrentEquippedItem() != null)
|
||||||
|
{
|
||||||
|
if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||||
|
{
|
||||||
|
tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the
|
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the
|
||||||
* shared face of two adjacent blocks and also whether the player can attach torches, redstone
|
* shared face of two adjacent blocks and also whether the player can attach torches, redstone
|
||||||
|
@ -69,6 +89,12 @@ public class BlockWire extends BlockConductor
|
||||||
return new TileEntityTickWire();
|
return new TileEntityTickWire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int damageDropped(int par1)
|
||||||
|
{
|
||||||
|
return par1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
package resonantinduction.wire;
|
package resonantinduction.wire;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockFurnace;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.PacketHandler;
|
||||||
|
import resonantinduction.base.IPacketReceiver;
|
||||||
import universalelectricity.compatibility.TileEntityUniversalConductor;
|
import universalelectricity.compatibility.TileEntityUniversalConductor;
|
||||||
import universalelectricity.core.block.IConnector;
|
|
||||||
import universalelectricity.core.block.INetworkProvider;
|
import universalelectricity.core.block.INetworkProvider;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
import universalelectricity.core.vector.VectorHelper;
|
import universalelectricity.core.vector.VectorHelper;
|
||||||
|
|
||||||
public class TileEntityWire extends TileEntityUniversalConductor
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
public class TileEntityWire extends TileEntityUniversalConductor implements IPacketReceiver
|
||||||
{
|
{
|
||||||
|
public int dyeID = -1;
|
||||||
|
public boolean isInsulated = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection direction)
|
public boolean canConnect(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
|
@ -27,9 +30,14 @@ public class TileEntityWire extends TileEntityUniversalConductor
|
||||||
|
|
||||||
Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction);
|
Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction);
|
||||||
|
|
||||||
if (connectPos.getTileEntity(this.worldObj) instanceof TileEntityWire && connectPos.getBlockMetadata(this.worldObj) != this.getTypeID())
|
if (connectPos.getTileEntity(this.worldObj) instanceof TileEntityWire)
|
||||||
{
|
{
|
||||||
return false;
|
TileEntityWire tileWire = (TileEntityWire) connectPos.getTileEntity(this.worldObj);
|
||||||
|
|
||||||
|
if ((tileWire.isInsulated && this.isInsulated && tileWire.dyeID != this.dyeID && this.dyeID != -1) || connectPos.getBlockMetadata(this.worldObj) != this.getTypeID())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -83,4 +91,59 @@ public class TileEntityWire extends TileEntityUniversalConductor
|
||||||
{
|
{
|
||||||
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dyeID
|
||||||
|
*/
|
||||||
|
public void setDye(int dyeID)
|
||||||
|
{
|
||||||
|
this.dyeID = dyeID;
|
||||||
|
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket()
|
||||||
|
{
|
||||||
|
return PacketHandler.getTileEntityPacket(this, this.dyeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(ByteArrayDataInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.dyeID = input.readInt();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a tile entity from NBT.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
this.dyeID = nbt.getInteger("dyeID");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a tile entity to NBT.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
nbt.setInteger("dyeID", this.dyeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList getNetworkedData(ArrayList data)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue