mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
90 lines
2.3 KiB
Java
90 lines
2.3 KiB
Java
package com.hbm.blocks.generic;
|
|
|
|
import java.util.Random;
|
|
|
|
import com.hbm.lib.RefStrings;
|
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockReeds extends Block {
|
|
|
|
@SideOnly(Side.CLIENT) public IIcon iconMid;
|
|
@SideOnly(Side.CLIENT) public IIcon iconBottom;
|
|
|
|
public BlockReeds() {
|
|
super(Material.plants);
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister reg) {
|
|
this.blockIcon = reg.registerIcon(RefStrings.MODID + ":reeds_top");
|
|
this.iconMid = reg.registerIcon(RefStrings.MODID + ":reeds_mid");
|
|
this.iconBottom = reg.registerIcon(RefStrings.MODID + ":reeds_bottom");
|
|
}
|
|
|
|
public IIcon getIcon(int height) {
|
|
return height == 0 ? this.blockIcon : height == 1 ? this.iconMid : this.iconBottom;
|
|
}
|
|
|
|
@Override
|
|
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
|
Block block = world.getBlock(x, y - 1, z);
|
|
return block == Blocks.water || block == Blocks.flowing_water;
|
|
}
|
|
|
|
@Override
|
|
public boolean canBlockStay(World world, int x, int y, int z) {
|
|
return this.canPlaceBlockAt(world, x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
|
super.onNeighborBlockChange(world, x, y, z, block);
|
|
this.checkAndDropBlock(world, x, y, z);
|
|
}
|
|
|
|
protected void checkAndDropBlock(World world, int x, int y, int z) {
|
|
if(!this.canBlockStay(world, x, y, z)) {
|
|
world.setBlock(x, y, z, Blocks.air);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public Item getItemDropped(int meta, Random rand, int fortune) {
|
|
return Items.stick;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean renderAsNormalBlock() {
|
|
return false;
|
|
}
|
|
|
|
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
|
|
|
@Override
|
|
public int getRenderType() {
|
|
return renderID;
|
|
}
|
|
}
|