mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
root package of block, first pass done
This commit is contained in:
1 parent
3fe15e6b7d
commit
999705294d
40 files changed
+416
-632
No files matched your search
@@ -11,7 +11,8 @@
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -19,12 +20,10 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.common.util.RotationHelper;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
@@ -35,19 +34,33 @@ import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockIncensePlate extends BlockModContainer implements ILexiconable {
|
||||
|
||||
private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 };
|
||||
|
||||
protected BlockIncensePlate() {
|
||||
super(Material.wood);
|
||||
setUnlocalizedName(LibBlockNames.INCENSE_PLATE);
|
||||
setHardness(2.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
setBlockBounds(true);
|
||||
setBlockBounds(EnumFacing.Axis.Z);
|
||||
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.CARDINALS, EnumFacing.SOUTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
|
||||
TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(x, y, z);
|
||||
public BlockState createBlockState() {
|
||||
return new BlockState(this, BotaniaStateProps.CARDINALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return ((EnumFacing) state.getValue(BotaniaStateProps.CARDINALS)).getHorizontalIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(BotaniaStateProps.CARDINALS, EnumFacing.getHorizontal(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing s, float xs, float ys, float zs) {
|
||||
TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(pos);
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
ItemStack plateStack = plate.getStackInSlot(0);
|
||||
boolean did = false;
|
||||
@@ -81,9 +94,8 @@ public class BlockIncensePlate extends BlockModContainer implements ILexiconable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {
|
||||
int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2);
|
||||
public void onBlockPlacedBy(World p_149689_1_, BlockPos pos, IBlockState state, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {
|
||||
p_149689_1_.setBlockState(pos, state.withProperty(BotaniaStateProps.CARDINALS, p_149689_5_.getHorizontalFacing().getOpposite()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,48 +104,33 @@ public class BlockIncensePlate extends BlockModContainer implements ILexiconable
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
return ((TileIncensePlate) world.getTileEntity(x, y, z)).comparatorOutput;
|
||||
public int getComparatorInputOverride(World world, BlockPos pos) {
|
||||
return ((TileIncensePlate) world.getTileEntity(pos)).comparatorOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) {
|
||||
setBlockBounds(w.getBlockMetadata(x, y, z) < 4);
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess w, BlockPos pos) {
|
||||
setBlockBounds(((EnumFacing) w.getBlockState(pos).getValue(BotaniaStateProps.CARDINALS)).getAxis());
|
||||
}
|
||||
|
||||
public void setBlockBounds(boolean horiz) {
|
||||
public void setBlockBounds(EnumFacing.Axis axis) {
|
||||
float f = 1F / 16F;
|
||||
float w = 12 * f;
|
||||
float l = 4 * f;
|
||||
float xs = (1F - w) / 2;
|
||||
float zs = (1F - l) / 2;
|
||||
if(horiz)
|
||||
if(axis == EnumFacing.Axis.Z)
|
||||
setBlockBounds(xs, 0F, zs, 1F - xs, f, 1f - zs);
|
||||
else setBlockBounds(zs, 0F, xs, 1F - zs, f, 1f - xs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
|
||||
return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return ModBlocks.livingwood.getIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
public boolean isFullCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user