Permalink
Browse files

Fixed light panels, fully functional again.

  • Loading branch information...
Ri5ux committed Nov 4, 2017
1 parent 4b855f2 commit 09e9eb6033e928e43b0ff0a35b80caf1a1db275f
@@ -1,19 +1,69 @@
package org.avp.block;
import org.avp.tile.TileEntityElectrical;
import org.avp.tile.TileEntityLightPanel;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockLightPanel extends Block
{
public BlockLightPanel(Material material)
{
super(material);
this.setLightOpacity(0);
}
@Override
public boolean isTranslucent(IBlockState state)
{
return true;
}
@Override
public boolean isBlockNormalCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullyOpaque(IBlockState state)
{
return false;
}
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityElectrical)
{
TileEntityElectrical e = (TileEntityElectrical) tile;
if (e.isOperational())
{
return 15;
}
}
return 0;
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
}
@Override
@@ -2,9 +2,9 @@
import org.avp.api.power.IVoltageReceiver;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.EnumSkyBlock;
public class TileEntityLightPanel extends TileEntityElectrical implements IVoltageReceiver
{
@@ -13,6 +13,20 @@ public TileEntityLightPanel()
super(false);
}
@Override
public void update()
{
super.update();
this.updateEnergyAsReceiver();
IBlockState state = world.getBlockState(this.getPos());
int light = this.isOperational() ? 15 : 0;
this.world.checkLightFor(EnumSkyBlock.BLOCK, pos);
this.world.notifyBlockUpdate(pos, state, state, 3);
this.world.notifyNeighborsOfStateChange(pos, blockType);
}
@Override
public boolean canConnectPower(EnumFacing from)
{
@@ -22,18 +36,18 @@ public boolean canConnectPower(EnumFacing from)
@Override
public double receiveVoltage(EnumFacing from, double maxReceive, boolean simulate)
{
return 0;
return super.receiveVoltage(from, maxReceive, simulate);
}
@Override
public double getCurrentVoltage(EnumFacing from)
{
return this.voltage;
return this.getVoltage();
}
@Override
public double getMaxVoltage(EnumFacing from)
{
return 10000;
return 240;
}
}

0 comments on commit 09e9eb6

Please sign in to comment.