mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Closes #1177
This commit is contained in:
parent
1cca640345
commit
1240287b3b
1 changed files with 59 additions and 60 deletions
|
@ -32,74 +32,73 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class BlockGreenhouseGlass extends BlockBase {
|
||||
|
||||
public BlockGreenhouseGlass(String name) {
|
||||
super(Material.GLASS, name);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
this.setHardness(0.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.setSoundType(SoundType.GLASS);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
public BlockGreenhouseGlass(String name) {
|
||||
super(Material.GLASS, name);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
this.setHardness(0.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.setSoundType(SoundType.GLASS);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
IBlockState otherState = world.getBlockState(pos.offset(side));
|
||||
Block block = otherState.getBlock();
|
||||
@Override
|
||||
@Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
IBlockState otherState = world.getBlockState(pos.offset(side));
|
||||
Block block = otherState.getBlock();
|
||||
|
||||
return state != otherState || block != this && super.shouldSideBeRendered(state, world, pos, side);
|
||||
return state != otherState || block != this && super.shouldSideBeRendered(state, world, pos, side);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.EPIC;
|
||||
}
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.EPIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
if (world.isRemote) return;
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
if (world.isRemote) return;
|
||||
|
||||
if (world.canBlockSeeSky(pos) && world.isDaytime()) {
|
||||
Triple<BlockPos, IBlockState, IGrowable> trip = firstBlock(world, pos);
|
||||
if (world.canBlockSeeSky(pos) && world.isDaytime()) {
|
||||
Triple<BlockPos, IBlockState, IGrowable> trip = firstBlock(world, pos);
|
||||
boolean once = false;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
IBlockState growState = i == 0 ? trip.getMiddle() : world.getBlockState(trip.getLeft());
|
||||
if (trip != null && trip.getRight().canGrow(world, trip.getLeft(), growState, false)) {
|
||||
trip.getRight().grow(world, rand, trip.getLeft(), growState);
|
||||
once = true;
|
||||
}
|
||||
}
|
||||
if (once) world.playEvent(2005, trip.getMiddle().isOpaqueCube() ? trip.getLeft().up() : trip.getLeft(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
boolean once = false;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (trip != null && trip.getRight().canGrow(world, trip.getLeft(), trip.getMiddle(), false)) {
|
||||
trip.getRight().grow(world, rand, trip.getLeft(), trip.getMiddle());
|
||||
once = true;
|
||||
}
|
||||
|
||||
if (once) world.playEvent(2005, trip.getMiddle().isOpaqueCube() ? trip.getLeft().up() : trip.getLeft(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static Triple<BlockPos, IBlockState, IGrowable> firstBlock(World world, BlockPos glassPos) {
|
||||
BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos(glassPos);
|
||||
while (true) {
|
||||
mut.setPos(mut.getX(), mut.getY() - 1, mut.getZ());
|
||||
IBlockState state = world.getBlockState(mut);
|
||||
if (!state.getBlock().isAir(state, world, mut)) {
|
||||
if (state.getBlock() instanceof IGrowable) return Triple.of(mut.toImmutable(), state, (IGrowable) state.getBlock());
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static Triple<BlockPos, IBlockState, IGrowable> firstBlock(World world, BlockPos glassPos) {
|
||||
BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos(glassPos);
|
||||
while (true) {
|
||||
mut.setPos(mut.getX(), mut.getY() - 1, mut.getZ());
|
||||
IBlockState state = world.getBlockState(mut);
|
||||
if (!state.getBlock().isAir(state, world, mut)) {
|
||||
if (state.getBlock() instanceof IGrowable) return Triple.of(mut.toImmutable(), state, (IGrowable) state.getBlock());
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue