Removed Item Lev by calc's request, and fixed some issue with past few scala conversion commits

This commit is contained in:
Robert S 2014-09-27 10:44:53 -04:00
parent 466efa3e36
commit 424b79f49d
14 changed files with 68 additions and 1237 deletions

View file

@ -17,7 +17,6 @@ import resonantinduction.electrical.laser.focus.crystal.{RenderFocusCrystal, Til
import resonantinduction.electrical.laser.focus.mirror.{RenderMirror, TileMirror}
import resonantinduction.electrical.laser.fx.{EntityBlockParticleFX, EntityLaserFX, EntityScorchFX}
import resonantinduction.electrical.laser.receiver.{RenderLaserReceiver, TileLaserReceiver}
import resonantinduction.electrical.levitator.RenderLevitator
import resonantinduction.electrical.multimeter.{RenderMultimeter, GuiMultimeter, PartMultimeter}
import resonantinduction.electrical.render.FXElectricBolt
import resonantinduction.electrical.tesla.{RenderTesla, TileTesla}
@ -36,7 +35,6 @@ class ClientProxy extends CommonProxy
override def init
{
ItemRenderHandler.register(ElectricalContent.itemTransformer, RenderTransformer.INSTANCE)
ItemRenderHandler.register(ElectricalContent.itemLevitator, RenderLevitator.INSTANCE)
ItemRenderHandler.register(ElectricalContent.itemMultimeter, RenderMultimeter.INSTANCE)
ItemRenderHandler.register(ElectricalContent.itemQuantumGlyph, RenderQuantumGlyph)

View file

@ -22,7 +22,6 @@ import resonantinduction.electrical.laser.focus.ItemFocusingMatrix
import resonantinduction.electrical.laser.focus.crystal.{BlockFocusCrystal, TileFocusCrystal}
import resonantinduction.electrical.laser.focus.mirror.{BlockMirror, TileMirror}
import resonantinduction.electrical.laser.receiver.{BlockLaserReceiver, TileLaserReceiver}
import resonantinduction.electrical.levitator.{ItemLevitator, PartLevitator}
import resonantinduction.electrical.multimeter.{ItemMultimeter, PartMultimeter}
import resonantinduction.electrical.tesla.TileTesla
import resonantinduction.electrical.transformer.{ItemElectricTransformer, PartElectricTransformer}
@ -86,7 +85,6 @@ object Electrical
ElectricalContent.itemTransformer = Electrical.contentRegistry.newItem(classOf[ItemElectricTransformer])
ElectricalContent.blockTesla = Electrical.contentRegistry.newBlock(classOf[TileTesla])
ElectricalContent.blockBattery = Electrical.contentRegistry.newBlock(classOf[TileBattery])
ElectricalContent.itemLevitator = Electrical.contentRegistry.newItem(classOf[ItemLevitator])
ElectricalContent.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[Item])
ElectricalContent.blockSolarPanel = Electrical.contentRegistry.newBlock(classOf[TileSolarPanel])
ElectricalContent.blockMotor = Electrical.contentRegistry.newBlock(classOf[TileMotor])
@ -106,7 +104,6 @@ object Electrical
ResonantPartFactory.register(classOf[PartFlatWire])
ResonantPartFactory.register(classOf[PartMultimeter])
ResonantPartFactory.register(classOf[PartElectricTransformer])
ResonantPartFactory.register(classOf[PartLevitator])
ResonantPartFactory.register(classOf[PartQuantumGlyph])
Electrical.proxy.preInit

View file

@ -12,8 +12,8 @@ import scala.collection.JavaConversions._
*/
class GridBattery extends Grid[TileBattery](classOf[NodeEnergy])
{
var totalEnergy: Long = 0
var totalCapacity: Long = 0
var totalEnergy: Double = 0
var totalCapacity: Double = 0
/**
* Causes the energy shared by all batteries to be distributed out to all linked batteries
@ -31,10 +31,10 @@ class GridBattery extends Grid[TileBattery](classOf[NodeEnergy])
totalCapacity += connector.energy.getEnergyCapacity
lowestY = Math.min(connector.yCoord, lowestY)
highestY = Math.max(connector.yCoord, highestY)
connector.renderEnergyAmount_$eq(0)
connector.renderEnergyAmount = 0
}
var remainingRenderEnergy: Long = totalEnergy
var remainingRenderEnergy: Double = totalEnergy
var y: Int = 0
while (y >= 0 && y <= highestY && remainingRenderEnergy > 0)
{
@ -48,7 +48,7 @@ class GridBattery extends Grid[TileBattery](classOf[NodeEnergy])
}
}
val levelSize: Int = connectorsInlevel.size
var used: Long = 0
var used: Double = 0
import scala.collection.JavaConversions._
for (connector <- connectorsInlevel)
{
@ -61,20 +61,20 @@ class GridBattery extends Grid[TileBattery](classOf[NodeEnergy])
}
val percentageLoss: Double = 0
val energyLoss: Long = (percentageLoss * 100).asInstanceOf[Long]
val energyLoss: Double = percentageLoss * 100
totalEnergy -= energyLoss
val amountOfNodes: Int = this.getNodes.size - exclusion.length
if (totalEnergy > 0 && amountOfNodes > 0)
{
var remainingEnergy: Long = totalEnergy
var remainingEnergy: Double = totalEnergy
val firstNode: TileBattery = this.getFirstNode
for (node <- this.getNodes)
{
if (node != firstNode && !Arrays.asList(exclusion).contains(node))
{
val percentage: Double = (node.energy.getEnergyCapacity.asInstanceOf[Double] / totalCapacity.asInstanceOf[Double])
val energyForBattery: Long = Math.max(Math.round(totalEnergy * percentage), 0)
val percentage: Double = (node.energy.getEnergyCapacity / totalCapacity)
val energyForBattery: Double = Math.max(totalEnergy * percentage, 0)
node.energy.setEnergy(energyForBattery)
remainingEnergy -= energyForBattery
}

View file

@ -142,20 +142,14 @@ class ItemBlockBattery(block: Block) extends ItemBlock(block) with IEnergyItem
return this.getEnergyCapacity(itemStack) / 100
}
@SuppressWarnings(Array("unchecked")) override def getSubItems(par1: Item, par2CreativeTabs: CreativeTabs, par3List: List[_])
@SuppressWarnings(Array("unchecked"))
override def getSubItems(par1: Item, par2CreativeTabs: CreativeTabs, par3List: List[_])
{
for (tier <- 0 to TileBattery.MAX_TIER)
{
var tier: Byte = 0
while (tier <= TileBattery.MAX_TIER)
{
{
par3List.add(Compatibility.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(this), tier), 0))
par3List.add(Compatibility.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier)))
}
({
tier += 1; tier - 1
})
}
par3List.add(Compatibility.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(this), tier.asInstanceOf[Byte]), 0))
par3List.add(Compatibility.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(this), tier.asInstanceOf[Byte]), TileBattery.getEnergyForTier(tier)))
}
}
}

View file

@ -63,7 +63,7 @@ class TileBattery extends TileElectric(Material.iron) with IPacketReceiver {
override def getDescPacket: AbstractPacket =
{
return new PacketTile(this, renderEnergyAmount, ioMap)
return new PacketTile(this, Array[Any](renderEnergyAmount, ioMap))
}
def read(data: ByteBuf, player: EntityPlayer, `type`: PacketType) {

View file

@ -1,49 +0,0 @@
package resonantinduction.electrical.generator;
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.content.prefab.scala.render.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
/**
* @author Calclavia
*
*/
public class RenderMotor extends TileEntitySpecialRenderer implements ISimpleItemRenderer
{
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelPath() + "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)
{
doRender(t.getBlockMetadata(), x, y, z, f);
}
private void doRender(int facingDirection, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
GL11.glRotatef(90, 0, 1, 0);
RenderUtility.rotateBlockBasedOnDirection(ForgeDirection.getOrientation(facingDirection));
bindTexture(TEXTURE);
MODEL.renderAll();
GL11.glPopMatrix();
}
@Override
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
{
doRender(2, 0, 0, 0, 0);
}
}

View file

@ -0,0 +1,48 @@
package resonantinduction.electrical.generator
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.content.prefab.scala.render.ISimpleItemRenderer
import resonant.lib.render.RenderUtility
import resonantinduction.core.Reference
/**
* @author Calclavia
*
*/
object RenderMotor
{
final val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "generator.tcn"))
final val TEXTURE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "generator.png")
}
class RenderMotor extends TileEntitySpecialRenderer with ISimpleItemRenderer
{
def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float)
{
doRender(t.getBlockMetadata, x, y, z, f)
}
private def doRender(facingDirection: Int, x: Double, y: Double, z: Double, f: Float)
{
GL11.glPushMatrix
GL11.glTranslatef(x.asInstanceOf[Float] + 0.5f, y.asInstanceOf[Float] + 0.5f, z.asInstanceOf[Float] + 0.5f)
GL11.glRotatef(90, 0, 1, 0)
RenderUtility.rotateBlockBasedOnDirection(ForgeDirection.getOrientation(facingDirection))
bindTexture(RenderMotor.TEXTURE)
RenderMotor.MODEL.renderAll
GL11.glPopMatrix
}
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
{
doRender(2, 0, 0, 0, 0)
}
}

View file

@ -1,18 +1,15 @@
package resonantinduction.electrical.generator
import net.minecraft.block.material.Material
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.util.IIcon
import net.minecraftforge.common.util.ForgeDirection
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 resonantinduction.core.{Reference, Settings}
import resonantinduction.electrical.battery.TileBattery
import universalelectricity.core.transform.region.Cuboid
class TileSolarPanel extends TileEnergyDistribution(Material.iron) {
class TileSolarPanel extends TileBattery {
energy.setCapacity(Settings.SOLAR_ENERGY * 20)
ioMap_$eq(728.asInstanceOf[Short])

View file

@ -1,29 +0,0 @@
package resonantinduction.electrical.levitator
import codechicken.lib.vec.{BlockCoord, Vector3}
import codechicken.microblock.FacePlacementGrid
import codechicken.multipart.{TItemMultiPart, TMultiPart}
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.util.MathHelper
import net.minecraft.world.World
import resonantinduction.core.ResonantPartFactory
import resonantinduction.core.prefab.part.IHighlight
class ItemLevitator extends Item with TItemMultiPart with IHighlight
{
def newPart(itemStack: ItemStack, player: EntityPlayer, world: World, pos: BlockCoord, bside: Int, hit: Vector3): TMultiPart =
{
val side = FacePlacementGrid.getHitSlot(hit, bside)
val part: PartLevitator = ResonantPartFactory.create(classOf[PartLevitator])
if (part != null)
{
val l: Int = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3
val facing: Int = if (l == 0) 2 else (if (l == 1) 5 else (if (l == 2) 3 else (if (l == 3) 4 else 0)))
part.preparePlacement(side, facing)
}
return part
}
def getHighlightType: Int = 0
}

View file

@ -1,246 +0,0 @@
package resonantinduction.electrical.levitator;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelEMContractor extends ModelBase
{
public boolean doSpin;
// fields
ModelRenderer frame1;
ModelRenderer frame2;
ModelRenderer frame3;
ModelRenderer frame4;
ModelRenderer frame5;
ModelRenderer frame6;
ModelRenderer frame7;
ModelRenderer frame8;
ModelRenderer left_frame_connector;
ModelRenderer right_frame_connector;
ModelRenderer teslapole;
ModelRenderer Coil1;
ModelRenderer coil2;
ModelRenderer coil3;
ModelRenderer coil4;
ModelRenderer pole1;
ModelRenderer pole2;
ModelRenderer pole3;
ModelRenderer pole4;
ModelRenderer poletop1;
ModelRenderer poletop2;
ModelRenderer poletop3;
ModelRenderer poletop4;
ModelRenderer base1;
ModelRenderer base2;
ModelRenderer base3;
public ModelEMContractor(boolean spin)
{
doSpin = spin;
textureWidth = 128;
textureHeight = 128;
frame1 = new ModelRenderer(this, 0, 24);
frame1.addBox(0F, 0F, 0F, 1, 8, 1);
frame1.setRotationPoint(-3F, 15F, -2F);
frame1.setTextureSize(128, 128);
frame1.mirror = true;
setRotation(frame1, 0F, 0F, 0F);
frame2 = new ModelRenderer(this, 0, 24);
frame2.addBox(0F, 0F, 0F, 1, 8, 1);
frame2.setRotationPoint(1F, 15F, 2F);
frame2.setTextureSize(128, 128);
frame2.mirror = true;
setRotation(frame2, 0F, 0F, 0F);
frame3 = new ModelRenderer(this, 0, 24);
frame3.addBox(0F, 0F, 0F, 1, 8, 1);
frame3.setRotationPoint(2F, 15F, -2F);
frame3.setTextureSize(128, 128);
frame3.mirror = true;
setRotation(frame3, 0F, 0F, 0F);
frame4 = new ModelRenderer(this, 0, 24);
frame4.addBox(0F, 0F, 0F, 1, 8, 1);
frame4.setRotationPoint(-3F, 15F, 1F);
frame4.setTextureSize(128, 128);
frame4.mirror = true;
setRotation(frame4, 0F, 0F, 0F);
frame5 = new ModelRenderer(this, 0, 24);
frame5.addBox(0F, 0F, 0F, 1, 8, 1);
frame5.setRotationPoint(2F, 15F, 1F);
frame5.setTextureSize(128, 128);
frame5.mirror = true;
setRotation(frame5, 0F, 0F, 0F);
frame6 = new ModelRenderer(this, 0, 24);
frame6.addBox(0F, 0F, 0F, 1, 8, 1);
frame6.setRotationPoint(1F, 15F, -3F);
frame6.setTextureSize(128, 128);
frame6.mirror = true;
setRotation(frame6, 0F, 0F, 0F);
frame7 = new ModelRenderer(this, 0, 24);
frame7.addBox(0F, 0F, 0F, 1, 8, 1);
frame7.setRotationPoint(-2F, 15F, 2F);
frame7.setTextureSize(128, 128);
frame7.mirror = true;
setRotation(frame7, 0F, 0F, 0F);
frame8 = new ModelRenderer(this, 0, 24);
frame8.addBox(0F, 0F, 0F, 1, 8, 1);
frame8.setRotationPoint(-2F, 15F, -3F);
frame8.setTextureSize(128, 128);
frame8.mirror = true;
setRotation(frame8, 0F, 0F, 0F);
left_frame_connector = new ModelRenderer(this, 0, 20);
left_frame_connector.addBox(0F, 0F, 0F, 1, 1, 2);
left_frame_connector.setRotationPoint(-3F, 15F, -1F);
left_frame_connector.setTextureSize(128, 128);
left_frame_connector.mirror = true;
setRotation(left_frame_connector, 0F, 0F, 0F);
right_frame_connector = new ModelRenderer(this, 0, 20);
right_frame_connector.addBox(0F, 0F, 0F, 1, 1, 2);
right_frame_connector.setRotationPoint(2F, 15F, -1F);
right_frame_connector.setTextureSize(128, 128);
right_frame_connector.mirror = true;
setRotation(right_frame_connector, 0F, 0F, 0F);
teslapole = new ModelRenderer(this, 0, 0);
teslapole.addBox(-1F, -1F, -1F, 2, 15, 2);
teslapole.setRotationPoint(0F, 9F, 0F);
teslapole.setTextureSize(128, 128);
teslapole.mirror = true;
setRotation(teslapole, 0F, 0F, 0F);
Coil1 = new ModelRenderer(this, 17, 0);
Coil1.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
Coil1.setRotationPoint(0F, 12.5F, 0F);
Coil1.setTextureSize(128, 128);
Coil1.mirror = true;
setRotation(Coil1, 0F, 0F, 0F);
coil2 = new ModelRenderer(this, 17, 0);
coil2.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
coil2.setRotationPoint(0F, 14F, 0F);
coil2.setTextureSize(128, 128);
coil2.mirror = true;
setRotation(coil2, 0F, 0F, 0F);
coil3 = new ModelRenderer(this, 17, 0);
coil3.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
coil3.setRotationPoint(0F, 9.5F, 0F);
coil3.setTextureSize(128, 128);
coil3.mirror = true;
setRotation(coil3, 0F, 0F, 0F);
coil4 = new ModelRenderer(this, 17, 0);
coil4.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
coil4.setRotationPoint(0F, 11F, 0F);
coil4.setTextureSize(128, 128);
coil4.mirror = true;
setRotation(coil4, 0F, 0F, 0F);
pole1 = new ModelRenderer(this, 5, 26);
pole1.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
pole1.setRotationPoint(0F, 18F, 6.5F);
pole1.setTextureSize(128, 128);
pole1.mirror = true;
setRotation(pole1, 0F, 0F, 0F);
pole2 = new ModelRenderer(this, 5, 26);
pole2.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
pole2.setRotationPoint(0F, 18F, -6.5F);
pole2.setTextureSize(128, 128);
pole2.mirror = true;
setRotation(pole2, 0F, 0F, 0F);
pole3 = new ModelRenderer(this, 5, 26);
pole3.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
pole3.setRotationPoint(-6.5F, 18F, 0F);
pole3.setTextureSize(128, 128);
pole3.mirror = true;
setRotation(pole3, 0F, 0F, 0F);
pole4 = new ModelRenderer(this, 5, 26);
pole4.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
pole4.setRotationPoint(6.5F, 18F, 0F);
pole4.setTextureSize(128, 128);
pole4.mirror = true;
setRotation(pole4, 0F, 0F, 0F);
poletop1 = new ModelRenderer(this, 31, 0);
poletop1.addBox(-1F, -1F, -1F, 2, 2, 2);
poletop1.setRotationPoint(0F, 16.5F, -6.5F);
poletop1.setTextureSize(128, 128);
poletop1.mirror = true;
setRotation(poletop1, 0F, 0F, 0F);
poletop2 = new ModelRenderer(this, 31, 0);
poletop2.addBox(-1F, -1F, -1F, 2, 2, 2);
poletop2.setRotationPoint(0F, 16.5F, 6.5F);
poletop2.setTextureSize(128, 128);
poletop2.mirror = true;
setRotation(poletop2, 0F, 0F, 0F);
poletop3 = new ModelRenderer(this, 31, 0);
poletop3.addBox(-1F, -1F, -1F, 2, 2, 2);
poletop3.setRotationPoint(6.5F, 16.5F, 0F);
poletop3.setTextureSize(128, 128);
poletop3.mirror = true;
setRotation(poletop3, 0F, 0F, 0F);
poletop4 = new ModelRenderer(this, 31, 0);
poletop4.addBox(-1F, -1F, -1F, 2, 2, 2);
poletop4.setRotationPoint(-6.5F, 16.5F, 0F);
poletop4.setTextureSize(128, 128);
poletop4.mirror = true;
setRotation(poletop4, 0F, 0F, 0F);
base1 = new ModelRenderer(this, 0, 55);
base1.addBox(0F, 0F, 0F, 16, 1, 8);
base1.setRotationPoint(-8F, 23F, -4F);
base1.setTextureSize(128, 128);
base1.mirror = true;
setRotation(base1, 0F, 0F, 0F);
base2 = new ModelRenderer(this, 0, 68);
base2.addBox(0F, 0F, 0F, 8, 1, 5);
base2.setRotationPoint(-4F, 23F, 3F);
base2.setTextureSize(128, 128);
base2.mirror = true;
setRotation(base2, 0F, 0F, 0F);
base3 = new ModelRenderer(this, 0, 79);
base3.addBox(0F, 0F, 0F, 8, 1, 5);
base3.setRotationPoint(-4F, 23F, -8F);
base3.setTextureSize(128, 128);
base3.mirror = true;
setRotation(base3, 0F, 0F, 0F);
}
public void render(float f5)
{
if (doSpin)
{
Coil1.rotateAngleY = (float) Math.toRadians(Math.toDegrees(Coil1.rotateAngleY) + 3 < 360 ? Math.toDegrees(Coil1.rotateAngleY) + 3 : 0);
coil2.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil2.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil2.rotateAngleY) + 3 : 0);
coil3.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil3.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil3.rotateAngleY) + 3 : 0);
coil4.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil4.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil4.rotateAngleY) + 3 : 0);
}
frame1.render(f5);
frame2.render(f5);
frame3.render(f5);
frame4.render(f5);
frame5.render(f5);
frame6.render(f5);
frame7.render(f5);
frame8.render(f5);
left_frame_connector.render(f5);
right_frame_connector.render(f5);
teslapole.render(f5);
Coil1.render(f5);
coil2.render(f5);
coil3.render(f5);
coil4.render(f5);
pole1.render(f5);
pole2.render(f5);
pole3.render(f5);
pole4.render(f5);
poletop1.render(f5);
poletop2.render(f5);
poletop3.render(f5);
poletop4.render(f5);
base1.render(f5);
base2.render(f5);
base3.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -1,690 +0,0 @@
package resonantinduction.electrical.levitator;
import java.lang.ref.WeakReference;
import java.util.List;
import net.minecraft.block.Block;
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.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;
import net.minecraftforge.fluids.IFluidBlock;
import resonant.lib.render.EnumColor;
import resonant.lib.utility.LinkUtility;
import resonant.lib.utility.WrenchUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.PartFace;
import resonantinduction.core.util.MultipartUtil;
import resonantinduction.electrical.Electrical;
import resonantinduction.electrical.ElectricalContent;
import resonantinduction.electrical.tesla.TileTesla;
import universalelectricity.core.transform.vector.Vector3;
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
{
/**
* true = suck, false = push
*/
public boolean input = true;
/**
* Client Side Only
*/
public float renderRotation = 0;
private int pushDelay;
private AxisAlignedBB operationBounds;
private AxisAlignedBB suckBounds;
/**
* Pathfinding
*/
private ThreadLevitatorPathfinding thread;
private PathfinderLevitator pathfinder;
private WeakReference<PartLevitator> linked;
private int lastCalcTime = 0;
/**
* Color of beam
*/
private int dyeID = TileTesla.DEFAULT_COLOR;
/**
* Linking
*/
private byte saveLinkSide;
private VectorWorld saveLinkVector;
public static boolean canBePath(World world, Vector3 position)
{
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
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack itemStack)
{
if (WrenchUtility.isWrench(itemStack))
{
if (tryLink(LinkUtility.getLink(itemStack), LinkUtility.getSide(itemStack)))
{
if (world().isRemote)
{
player.addChatMessage(new ChatComponentText("Successfully linked devices."));
}
LinkUtility.clearLink(itemStack);
}
else
{
if (world().isRemote)
{
player.addChatMessage(new ChatComponentText("Marked link for device."));
}
LinkUtility.setLink(itemStack, new VectorWorld(world(), x(), y(), z()));
LinkUtility.setSide(itemStack, (byte) placementSide.ordinal());
}
return true;
}
if (player.getCurrentEquippedItem() != null)
{
if (player.getCurrentEquippedItem().getItem() == Items.dye)
{
setDye(player.getCurrentEquippedItem().getItemDamage());
if (!player.capabilities.isCreativeMode)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
return true;
}
}
if (player.isSneaking())
{
input = !input;
}
updateBounds();
updatePath();
return true;
}
/**
* Link methods
*/
public boolean tryLink(VectorWorld linkVector, byte side)
{
if (linkVector != null)
{
TMultiPart part = MultipartUtil.getMultipart(world(), linkVector, side);
if (part instanceof PartLevitator)
{
setLink((PartLevitator) part, true);
}
return true;
}
return false;
}
public PartLevitator getLink()
{
return linked != null && linked.get() != null && linked.get().world() != null ? linked.get() : null;
}
@Override
public void onEntityCollision(Entity entity)
{
/**
* Attempt to pull items in.
*/
if (!world().isRemote && input && canFunction() && entity instanceof EntityItem)
{
EntityItem entityItem = (EntityItem) entity;
IInventory inventory = (IInventory) getLatched();
ItemStack remains = InventoryUtility.putStackInInventory(inventory, entityItem.getEntityItem(), placementSide.getOpposite().getOpposite().ordinal(), false);
if (remains == null)
{
entityItem.setDead();
}
else
{
entityItem.getEntityItem().stackSize = remains.stackSize;
}
// TODO: Add redstone pulse and reaction?
}
}
@Override
public void update()
{
if (ticks % 60 == 0)
{
updateBounds();
}
super.update();
pushDelay = Math.max(0, pushDelay - 1);
/**
* Try to use temp link vectors from save/loads to link.
*/
if (saveLinkVector != null)
{
tryLink(saveLinkVector, saveLinkSide);
saveLinkVector = null;
}
if (canFunction())
{
IInventory inventory = (IInventory) getLatched();
/**
* Place items or take items from the inventory into the world.
*/
if (!input)
{
renderRotation = Math.min(20, renderRotation + 0.8f);
/**
* Attempt to push items out.
*/
if (pushDelay == 0)
{
ItemStack retrieved = InventoryUtility.takeTopItemFromInventory(inventory, placementSide.getOpposite().getOpposite().ordinal());
if (retrieved != null)
{
EntityItem entityItem = getItemWithPosition(retrieved);
if (!world().isRemote)
{
world().spawnEntityInWorld(entityItem);
}
pushDelay = Settings.LEVITATOR_PUSH_DELAY();
}
}
}
else if (input)
{
renderRotation = Math.max(0, renderRotation - 0.8f);
}
final int renderPeriod = 1;
final boolean renderBeam = ticks % renderPeriod == 0 && hasLink() && getLink().input != input;
if (!input)
{
if (hasLink())
{
if (getLink().input)
{
/**
* Linked usage.
*/
if (thread != null)
{
PathfinderLevitator newPath = thread.getPath();
if (newPath != null)
{
pathfinder = newPath;
pathfinder.results.add(getPosition());
thread = null;
}
}
// Push entity along path.
if (pathfinder != null)
{
List<Vector3> results = pathfinder.results;
/**
* Draw default beams.
*/
if (renderBeam)
{
Electrical.proxy().renderElectricShock(world(), getBeamSpawnPosition(), getPosition().add(0.5), EnumColor.DYES[dyeID].toColor(), world().rand.nextFloat() > 0.9);
Electrical.proxy().renderElectricShock(world(), getLink().getPosition().add(0.5), getLink().getBeamSpawnPosition(), EnumColor.DYES[dyeID].toColor(), world().rand.nextFloat() > 0.9);
}
for (int i = 0; i < results.size(); i++)
{
Vector3 result = results.get(i).clone();
if (canBeMovePath(world(), result))
{
if (i - 1 >= 0)
{
Vector3 prevResult = results.get(i - 1).clone();
Vector3 difference = prevResult.clone().subtract(result);
final ForgeDirection direction = difference.toForgeDirection();
if (renderBeam)
{
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.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)
{
moveEntity(entityItem, direction, result);
}
}
}
else
{
updatePath();
break;
}
}
}
else
{
updatePath();
}
}
}
else if (operationBounds != null)
{
/**
* Non-linked usage.
*/
for (EntityItem entityItem : (List<EntityItem>) world().getEntitiesWithinAABB(EntityItem.class, operationBounds))
{
moveEntity(entityItem, placementSide.getOpposite(), getPosition());
}
if (ticks % renderPeriod == 0)
{
Electrical.proxy().renderElectricShock(world(), getBeamSpawnPosition(), new Vector3(operationBounds.maxX - 0.5 - placementSide.offsetX / 3f, operationBounds.maxY - 0.5 - placementSide.offsetY / 3f, operationBounds.maxZ - 0.5 - placementSide.offsetZ / 3f), EnumColor.DYES[dyeID].toColor(), world().rand.nextFloat() > 0.9);
}
}
}
lastCalcTime--;
}
}
public boolean canBeMovePath(World world, Vector3 position)
{
TMultiPart partSelf = MultipartUtil.getMultipart(new VectorWorld(world, position), placementSide.ordinal());
if (partSelf == this)
{
return true;
}
TMultiPart partLink = MultipartUtil.getMultipart(new VectorWorld(world, position), getLink().placementSide.ordinal());
if (partLink == getLink())
{
return true;
}
return canBePath(world, position);
}
private boolean hasLink()
{
return getLink() != null && getLink().getLink() == this;
}
private void moveEntity(EntityItem entityItem, ForgeDirection direction, Vector3 lockVector)
{
switch (direction)
{
case DOWN:
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());
}
else
{
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.motionX = 0;
entityItem.motionZ = 0;
if (!input)
{
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());
}
break;
case NORTH:
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());
}
else
{
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.motionX = 0;
entityItem.motionY = 0;
if (!input)
{
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());
}
break;
case WEST:
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());
}
else
{
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.motionY = 0;
entityItem.motionZ = 0;
if (!input)
{
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());
}
break;
default:
break;
}
entityItem.ticksExisted = 1;
entityItem.isAirBorne = true;
entityItem.delayBeforeCanPickup = 1;
entityItem.age = Math.max(entityItem.age - 1, 0);
}
private EntityItem getItemWithPosition(ItemStack toSend)
{
EntityItem item = new EntityItem(world(), x() + 0.5, y() + 0.5, z() + 0.5, toSend);
item.motionX = 0;
item.motionY = 0;
item.motionZ = 0;
return item;
}
public void updateBounds()
{
suckBounds = operationBounds = null;
ForgeDirection dir = placementSide.getOpposite();
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();
if (mop != null)
{
if (MultipartUtil.getMultipart(world(), mop.blockX, mop.blockY, mop.blockZ, placementSide.getOpposite().ordinal()) instanceof PartLevitator)
{
reach = (int) Math.min(getPosition().distance(new Vector3(mop.hitVec)), reach);
if (dir.offsetX + dir.offsetY + dir.offsetZ < 0)
{
operationBounds = AxisAlignedBB.getBoundingBox(x() + dir.offsetX * reach, y() + dir.offsetY * reach, z() + dir.offsetZ * reach, x() + 1, y() + 1, z() + 1);
suckBounds = AxisAlignedBB.getBoundingBox(x() + dir.offsetX, y() + dir.offsetY, z() + dir.offsetZ, x() + 1, y() + 1, z() + 1);
}
else
{
operationBounds = AxisAlignedBB.getBoundingBox(x(), y(), z(), x() + 1 + dir.offsetX * reach, y() + 1 + dir.offsetY * reach, z() + 1 + dir.offsetZ * reach);
suckBounds = AxisAlignedBB.getBoundingBox(x(), y(), z(), x() + 1 + dir.offsetX, y() + 1 + dir.offsetY, z() + 1 + dir.offsetZ);
}
}
}
}
@Override
public void onNeighborChanged()
{
super.onNeighborChanged();
updateBounds();
}
public boolean canFunction()
{
//TODO remove (false) when working on
return false && isLatched() && !world().isBlockIndirectlyGettingPowered(x(), y(), z());
}
public boolean isLatched()
{
return getLatched() != null;
}
public TileEntity getLatched()
{
ForgeDirection side = placementSide;
TileEntity tile = world().getTileEntity(x() + side.offsetX, y() + side.offsetY, z() + side.offsetZ);
if (tile instanceof IInventory)
{
return tile;
}
return null;
}
@Override
public void readDesc(MCDataInput packet)
{
super.readDesc(packet);
input = packet.readBoolean();
dyeID = packet.readByte();
if (packet.readBoolean())
{
saveLinkVector = new VectorWorld(packet.readNBTTagCompound());
saveLinkSide = packet.readByte();
}
}
@Override
public void writeDesc(MCDataOutput packet)
{
super.writeDesc(packet);
packet.writeBoolean(input);
packet.writeByte(dyeID);
if (getLink() != null)
{
packet.writeBoolean(true);
NBTTagCompound nbt = new NBTTagCompound();
new VectorWorld(getLink().world(), getLink().x(), getLink().y(), getLink().z()).writeNBT(nbt);
packet.writeNBTTagCompound(nbt);
packet.writeByte(getLink().placementSide.ordinal());
}
else
{
packet.writeBoolean(false);
}
}
@Override
public void load(NBTTagCompound nbt)
{
super.load(nbt);
this.input = nbt.getBoolean("suck");
this.dyeID = nbt.getInteger("dyeID");
if (nbt.hasKey("link"))
{
saveLinkVector = new VectorWorld(nbt.getCompoundTag("link"));
saveLinkSide = nbt.getByte("linkSide");
}
}
@Override
public void save(NBTTagCompound nbt)
{
super.save(nbt);
nbt.setBoolean("suck", input);
nbt.setInteger("dyeID", dyeID);
if (getLink() != null && getLink().world() != null)
{
nbt.setTag("link", new VectorWorld(getLink().world(), getLink().x(), getLink().y(), getLink().z()).writeNBT(new NBTTagCompound()));
nbt.setByte("linkSide", (byte) getLink().placementSide.ordinal());
}
}
/**
* Link between two TileEntities, do pathfinding operation.
*/
public void setLink(PartLevitator levitator, boolean setOpponent)
{
if (getLink() != null && setOpponent)
{
getLink().setLink(null, false);
}
linked = new WeakReference(levitator);
if (setOpponent)
{
getLink().setLink(this, false);
}
updatePath();
}
public void updatePath()
{
if (thread == null && getLink() != null && lastCalcTime <= 0)
{
pathfinder = null;
Vector3 start = getPosition();
Vector3 target = new Vector3(getLink().x(), getLink().y(), getLink().z());
if (start.distance(target) < Settings.MAX_LEVITATOR_DISTANCE())
{
if (canBeMovePath(world(), start) && canBeMovePath(world(), target))
{
thread = new ThreadLevitatorPathfinding(new PathfinderLevitator(world(), target), start);
thread.start();
lastCalcTime = 40;
}
}
}
}
public void setDye(int dye)
{
dyeID = dye;
world().markBlockForUpdate(x(), y(), z());
}
public Vector3 getPosition()
{
return new Vector3(x(), y(), z());
}
public Vector3 getBeamSpawnPosition()
{
return new Vector3(x() + 0.5 + placementSide.offsetX / 3f, y() + 0.5 + placementSide.offsetY / 3f, z() + 0.5 + placementSide.offsetZ / 3f);
}
@Override
protected ItemStack getItem()
{
return new ItemStack(ElectricalContent.itemLevitator());
}
@Override
public String getType()
{
return "resonant_induction_levitator";
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
{
if (pass == 0)
{
RenderLevitator.INSTANCE.render(this, pos.x, pos.y, pos.z);
}
}
}

View file

@ -1,79 +0,0 @@
package resonantinduction.electrical.levitator;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.lib.path.IPathCallBack;
import resonant.lib.path.Pathfinder;
import resonant.lib.path.PathfinderAStar;
import universalelectricity.core.transform.vector.Vector3;
/**
* Uses the well known A* Pathfinding algorithm.
*
* @author Calclavia
*
*/
public class PathfinderLevitator extends PathfinderAStar
{
private World world;
private double maxSearchDistance;
public PathfinderLevitator(final World world, final Vector3 goal)
{
super(new IPathCallBack()
{
@Override
public Set<Vector3> getConnectedNodes(Pathfinder finder, Vector3 currentNode)
{
Set<Vector3> neighbors = new HashSet<Vector3>();
for (int i = 0; i < 6; i++)
{
Vector3 neighbor = currentNode.clone().add(ForgeDirection.getOrientation(i));
if (PartLevitator.canBePath(world, neighbor) || neighbor.equals(goal))
{
neighbors.add(neighbor);
}
}
return neighbors;
}
@Override
public boolean onSearch(Pathfinder finder, Vector3 start, Vector3 node)
{
return !(start.distance(node) < (start.distance(goal) * 2));
}
}, goal);
this.world = world;
}
@Override
public boolean findNodes(Vector3 start)
{
int blockCount = 0;
for (int i = 0; i < 6; i++)
{
ForgeDirection direction = ForgeDirection.getOrientation(i);
Vector3 neighbor = this.goal.clone().add(new Vector3(direction.offsetX, direction.offsetY, direction.offsetZ));
if (!PartLevitator.canBePath(this.world, neighbor))
{
blockCount++;
}
}
if (blockCount >= 6)
{
return false;
}
return super.findNodes(start);
}
}

View file

@ -1,69 +0,0 @@
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.content.prefab.scala.render.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import cpw.mods.fml.client.FMLClientHandler;
public class RenderLevitator implements ISimpleItemRenderer
{
public static final RenderLevitator INSTANCE = new RenderLevitator();
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelPath() + "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)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
RenderUtility.rotateFaceToSideNoTranslate(part.placementSide);
if (part.canFunction())
RenderUtility.bind(TEXTURE_ON);
else
RenderUtility.bind(TEXTURE_OFF);
GL11.glPushMatrix();
GL11.glRotatef(part.renderRotation, 1, 0, 0);
MODEL.renderOnly("ring1");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef(-part.renderRotation, 1, 0, 0);
MODEL.renderOnly("ring2");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef(part.renderRotation, 0, 0, 1);
MODEL.renderOnly("ring3");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef(-part.renderRotation, 0, 0, 1);
MODEL.renderOnly("ring4");
GL11.glPopMatrix();
MODEL.renderAllExcept("ring1", "ring2", "ring3", "ring4");
GL11.glPopMatrix();
}
@Override
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
{
GL11.glPushMatrix();
GL11.glTranslatef(0f, 0.5f, 0f);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_OFF);
MODEL.renderAll();
GL11.glPopMatrix();
}
}

View file

@ -1,41 +0,0 @@
/**
*
*/
package resonantinduction.electrical.levitator;
import universalelectricity.core.transform.vector.Vector3;
/**
* @author Calclavia
*
*/
public class ThreadLevitatorPathfinding extends Thread
{
private boolean isCompleted = false;
private PathfinderLevitator pathfinder;
private Vector3 start;
public ThreadLevitatorPathfinding(PathfinderLevitator pathfinder, Vector3 start)
{
this.pathfinder = pathfinder;
this.start = start;
this.setPriority(Thread.MIN_PRIORITY);
}
@Override
public void run()
{
this.pathfinder.findNodes(this.start);
this.isCompleted = true;
}
public PathfinderLevitator getPath()
{
if (this.isCompleted)
{
return this.pathfinder;
}
return null;
}
}