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 y = dataStream.readInt();
int z = dataStream.readInt();
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IPacketReceiver)
{
sendTileEntityPacketToClients(tileEntity, ((IPacketReceiver) tileEntity).getNetworkedData(new ArrayList()).toArray());
@ -106,7 +106,7 @@ public class PacketHandler implements IPacketHandler
}
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)
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@ -135,7 +135,7 @@ public class PacketHandler implements IPacketHandler
packet.channel = ResonantInduction.CHANNEL;
packet.data = bytes.toByteArray();
packet.length = packet.data.length;
PacketDispatcher.sendPacketToServer(packet);
}
@ -177,7 +177,6 @@ public class PacketHandler implements IPacketHandler
public static enum PacketType
{
TILE,
DATA_REQUEST
TILE, DATA_REQUEST
}
}

View file

@ -13,6 +13,7 @@ import resonantinduction.contractor.BlockEMContractor;
import resonantinduction.contractor.ItemBlockContractor;
import resonantinduction.contractor.TileEntityEMContractor;
import resonantinduction.entangler.ItemQuantumEntangler;
import resonantinduction.multimeter.BlockMultimeter;
import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla;
import cpw.mods.fml.common.FMLLog;
@ -106,6 +107,7 @@ public class ResonantInduction
// Blocks
public static Block blockTesla;
public static Block blockMultimeter;
public static Block blockEMContractor;
@EventHandler
@ -118,15 +120,18 @@ public class ResonantInduction
// Config
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);
// Items
itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID());
GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName());
// Blocks
blockTesla = new BlockTesla(getNextBlockID());
blockMultimeter = new BlockMultimeter(getNextBlockID());
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerBlock(blockMultimeter, blockMultimeter.getUnlocalizedName());
blockEMContractor = new BlockEMContractor(getNextBlockID());
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;
public interface IPacketReceiver
public interface IPacketReceiver
{
public void handle(ByteArrayDataInput input);
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);
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")
List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
double closestEntity = reachDistance;

View file

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

View file

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

View file

@ -23,81 +23,82 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
public static int PUSH_DELAY = 5;
public static double MAX_SPEED = .1;
public static double ACCELERATION = .01;
private ForgeDirection facing = ForgeDirection.UP;
public int pushDelay;
public AxisAlignedBB operationBounds;
public AxisAlignedBB suckBounds;
/**
* true = suck, false = push
*/
public boolean suck = true;
@Override
public void updateEntity()
{
pushDelay = Math.max(0, pushDelay-1);
if(isLatched())
pushDelay = Math.max(0, pushDelay - 1);
if (isLatched())
{
TileEntity inventoryTile = getLatched();
IInventory inventory = (IInventory)inventoryTile;
if(!suck && pushDelay == 0)
IInventory inventory = (IInventory) inventoryTile;
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();
toSend.stackSize = 1;
EntityItem item = getItemWithPosition(toSend);
if(!worldObj.isRemote)
if (!worldObj.isRemote)
{
worldObj.spawnEntityInWorld(item);
}
inventory.decrStackSize(i, 1);
pushDelay = PUSH_DELAY;
break;
}
}
}
else {
ISidedInventory sidedInventory = (ISidedInventory)inventoryTile;
else
{
ISidedInventory sidedInventory = (ISidedInventory) inventoryTile;
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];
if(sidedInventory.getStackInSlot(slotID) != null)
if (sidedInventory.getStackInSlot(slotID) != null)
{
ItemStack toSend = sidedInventory.getStackInSlot(slotID);
toSend.stackSize = 1;
if(sidedInventory.canExtractItem(slotID, toSend, facing.ordinal()))
if (sidedInventory.canExtractItem(slotID, toSend, facing.ordinal()))
{
EntityItem item = getItemWithPosition(toSend);
if(!worldObj.isRemote)
if (!worldObj.isRemote)
{
worldObj.spawnEntityInWorld(item);
}
sidedInventory.decrStackSize(slotID, 1);
pushDelay = PUSH_DELAY;
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);
for(EntityItem item : list)
for (EntityItem item : list)
{
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);
if(inSlot == null)
if (inSlot == null)
{
inventory.setInventorySlotContents(i, itemStack);
item.setDead();
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();
toSet.stackSize+=inSlot.stackSize;
toSet.stackSize += inSlot.stackSize;
inventory.setInventorySlotContents(i, toSet);
item.setDead();
break;
}
else {
int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize();
else
{
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy();
toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy();
remains.stackSize = rejects;
inventory.setInventorySlotContents(i, toSet);
item.setEntityItemStack(remains);
}
@ -156,44 +158,46 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
}
}
}
else {
ISidedInventory sidedInventory = (ISidedInventory)inventoryTile;
else
{
ISidedInventory sidedInventory = (ISidedInventory) inventoryTile;
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];
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);
if(inSlot == null)
if (inSlot == null)
{
inventory.setInventorySlotContents(slotID, itemStack);
item.setDead();
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();
toSet.stackSize+=inSlot.stackSize;
toSet.stackSize += inSlot.stackSize;
inventory.setInventorySlotContents(slotID, toSet);
item.setDead();
break;
}
else {
int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize();
else
{
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy();
toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy();
remains.stackSize = rejects;
inventory.setInventorySlotContents(slotID, toSet);
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);
for(Entity entity : list)
for (Entity entity : list)
{
if(entity instanceof EntityItem)
if (entity instanceof EntityItem)
{
EntityItem entityItem = (EntityItem)entity;
switch(facing)
EntityItem entityItem = (EntityItem) entity;
switch (facing)
{
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.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 {
entityItem.motionY = Math.min((MAX_SPEED*4), entityItem.motionY+(ACCELERATION*5));
else
{
entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5));
}
entityItem.isAirBorne = true;
break;
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.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 {
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY-ACCELERATION);
else
{
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION);
}
entityItem.isAirBorne = true;
break;
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.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 {
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION);
else
{
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION);
}
entityItem.isAirBorne = true;
break;
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.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 {
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION);
else
{
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION);
}
entityItem.isAirBorne = true;
break;
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.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 {
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION);
else
{
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION);
}
entityItem.isAirBorne = true;
break;
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.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 {
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION);
else
{
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION);
}
entityItem.isAirBorne = true;
break;
}
@ -337,147 +347,151 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
}
}
}
private EntityItem getItemWithPosition(ItemStack toSend)
{
EntityItem item = null;
switch(facing)
switch (facing)
{
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;
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;
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;
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;
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;
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;
}
return item;
}
@Override
public void validate()
{
super.validate();
if(worldObj.isRemote)
if (worldObj.isRemote)
{
PacketHandler.sendDataRequest(this);
}
}
public void updateBounds()
{
switch(facing)
switch (facing)
{
case DOWN:
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);
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);
break;
case UP:
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);
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);
break;
case NORTH:
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);
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);
break;
case SOUTH:
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);
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);
break;
case WEST:
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);
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);
break;
case EAST:
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);
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);
break;
}
}
public boolean isLatched()
{
return getLatched() != null;
}
public TileEntity getLatched()
{
ForgeDirection side = facing.getOpposite();
TileEntity tile = worldObj.getBlockTileEntity(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ);
if(tile instanceof IInventory)
TileEntity tile = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
if (tile instanceof IInventory)
{
return tile;
}
return null;
}
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));
}
public ForgeDirection getFacing()
{
return facing;
}
public void setFacing(ForgeDirection side)
{
facing = side;
if(!worldObj.isRemote)
if (!worldObj.isRemote)
{
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
}
updateBounds();
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
facing = ForgeDirection.getOrientation(nbtTags.getInteger("facing"));
suck = nbtTags.getBoolean("suck");
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("facing", facing.ordinal());
nbtTags.setBoolean("suck", suck);
}
}
@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());
suck = input.readBoolean();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
updateBounds();
} catch(Exception e) {}
}
catch (Exception e)
{
}
}
@Override

View file

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

View file

@ -154,7 +154,7 @@ public class FXElectricBolt extends EntityFX
*/
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));
newPoints[i] = new BoltPoint(basePoint, newOffset);
@ -227,7 +227,7 @@ public class FXElectricBolt extends EntityFX
{
lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
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;
@ -235,7 +235,7 @@ public class FXElectricBolt extends EntityFX
lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
lastSplitCalc = 0;
lastActiveSeg = ((Integer) lastActiveSegment.get(0)).intValue();
lastActiveSeg = lastActiveSegment.get(0).intValue();
BoltSegment segment;
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 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");
@Override
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.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
switch(((TileEntityEMContractor)t).getFacing())
switch (((TileEntityEMContractor) t).getFacing())
{
case DOWN:
GL11.glRotatef(180, 0, 0, 1);
@ -49,15 +49,16 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
GL11.glRotatef(90, 1, 0, 0);
break;
}
if(((TileEntityEMContractor)t).suck)
if (((TileEntityEMContractor) t).suck)
{
this.func_110628_a(TEXTURE);
}
else {
else
{
this.func_110628_a(TEXTURE_PUSH);
}
MODEL.render(0.0625f);
GL11.glPopMatrix();

View file

@ -8,7 +8,7 @@ import java.util.Iterator;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import resonantinduction.ITesla;
import resonantinduction.api.ITesla;
import cpw.mods.fml.common.FMLCommonHandler;
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.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import resonantinduction.ITesla;
import resonantinduction.PacketHandler;
import resonantinduction.ResonantInduction;
import resonantinduction.api.ITesla;
import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
@ -150,7 +149,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
{
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);
@ -164,8 +163,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
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);
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
this.transfer(-transferEnergy);
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true);
this.transfer(-transferEnergy, true);
if (this.attackEntities && this.zapCounter % 5 == 0)
{
@ -225,7 +224,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
}
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);
}
@ -242,7 +241,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
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);
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
@ -314,17 +313,22 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
}
@Override
public void transfer(float transferEnergy)
public float transfer(float transferEnergy, boolean doTransfer)
{
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.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
return transferEnergy;
}
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.
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
@ -495,6 +500,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);