This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
/
BlockEnergyBridge.java
66 lines (58 loc) · 2.1 KB
/
BlockEnergyBridge.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package net.xalcon.energyconverters.common.blocks;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.xalcon.energyconverters.EnergyConverters;
import net.xalcon.energyconverters.common.tiles.TileEntityEnergyBridge;
public class BlockEnergyBridge extends BlockBase implements ITileEntityProvider
{
public final static String INTERNAL_NAME = "energy_bridge";
public BlockEnergyBridge()
{
super(Material.IRON, INTERNAL_NAME);
}
@Override
public BlockRenderLayer getRenderLayer()
{
return BlockRenderLayer.TRANSLUCENT;
}
@Override
@SuppressWarnings("deprecation")
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
@SuppressWarnings("deprecation")
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if(!worldIn.isRemote)
{
TileEntity te = worldIn.getTileEntity(pos);
if(te instanceof TileEntityEnergyBridge)
{
double amount = ((TileEntityEnergyBridge) te).getStoredEnergy();
playerIn.sendStatusMessage(new TextComponentTranslation(EnergyConverters.MOD_ID + ".energybridge.stored", Math.round(amount)), true);
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityEnergyBridge();
}
}