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

@ -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);
} }
} }
} }
@ -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
@ -125,7 +127,10 @@ public class ResonantInduction
// 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

@ -241,7 +241,8 @@ 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);

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;
@ -34,13 +31,14 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
@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;
} }
@ -50,15 +48,15 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
@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

@ -20,18 +20,18 @@ public class ItemBlockContractor extends ItemBlock
{ {
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;

View file

@ -39,27 +39,27 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
@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);
} }
@ -71,26 +71,27 @@ 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());
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);
} }
@ -105,43 +106,44 @@ 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();
@ -156,37 +158,39 @@ 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();
@ -206,128 +210,134 @@ 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;
@ -342,25 +352,25 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
{ {
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;
} }
@ -372,7 +382,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
{ {
super.validate(); super.validate();
if(worldObj.isRemote) if (worldObj.isRemote)
{ {
PacketHandler.sendDataRequest(this); PacketHandler.sendDataRequest(this);
} }
@ -380,31 +390,31 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
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;
} }
} }
@ -418,9 +428,9 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
{ {
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;
} }
@ -430,7 +440,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
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));
} }
@ -443,7 +453,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
{ {
facing = side; facing = side;
if(!worldObj.isRemote) if (!worldObj.isRemote)
{ {
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray()); PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
} }
@ -472,12 +482,16 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
@Override @Override
public void handle(ByteArrayDataInput input) public void handle(ByteArrayDataInput input)
{ {
try { 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

@ -24,7 +24,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
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);
@ -50,11 +50,12 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
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);
} }

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)
{
if (doTransfer)
{ {
this.energy = Math.max(this.energy + transferEnergy, 0); 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);