Fixed tesla linking not working
This commit is contained in:
parent
9a444efca1
commit
d95cea31e0
3 changed files with 46 additions and 28 deletions
|
@ -62,7 +62,8 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
|
|||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
energy.setMaxTransfer((long) Math.min(Math.pow(10000, this.getNetwork().getConnectors().size()), energy.getEnergyCapacity()));
|
||||
//energy.setMaxTransfer((long) Math.min(Math.pow(10000, this.getNetwork().getConnectors().size()), energy.getEnergyCapacity()));
|
||||
energy.setMaxTransfer(energy.getEnergyCapacity());
|
||||
markDistributionUpdate |= produce() > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,18 @@ package resonantinduction.electrical.tesla;
|
|||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.MultipartUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||
import universalelectricity.api.UniversalElectricity;
|
||||
import universalelectricity.api.vector.VectorWorld;
|
||||
import calclavia.components.tool.ToolModeLink;
|
||||
import calclavia.lib.prefab.block.BlockSidedIO;
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import calclavia.lib.utility.WrenchUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -91,6 +95,38 @@ public class BlockTesla extends BlockSidedIO implements ITileEntityProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileTesla)
|
||||
{
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
|
||||
if (WrenchUtility.isWrench(itemStack))
|
||||
{
|
||||
if (((TileTesla)tile).tryLink(ToolModeLink.getLink(itemStack)))
|
||||
{
|
||||
if (world.isRemote)
|
||||
player.addChatMessage("Successfully linked devices.");
|
||||
ToolModeLink.clearLink(itemStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (world.isRemote)
|
||||
player.addChatMessage("Marked link for device.");
|
||||
|
||||
ToolModeLink.setLink(itemStack, new VectorWorld(world, x, y, z));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.MultipartUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.Settings;
|
||||
|
@ -31,10 +32,9 @@ import calclavia.lib.multiblock.reference.IMultiBlockStructure;
|
|||
import calclavia.lib.multiblock.reference.MultiBlockHandler;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.IPacketSender;
|
||||
import calclavia.lib.prefab.block.ILinkable;
|
||||
import calclavia.lib.prefab.tile.TileElectrical;
|
||||
import calclavia.lib.render.EnumColor;
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -48,7 +48,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileTesla extends TileElectrical implements IMultiBlockStructure<TileTesla>, ITesla, IPacketSender, IPacketReceiver, ILinkable
|
||||
public class TileTesla extends TileElectrical implements IMultiBlockStructure<TileTesla>, ITesla, IPacketSender, IPacketReceiver
|
||||
{
|
||||
public final static int DEFAULT_COLOR = 12;
|
||||
public final long TRANSFER_CAP = 10000;
|
||||
|
@ -578,35 +578,16 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLink(EntityPlayer player, VectorWorld vector)
|
||||
public boolean tryLink(VectorWorld vector)
|
||||
{
|
||||
if (linked == null)
|
||||
if (vector != null)
|
||||
{
|
||||
if (vector != null)
|
||||
if (vector.getTileEntity() instanceof TileTesla)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
World otherWorld = vector.world;
|
||||
|
||||
if (vector.getTileEntity(otherWorld) instanceof TileTesla)
|
||||
{
|
||||
this.setLink(new Vector3(((TileTesla) vector.getTileEntity(otherWorld)).getTopTelsa()), vector.world.provider.dimensionId, true);
|
||||
player.addChatMessage(LanguageUtility.getLocal("message.tesla.pair").replace("%v0", this.getBlockType().getLocalizedName()).replace("%v1", vector.x + "").replace("%v2", vector.y + "").replace("%v3", vector.z + ""));
|
||||
worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, "ambient.weather.thunder", 5, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
setLink(vector, vector.world.provider.dimensionId, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setLink(null, worldObj.provider.dimensionId, true);
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
player.addChatMessage("Unlinked Tesla.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue