More general update work

This commit is contained in:
Robert S 2014-08-06 07:57:45 -04:00
parent 515179ea32
commit 9d5a41dec7
49 changed files with 479 additions and 1839 deletions

View file

@ -72,7 +72,7 @@ class Archaic {
def preInit( evt : FMLPreInitializationEvent ) {
NetworkRegistry.instance().registerGuiHandler( this, proxy )
Settings.config.load()
ArchaicBlocks.blockEngineeringTable = contentRegistry.newBlock( classOf[ TileEngineeringTable ] )
ArchaicBlocks.blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class)
ArchaicBlocks.blockCrate = contentRegistry.createBlock( classOf[ BlockCrate ], classOf[ ItemBlockCrate ], classOf[ TileCrate ] )
ArchaicBlocks.blockImprinter = contentRegistry.createTile( classOf[ BlockImprinter ], classOf[ TileImprinter ] )
ArchaicBlocks.blockTurntable = contentRegistry.newBlock( classOf[ TileTurntable ] )

View file

@ -24,9 +24,9 @@ import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.charger.ItemCharger;
import resonantinduction.electrical.generator.BlockMotor;
import resonantinduction.electrical.generator.TileMotor;
import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.generator.TileSolarPanel;
import resonantinduction.electrical.generator.thermopile.BlockThermopile;
import resonantinduction.electrical.generator.thermopile.TileThermopile;
import resonantinduction.electrical.generator.TileThermopile;
import resonantinduction.electrical.laser.gun.ItemMiningLaser;
import resonantinduction.electrical.levitator.ItemLevitator;
import resonantinduction.electrical.multimeter.ItemMultimeter;

View file

@ -4,18 +4,24 @@ import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import scala.reflect.ClassTag;
import universalelectricity.api.core.grid.electric.IEnergyNode;
import universalelectricity.core.grid.Grid;
import universalelectricity.core.grid.NodeGrid;
import universalelectricity.core.grid.TickingGrid;
import universalelectricity.core.grid.node.EnergyNode;
import universalelectricity.core.net.Network;
/** Energy network designed to allow several tiles to act as if they share the same energy
* level */
public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork, TileEnergyDistribution>
public class EnergyDistributionNetwork extends TickingGrid<EnergyNode>
{
public long totalEnergy = 0;
public long totalCapacity = 0;
public EnergyDistributionNetwork()
public EnergyDistributionNetwork(ClassTag<IEnergyNode> evidence$1)
{
super(TileEnergyDistribution.class);
super(evidence$1);
}
public void redistribute(TileEnergyDistribution... exclusion)

View file

@ -1,26 +1,20 @@
package resonantinduction.electrical.battery;
import java.util.ArrayList;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.Packet;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.IPacketSender;
import resonantinduction.core.ResonantInduction;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.electricity.IVoltageInput;
import universalelectricity.api.electricity.IVoltageOutput;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.energy.IEnergyContainer;
import universalelectricity.api.energy.IEnergyInterface;
import resonant.engine.ResonantEngine;
import resonant.lib.network.discriminator.PacketTile;
import com.google.common.io.ByteArrayDataInput;
import resonant.lib.network.discriminator.PacketType;
import resonant.lib.network.handle.IPacketReceiver;
/** A modular battery box that allows shared connections with boxes next to it.
*
* @author Calclavia */
public class TileBattery extends TileEnergyDistribution
public class TileBattery extends TileEnergyDistribution implements IPacketReceiver
{
/** Tiers: 0, 1, 2 */
public static final int MAX_TIER = 2;
@ -30,10 +24,8 @@ public class TileBattery extends TileEnergyDistribution
public TileBattery()
{
this.setEnergyHandler(new EnergyStorageHandler(0));
this.getEnergyHandler().setCapacity(Long.MAX_VALUE);
this.ioMap_$eq(0);
this.saveIOMap = true;
this.ioMap_$eq((short) 0);
this.saveIOMap_$eq(true);
}
/** @param tier - 0, 1, 2
@ -43,63 +35,17 @@ public class TileBattery extends TileEnergyDistribution
return Math.round(Math.pow(500000000, (tier / (MAX_TIER + 0.7f)) + 1) / (500000000)) * (500000000);
}
@Override
public void initiate()
{
super.initiate();
getEnergyHandler().setCapacity(getEnergyForTier(getBlockMetadata()));
getEnergyHandler().setMaxTransfer(getEnergyHandler().getEnergyCapacity());
}
@Override
public void updateEntity()
{
if (!this.worldObj.isRemote)
{
markDistributionUpdate |= produce() > 0;
}
super.updateEntity();
}
@Override
public Packet getDescriptionPacket()
{
return ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray());
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(this, renderEnergyAmount, ioMap()));
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
public void read(ByteBuf data, EntityPlayer player, PacketType type)
{
getEnergyHandler().setEnergy(data.readLong());
ioMap = data.readShort();
}
@Override
public ArrayList getPacketData(int type)
{
ArrayList data = new ArrayList();
data.add(renderEnergyAmount);
data.add(ioMap);
return data;
}
@Override
public long getVoltageOutput(ForgeDirection side)
{
return UniversalElectricity.DEFAULT_VOLTAGE;
}
@Override
public long getVoltageInput(ForgeDirection direction)
{
return UniversalElectricity.DEFAULT_VOLTAGE;
}
@Override
public void onWrongVoltage(ForgeDirection direction, long voltage)
{
this.electricNode().energy().setEnergy(data.readLong());
this.ioMap_$eq(data.readShort());
}
@Override

View file

@ -24,140 +24,23 @@ public class TileEnergyDistribution extends TileElectric
}
@Override
public void initiate()
public void update()
{
super.initiate();
this.updateStructure();
}
@Override
public void onAdded()
{
if (!world().isRemote)
{
updateStructure();
}
}
@Override
public void onNeighborChanged()
{
if (!world().isRemote)
{
updateStructure();
}
}
@Override
public void updateEntity()
{
super.updateEntity();
super.update();
if (!this.worldObj.isRemote)
{
if (markDistributionUpdate && ticks % 5 == 0)
if (markDistributionUpdate && ticks() % 5 == 0)
{
getNetwork().redistribute();
//TODO update node
markDistributionUpdate = false;
}
if (markClientUpdate && ticks % 5 == 0)
if (markClientUpdate && ticks() % 5 == 0)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
@Override
public long getEnergy(ForgeDirection from)
{
return getNetwork().totalEnergy;
}
@Override
public long getEnergyCapacity(ForgeDirection from)
{
return getNetwork().totalCapacity;
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
long returnValue = super.onReceiveEnergy(from, receive, doReceive);
markDistributionUpdate = true;
markClientUpdate = true;
return returnValue;
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
long returnValue = super.onExtractEnergy(from, extract, doExtract);
markDistributionUpdate = true;
markClientUpdate = true;
return returnValue;
}
@Override
public EnergyDistributionNetwork getNetwork()
{
if (this.network == null)
{
this.network = new EnergyDistributionNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(EnergyDistributionNetwork structure)
{
this.network = structure;
}
public void updateStructure()
{
if (!this.worldObj.isRemote)
{
for (Object obj : getConnections())
{
if (obj != null)
{
this.getNetwork().merge(((TileEnergyDistribution) obj).getNetwork());
}
}
markDistributionUpdate = true;
markClientUpdate = true;
}
}
@Override
public Object[] getConnections()
{
Object[] connections = new Object[6];
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = new Vector3(this).add(dir).getTileEntity(this.worldObj);
if (tile != null && tile.getClass() == this.getClass())
{
connections[dir.ordinal()] = tile;
}
}
return connections;
}
@Override
public void invalidate()
{
this.getNetwork().redistribute(this);
this.getNetwork().split(this);
super.invalidate();
}
}

View file

@ -1,23 +1,23 @@
package resonantinduction.electrical.em
import cpw.mods.fml.common.{SidedProxy, Mod}
import cpw.mods.fml.common.Mod.EventHandler
import cpw.mods.fml.common.event.{FMLPreInitializationEvent, FMLInitializationEvent}
import cpw.mods.fml.common.registry.{LanguageRegistry, GameRegistry}
import net.minecraft.util.{EnumChatFormatting, ResourceLocation}
import resonantinduction.electrical.em.laser.emitter.BlockLaserEmitter
import resonantinduction.electrical.em.laser.focus.mirror.BlockMirror
import resonantinduction.electrical.em.laser.receiver.BlockLaserReceiver
import net.minecraft.init.{Items, Blocks}
import net.minecraftforge.oredict.ShapedOreRecipe
import net.minecraftforge.common.MinecraftForge
import cpw.mods.fml.common.event.{FMLInitializationEvent, FMLPreInitializationEvent}
import cpw.mods.fml.common.eventhandler.SubscribeEvent
import net.minecraft.item.ItemStack
import net.minecraftforge.event.entity.EntityJoinWorldEvent
import cpw.mods.fml.common.registry.{GameRegistry, LanguageRegistry}
import cpw.mods.fml.common.{Mod, SidedProxy}
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.{NBTTagString, NBTTagList, NBTTagCompound}
import net.minecraft.init.{Blocks, Items}
import net.minecraft.item.ItemStack
import net.minecraft.nbt.{NBTTagCompound, NBTTagList, NBTTagString}
import net.minecraft.util.{EnumChatFormatting, ResourceLocation}
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.entity.EntityJoinWorldEvent
import net.minecraftforge.oredict.ShapedOreRecipe
import resonantinduction.electrical.em.laser.emitter.BlockLaserEmitter
import resonantinduction.electrical.em.laser.focus.ItemFocusingMatrix
import resonantinduction.electrical.em.laser.focus.crystal.BlockFocusCrystal
import resonantinduction.electrical.em.laser.focus.mirror.BlockMirror
import resonantinduction.electrical.em.laser.receiver.BlockLaserReceiver
/**
* @author Calclavia

View file

@ -1,22 +0,0 @@
package resonantinduction.electrical.em
import net.minecraft.creativetab.CreativeTabs
import net.minecraft.item.ItemStack
import cpw.mods.fml.relauncher.{SideOnly, Side}
import scala.collection.convert.wrapAsScala._
/**
* @author Calclavia
*/
object TabEC extends CreativeTabs(CreativeTabs.getNextID, "ec")
{
override def getTabIconItem = new ItemStack(ElectromagneticCoherence.blockLaserEmitter).getItem
@SideOnly(Side.CLIENT)
override def displayAllReleventItems(list: java.util.List[_])
{
super.displayAllReleventItems(list)
def add[T](list: java.util.List[T], value: Any) = list.add(value.asInstanceOf[T])
add(list, ElectromagneticCoherence.guideBook)
}
}

View file

@ -1,282 +0,0 @@
package resonantinduction.electrical.em
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.util.ForgeDirection
import net.minecraft.util.{AxisAlignedBB, MovingObjectPosition, Vec3}
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.world.World
import java.lang.Double.doubleToLongBits
import net.minecraft.entity.Entity
import scala.collection.convert.wrapAsScala._
/**
* @author Calclavia
*/
class Vector3
{
var x = 0D
var y = 0D
var z = 0D
def this(newX: Double, newY: Double, newZ: Double)
{
this()
this.x = newX
this.y = newY
this.z = newZ
}
def this(yaw: Double, pitch: Double)
{
this(-Math.sin(Math.toRadians(yaw)), Math.sin(Math.toRadians(pitch)), -Math.cos(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)))
}
def this(tile: TileEntity)
{
this(tile.xCoord, tile.yCoord, tile.zCoord)
}
def this(entity: Entity)
{
this(entity.posX, entity.posY, entity.posZ)
}
def this(vec: Vec3)
{
this(vec.xCoord, vec.yCoord, vec.zCoord)
}
def this(nbt: NBTTagCompound)
{
this(nbt.getDouble("x"), nbt.getDouble("y"), nbt.getDouble("z"))
}
def this(dir: ForgeDirection)
{
this(dir.offsetX, dir.offsetY, dir.offsetZ)
}
def toVec3 = Vec3.createVectorHelper(x, y, z)
/**
* Operations
*/
def +=(amount: Double): Vector3 =
{
x += amount
y += amount
z += amount
return this
}
def -=(amount: Double): Vector3 =
{
this += -amount
return this
}
def /=(amount: Double): Vector3 =
{
x /= amount
y /= amount
z /= amount
return this
}
def *=(amount: Double): Vector3 =
{
x *= amount
y *= amount
z *= amount
return this
}
def +(amount: Double): Vector3 =
{
return new Vector3(x + amount, y + amount, z + amount)
}
def +(amount: Vector3): Vector3 =
{
return new Vector3(x + amount.x, y + amount.y, z + amount.z)
}
def -(amount: Double): Vector3 =
{
return (this + -amount)
}
def -(amount: Vector3): Vector3 =
{
return (this + (amount * -1))
}
def /(amount: Double): Vector3 =
{
return new Vector3(x / amount, y / amount, z / amount)
}
def *(amount: Double): Vector3 =
{
return new Vector3(x * amount, y * amount, z * amount)
}
def $(other: Vector3) = x * other.x + y * other.y + z * other.z
def x(other: Vector3): Vector3 = new Vector3(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x)
def magnitudeSquared = this $ this;
def magnitude = Math.sqrt(magnitudeSquared)
def normalize = this / magnitude
def distance(other: Vector3) = (other - this).magnitude
def rotate(angle: Double, axis: Vector3): Vector3 =
{
return translateMatrix(getRotationMatrix(angle, axis), this)
}
def getRotationMatrix(angle: Double, axis: Vector3): Seq[Double] = axis.getRotationMatrix(angle)
def getRotationMatrix(newAngle: Double): Seq[Double] =
{
var angle = newAngle
val matrix = new Array[Double](16)
val axis = this.clone().normalize
val x = axis.x
val y = axis.y
val z = axis.z
angle *= 0.0174532925D
val cos = Math.cos(angle)
val ocos = 1.0F - cos
val sin = Math.sin(angle)
matrix(0) = (x * x * ocos + cos)
matrix(1) = (y * x * ocos + z * sin)
matrix(2) = (x * z * ocos - y * sin)
matrix(4) = (x * y * ocos - z * sin)
matrix(5) = (y * y * ocos + cos)
matrix(6) = (y * z * ocos + x * sin)
matrix(8) = (x * z * ocos + y * sin)
matrix(9) = (y * z * ocos - x * sin)
matrix(10) = (z * z * ocos + cos)
matrix(15) = 1.0F
return matrix
}
def translateMatrix(matrix: Seq[Double], translation: Vector3): Vector3 =
{
val x = translation.x * matrix(0) + translation.y * matrix(1) + translation.z * matrix(2) + matrix(3)
val y = translation.x * matrix(4) + translation.y * matrix(5) + translation.z * matrix(6) + matrix(7)
val z = translation.x * matrix(8) + translation.y * matrix(9) + translation.z * matrix(10) + matrix(11)
translation.x = x
translation.y = y
translation.z = z
return translation
}
def eulerAngles = new Vector3(Math.toDegrees(Math.atan2(x, z)), Math.toDegrees(-Math.atan2(y, Math.hypot(z, x))), 0)
def rayTrace(world: World, end: Vector3): MovingObjectPosition =
{
val block = world.rayTraceBlocks(toVec3, end.toVec3)
val entity = rayTraceEntities(world, end)
if (block == null)
return entity
if (entity == null)
return block
if (distance(new Vector3(block.hitVec)) < distance(new Vector3(entity.hitVec)))
return block
return entity
}
def rayTraceEntities(world: World, end: Vector3): MovingObjectPosition =
{
var closestEntityMOP: MovingObjectPosition = null
var closetDistance = 0D
val checkDistance = distance(end)
val scanRegion = AxisAlignedBB.getBoundingBox(-checkDistance, -checkDistance, -checkDistance, checkDistance, checkDistance, checkDistance).offset(x, y, z)
val checkEntities = world.getEntitiesWithinAABB(classOf[Entity], scanRegion).map(_.asInstanceOf[Entity])
checkEntities.foreach(
entity =>
{
if (entity != null && entity.canBeCollidedWith && entity.boundingBox != null)
{
val border = entity.getCollisionBorderSize
val bounds = entity.boundingBox.expand(border, border, border)
val hit = bounds.calculateIntercept(toVec3, end.toVec3)
if (hit != null)
{
if (bounds.isVecInside(toVec3))
{
if (0 < closetDistance || closetDistance == 0)
{
closestEntityMOP = new MovingObjectPosition(entity)
closestEntityMOP.hitVec = hit.hitVec
closetDistance = 0
}
}
else
{
val dist = distance(new Vector3(hit.hitVec))
if (dist < closetDistance || closetDistance == 0)
{
closestEntityMOP = new MovingObjectPosition(entity)
closestEntityMOP.hitVec = hit.hitVec
closetDistance = dist
}
}
}
}
}
)
return closestEntityMOP
}
def writeToNBT(nbt: NBTTagCompound)
{
nbt.setDouble("x", x)
nbt.setDouble("y", y)
nbt.setDouble("z", z)
}
override def equals(o: Any): Boolean =
{
if (o.isInstanceOf[Vector3])
{
val other = o.asInstanceOf[Vector3]
return other.x == x && other.y == y && other.z == z
}
return false
}
override def clone = new Vector3(x, y, z)
override def toString = "Vector3[" + x + "," + y + "," + z + "]"
override def hashCode(): Int =
{
val x = doubleToLongBits(this.x)
val y = doubleToLongBits(this.y)
val z = doubleToLongBits(this.z)
var hash = (x ^ (x >>> 32))
hash = 31 * hash + y ^ (y >>> 32)
hash = 31 * hash + z ^ (z >>> 32)
return hash.toInt;
}
}

View file

@ -1,14 +1,14 @@
package resonantinduction.electrical.em.laser
import cpw.mods.fml.client.registry.{RenderingRegistry, ISimpleBlockRenderingHandler}
import cpw.mods.fml.client.registry.{ISimpleBlockRenderingHandler, RenderingRegistry}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.Block
import net.minecraft.client.renderer.RenderBlocks
import net.minecraft.world.IBlockAccess
import net.minecraft.block.Block
import resonantinduction.electrical.em.laser.focus.mirror.{RenderMirror, BlockMirror}
import resonantinduction.electrical.em.laser.emitter.{RenderLaserEmitter, BlockLaserEmitter}
import resonantinduction.electrical.em.laser.receiver.{RenderLaserReceiver, BlockLaserReceiver}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import resonantinduction.electrical.em.laser.emitter.{BlockLaserEmitter, RenderLaserEmitter}
import resonantinduction.electrical.em.laser.focus.crystal.{BlockFocusCrystal, RenderFocusCrystal}
import resonantinduction.electrical.em.laser.focus.mirror.{BlockMirror, RenderMirror}
import resonantinduction.electrical.em.laser.receiver.{BlockLaserReceiver, RenderLaserReceiver}
/**
* @author Calclavia

View file

@ -1,16 +1,19 @@
package resonantinduction.electrical.em.laser
import resonantinduction.electrical.em.{ElectromagneticCoherence, Vector3}
import net.minecraft.world.World
import net.minecraft.util.{DamageSource, MovingObjectPosition}
import net.minecraft.block.{BlockTNT, BlockStainedGlassPane, BlockStainedGlass, Block}
import net.minecraft.block.material.Material
import scala.collection.mutable
import net.minecraft.item.ItemDye
import java.awt.Color
import net.minecraft.init.Blocks
import net.minecraft.tileentity.TileEntityFurnace
import cpw.mods.fml.relauncher.ReflectionHelper
import net.minecraft.block.material.Material
import net.minecraft.block.{Block, BlockStainedGlass, BlockStainedGlassPane, BlockTNT}
import net.minecraft.init.Blocks
import net.minecraft.item.ItemDye
import net.minecraft.tileentity.TileEntityFurnace
import net.minecraft.util.{DamageSource, MovingObjectPosition}
import net.minecraft.world.World
import resonantinduction.electrical.em.ElectromagneticCoherence
import universalelectricity.core.transform.vector.Vector3
import scala.collection.mutable
/**
* @author Calclavia

View file

@ -1,8 +1,7 @@
package resonantinduction.electrical.em.laser
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.electrical.em.Vector3
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.util.ForgeDirection
/**
* @author Calclavia

View file

@ -1,15 +1,14 @@
package resonantinduction.electrical.em.laser.emitter
import net.minecraft.block.{BlockPistonBase, BlockContainer}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.material.Material
import net.minecraft.world.{IBlockAccess, World}
import net.minecraft.creativetab.CreativeTabs
import net.minecraft.tileentity.TileEntity
import resonantinduction.electrical.em.{TabEC, ElectromagneticCoherence}
import net.minecraft.block.{BlockContainer, BlockPistonBase}
import net.minecraft.entity.EntityLivingBase
import net.minecraft.item.ItemStack
import resonantinduction.electrical.em.laser.{Laser, BlockRenderingHandler}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.{IBlockAccess, World}
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.{BlockRenderingHandler, Laser}
/**
* @author Calclavia

View file

@ -1,15 +1,15 @@
package resonantinduction.electrical.em.laser.emitter
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.client.model.AdvancedModelLoader
import resonantinduction.electrical.em.ElectromagneticCoherence
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.AdvancedModelLoader
import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11._
import cpw.mods.fml.client.FMLClientHandler
import net.minecraftforge.common.util.ForgeDirection
import cpw.mods.fml.relauncher.{Side, SideOnly}
import resonantinduction.electrical.em.ElectromagneticCoherence
/**
* @author Calclavia

View file

@ -1,8 +1,7 @@
package resonantinduction.electrical.em.laser.emitter
import resonantinduction.electrical.em.laser.{ILaserHandler, Laser, TileBase}
import resonantinduction.electrical.em.Vector3
import net.minecraft.util.MovingObjectPosition
import resonantinduction.electrical.em.laser.{ILaserHandler, Laser, TileBase}
/**
* @author Calclavia

View file

@ -2,12 +2,12 @@ package resonantinduction.electrical.em.laser.focus
import net.minecraft.block.BlockContainer
import net.minecraft.block.material.Material
import net.minecraft.world.World
import net.minecraft.entity.player.EntityPlayer
import resonantinduction.electrical.em.Vector3
import net.minecraftforge.common.util.ForgeDirection
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection
import universalelectricity.core.transform.vector.Vector3
/**
* @author Calclavia

View file

@ -1,6 +1,7 @@
package resonantinduction.electrical.em.laser.focus;
import resonantinduction.electrical.em.Vector3;
import universalelectricity.core.transform.vector.Vector3;
import java.util.List;

View file

@ -1,14 +1,17 @@
package resonantinduction.electrical.em.laser.focus
import net.minecraft.item.{ItemStack, Item}
import net.minecraft.world.World
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.entity.player.EntityPlayer
import cpw.mods.fml.relauncher.{SideOnly, Side}
import resonantinduction.electrical.em.{TabEC, ElectromagneticCoherence, Vector3}
import net.minecraft.util.{EnumChatFormatting, ChatComponentText}
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.{ChatComponentText, EnumChatFormatting}
import net.minecraft.world.World
import resonantinduction.core.ResonantTab
import resonantinduction.electrical.em.ElectromagneticCoherence
import universalelectricity.core.transform.vector.Vector3
import scala.collection.convert.wrapAsScala._
import scala.util.Random
import net.minecraft.nbt.NBTTagCompound
/**
* @author Calclavia
@ -17,7 +20,7 @@ class ItemFocusingMatrix extends Item
{
setUnlocalizedName(ElectromagneticCoherence.PREFIX + "focusingMatrix")
setTextureName(ElectromagneticCoherence.PREFIX + "focusingMatrix")
setCreativeTab(TabEC)
setCreativeTab(ResonantTab)
/**
* allows items to add custom lines of information to the mouseover description
@ -31,10 +34,10 @@ class ItemFocusingMatrix extends Item
add(list, "Focusing:")
val vec = getControlCoordinate(itemStack)
val vec : Vector3 = getControlCoordinate(itemStack)
if (vec != null)
add(list, "[" + vec.x.toInt + ", " + vec.y.toInt + ", " + vec.z.toInt + "]")
add(list, "[" + vec.xi + ", " + vec.yi + ", " + vec.z.toInt + "]")
else
add(list, "None")
}
@ -116,7 +119,7 @@ class ItemFocusingMatrix extends Item
def setControlCoordinate(stack: ItemStack, vec: Vector3)
{
val nbt = if (stack.getTagCompound != null) stack.getTagCompound else new NBTTagCompound()
vec.writeToNBT(nbt)
vec.writeNBT(nbt)
stack.setTagCompound(nbt)
}

View file

@ -1,11 +1,11 @@
package resonantinduction.electrical.em.laser.focus.crystal
import net.minecraft.block.material.Material
import resonantinduction.electrical.em.{TabEC, ElectromagneticCoherence}
import net.minecraft.world.World
import net.minecraft.tileentity.TileEntity
import resonantinduction.electrical.em.laser.BlockRenderingHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.material.Material
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.World
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.BlockRenderingHandler
import resonantinduction.electrical.em.laser.focus.BlockFocusBase
/**

View file

@ -1,15 +1,14 @@
package resonantinduction.electrical.em.laser.focus.crystal
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.client.model.AdvancedModelLoader
import resonantinduction.electrical.em.ElectromagneticCoherence
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.AdvancedModelLoader
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11._
import cpw.mods.fml.client.FMLClientHandler
import net.minecraftforge.common.util.ForgeDirection
import cpw.mods.fml.relauncher.{Side, SideOnly}
import resonantinduction.electrical.em.ElectromagneticCoherence
/**
* @author Calclavia

View file

@ -1,13 +1,13 @@
package resonantinduction.electrical.em.laser.focus.crystal
import resonantinduction.electrical.em.{ElectromagneticCoherence, Vector3}
import resonantinduction.electrical.em.laser.{Laser, TileBase, ILaserHandler}
import net.minecraft.util.MovingObjectPosition
import resonantinduction.electrical.em.laser.focus.IFocus
import net.minecraft.network.{NetworkManager, Packet}
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.network.play.server.S35PacketUpdateTileEntity
import net.minecraft.network.{NetworkManager, Packet}
import net.minecraft.util.MovingObjectPosition
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.focus.IFocus
import resonantinduction.electrical.em.laser.{ILaserHandler, Laser, TileBase}
/**
* Redirects lasers to one point

View file

@ -1,17 +1,13 @@
package resonantinduction.electrical.em.laser.focus.mirror
import net.minecraft.block.BlockContainer
import net.minecraft.block.material.Material
import resonantinduction.electrical.em.{TabEC, Vector3, ElectromagneticCoherence}
import net.minecraft.world.World
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.EntityLivingBase
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity
import resonantinduction.electrical.em.laser.BlockRenderingHandler
import net.minecraftforge.common.util.ForgeDirection
import cpw.mods.fml.relauncher.{Side, SideOnly}
import resonantinduction.electrical.em.laser.focus.{BlockFocusBase, IFocus, ItemFocusingMatrix}
import net.minecraft.block.material.Material
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.World
import resonantinduction.core.ResonantTab
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.BlockRenderingHandler
import resonantinduction.electrical.em.laser.focus.BlockFocusBase
/**
* @author Calclavia
@ -20,7 +16,7 @@ class BlockMirror extends BlockFocusBase(Material.rock)
{
setBlockName(ElectromagneticCoherence.PREFIX + "mirror")
setBlockTextureName("stone")
setCreativeTab(TabEC)
setCreativeTab(ResonantTab)
override def createNewTileEntity(world: World, metadata: Int): TileEntity =

View file

@ -1,14 +1,14 @@
package resonantinduction.electrical.em.laser.focus.mirror
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraftforge.client.model.AdvancedModelLoader
import net.minecraft.util.ResourceLocation
import resonantinduction.electrical.em.ElectromagneticCoherence
import net.minecraft.tileentity.TileEntity
import org.lwjgl.opengl.GL11._
import cpw.mods.fml.client.FMLClientHandler
import org.lwjgl.opengl.GL11
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.AdvancedModelLoader
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11._
import resonantinduction.electrical.em.ElectromagneticCoherence
/**
* @author Calclavia

View file

@ -1,14 +1,16 @@
package resonantinduction.electrical.em.laser.focus.mirror
import resonantinduction.electrical.em.{ElectromagneticCoherence, Vector3}
import net.minecraft.nbt.NBTTagCompound
import resonantinduction.electrical.em.laser.{TileBase, Laser, ILaserHandler}
import net.minecraft.util.MovingObjectPosition
import net.minecraft.network.{NetworkManager, Packet}
import net.minecraft.network.play.server.S35PacketUpdateTileEntity
import net.minecraft.network.{NetworkManager, Packet}
import net.minecraft.util.MovingObjectPosition
import net.minecraftforge.common.util.ForgeDirection
import scala.collection.convert.wrapAsJava._
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.focus.IFocus
import resonantinduction.electrical.em.laser.{ILaserHandler, Laser, TileBase}
import universalelectricity.core.transform.vector.Vector3
import scala.collection.convert.wrapAsJava._
/**
* @author Calclavia
@ -108,7 +110,7 @@ class TileMirror extends TileBase with ILaserHandler with IFocus
{
super.writeToNBT(nbt)
val normalNBT = new NBTTagCompound()
normal.writeToNBT(normalNBT)
normal.writeNBT(normalNBT)
nbt.setTag("normal", normalNBT)
}
}

View file

@ -1,10 +1,10 @@
package resonantinduction.electrical.em.laser.fx
import net.minecraft.client.particle.EntityFX
import net.minecraft.world.World
import net.minecraft.block.Block
import net.minecraft.init.Blocks
import net.minecraft.client.particle.EntityFX
import net.minecraft.client.renderer.Tessellator
import net.minecraft.init.Blocks
import net.minecraft.world.World
/**
* @author Calclavia

View file

@ -1,14 +1,15 @@
package resonantinduction.electrical.em.laser.fx
import net.minecraft.world.World
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.particle.EntityFX
import net.minecraft.client.renderer.Tessellator
import org.lwjgl.opengl.GL11._
import cpw.mods.fml.client.FMLClientHandler
import resonantinduction.electrical.em.{Vector3, ElectromagneticCoherence}
import net.minecraft.util.ResourceLocation
import net.minecraft.world.World
import org.lwjgl.opengl.GL11._
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.Laser
import cpw.mods.fml.relauncher.{Side, SideOnly}
import universalelectricity.core.transform.vector.Vector3
/**
* @author Calclavia
@ -90,8 +91,8 @@ class EntityLaserFX(par1World: World, start: Vector3, end: Vector3, color: Vecto
/**
* Rotate the beam
*/
glRotated(angles.x, 0, 1, 0)
glRotated(angles.y, 1, 0, 0)
glRotated(angles.x(), 0, 1, 0)
glRotated(angles.y(), 1, 0, 0)
glRotated(90, 1, 0, 0)

View file

@ -1,14 +1,14 @@
package resonantinduction.electrical.em.laser.fx
import net.minecraft.world.World
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.particle.EntityFX
import net.minecraft.client.renderer.Tessellator
import org.lwjgl.opengl.GL11._
import cpw.mods.fml.client.FMLClientHandler
import resonantinduction.electrical.em.{Vector3, ElectromagneticCoherence}
import net.minecraft.util.ResourceLocation
import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection
import cpw.mods.fml.relauncher.{Side, SideOnly}
import org.lwjgl.opengl.GL11._
import resonantinduction.electrical.em.ElectromagneticCoherence
/**
* @author Calclavia

View file

@ -7,8 +7,8 @@ import net.minecraft.entity.EntityLivingBase
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.{IBlockAccess, World}
import resonantinduction.electrical.em.ElectromagneticCoherence
import resonantinduction.electrical.em.laser.BlockRenderingHandler
import resonantinduction.electrical.em.{ElectromagneticCoherence, TabEC}
/**
* @author Calclavia

View file

@ -1,15 +1,15 @@
package resonantinduction.electrical.em.laser.receiver
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.client.model.AdvancedModelLoader
import resonantinduction.electrical.em.ElectromagneticCoherence
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.AdvancedModelLoader
import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11._
import cpw.mods.fml.client.FMLClientHandler
import net.minecraftforge.common.util.ForgeDirection
import cpw.mods.fml.relauncher.{Side, SideOnly}
import resonantinduction.electrical.em.ElectromagneticCoherence
/**
* @author Calclavia

View file

@ -1,9 +1,8 @@
package resonantinduction.electrical.em.laser.receiver
import resonantinduction.electrical.em.{ElectromagneticCoherence, Vector3}
import resonantinduction.electrical.em.laser.{Laser, TileBase, ILaserHandler}
import net.minecraft.util.MovingObjectPosition
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.electrical.em.laser.{ILaserHandler, Laser, TileBase}
/**
* @author Calclavia

View file

@ -1,90 +0,0 @@
package resonantinduction.electrical.generator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.lib.prefab.block.BlockRotatable;
import resonant.lib.render.block.BlockRenderingHandler;
import resonantinduction.core.Reference;
import universalelectricity.api.UniversalElectricity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockMotor extends BlockRotatable
{
public BlockMotor(int id)
{
super(id, UniversalElectricity.machine);
setTextureName(Reference.PREFIX + "material_stone");
rotationMask = Byte.parseByte("111111", 2);
}
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileMotor)
{
if (!world.isRemote)
{
int gear = ((TileMotor) tileEntity).toggleGearRatio();
entityPlayer.addChatMessage("Generator set to " + (gear == 0 ? "low" : gear == 1 ? "medium" : "high") + " gear.");
}
return true;
}
return false;
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
return doRotateBlock(world, x, y, z, ForgeDirection.getOrientation(side));
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileMotor)
{
if (!world.isRemote)
{
((TileMotor) tileEntity).isInversed = !((TileMotor) tileEntity).isInversed;
entityPlayer.addChatMessage("Generator now producing " + (((TileMotor) tileEntity).isInversed ? "resonantinduction/mechanical" : "electrical") + " energy.");
}
return true;
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileMotor();
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.ID;
}
}

View file

@ -4,13 +4,14 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.content.prefab.scala.render.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
@ -20,8 +21,8 @@ import resonantinduction.core.Reference;
*/
public class RenderMotor extends TileEntitySpecialRenderer implements ISimpleItemRenderer
{
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "generator.tcn");
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "generator.png");
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.modelDirectory() + "generator.tcn"));
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.domain(), Reference.modelPath() + "generator.png");
@Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
@ -41,7 +42,7 @@ public class RenderMotor extends TileEntitySpecialRenderer implements ISimpleIte
}
@Override
public void renderInventoryItem(ItemStack itemStack)
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
{
doRender(2, 0, 0, 0, 0);
}

View file

@ -1,184 +0,0 @@
package resonantinduction.electrical.generator;
import java.util.EnumSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.api.IRotatable;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonant.lib.grid.NodeRegistry;
import resonant.lib.prefab.tile.TileElectrical;
import resonantinduction.core.interfaces.IMechanicalNode;
import universalelectricity.api.energy.EnergyStorageHandler;
/**
* A kinetic energy to electrical energy converter.
*
* @author Calclavia
*/
public class TileMotor extends TileElectrical implements IRotatable, INodeProvider
{
protected IMechanicalNode node;
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
public boolean isInversed = true;
private byte gearRatio;
public TileMotor()
{
energy = new EnergyStorageHandler(1000000);
node = NodeRegistry.get(this, IMechanicalNode.class);
if (node != null)
node.setLoad(0.5);
}
public byte toggleGearRatio()
{
return gearRatio = (byte) ((gearRatio + 1) % 3);
}
@Override
public void initiate()
{
super.initiate();
if (node != null)
node.reconstruct();
}
@Override
public void invalidate()
{
node.deconstruct();
super.invalidate();
}
@Override
public void updateEntity()
{
super.updateEntity();
if (node != null)
{
node.update(0.05f);
if (!isInversed)
{
receiveMechanical();
produce();
}
else
{
produceMechanical();
}
}
}
public void receiveMechanical()
{
double power = node.getEnergy();
long receive = energy.receiveEnergy((long) power, true);
if (receive > 0)
{
double percentageUsed = receive / power;
node.apply(this, -node.getTorque() * percentageUsed, -node.getAngularSpeed() * percentageUsed);
}
}
public void produceMechanical()
{
long extract = energy.extractEnergy(energy.getEnergy(), false);
if (extract > 0)
{
long torqueRatio = (long) ((gearRatio + 1) / 2.2d * (extract));
if (torqueRatio > 0)
{
final double maxAngularVelocity = extract / (float) torqueRatio;
final double maxTorque = (extract) / maxAngularVelocity;
double setAngularVelocity = maxAngularVelocity;
double setTorque = maxTorque;
double currentTorque = Math.abs(node.getTorque());
if (currentTorque != 0)
setTorque = Math.min(setTorque, maxTorque) * (node.getTorque() / currentTorque);
double currentVelo = Math.abs(node.getAngularSpeed());
if (currentVelo != 0)
setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (node.getAngularSpeed() / currentVelo);
node.apply(this, setTorque - node.getTorque(), setAngularVelocity - node.getAngularSpeed());
energy.extractEnergy((long) Math.abs(setTorque * setAngularVelocity), true);
}
}
}
@Override
public EnumSet<ForgeDirection> getInputDirections()
{
return getOutputDirections();
}
@Override
public EnumSet<ForgeDirection> getOutputDirections()
{
EnumSet<ForgeDirection> dirs = EnumSet.allOf(ForgeDirection.class);
dirs.remove(this.getDirection());
dirs.remove(this.getDirection().getOpposite());
return dirs;
}
@Override
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
@Override
public void setDirection(ForgeDirection dir)
{
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, dir.ordinal(), 3);
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
isInversed = nbt.getBoolean("isInversed");
gearRatio = nbt.getByte("gear");
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("isInversed", isInversed);
nbt.setByte("gear", gearRatio);
}
@Override
public INode getNode(Class<? extends INode> nodeType, ForgeDirection from)
{
if (from == getDirection() || from == getDirection().getOpposite())
{
if (nodeType.isAssignableFrom(node.getClass()))
return node;
}
return null;
}
@Override
public String toString()
{
return "[TileMotor]" + x() + "x " + y() + "y " + z() + "z ";
}
}

View file

@ -0,0 +1,123 @@
package resonantinduction.electrical.generator
import java.util.HashSet
import net.minecraft.block.material.Material
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.IRotatable
import resonant.lib.content.prefab.java.TileElectric
import resonantinduction.core.interfaces.IMechanicalNode
import universalelectricity.api.core.grid.{INode, NodeRegistry}
/**
* A kinetic energy to electrical energy converter.
*
* @author Calclavia
*/
class TileMotor extends TileElectric(Material.iron) with IRotatable {
var mech_node : IMechanicalNode = NodeRegistry.get(this, classOf[IMechanicalNode])
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
var isInversed: Boolean = true
private var gearRatio: Byte = 0
def toggleGearRatio: Byte = {
return ((gearRatio + 1) % 3).asInstanceOf[Byte]
}
override def initiate {
super.initiate
if (mech_node != null) mech_node.reconstruct
}
override def invalidate {
mech_node.deconstruct
super.invalidate
}
override def update {
super.update
if (mech_node != null) {
mech_node.update(0.05f)
if (!isInversed) {
receiveMechanical
}
else {
produceMechanical
}
}
}
def receiveMechanical {
val power: Double = mech_node.getEnergy
val receive: Double = electricNode.addEnergy(power, true)
if (receive > 0) {
val percentageUsed: Double = receive / power
mech_node.apply(this, -mech_node.getTorque * percentageUsed, -mech_node.getAngularSpeed * percentageUsed)
}
}
def produceMechanical {
val extract: Double = electricNode.removeEnergy(electricNode.getEnergy, false)
if (extract > 0) {
val torqueRatio: Long = ((gearRatio + 1) / 2.2d * (extract)).asInstanceOf[Long]
if (torqueRatio > 0) {
val maxAngularVelocity: Double = extract / torqueRatio.asInstanceOf[Float]
val maxTorque: Double = (extract) / maxAngularVelocity
var setAngularVelocity: Double = maxAngularVelocity
var setTorque: Double = maxTorque
val currentTorque: Double = Math.abs(mech_node.getTorque)
if (currentTorque != 0) setTorque = Math.min(setTorque, maxTorque) * (mech_node.getTorque / currentTorque)
val currentVelo: Double = Math.abs(mech_node.getAngularSpeed)
if (currentVelo != 0) setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mech_node.getAngularSpeed / currentVelo)
mech_node.apply(this, setTorque - mech_node.getTorque, setAngularVelocity - mech_node.getAngularSpeed)
electricNode.removeEnergy(Math.abs(setTorque * setAngularVelocity).asInstanceOf[Long], true)
}
}
}
override def getInputDirections: HashSet[ForgeDirection] = {
return getOutputDirections
}
override def getOutputDirections: HashSet[ForgeDirection] = {
val dirs: HashSet[ForgeDirection] = new HashSet[ForgeDirection]
for (dir <- ForgeDirection.VALID_DIRECTIONS) {
if (dir != getDirection && dir != getDirection.getOpposite && dir != ForgeDirection.UNKNOWN) dirs.add(dir)
}
return dirs
}
def getDirection: ForgeDirection = {
return ForgeDirection.getOrientation(this.getBlockMetadata)
}
def setDirection(dir: ForgeDirection) {
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, dir.ordinal, 3)
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
isInversed = nbt.getBoolean("isInversed")
gearRatio = nbt.getByte("gear")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
nbt.setBoolean("isInversed", isInversed)
nbt.setByte("gear", gearRatio)
}
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode = {
if (from == getDirection || from == getDirection.getOpposite) {
if (nodeType.isAssignableFrom(mech_node.getClass)) return mech_node
}
return super.getNode(nodeType, from)
}
override def toString: String = {
return "[TileMotor]" + x + "x " + y + "y " + z + "z "
}
}

View file

@ -0,0 +1,51 @@
package resonantinduction.electrical.generator
import net.minecraft.block.material.Material
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.util.IIcon
import resonant.content.spatial.block.SpatialBlock
import resonantinduction.core.Reference
import resonantinduction.core.Settings
import resonantinduction.electrical.battery.TileEnergyDistribution
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import universalelectricity.core.transform.region.Cuboid
class TileSolarPanel extends TileEnergyDistribution(Material.iron) {
electricNode.energy.setCapacity(Settings.SOLAR_ENERGY * 20)
ioMap_$eq(728.asInstanceOf[Short])
setTextureName("solarPanel_top")
bounds(new Cuboid(0, 0, 0, 1, 0.3f, 1))
isOpaqueCube(false)
normalRender(false)
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IIconRegister) {
SpatialBlock.icon.put("solarPanel_side", iconReg.registerIcon(Reference.prefix + "solarPanel_side"))
SpatialBlock.icon.put("solarPanel_bottom", iconReg.registerIcon(Reference.prefix + "solarPanel_bottom"))
super.registerIcons(iconReg)
}
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon = {
if (side == 0) {
return SpatialBlock.icon.get("solarPanel_bottom")
}
else if (side == 1) {
return getIcon
}
return SpatialBlock.icon.get("solarPanel_side")
}
override def update {
if (!this.worldObj.isRemote) {
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky) {
if (this.worldObj.isDaytime) {
if (!(this.worldObj.isThundering || this.worldObj.isRaining)) {
this.electricNode.addEnergy(Settings.SOLAR_ENERGY, true)
}
}
}
}
super.update
}
}

View file

@ -0,0 +1,93 @@
package resonantinduction.electrical.generator
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.init.Blocks
import net.minecraft.util.IIcon
import net.minecraftforge.common.util.ForgeDirection
import resonant.content.spatial.block.SpatialBlock
import resonantinduction.core.Reference
import universalelectricity.core.transform.vector.Vector3
import resonant.lib.content.prefab.java.TileElectric
class TileThermopile extends TileElectric(Material.rock) {
this.ioMap = 728.asInstanceOf[Short]
override def update {
super.update
if (!this.worldObj.isRemote) {
var heatSources: Int = 0
var coolingSources: Int = 0
for (dir <- ForgeDirection.VALID_DIRECTIONS) {
val checkPos: Vector3 = new Vector3(this).add(dir)
val block: Block = checkPos.getBlock(worldObj)
if (block eq Blocks.water) {
coolingSources += 1
}
else if (block eq Blocks.snow) {
coolingSources += 2
}
else if (block eq Blocks.ice) {
coolingSources += 2
}
else if (block eq Blocks.fire) {
heatSources += 1
}
else if (block eq Blocks.lava) {
heatSources += 2
}
}
val multiplier: Int = (3 - Math.abs(heatSources - coolingSources))
if (multiplier > 0 && coolingSources > 0 && heatSources > 0) {
electricNode.addEnergy(15 * multiplier, true)
if (({
usingTicks += 1; usingTicks
}) >= MAX_USE_TICKS) {
for (dir <- ForgeDirection.VALID_DIRECTIONS) {
val checkPos: Vector3 = new Vector3(this).add(dir)
val blockID: Block = checkPos.getBlock(worldObj)
if (blockID eq Blocks.water) {
checkPos.setBlockToAir(worldObj)
}
else if (blockID eq Blocks.ice) {
checkPos.setBlock(worldObj, Blocks.water)
}
else if (blockID eq Blocks.fire) {
checkPos.setBlockToAir(worldObj)
}
else if (blockID eq Blocks.lava) {
checkPos.setBlock(worldObj, Blocks.stone)
}
}
usingTicks = 0
}
}
}
}
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IIconRegister)
{
SpatialBlock.icon.put("thermopile_top", iconReg.registerIcon(Reference.prefix + "thermopile_top"))
super.registerIcons(iconReg)
}
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon =
{
if (side == 1)
{
return SpatialBlock.icon.get("thermopile_top")
}
return super.getIcon(side, meta)
}
private final val MAX_USE_TICKS: Int = 120 * 20
/**
* The amount of ticks the thermopile will use the temperature differences before turning all
* adjacent sides to thermal equilibrium.
*/
private var usingTicks: Int = 0
}

View file

@ -1,85 +0,0 @@
package resonantinduction.electrical.generator.solar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import resonant.lib.content.module.TileRender;
import resonant.lib.prefab.vector.Cuboid;
import resonant.lib.utility.ConnectedTextureRenderer;
import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.electrical.battery.TileEnergyDistribution;
import universalelectricity.api.energy.EnergyStorageHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileSolarPanel extends TileEnergyDistribution
{
@SideOnly(Side.CLIENT)
public static IIcon sideIcon, bottomIcon;
public TileSolarPanel()
{
super(Material.iron);
energy = new EnergyStorageHandler(Settings.SOLAR_ENERGY * 20);
ioMap = 728;
textureName = "solarPanel_top";
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1);
isOpaqueCube = false;
normalRender = false;
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister iconReg)
{
sideIcon = iconReg.registerIcon(Reference.PREFIX + "solarPanel_side");
bottomIcon = iconReg.registerIcon(Reference.PREFIX + "solarPanel_bottom");
super.registerIcons(iconReg);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if (side == 0)
{
return bottomIcon;
}
else if (side == 1)
{
return getIcon();
}
return sideIcon;
}
@Override
public void updateEntity()
{
if (!this.worldObj.isRemote)
{
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
{
if (this.worldObj.isDaytime())
{
if (!(this.worldObj.isThundering() || this.worldObj.isRaining()))
{
this.energy.receiveEnergy(Settings.SOLAR_ENERGY, true);
markDistributionUpdate |= produce() > 0;
}
}
}
}
super.updateEntity();
}
@Override
@SideOnly(Side.CLIENT)
protected TileRender newRenderer()
{
return new ConnectedTextureRenderer(this, Reference.PREFIX + "tankEdge");
}
}

View file

@ -1,47 +0,0 @@
package resonantinduction.electrical.generator.thermopile;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonantinduction.core.Reference;
import universalelectricity.api.UniversalElectricity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockThermopile extends BlockTile
{
public IIcon topIcon;
public BlockThermopile(int id)
{
super(id, UniversalElectricity.machine);
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister iconReg)
{
topIcon = iconReg.registerIcon(Reference.PREFIX + "thermopile_top");
super.registerIcons(iconReg);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if (side == 1)
{
return topIcon;
}
return blockIcon;
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileThermopile();
}
}

View file

@ -1,106 +0,0 @@
package resonantinduction.electrical.generator.thermopile;
import net.minecraft.block.Block;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.lib.prefab.tile.TileElectrical;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.core.transform.vector.Vector3;
public class TileThermopile extends TileElectrical
{
private final int MAX_USE_TICKS = 120 * 20;
/**
* The amount of ticks the thermopile will use the temperature differences before turning all
* adjacent sides to thermal equilibrium.
*/
private int usingTicks = 0;
public TileThermopile()
{
this.energy = new EnergyStorageHandler(300);
this.ioMap = 728;
}
@Override
public void updateEntity()
{
super.updateEntity();
if (!this.worldObj.isRemote)
{
int heatSources = 0;
int coolingSources = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
Vector3 checkPos = new Vector3(this).add(dir);
int blockID = checkPos.getBlock(worldObj);
if (blockID == Block.waterStill.blockID)
{
coolingSources++;
}
else if (blockID == Block.snow.blockID)
{
coolingSources += 2;
}
else if (blockID == Block.ice.blockID)
{
coolingSources += 2;
}
else if (blockID == Block.fire.blockID)
{
heatSources++;
}
else if (blockID == Block.lavaStill.blockID)
{
heatSources += 2;
}
}
// Max difference would be "3"
int multiplier = (3 - Math.abs(heatSources - coolingSources));
if (multiplier > 0 && coolingSources > 0 && heatSources > 0)
{
energy.receiveEnergy(15 * multiplier, true);
if (++usingTicks >= MAX_USE_TICKS)
{
/**
* Create Thermal Equilibrium
*/
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
Vector3 checkPos = new Vector3(this).add(dir);
int blockID = checkPos.getBlock(worldObj);
if (blockID == Block.waterStill.blockID)
{
checkPos.setBlock(worldObj, 0);
}
else if (blockID == Block.ice.blockID)
{
checkPos.setBlock(worldObj, Block.waterStill.blockID);
}
else if (blockID == Block.fire.blockID)
{
checkPos.setBlock(worldObj, 0);
}
else if (blockID == Block.lavaStill.blockID)
{
checkPos.setBlock(worldObj, Block.stone.blockID);
}
}
usingTicks = 0;
}
}
produce();
}
}
}

View file

@ -16,11 +16,6 @@ import codechicken.multipart.TMultiPart;
public class ItemLevitator extends JItemMultiPart implements IHighlight
{
public ItemLevitator(int id)
{
super(id);
}
@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4)

View file

@ -4,19 +4,21 @@ import java.lang.ref.WeakReference;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid;
import net.minecraft.block.BlockLadder;
import net.minecraft.block.BlockSnow;
import net.minecraft.block.BlockVine;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -31,12 +33,12 @@ import resonantinduction.core.prefab.part.PartFace;
import resonantinduction.electrical.Electrical;
import resonantinduction.electrical.tesla.TileTesla;
import universalelectricity.core.transform.vector.Vector3;
import universalelectricity.api.vector.VectorWorld;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.multipart.TMultiPart;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import universalelectricity.core.transform.vector.VectorWorld;
public class PartLevitator extends PartFace
{
@ -70,8 +72,8 @@ public class PartLevitator extends PartFace
public static boolean canBePath(World world, Vector3 position)
{
Block block = Block.blocksList[position.getBlock(world)];
return block == null || (block instanceof BlockSnow || block instanceof BlockVine || block instanceof BlockLadder || ((block instanceof BlockFluid || block instanceof IFluidBlock) && block.blockID != Block.lavaMoving.blockID && block.blockID != Block.lavaStill.blockID));
Block block = position.getBlock(world);
return block == null || (block instanceof BlockSnow || block instanceof BlockVine || block instanceof BlockLadder || (block instanceof IFluidBlock && block != Blocks.flowing_lava && block != Blocks.lava));
}
@Override
@ -83,7 +85,7 @@ public class PartLevitator extends PartFace
{
if (world().isRemote)
{
player.addChatMessage("Successfully linked devices.");
player.addChatMessage(new ChatComponentText("Successfully linked devices."));
}
LinkUtility.clearLink(itemStack);
}
@ -91,7 +93,7 @@ public class PartLevitator extends PartFace
{
if (world().isRemote)
{
player.addChatMessage("Marked link for device.");
player.addChatMessage(new ChatComponentText("Marked link for device."));
}
LinkUtility.setLink(itemStack, new VectorWorld(world(), x(), y(), z()));
@ -103,7 +105,7 @@ public class PartLevitator extends PartFace
if (player.getCurrentEquippedItem() != null)
{
if (player.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
if (player.getCurrentEquippedItem().getItem() == Items.dye)
{
setDye(player.getCurrentEquippedItem().getItemDamage());
@ -226,7 +228,7 @@ public class PartLevitator extends PartFace
world().spawnEntityInWorld(entityItem);
}
pushDelay = Settings.LEVITATOR_PUSH_DELAY;
pushDelay = Settings.LEVITATOR_PUSH_DELAY();
}
}
}
@ -283,7 +285,7 @@ public class PartLevitator extends PartFace
{
Vector3 prevResult = results.get(i - 1).clone();
Vector3 difference = prevResult.clone().difference(result);
Vector3 difference = prevResult.clone().subtract(result);
final ForgeDirection direction = difference.toForgeDirection();
if (renderBeam)
@ -291,7 +293,7 @@ public class PartLevitator extends PartFace
Electrical.proxy.renderElectricShock(world(), prevResult.clone().add(0.5), result.clone().add(0.5), EnumColor.DYES[dyeID].toColor(), world().rand.nextFloat() > 0.9);
}
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.x, result.y, result.z, result.x + 1, result.y + 1, result.z + 1);
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(result.x(), result.y(), result.z(), result.x() + 1, result.y() + 1, result.z() + 1);
List<EntityItem> entities = world().getEntitiesWithinAABB(EntityItem.class, bounds);
for (EntityItem entityItem : entities)
@ -362,102 +364,102 @@ public class PartLevitator extends PartFace
switch (direction)
{
case DOWN:
entityItem.setPosition(lockVector.x + 0.5, entityItem.posY, lockVector.z + 0.5);
entityItem.setPosition(lockVector.x() + 0.5, entityItem.posY, lockVector.z() + 0.5);
entityItem.motionX = 0;
entityItem.motionZ = 0;
if (!input)
{
entityItem.motionY = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionY - Settings.LEVITATOR_ACCELERATION);
entityItem.motionY = Math.max(-Settings.LEVITATOR_MAX_SPEED(), entityItem.motionY - Settings.LEVITATOR_ACCELERATION());
}
else
{
entityItem.motionY = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionY + .04 + Settings.LEVITATOR_ACCELERATION);
entityItem.motionY = Math.min(Settings.LEVITATOR_MAX_SPEED(), entityItem.motionY + .04 + Settings.LEVITATOR_ACCELERATION());
}
break;
case UP:
entityItem.setPosition(lockVector.x + 0.5, entityItem.posY, lockVector.z + 0.5);
entityItem.setPosition(lockVector.x() + 0.5, entityItem.posY, lockVector.z() + 0.5);
entityItem.motionX = 0;
entityItem.motionZ = 0;
if (!input)
{
entityItem.motionY = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionY + .04 + Settings.LEVITATOR_ACCELERATION);
entityItem.motionY = Math.min(Settings.LEVITATOR_MAX_SPEED(), entityItem.motionY + .04 + Settings.LEVITATOR_ACCELERATION());
}
else
{
entityItem.motionY = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionY - Settings.LEVITATOR_ACCELERATION);
entityItem.motionY = Math.max(-Settings.LEVITATOR_MAX_SPEED(), entityItem.motionY - Settings.LEVITATOR_ACCELERATION());
}
break;
case NORTH:
entityItem.setPosition(lockVector.x + 0.5, lockVector.y + 0.5, entityItem.posZ);
entityItem.setPosition(lockVector.x() + 0.5, lockVector.y() + 0.5, entityItem.posZ);
entityItem.motionX = 0;
entityItem.motionY = 0;
if (!input)
{
entityItem.motionZ = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ - Settings.LEVITATOR_ACCELERATION);
entityItem.motionZ = Math.max(-Settings.LEVITATOR_MAX_SPEED(), entityItem.motionZ - Settings.LEVITATOR_ACCELERATION());
}
else
{
entityItem.motionZ = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ + Settings.LEVITATOR_ACCELERATION);
entityItem.motionZ = Math.min(Settings.LEVITATOR_MAX_SPEED(), entityItem.motionZ + Settings.LEVITATOR_ACCELERATION());
}
break;
case SOUTH:
entityItem.setPosition(lockVector.x + 0.5, lockVector.y + 0.5, entityItem.posZ);
entityItem.setPosition(lockVector.x() + 0.5, lockVector.y() + 0.5, entityItem.posZ);
entityItem.motionX = 0;
entityItem.motionY = 0;
if (!input)
{
entityItem.motionZ = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ + Settings.LEVITATOR_ACCELERATION);
entityItem.motionZ = Math.min(Settings.LEVITATOR_MAX_SPEED(), entityItem.motionZ + Settings.LEVITATOR_ACCELERATION());
}
else
{
entityItem.motionZ = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ - Settings.LEVITATOR_ACCELERATION);
entityItem.motionZ = Math.max(-Settings.LEVITATOR_MAX_SPEED(), entityItem.motionZ - Settings.LEVITATOR_ACCELERATION());
}
break;
case WEST:
entityItem.setPosition(entityItem.posX, lockVector.y + 0.5, lockVector.z + 0.5);
entityItem.setPosition(entityItem.posX, lockVector.y() + 0.5, lockVector.z() + 0.5);
entityItem.motionY = 0;
entityItem.motionZ = 0;
if (!input)
{
entityItem.motionX = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionX - Settings.LEVITATOR_ACCELERATION);
entityItem.motionX = Math.max(-Settings.LEVITATOR_MAX_SPEED(), entityItem.motionX - Settings.LEVITATOR_ACCELERATION());
}
else
{
entityItem.motionX = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionX + Settings.LEVITATOR_ACCELERATION);
entityItem.motionX = Math.min(Settings.LEVITATOR_MAX_SPEED(), entityItem.motionX + Settings.LEVITATOR_ACCELERATION());
}
break;
case EAST:
entityItem.setPosition(entityItem.posX, lockVector.y + 0.5, lockVector.z + 0.5);
entityItem.setPosition(entityItem.posX, lockVector.y() + 0.5, lockVector.z() + 0.5);
entityItem.motionY = 0;
entityItem.motionZ = 0;
if (!input)
{
entityItem.motionX = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionX + Settings.LEVITATOR_ACCELERATION);
entityItem.motionX = Math.min(Settings.LEVITATOR_MAX_SPEED(), entityItem.motionX + Settings.LEVITATOR_ACCELERATION());
}
else
{
entityItem.motionX = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionX - Settings.LEVITATOR_ACCELERATION);
entityItem.motionX = Math.max(-Settings.LEVITATOR_MAX_SPEED(), entityItem.motionX - Settings.LEVITATOR_ACCELERATION());
}
break;
@ -485,9 +487,9 @@ public class PartLevitator extends PartFace
suckBounds = operationBounds = null;
ForgeDirection dir = placementSide.getOpposite();
MovingObjectPosition mop = world().clip(getPosition().add(dir).toVec3(), getPosition().add(dir, Settings.LEVITATOR_MAX_REACH).toVec3());
MovingObjectPosition mop = world().rayTraceBlocks(getPosition().add(dir).toVec3(), getPosition().add(dir.offsetX * Settings.LEVITATOR_MAX_REACH(), dir.offsetY * Settings.LEVITATOR_MAX_REACH(), dir.offsetZ * Settings.LEVITATOR_MAX_REACH()).toVec3());
int reach = Settings.LEVITATOR_MAX_REACH;
int reach = Settings.LEVITATOR_MAX_REACH();
if (mop != null)
{
@ -566,7 +568,7 @@ public class PartLevitator extends PartFace
{
packet.writeBoolean(true);
NBTTagCompound nbt = new NBTTagCompound();
new VectorWorld(getLink().world(), getLink().x(), getLink().y(), getLink().z()).writeToNBT(nbt);
new VectorWorld(getLink().world(), getLink().x(), getLink().y(), getLink().z()).writeNBT(nbt);
packet.writeNBTTagCompound(nbt);
packet.writeByte(getLink().placementSide.ordinal());
}
@ -602,7 +604,7 @@ public class PartLevitator extends PartFace
if (getLink() != null && getLink().world() != null)
{
nbt.setCompoundTag("link", new VectorWorld(getLink().world(), getLink().x(), getLink().y(), getLink().z()).writeToNBT(new NBTTagCompound()));
nbt.setTag("link", new VectorWorld(getLink().world(), getLink().x(), getLink().y(), getLink().z()).writeNBT(new NBTTagCompound()));
nbt.setByte("linkSide", (byte) getLink().placementSide.ordinal());
}
}
@ -636,7 +638,7 @@ public class PartLevitator extends PartFace
Vector3 start = getPosition();
Vector3 target = new Vector3(getLink().x(), getLink().y(), getLink().z());
if (start.distance(target) < Settings.MAX_LEVITATOR_DISTANCE)
if (start.distance(target) < Settings.MAX_LEVITATOR_DISTANCE())
{
if (canBeMovePath(world(), start) && canBeMovePath(world(), target))
{

View file

@ -2,12 +2,13 @@ package resonantinduction.electrical.levitator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.content.prefab.scala.render.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import cpw.mods.fml.client.FMLClientHandler;
@ -16,9 +17,9 @@ public class RenderLevitator implements ISimpleItemRenderer
{
public static final RenderLevitator INSTANCE = new RenderLevitator();
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "levitator.tcn");
public static final ResourceLocation TEXTURE_ON = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "levitator_on.png");
public static final ResourceLocation TEXTURE_OFF = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "levitator_off.png");
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelDirectory() + "levitator.tcn"));
public static final ResourceLocation TEXTURE_ON = new ResourceLocation(Reference.domain(), Reference.modelPath() + "levitator_on.png");
public static final ResourceLocation TEXTURE_OFF = new ResourceLocation(Reference.domain(), Reference.modelPath() + "levitator_off.png");
public void render(PartLevitator part, double x, double y, double z)
{
@ -57,7 +58,7 @@ public class RenderLevitator implements ISimpleItemRenderer
}
@Override
public void renderInventoryItem(ItemStack itemStack)
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
{
GL11.glPushMatrix();
GL11.glTranslatef(0f, 0.5f, 0f);

View file

@ -5,6 +5,8 @@ import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -280,7 +282,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
{
if (item != null)
{
if (item.getItem().itemID == Block.lever.blockID)
if (Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.lever))
{
TileMultipart tile = tile();
World w = world();
@ -805,7 +807,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
int absDir = Rotation.rotateSide(side, r);
BlockCoord pos = new BlockCoord(tile()).offset(absDir).offset(side);
world().notifyBlockOfNeighborChange(pos.x, pos.y, pos.z, tile().getBlockType().blockID);
world().notifyBlockOfNeighborChange(pos.x, pos.y, pos.z, tile().getBlockType());
}
public void notifyStraightChange(int r)
@ -813,7 +815,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
int absDir = Rotation.rotateSide(side, r);
BlockCoord pos = new BlockCoord(tile()).offset(absDir);
world().notifyBlockOfNeighborChange(pos.x, pos.y, pos.z, tile().getBlockType().blockID);
world().notifyBlockOfNeighborChange(pos.x, pos.y, pos.z, tile().getBlockType());
}
public boolean maskConnects(int r)
@ -891,7 +893,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
{
if (isInsulated)
{
Colour color = new ColourARGB(ItemDye.dyeColors[this.color]);
Colour color = new ColourARGB(ItemDye.field_150922_c[this.color]);
color.a = (byte) 255;
return color;
}

View file

@ -3,19 +3,16 @@ package resonantinduction.electrical.wire.flat;
import java.util.Arrays;
import java.util.LinkedList;
import codechicken.lib.render.uv.IconTransformation;
import codechicken.lib.render.uv.UV;
import codechicken.lib.render.uv.UVScale;
import codechicken.lib.render.uv.UVTranslation;
import net.minecraft.util.IIcon;
import codechicken.lib.lighting.LightModel;
import codechicken.lib.math.MathHelper;
import codechicken.lib.render.CCModel;
import codechicken.lib.render.ColourModifier;
import codechicken.lib.render.ColourMultiplier;
import codechicken.lib.render.IUVTransformation;
import codechicken.lib.render.IVertexModifier;
import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.render.UV;
import codechicken.lib.render.UVScale;
import codechicken.lib.render.UVTranslation;
import codechicken.lib.render.Vertex5;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Rotation;

View file

@ -1,94 +0,0 @@
package resonantinduction.electrical.wire.framed;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import codechicken.lib.vec.BlockCoord;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TileMultipart;
public class PartFramedSwitchWire extends PartFramedWire
{
@Override
public boolean isBlockedOnSide(ForgeDirection side)
{
if (this.checkRedstone(6))
{
return super.isBlockedOnSide(side);
}
return true;
}
@Override
public String getType()
{
return "resonant_induction_switch_wire";
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
TileMultipart tile = tile();
World w = world();
if (item != null && item.getItem().itemID == Block.lever.blockID)
{
if (!w.isRemote)
{
PartFramedWire wire = (PartFramedWire) MultiPartRegistry.createPart("resonant_induction_wire", false);
wire.copyFrom(this);
if (tile.canReplacePart(this, wire))
{
tile.remPart(this);
TileMultipart.addPart(w, new BlockCoord(tile), wire);
if (!player.capabilities.isCreativeMode)
{
tile.dropItems(Collections.singletonList(new ItemStack(Block.lever, 1)));
}
}
}
return true;
}
else
{
return super.activate(player, part, item);
}
}
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = (List<ItemStack>) super.getDrops();
drops.add(new ItemStack(Block.lever, 1));
return drops;
}
@Override
public byte getPossibleAcceptorConnections()
{
if (this.checkRedstone(6))
{
return super.getPossibleAcceptorConnections();
}
return 0x00;
}
@Override
public byte getPossibleWireConnections()
{
if (this.checkRedstone(6))
{
return super.getPossibleWireConnections();
}
return 0x00;
}
}

View file

@ -1,365 +0,0 @@
package resonantinduction.electrical.wire.framed;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyTile;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import resonant.lib.prefab.damage.ElectricalDamage;
import resonantinduction.core.prefab.part.PartFramedConnection;
import resonantinduction.electrical.Electrical;
import resonantinduction.electrical.wire.EnumWireMaterial;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalClass;
import universalelectricity.api.electricity.IElectricalNetwork;
import universalelectricity.api.energy.EnergyNetworkLoader;
import universalelectricity.api.energy.IConductor;
import universalelectricity.api.energy.IEnergyNetwork;
import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Translation;
import codechicken.microblock.IHollowConnect;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.PartMap;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@UniversalClass
public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, IConductor, IEnergyNetwork> implements IConductor, TSlottedPart, JNormalOcclusion, IHollowConnect
{
public PartFramedWire()
{
super(Electrical.itemInsulation);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
breakIcon = RenderFramedWire.breakIcon;
}
public PartFramedWire(EnumWireMaterial type)
{
this();
material = type;
}
public PartFramedWire(int typeID)
{
this(EnumWireMaterial.values()[typeID]);
}
@Override
public String getType()
{
return "resonant_induction_wire";
}
/** IC2 Functions */
@Override
public void onWorldJoin()
{
if (tile() instanceof IEnergyTile && !world().isRemote)
{
// Check if there's another part that's an IEnergyTile
boolean foundAnotherPart = false;
for (int i = 0; i < tile().partList().size(); i++)
{
TMultiPart part = tile().partMap(i);
if (part instanceof IEnergyTile && part != this)
{
foundAnotherPart = true;
break;
}
}
if (!foundAnotherPart)
{
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) tile()));
}
}
super.onWorldJoin();
}
@Override
public void preRemove()
{
if (!world().isRemote)
{
this.getNetwork().split(this);
if (tile() instanceof IEnergyTile)
{
// Check if there's another part that's an IEnergyTile
boolean foundAnotherPart = false;
for (int i = 0; i < tile().partList().size(); i++)
{
TMultiPart part = tile().partMap(i);
if (part instanceof IEnergyTile && part != this)
{
foundAnotherPart = true;
break;
}
}
if (!foundAnotherPart)
{
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) tile()));
}
}
}
super.preRemove();
}
@Override
public boolean doesTick()
{
return false;
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
if (!world().isRemote)
System.out.println(getNetwork());
if (item != null)
{
if (item.getItem().itemID == Block.lever.blockID)
{
TileMultipart tile = tile();
World w = world();
if (!w.isRemote)
{
PartFramedSwitchWire wire = (PartFramedSwitchWire) MultiPartRegistry.createPart("resonant_induction_switch_wire", false);
wire.copyFrom(this);
if (tile.canReplacePart(this, wire))
{
tile.remPart(this);
TileMultipart.addPart(w, new BlockCoord(tile), wire);
if (!player.capabilities.isCreativeMode)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
return true;
}
}
return super.activate(player, part, item);
}
@Override
public void preparePlacement(int meta)
{
this.setMaterial(meta);
}
@Override
public Iterable<Cuboid6> getCollisionBoxes()
{
Set<Cuboid6> collisionBoxes = new HashSet<Cuboid6>();
collisionBoxes.addAll((Collection<? extends Cuboid6>) getSubParts());
return collisionBoxes;
}
@Override
public float getStrength(MovingObjectPosition hit, EntityPlayer player)
{
return 10F;
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass)
{
if (pass == 0)
{
RenderFramedWire.INSTANCE.renderStatic(this);
}
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
{
if (getMaterial() == EnumWireMaterial.SILVER)
{
RenderFramedWire.INSTANCE.renderShine(this, pos.x, pos.y, pos.z, frame);
}
}
@Override
public void drawBreaking(RenderBlocks renderBlocks)
{
CCRenderState.reset();
RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null);
}
@Override
public Iterable<Cuboid6> getOcclusionBoxes()
{
return getCollisionBoxes();
}
@Override
public int getSlotMask()
{
return PartMap.CENTER.mask;
}
@Override
public int getHollowSize()
{
return isInsulated ? 8 : 6;
}
@Override
protected boolean canConnectTo(TileEntity tile, ForgeDirection side)
{
Object obj = tile instanceof TileMultipart ? ((TileMultipart) tile).partMap(ForgeDirection.UNKNOWN.ordinal()) : tile;
return canConnect(side, obj);
}
@Override
public IConductor getConnector(TileEntity tile)
{
if (tile instanceof IConductor)
return (IConductor) ((IConductor) tile).getInstance(ForgeDirection.UNKNOWN);
return null;
}
/** Shouldn't need to be overridden. Override connectionPrevented instead */
@Override
public boolean canConnect(ForgeDirection from, Object obj)
{
if (isBlockedOnSide(from))
return false;
if (obj instanceof PartFramedWire)
{
if (world().isBlockIndirectlyGettingPowered(x(), y(), z()))
{
return false;
}
PartFramedWire wire = (PartFramedWire) obj;
if (this.getMaterial() == wire.getMaterial())
{
if (isInsulated() && wire.isInsulated())
{
return getColor() == wire.getColor() || (getColor() == DEFAULT_COLOR || wire.getColor() == DEFAULT_COLOR);
}
return true;
}
return false;
}
return CompatibilityModule.canConnect(obj, from.getOpposite(), this);
}
@Override
public float getResistance()
{
return this.getMaterial().resistance;
}
public void copyFrom(PartFramedWire otherCable)
{
this.isInsulated = otherCable.isInsulated;
this.color = otherCable.color;
this.connections = otherCable.connections;
this.material = otherCable.material;
this.currentWireConnections = otherCable.currentWireConnections;
this.currentAcceptorConnections = otherCable.currentAcceptorConnections;
this.setNetwork(otherCable.getNetwork());
this.getNetwork().setBufferFor(this, otherCable.getInstance(ForgeDirection.UNKNOWN).getNetwork().getBufferOf(otherCable));
}
@Override
public IEnergyNetwork getNetwork()
{
if (network == null)
{
setNetwork(EnergyNetworkLoader.getNewNetwork(this));
}
return network;
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
return this.getNetwork().produce(this, from.getOpposite(), receive, doReceive);
}
@Override
public long onExtractEnergy(ForgeDirection from, long request, boolean doExtract)
{
return 0;
}
@Override
public long getCurrentCapacity()
{
return this.getMaterial().maxAmps;
}
@Override
public void setMaterial(int i)
{
setMaterial(EnumWireMaterial.values()[i]);
}
@Override
protected ItemStack getItem()
{
return new ItemStack(Electrical.itemWire, 1, getMaterialID());
}
@Override
public void onEntityCollision(Entity entity)
{
if (!this.isInsulated() && this.getNetwork() instanceof IElectricalNetwork)
ElectricalDamage.handleElectrocution(entity, this, (IElectricalNetwork) this.getNetwork());
}
@Override
public String toString()
{
return "[PartFramedWire]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
}

View file

@ -1,185 +0,0 @@
package resonantinduction.electrical.wire.framed;
import java.nio.FloatBuffer;
import java.util.Map;
import net.minecraft.item.ItemDye;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.part.PartFramedConnection;
import resonantinduction.core.render.InvertX;
import codechicken.lib.colour.Colour;
import codechicken.lib.colour.ColourARGB;
import codechicken.lib.lighting.LightModel;
import codechicken.lib.render.CCModel;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.ColourMultiplier;
import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.TextureUtils;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Translation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author unpairedbracket
*
*/
@SideOnly(Side.CLIENT)
public class RenderFramedWire
{
public static final ResourceLocation WIRE_SHINE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "white.png");
public static final Map<String, CCModel> models;
public static final Map<String, CCModel> shinyModels;
public static IIcon wireIcon;
public static IIcon lainWireIcon;
public static IIcon insulationIcon;
public static IIcon breakIcon;
public static FloatBuffer location = BufferUtils.createFloatBuffer(4);
public static FloatBuffer specular = BufferUtils.createFloatBuffer(4);
public static FloatBuffer zero = BufferUtils.createFloatBuffer(4);
public static FloatBuffer defaultAmbient = BufferUtils.createFloatBuffer(4);
public static final RenderFramedWire INSTANCE = new RenderFramedWire();
static
{
models = CCModel.parseObjModels(new ResourceLocation(Reference.DOMAIN, "models/wire.obj"), 7, new InvertX());
for (CCModel c : models.values())
{
c.apply(new Translation(.5, 0, .5));
c.computeLighting(LightModel.standardLightModel);
c.shrinkUVs(0.0005);
}
shinyModels = CCModel.parseObjModels(new ResourceLocation(Reference.DOMAIN, "models/wireShine.obj"), 7, new InvertX());
for (CCModel c : shinyModels.values())
{
c.apply(new Translation(.5, 0, .5));
c.computeLighting(LightModel.standardLightModel);
c.shrinkUVs(0.0005);
}
loadBuffer(location, 0, 0, 0, 1);
loadBuffer(specular, 1, 1, 1, 1);
loadBuffer(zero, 0, 0, 0, 0);
loadBuffer(defaultAmbient, 0.4F, 0.4F, 0.4F, 1);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero);
GL11.glLight(GL11.GL_LIGHT3, GL11.GL_SPECULAR, specular);
GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, specular);
GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, zero);
GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, zero);
GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 128f);
}
public static void loadBuffer(FloatBuffer buffer, float... src)
{
buffer.clear();
buffer.put(src);
buffer.flip();
}
public void renderShine(PartFramedWire wire, double x, double y, double z, float f)
{
if (wire != null)
{
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_LIGHT0);
GL11.glDisable(GL11.GL_LIGHT1);
GL11.glEnable(GL11.GL_LIGHT3);
GL11.glLight(GL11.GL_LIGHT3, GL11.GL_POSITION, location);
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero);
CCRenderState.reset();
CCRenderState.useNormals(true);
CCRenderState.changeTexture(WIRE_SHINE);
CCRenderState.startDrawing(7);
renderSideShine(ForgeDirection.UNKNOWN, wire);
byte renderSides = wire.getAllCurrentConnections();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if (PartFramedConnection.connectionMapContainsSide(renderSides, side))
renderSideShine(side, wire);
}
CCRenderState.draw();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_LIGHT0);
GL11.glEnable(GL11.GL_LIGHT1);
GL11.glDisable(GL11.GL_LIGHT3);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, defaultAmbient);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glPopMatrix();
}
}
public void renderStatic(PartFramedWire wire)
{
TextureUtils.bindAtlas(0);
CCRenderState.reset();
CCRenderState.useModelColours(true);
CCRenderState.setBrightness(wire.world(), wire.x(), wire.y(), wire.z());
renderSide(ForgeDirection.UNKNOWN, wire);
byte renderSides = wire.getAllCurrentConnections();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if (PartFramedConnection.connectionMapContainsSide(renderSides, side))
{
renderSide(side, wire);
}
}
}
public void renderSide(ForgeDirection side, PartFramedWire wire)
{
String name = side.name().toLowerCase();
name = name.equals("unknown") ? "center" : name;
Colour colour = wire.getMaterial().color;
renderPart(wireIcon, models.get(name), wire.x(), wire.y(), wire.z(), colour);
if (wire.isInsulated())
{
Colour insulationColour = new ColourARGB(ItemDye.dyeColors[wire.getColor()]);
insulationColour.a = (byte) 255;
renderPart(insulationIcon, models.get(name + "Insulation"), wire.x(), wire.y(), wire.z(), insulationColour);
}
}
public void renderSideShine(ForgeDirection side, PartFramedWire wire)
{
String name = side.name().toLowerCase();
name = name.equals("unknown") ? "center" : name;
renderPartShine(shinyModels.get(name));
}
public void renderPart(IIcon icon, CCModel cc, double x, double y, double z, Colour colour)
{
cc.render(0, cc.verts.length, Rotation.sideOrientation(0, Rotation.rotationTo(0, 2)).at(codechicken.lib.vec.Vector3.center).with(new Translation(x, y, z)), new IconTransformation(icon), new ColourMultiplier(colour));
}
public void renderPartShine(CCModel cc)
{
cc.render(null, 0, 0);
}
}

View file

@ -6,7 +6,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.api.IRotatable;
@ -25,7 +24,7 @@ public class TilePump extends TileMechanical implements IRotatable, IFluidHandle
normalRender(false);
isOpaqueCube(false);
customItemRender(true);
textureName("material_steel");
setTextureName("material_steel");
pressureNode = new FluidPressureNode(this)
{
@Override

View file

@ -188,7 +188,7 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
@Override
public universalelectricity.core.transform.vector.Vector3[] getMultiBlockVectors()
{
return (universalelectricity.core.transform.vector.Vector3[])new universalelectricity.core.transform.vector.Vector3(this.x(), this.y(), this.z()).getAround(this.world(), placementSide, 1).toArray();
return new universalelectricity.core.transform.vector.Vector3(this.x(), this.y(), this.z()).getAround(this.world(), placementSide, 1);
}
@Override

View file

@ -34,7 +34,7 @@ public class TileDetector extends TileFilterable implements IPacketIDReceiver
public TileDetector()
{
super();
textureName(Reference.prefix() + "material_metal_side");
setTextureName(Reference.prefix() + "material_metal_side");
this.isOpaqueCube(false);
this.normalRender(false);
this.canProvidePower(true);