Permalink
Browse files

CCFL tube lights now act as power passthroughs.

  • Loading branch information...
Ri5ux committed Nov 5, 2017
1 parent c049721 commit cf9db7d62989e9456dccb692e5b310262d0afc12
@@ -4,7 +4,6 @@
import org.avp.tile.TileEntityElectrical;
import com.arisux.mdx.lib.world.entity.Entities;
import com.arisux.mdx.lib.world.tile.IRotatableYAxis;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@@ -81,7 +80,6 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
{
ccfl.setRotationYAxis(Entities.getEntityFacingRotY(placer));
ccfl.setRotationXAxis(Entities.getEntityFacingRotX(placer));
System.out.println(ccfl.getRotationXAxis());
world.markBlockRangeForRenderUpdate(pos, pos);
}
}
@@ -38,23 +38,6 @@ public ModelCCFL()
@Override
public void render(Object obj)
{
// this.middleRod = new ModelRenderer(this, 0, 0);
// this.middleRod.setRotationPoint(0.0F, 9.0F, 0.0F);
// this.middleRod.addBox(-7.5F, -0.5F, -0.5F, 15, 1, 1, 0.0F);
// this.lightTube = new ModelRenderer(this, 0, 5);
// this.lightTube.setRotationPoint(0.0F, 9.0F, 0.0F);
// this.lightTube.addBox(-6.0F, -0.5F, -0.5F, 12, 1, 1, 0.0F);
// this.lCap = new ModelRenderer(this, 0, 9);
// this.lCap.setRotationPoint(-7.3F, 9.0F, 0.0F);
// this.lCap.addBox(-1.0F, -1.0F, -1.0F, 1, 2, 2, 0.0F);
// this.lightAura = new ModelRenderer(this, 0, 18);
// this.lightAura.setRotationPoint(0.0F, 9.0F, 0.0F);
// this.lightAura.addBox(-5.5F, -0.5F, -0.5F, 11, 1, 1, 0.0F);
// this.rCap = new ModelRenderer(this, 0, 9);
// this.rCap.mirror = true;
// this.rCap.setRotationPoint(7.3F, 9.0F, 0.0F);
// this.rCap.addBox(0.0F, -1.0F, -1.0F, 1, 2, 2, 0.0F);
this.middleRod.render(DEFAULT_SCALE);
GlStateManager.pushMatrix();
GlStateManager.translate(this.lightTube.offsetX, this.lightTube.offsetY, this.lightTube.offsetZ);
@@ -6,10 +6,10 @@
import org.avp.tile.TileEntityCCFLTube;
import com.arisux.mdx.lib.client.render.OpenGL;
import com.arisux.mdx.lib.game.Game;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.EnumFacing;
public class RenderCCFLTube extends TileEntitySpecialRenderer<TileEntityCCFLTube>
{
@@ -19,8 +19,14 @@ public void renderTileEntityAt(TileEntityCCFLTube ccfl, double x, double y, doub
GlStateManager.pushMatrix();
OpenGL.disable(GL_CULL_FACE);
GlStateManager.translate(x + 0.5F, y + 0.5F, z + 0.5F);
OpenGL.rotate(90F, 0F, 1F, 0F);
OpenGL.rotate(ccfl);
// GlStateManager.rotate(Game.minecraft().world.getWorldTime() % 360, 0, 0, 1);
if (ccfl.getRotationXAxis() == EnumFacing.NORTH)
{
GlStateManager.translate(0F, -0.5F, 0F);
}
OpenGL.translate(0, -0.1F, 0);
AliensVsPredator.resources().models().CCFL_BALLAST.draw(ccfl);
@@ -1,12 +1,15 @@
package org.avp.tile;
import com.arisux.mdx.lib.world.tile.IRotatableYAxis;
import org.avp.api.power.IVoltageProvider;
import com.arisux.mdx.lib.world.tile.IRotatableXAxis;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
public class TileEntityCCFLTube extends TileEntityLightPanel implements IRotatableYAxis, IRotatableXAxis
public class TileEntityCCFLTube extends TileEntityLightPanel implements IVoltageProvider, IRotatableYAxis, IRotatableXAxis
{
private EnumFacing rotationX;
private EnumFacing rotationY;
@@ -35,6 +38,34 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt)
return super.writeToNBT(nbt);
}
@Override
public boolean canConnectPower(EnumFacing from)
{
return canProvideEnergyToReceiver(from);
}
@Override
public boolean canProvideEnergyToReceiver(EnumFacing side)
{
if (side == EnumFacing.UP || side == EnumFacing.DOWN)
{
return false;
}
if (side == this.getRotationYAxis() || side == this.getRotationYAxis().getOpposite())
{
return true;
}
return false;
}
@Override
public boolean canReceiveVoltageFromSide(EnumFacing from)
{
return canProvideEnergyToReceiver(from);
}
@Override
public void update()
{
@@ -304,13 +304,22 @@ public double extractVoltage(EnumFacing from, double maxExtract, boolean simulat
*/
public double receiveVoltage(EnumFacing from, double maxReceive, boolean simulate)
{
double result = this.getVoltage() + maxReceive;
if (!simulate)
if (this.canReceiveVoltageFromSide(from))
{
this.setVoltage(result);
}
double result = this.getVoltage() + maxReceive;
if (!simulate)
{
this.setVoltage(result);
}
return result;
return result;
}
return this.voltage;
}
public boolean canReceiveVoltageFromSide(EnumFacing from)
{
return true;
}
}

0 comments on commit cf9db7d

Please sign in to comment.