Added multimeter, no OP

This commit is contained in:
Calclavia 2013-08-03 19:19:20 -04:00
parent ba0494c624
commit 32cbb970f4
17 changed files with 338 additions and 289 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

View file

@ -1,18 +0,0 @@
/**
*
*/
package resonantinduction;
import net.minecraft.tileentity.TileEntity;
/**
* @author Calclavia
*
*/
public interface ITesla
{
public void transfer(float transferEnergy);
public boolean canReceive(TileEntity tileEntity);
}

View file

@ -58,9 +58,9 @@ public class PacketHandler implements IPacketHandler
int x = dataStream.readInt(); int x = dataStream.readInt();
int y = dataStream.readInt(); int y = dataStream.readInt();
int z = dataStream.readInt(); int z = dataStream.readInt();
TileEntity tileEntity = world.getBlockTileEntity(x, y, z); TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IPacketReceiver) if (tileEntity instanceof IPacketReceiver)
{ {
sendTileEntityPacketToClients(tileEntity, ((IPacketReceiver) tileEntity).getNetworkedData(new ArrayList()).toArray()); sendTileEntityPacketToClients(tileEntity, ((IPacketReceiver) tileEntity).getNetworkedData(new ArrayList()).toArray());
@ -106,7 +106,7 @@ public class PacketHandler implements IPacketHandler
} }
else if (data instanceof Object[]) else if (data instanceof Object[])
{ {
encode((Object[])data, output); encode((Object[]) data, output);
} }
} }
} }
@ -114,7 +114,7 @@ public class PacketHandler implements IPacketHandler
{ {
} }
} }
public static void sendDataRequest(TileEntity tileEntity) public static void sendDataRequest(TileEntity tileEntity)
{ {
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@ -135,7 +135,7 @@ public class PacketHandler implements IPacketHandler
packet.channel = ResonantInduction.CHANNEL; packet.channel = ResonantInduction.CHANNEL;
packet.data = bytes.toByteArray(); packet.data = bytes.toByteArray();
packet.length = packet.data.length; packet.length = packet.data.length;
PacketDispatcher.sendPacketToServer(packet); PacketDispatcher.sendPacketToServer(packet);
} }
@ -177,7 +177,6 @@ public class PacketHandler implements IPacketHandler
public static enum PacketType public static enum PacketType
{ {
TILE, TILE, DATA_REQUEST
DATA_REQUEST
} }
} }

View file

@ -13,6 +13,7 @@ import resonantinduction.contractor.BlockEMContractor;
import resonantinduction.contractor.ItemBlockContractor; import resonantinduction.contractor.ItemBlockContractor;
import resonantinduction.contractor.TileEntityEMContractor; import resonantinduction.contractor.TileEntityEMContractor;
import resonantinduction.entangler.ItemQuantumEntangler; import resonantinduction.entangler.ItemQuantumEntangler;
import resonantinduction.multimeter.BlockMultimeter;
import resonantinduction.tesla.BlockTesla; import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
@ -106,6 +107,7 @@ public class ResonantInduction
// Blocks // Blocks
public static Block blockTesla; public static Block blockTesla;
public static Block blockMultimeter;
public static Block blockEMContractor; public static Block blockEMContractor;
@EventHandler @EventHandler
@ -118,15 +120,18 @@ public class ResonantInduction
// Config // Config
POWER_PER_COAL = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Coal Wattage", POWER_PER_COAL).getDouble(POWER_PER_COAL); POWER_PER_COAL = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Coal Wattage", POWER_PER_COAL).getDouble(POWER_PER_COAL);
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS); SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
// Items // Items
itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID()); itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID());
GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName()); GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName());
// Blocks // Blocks
blockTesla = new BlockTesla(getNextBlockID()); blockTesla = new BlockTesla(getNextBlockID());
blockMultimeter = new BlockMultimeter(getNextBlockID());
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName()); GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerBlock(blockMultimeter, blockMultimeter.getUnlocalizedName());
blockEMContractor = new BlockEMContractor(getNextBlockID()); blockEMContractor = new BlockEMContractor(getNextBlockID());
GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName()); GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName());

View file

@ -0,0 +1,23 @@
/**
*
*/
package resonantinduction.api;
import net.minecraft.tileentity.TileEntity;
/**
* @author Calclavia
*
*/
public interface ITesla
{
/**
* @param transferEnergy - The energy amount in kilojoules.
* @param doTransfer - Actually transfer
* @return Energy actually transfered.
*/
public float transfer(float transferEnergy, boolean doTransfer);
public boolean canReceive(TileEntity transferTile);
}

View file

@ -4,9 +4,9 @@ import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public interface IPacketReceiver public interface IPacketReceiver
{ {
public void handle(ByteArrayDataInput input); public void handle(ByteArrayDataInput input);
public ArrayList getNetworkedData(ArrayList data); public ArrayList getNetworkedData(ArrayList data);
} }

View file

@ -241,8 +241,9 @@ public class Vector3
Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance); Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
double checkBorder = 1.1 * reachDistance; double checkBorder = 1.1 * reachDistance;
AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);; AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);
;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan); List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
double closestEntity = reachDistance; double closestEntity = reachDistance;

View file

@ -2,12 +2,9 @@ package resonantinduction.contractor;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
@ -18,7 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockEMContractor extends BlockBase implements ITileEntityProvider public class BlockEMContractor extends BlockBase implements ITileEntityProvider
{ {
public BlockEMContractor(int id) public BlockEMContractor(int id)
{ {
super("contractor", id, Material.iron); super("contractor", id, Material.iron);
this.func_111022_d(ResonantInduction.PREFIX + "machine"); this.func_111022_d(ResonantInduction.PREFIX + "machine");
@ -30,35 +27,36 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
{ {
return BlockRenderingHandler.INSTANCE.getRenderId(); return BlockRenderingHandler.INSTANCE.getRenderId();
} }
@Override @Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{ {
TileEntityEMContractor contractor = (TileEntityEMContractor)par1World.getBlockTileEntity(par2, par3, par4); TileEntityEMContractor contractor = (TileEntityEMContractor) par1World.getBlockTileEntity(par2, par3, par4);
if(!par5EntityPlayer.isSneaking()) if (!par5EntityPlayer.isSneaking())
{ {
contractor.incrementFacing(); contractor.incrementFacing();
} }
else { else
{
contractor.suck = !contractor.suck; contractor.suck = !contractor.suck;
} }
return true; return true;
} }
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{ {
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z); TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z);
if(!world.isRemote && !tileContractor.isLatched()) if (!world.isRemote && !tileContractor.isLatched())
{ {
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
TileEntity tileEntity = world.getBlockTileEntity(x+side.offsetX, y+side.offsetY, z+side.offsetZ); TileEntity tileEntity = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
if(tileEntity instanceof IInventory) if (tileEntity instanceof IInventory)
{ {
tileContractor.setFacing(side.getOpposite()); tileContractor.setFacing(side.getOpposite());
return; return;

View file

@ -10,36 +10,36 @@ import net.minecraftforge.common.ForgeDirection;
public class ItemBlockContractor extends ItemBlock public class ItemBlockContractor extends ItemBlock
{ {
public ItemBlockContractor(int id) public ItemBlockContractor(int id)
{ {
super(id); super(id);
} }
@Override @Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{ {
boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
if(place) if (place)
{ {
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z); TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z);
tileContractor.setFacing(ForgeDirection.getOrientation(side)); tileContractor.setFacing(ForgeDirection.getOrientation(side));
if(!tileContractor.isLatched()) if (!tileContractor.isLatched())
{ {
for(ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS)
{ {
TileEntity tileEntity = world.getBlockTileEntity(x+side1.offsetX, y+side1.offsetY, z+side1.offsetZ); TileEntity tileEntity = world.getBlockTileEntity(x + side1.offsetX, y + side1.offsetY, z + side1.offsetZ);
if(tileEntity instanceof IInventory) if (tileEntity instanceof IInventory)
{ {
tileContractor.setFacing(side1.getOpposite()); tileContractor.setFacing(side1.getOpposite());
break; break;
} }
} }
} }
} }
return place; return place;
} }
} }

View file

@ -23,81 +23,82 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
public static int PUSH_DELAY = 5; public static int PUSH_DELAY = 5;
public static double MAX_SPEED = .1; public static double MAX_SPEED = .1;
public static double ACCELERATION = .01; public static double ACCELERATION = .01;
private ForgeDirection facing = ForgeDirection.UP; private ForgeDirection facing = ForgeDirection.UP;
public int pushDelay; public int pushDelay;
public AxisAlignedBB operationBounds; public AxisAlignedBB operationBounds;
public AxisAlignedBB suckBounds; public AxisAlignedBB suckBounds;
/** /**
* true = suck, false = push * true = suck, false = push
*/ */
public boolean suck = true; public boolean suck = true;
@Override @Override
public void updateEntity() public void updateEntity()
{ {
pushDelay = Math.max(0, pushDelay-1); pushDelay = Math.max(0, pushDelay - 1);
if(isLatched()) if (isLatched())
{ {
TileEntity inventoryTile = getLatched(); TileEntity inventoryTile = getLatched();
IInventory inventory = (IInventory)inventoryTile; IInventory inventory = (IInventory) inventoryTile;
if(!suck && pushDelay == 0) if (!suck && pushDelay == 0)
{ {
if(!(inventoryTile instanceof ISidedInventory)) if (!(inventoryTile instanceof ISidedInventory))
{ {
for(int i = inventory.getSizeInventory()-1; i >= 0; i--) for (int i = inventory.getSizeInventory() - 1; i >= 0; i--)
{ {
if(inventory.getStackInSlot(i) != null) if (inventory.getStackInSlot(i) != null)
{ {
ItemStack toSend = inventory.getStackInSlot(i).copy(); ItemStack toSend = inventory.getStackInSlot(i).copy();
toSend.stackSize = 1; toSend.stackSize = 1;
EntityItem item = getItemWithPosition(toSend); EntityItem item = getItemWithPosition(toSend);
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
worldObj.spawnEntityInWorld(item); worldObj.spawnEntityInWorld(item);
} }
inventory.decrStackSize(i, 1); inventory.decrStackSize(i, 1);
pushDelay = PUSH_DELAY; pushDelay = PUSH_DELAY;
break; break;
} }
} }
} }
else { else
ISidedInventory sidedInventory = (ISidedInventory)inventoryTile; {
ISidedInventory sidedInventory = (ISidedInventory) inventoryTile;
int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal()); int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal());
if(slots != null) if (slots != null)
{ {
for(int get = slots.length-1; get >= 0; get--) for (int get = slots.length - 1; get >= 0; get--)
{ {
int slotID = slots[get]; int slotID = slots[get];
if(sidedInventory.getStackInSlot(slotID) != null) if (sidedInventory.getStackInSlot(slotID) != null)
{ {
ItemStack toSend = sidedInventory.getStackInSlot(slotID); ItemStack toSend = sidedInventory.getStackInSlot(slotID);
toSend.stackSize = 1; toSend.stackSize = 1;
if(sidedInventory.canExtractItem(slotID, toSend, facing.ordinal())) if (sidedInventory.canExtractItem(slotID, toSend, facing.ordinal()))
{ {
EntityItem item = getItemWithPosition(toSend); EntityItem item = getItemWithPosition(toSend);
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
worldObj.spawnEntityInWorld(item); worldObj.spawnEntityInWorld(item);
} }
sidedInventory.decrStackSize(slotID, 1); sidedInventory.decrStackSize(slotID, 1);
pushDelay = PUSH_DELAY; pushDelay = PUSH_DELAY;
break; break;
} }
} }
@ -105,50 +106,51 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
} }
} }
} }
else if(suck) else if (suck)
{ {
if(suckBounds != null) if (suckBounds != null)
{ {
List<EntityItem> list = worldObj.getEntitiesWithinAABB(EntityItem.class, suckBounds); List<EntityItem> list = worldObj.getEntitiesWithinAABB(EntityItem.class, suckBounds);
for(EntityItem item : list) for (EntityItem item : list)
{ {
ItemStack itemStack = item.getEntityItem(); ItemStack itemStack = item.getEntityItem();
if(!(inventoryTile instanceof ISidedInventory)) if (!(inventoryTile instanceof ISidedInventory))
{ {
for(int i = 0; i <= inventory.getSizeInventory()-1; i++) for (int i = 0; i <= inventory.getSizeInventory() - 1; i++)
{ {
if(inventory.isItemValidForSlot(i, itemStack)) if (inventory.isItemValidForSlot(i, itemStack))
{ {
ItemStack inSlot = inventory.getStackInSlot(i); ItemStack inSlot = inventory.getStackInSlot(i);
if(inSlot == null) if (inSlot == null)
{ {
inventory.setInventorySlotContents(i, itemStack); inventory.setInventorySlotContents(i, itemStack);
item.setDead(); item.setDead();
break; break;
} }
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) else if (inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
{ {
if(inSlot.stackSize+itemStack.stackSize <= inSlot.getMaxStackSize()) if (inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
{ {
ItemStack toSet = itemStack.copy(); ItemStack toSet = itemStack.copy();
toSet.stackSize+=inSlot.stackSize; toSet.stackSize += inSlot.stackSize;
inventory.setInventorySlotContents(i, toSet); inventory.setInventorySlotContents(i, toSet);
item.setDead(); item.setDead();
break; break;
} }
else { else
int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize(); {
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy(); ItemStack toSet = itemStack.copy();
toSet.stackSize = inSlot.getMaxStackSize(); toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy(); ItemStack remains = itemStack.copy();
remains.stackSize = rejects; remains.stackSize = rejects;
inventory.setInventorySlotContents(i, toSet); inventory.setInventorySlotContents(i, toSet);
item.setEntityItemStack(remains); item.setEntityItemStack(remains);
} }
@ -156,44 +158,46 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
} }
} }
} }
else { else
ISidedInventory sidedInventory = (ISidedInventory)inventoryTile; {
ISidedInventory sidedInventory = (ISidedInventory) inventoryTile;
int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal()); int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal());
for(int get = 0; get <= slots.length-1; get++) for (int get = 0; get <= slots.length - 1; get++)
{ {
int slotID = slots[get]; int slotID = slots[get];
if(sidedInventory.isItemValidForSlot(slotID, itemStack) && sidedInventory.canInsertItem(slotID, itemStack, facing.ordinal())) if (sidedInventory.isItemValidForSlot(slotID, itemStack) && sidedInventory.canInsertItem(slotID, itemStack, facing.ordinal()))
{ {
ItemStack inSlot = inventory.getStackInSlot(slotID); ItemStack inSlot = inventory.getStackInSlot(slotID);
if(inSlot == null) if (inSlot == null)
{ {
inventory.setInventorySlotContents(slotID, itemStack); inventory.setInventorySlotContents(slotID, itemStack);
item.setDead(); item.setDead();
break; break;
} }
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) else if (inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
{ {
if(inSlot.stackSize+itemStack.stackSize <= inSlot.getMaxStackSize()) if (inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
{ {
ItemStack toSet = itemStack.copy(); ItemStack toSet = itemStack.copy();
toSet.stackSize+=inSlot.stackSize; toSet.stackSize += inSlot.stackSize;
inventory.setInventorySlotContents(slotID, toSet); inventory.setInventorySlotContents(slotID, toSet);
item.setDead(); item.setDead();
break; break;
} }
else { else
int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize(); {
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy(); ItemStack toSet = itemStack.copy();
toSet.stackSize = inSlot.getMaxStackSize(); toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy(); ItemStack remains = itemStack.copy();
remains.stackSize = rejects; remains.stackSize = rejects;
inventory.setInventorySlotContents(slotID, toSet); inventory.setInventorySlotContents(slotID, toSet);
item.setEntityItemStack(remains); item.setEntityItemStack(remains);
} }
@ -205,131 +209,137 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
} }
} }
} }
if(operationBounds != null) if (operationBounds != null)
{ {
List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, operationBounds); List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, operationBounds);
for(Entity entity : list) for (Entity entity : list)
{ {
if(entity instanceof EntityItem) if (entity instanceof EntityItem)
{ {
EntityItem entityItem = (EntityItem)entity; EntityItem entityItem = (EntityItem) entity;
switch(facing) switch (facing)
{ {
case DOWN: case DOWN:
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
entityItem.setPosition(xCoord+0.5, entityItem.posY, zCoord+0.5); entityItem.setPosition(xCoord + 0.5, entityItem.posY, zCoord + 0.5);
} }
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
if(!suck) if (!suck)
{ {
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY-ACCELERATION); entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION);
} }
else { else
entityItem.motionY = Math.min((MAX_SPEED*4), entityItem.motionY+(ACCELERATION*5)); {
entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5));
} }
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case UP: case UP:
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
entityItem.setPosition(xCoord+0.5, entityItem.posY, zCoord+0.5); entityItem.setPosition(xCoord + 0.5, entityItem.posY, zCoord + 0.5);
} }
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
if(!suck) if (!suck)
{ {
entityItem.motionY = Math.min((MAX_SPEED*4), entityItem.motionY+(ACCELERATION*5)); entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5));
} }
else { else
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY-ACCELERATION); {
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION);
} }
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case NORTH: case NORTH:
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ); entityItem.setPosition(xCoord + 0.5, yCoord + 0.5, entityItem.posZ);
} }
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionY = 0; entityItem.motionY = 0;
if(!suck) if (!suck)
{ {
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION); entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION);
} }
else { else
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION); {
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION);
} }
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case SOUTH: case SOUTH:
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ); entityItem.setPosition(xCoord + 0.5, yCoord + 0.5, entityItem.posZ);
} }
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionY = 0; entityItem.motionY = 0;
if(!suck) if (!suck)
{ {
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION); entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION);
} }
else { else
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION); {
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION);
} }
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case WEST: case WEST:
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5); entityItem.setPosition(entityItem.posX, yCoord + 0.5, zCoord + 0.5);
} }
entityItem.motionY = 0; entityItem.motionY = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
if(!suck) if (!suck)
{ {
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION); entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION);
} }
else { else
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION); {
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION);
} }
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
case EAST: case EAST:
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5); entityItem.setPosition(entityItem.posX, yCoord + 0.5, zCoord + 0.5);
} }
entityItem.motionY = 0; entityItem.motionY = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
if(!suck) if (!suck)
{ {
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION); entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION);
} }
else { else
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION); {
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION);
} }
entityItem.isAirBorne = true; entityItem.isAirBorne = true;
break; break;
} }
@ -337,147 +347,151 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
} }
} }
} }
private EntityItem getItemWithPosition(ItemStack toSend) private EntityItem getItemWithPosition(ItemStack toSend)
{ {
EntityItem item = null; EntityItem item = null;
switch(facing) switch (facing)
{ {
case DOWN: case DOWN:
item = new EntityItem(worldObj, xCoord+0.5, yCoord, zCoord+0.5, toSend); item = new EntityItem(worldObj, xCoord + 0.5, yCoord, zCoord + 0.5, toSend);
break; break;
case UP: case UP:
item = new EntityItem(worldObj, xCoord+0.5, yCoord+1, zCoord+0.5, toSend); item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, toSend);
break; break;
case NORTH: case NORTH:
item = new EntityItem(worldObj, xCoord+0.5, yCoord+0.5, zCoord, toSend); item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord, toSend);
break; break;
case SOUTH: case SOUTH:
item = new EntityItem(worldObj, xCoord+0.5, yCoord+0.5, zCoord+1, toSend); item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 1, toSend);
break; break;
case WEST: case WEST:
item = new EntityItem(worldObj, xCoord, yCoord+0.5, zCoord+0.5, toSend); item = new EntityItem(worldObj, xCoord, yCoord + 0.5, zCoord + 0.5, toSend);
break; break;
case EAST: case EAST:
item = new EntityItem(worldObj, xCoord+1, yCoord+0.5, zCoord+0.5, toSend); item = new EntityItem(worldObj, xCoord + 1, yCoord + 0.5, zCoord + 0.5, toSend);
break; break;
} }
return item; return item;
} }
@Override @Override
public void validate() public void validate()
{ {
super.validate(); super.validate();
if(worldObj.isRemote) if (worldObj.isRemote)
{ {
PacketHandler.sendDataRequest(this); PacketHandler.sendDataRequest(this);
} }
} }
public void updateBounds() public void updateBounds()
{ {
switch(facing) switch (facing)
{ {
case DOWN: case DOWN:
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord-MAX_REACH, 1), zCoord, xCoord+1, yCoord, zCoord+1); operationBounds = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord - MAX_REACH, 1), zCoord, xCoord + 1, yCoord, zCoord + 1);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord-0.1, zCoord, xCoord+1, yCoord, zCoord+1); suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord - 0.1, zCoord, xCoord + 1, yCoord, zCoord + 1);
break; break;
case UP: case UP:
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord+1, zCoord, xCoord+1, Math.min(yCoord+1+MAX_REACH, 255), zCoord+1); operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, Math.min(yCoord + 1 + MAX_REACH, 255), zCoord + 1);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord+1, zCoord, xCoord+1, yCoord+1.1, zCoord+1); suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 1.1, zCoord + 1);
break; break;
case NORTH: case NORTH:
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-MAX_REACH, xCoord+1, yCoord+1, zCoord); operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - MAX_REACH, xCoord + 1, yCoord + 1, zCoord);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-0.1, xCoord+1, yCoord+1, zCoord); suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - 0.1, xCoord + 1, yCoord + 1, zCoord);
break; break;
case SOUTH: case SOUTH:
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord+1, xCoord+1, yCoord+1, zCoord+1+MAX_REACH); operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord + 1, xCoord + 1, yCoord + 1, zCoord + 1 + MAX_REACH);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord+1, xCoord+1, yCoord+1, zCoord+1.1); suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord + 1, xCoord + 1, yCoord + 1, zCoord + 1.1);
break; break;
case WEST: case WEST:
operationBounds = AxisAlignedBB.getBoundingBox(xCoord-MAX_REACH, yCoord, zCoord, xCoord, yCoord+1, zCoord+1); operationBounds = AxisAlignedBB.getBoundingBox(xCoord - MAX_REACH, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord-0.1, yCoord, zCoord, xCoord, yCoord+1, zCoord+1); suckBounds = AxisAlignedBB.getBoundingBox(xCoord - 0.1, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1);
break; break;
case EAST: case EAST:
operationBounds = AxisAlignedBB.getBoundingBox(xCoord+1, yCoord, zCoord, xCoord+1+MAX_REACH, yCoord+1, zCoord+1); operationBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1 + MAX_REACH, yCoord + 1, zCoord + 1);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord+1, yCoord, zCoord, xCoord+1.1, yCoord+1, zCoord+1); suckBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1.1, yCoord + 1, zCoord + 1);
break; break;
} }
} }
public boolean isLatched() public boolean isLatched()
{ {
return getLatched() != null; return getLatched() != null;
} }
public TileEntity getLatched() public TileEntity getLatched()
{ {
ForgeDirection side = facing.getOpposite(); ForgeDirection side = facing.getOpposite();
TileEntity tile = worldObj.getBlockTileEntity(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ); TileEntity tile = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
if(tile instanceof IInventory) if (tile instanceof IInventory)
{ {
return tile; return tile;
} }
return null; return null;
} }
public void incrementFacing() public void incrementFacing()
{ {
int newOrdinal = facing.ordinal() < 5 ? facing.ordinal()+1 : 0; int newOrdinal = facing.ordinal() < 5 ? facing.ordinal() + 1 : 0;
setFacing(ForgeDirection.getOrientation(newOrdinal)); setFacing(ForgeDirection.getOrientation(newOrdinal));
} }
public ForgeDirection getFacing() public ForgeDirection getFacing()
{ {
return facing; return facing;
} }
public void setFacing(ForgeDirection side) public void setFacing(ForgeDirection side)
{ {
facing = side; facing = side;
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray()); PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
} }
updateBounds(); updateBounds();
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbtTags) public void readFromNBT(NBTTagCompound nbtTags)
{ {
super.readFromNBT(nbtTags); super.readFromNBT(nbtTags);
facing = ForgeDirection.getOrientation(nbtTags.getInteger("facing")); facing = ForgeDirection.getOrientation(nbtTags.getInteger("facing"));
suck = nbtTags.getBoolean("suck"); suck = nbtTags.getBoolean("suck");
} }
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("facing", facing.ordinal());
nbtTags.setBoolean("suck", suck);
}
@Override @Override
public void handle(ByteArrayDataInput input) public void writeToNBT(NBTTagCompound nbtTags)
{ {
try { super.writeToNBT(nbtTags);
nbtTags.setInteger("facing", facing.ordinal());
nbtTags.setBoolean("suck", suck);
}
@Override
public void handle(ByteArrayDataInput input)
{
try
{
facing = ForgeDirection.getOrientation(input.readInt()); facing = ForgeDirection.getOrientation(input.readInt());
suck = input.readBoolean(); suck = input.readBoolean();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
updateBounds(); updateBounds();
} catch(Exception e) {} }
catch (Exception e)
{
}
} }
@Override @Override

View file

@ -2,13 +2,11 @@ package resonantinduction.entangler;
import java.util.List; import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.ResonantInduction;
import resonantinduction.base.ItemBase; import resonantinduction.base.ItemBase;
import resonantinduction.base.Vector3; import resonantinduction.base.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;

View file

@ -154,7 +154,7 @@ public class FXElectricBolt extends EntityFX
*/ */
for (int i = 1; i < splitAmount; i++) for (int i = 1; i < splitAmount; i++)
{ {
Vector3 newOffset = segment.difference.getPerpendicular().rotate((float) (this.rand.nextFloat() * 180), segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset); Vector3 newOffset = segment.difference.getPerpendicular().rotate(this.rand.nextFloat() * 180, segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset);
Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i)); Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i));
newPoints[i] = new BoltPoint(basePoint, newOffset); newPoints[i] = new BoltPoint(basePoint, newOffset);
@ -227,7 +227,7 @@ public class FXElectricBolt extends EntityFX
{ {
lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
lastSplitCalc = segment.splitID; lastSplitCalc = segment.splitID;
lastActiveSeg = ((Integer) lastActiveSegment.get(this.parentIDMap.get(segment.splitID))).intValue(); lastActiveSeg = lastActiveSegment.get(this.parentIDMap.get(segment.splitID)).intValue();
} }
lastActiveSeg = segment.id; lastActiveSeg = segment.id;
@ -235,7 +235,7 @@ public class FXElectricBolt extends EntityFX
lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
lastSplitCalc = 0; lastSplitCalc = 0;
lastActiveSeg = ((Integer) lastActiveSegment.get(0)).intValue(); lastActiveSeg = lastActiveSegment.get(0).intValue();
BoltSegment segment; BoltSegment segment;
for (Iterator<BoltSegment> iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate()) for (Iterator<BoltSegment> iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate())

View file

@ -0,0 +1,22 @@
/**
*
*/
package resonantinduction.multimeter;
import net.minecraft.block.material.Material;
import resonantinduction.base.BlockBase;
/**
* A block that detects power.
*
* @author Calclavia
*
*/
public class BlockMultimeter extends BlockBase
{
public BlockMultimeter(int id)
{
super("multimeter", id, Material.iron);
}
}

View file

@ -15,7 +15,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
public static final ModelEMContractor MODEL = new ModelEMContractor(); public static final ModelEMContractor MODEL = new ModelEMContractor();
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor.png"); public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor.png");
public static final ResourceLocation TEXTURE_PUSH = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor_push.png"); public static final ResourceLocation TEXTURE_PUSH = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor_push.png");
@Override @Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
{ {
@ -23,8 +23,8 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
switch(((TileEntityEMContractor)t).getFacing()) switch (((TileEntityEMContractor) t).getFacing())
{ {
case DOWN: case DOWN:
GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 0, 1);
@ -49,15 +49,16 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
GL11.glRotatef(90, 1, 0, 0); GL11.glRotatef(90, 1, 0, 0);
break; break;
} }
if(((TileEntityEMContractor)t).suck) if (((TileEntityEMContractor) t).suck)
{ {
this.func_110628_a(TEXTURE); this.func_110628_a(TEXTURE);
} }
else { else
{
this.func_110628_a(TEXTURE_PUSH); this.func_110628_a(TEXTURE_PUSH);
} }
MODEL.render(0.0625f); MODEL.render(0.0625f);
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -8,7 +8,7 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import resonantinduction.ITesla; import resonantinduction.api.ITesla;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;

View file

@ -17,12 +17,11 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import resonantinduction.ITesla;
import resonantinduction.PacketHandler; import resonantinduction.PacketHandler;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.api.ITesla;
import resonantinduction.base.IPacketReceiver; import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.TileEntityBase; import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3; import resonantinduction.base.Vector3;
@ -150,7 +149,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
{ {
if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS) if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS)
{ {
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, (float) (1.3f - 0.5f * ((float) this.dyeID / 16f))); this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, 1.3f - 0.5f * (this.dyeID / 16f));
} }
Vector3 targetVector = new Vector3((TileEntity) tesla); Vector3 targetVector = new Vector3((TileEntity) tesla);
@ -164,8 +163,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
double distance = topTeslaVector.distance(targetVector); double distance = topTeslaVector.distance(targetVector);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z); ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z);
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f))); tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true);
this.transfer(-transferEnergy); this.transfer(-transferEnergy, true);
if (this.attackEntities && this.zapCounter % 5 == 0) if (this.attackEntities && this.zapCounter % 5 == 0)
{ {
@ -225,7 +224,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
} }
else else
{ {
this.transfer(ResonantInduction.POWER_PER_COAL / 20); this.transfer(ResonantInduction.POWER_PER_COAL / 20, true);
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
} }
@ -242,7 +241,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0; boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
furnaceTile.furnaceBurnTime += 2; furnaceTile.furnaceBurnTime += 2;
this.transfer(-ResonantInduction.POWER_PER_COAL / 20); this.transfer(-ResonantInduction.POWER_PER_COAL / 20, true);
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0) if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
@ -314,17 +313,22 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
} }
@Override @Override
public void transfer(float transferEnergy) public float transfer(float transferEnergy, boolean doTransfer)
{ {
if (isController() || this.getControllingTelsa() == this) if (isController() || this.getControllingTelsa() == this)
{ {
this.energy = Math.max(this.energy + transferEnergy, 0); if (doTransfer)
{
this.energy = Math.max(this.energy + transferEnergy, 0);
}
this.doTransfer = true; this.doTransfer = true;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
return transferEnergy;
} }
else else
{ {
this.getControllingTelsa().transfer(transferEnergy); return this.getControllingTelsa().transfer(transferEnergy, doTransfer);
} }
} }
@ -484,6 +488,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
/** /**
* Reads a tile entity from NBT. * Reads a tile entity from NBT.
*/ */
@Override
public void readFromNBT(NBTTagCompound nbt) public void readFromNBT(NBTTagCompound nbt)
{ {
super.readFromNBT(nbt); super.readFromNBT(nbt);
@ -495,6 +500,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
/** /**
* Writes a tile entity to NBT. * Writes a tile entity to NBT.
*/ */
@Override
public void writeToNBT(NBTTagCompound nbt) public void writeToNBT(NBTTagCompound nbt)
{ {
super.writeToNBT(nbt); super.writeToNBT(nbt);