/
BlockNetherGlass.java
140 lines (118 loc) · 3.82 KB
/
BlockNetherGlass.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.progwml6.natura.nether.block.glass;
import java.util.Locale;
import java.util.Random;
import javax.annotation.Nullable;
import com.progwml6.natura.library.NaturaRegistry;
import com.progwml6.natura.nether.NaturaNether;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import slimeknights.mantle.block.EnumBlock;
public class BlockNetherGlass extends EnumBlock<BlockNetherGlass.GlassType>
{
public static PropertyEnum<GlassType> TYPE = PropertyEnum.create("type", GlassType.class);
protected static final AxisAlignedBB HEAT_SAND_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D);
public BlockNetherGlass()
{
super(Material.GLASS, TYPE, GlassType.class);
this.setHardness(1.0F);
this.setResistance(3000F);
this.setSoundType(SoundType.GLASS);
this.setCreativeTab(NaturaRegistry.tabWorld);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random random)
{
return 0;
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
protected boolean canSilkHarvest()
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.TRANSLUCENT;
}
@SuppressWarnings("deprecation")
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
Block block = blockAccess.getBlockState(pos.offset(side)).getBlock();
return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
{
if (blockState.getValue(TYPE) == GlassType.SOUL)
return NULL_AABB;
else
return HEAT_SAND_AABB;
}
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
if (entityIn instanceof EntityLivingBase)
{
if (state.getValue(TYPE) == GlassType.SOUL)
{
((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 1));
}
else if (state.getValue(TYPE) == GlassType.HEAT)
{
NaturaNether.netherHeatSand.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);
}
}
}
public enum GlassType implements IStringSerializable, EnumBlock.IEnumMeta
{
SOUL, HEAT;
public final int meta;
GlassType()
{
this.meta = this.ordinal();
}
@Override
public String getName()
{
return this.toString().toLowerCase(Locale.US);
}
@Override
public int getMeta()
{
return this.meta;
}
}
}