mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 12:19:46 +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
@@ -14,7 +14,8 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.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.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -23,12 +24,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
@@ -40,8 +39,6 @@ import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockAvatar extends BlockModContainer implements ILexiconable {
|
||||
|
||||
private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 };
|
||||
|
||||
Random random;
|
||||
|
||||
protected BlockAvatar() {
|
||||
@@ -49,14 +46,19 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable {
|
||||
setHardness(2.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
setUnlocalizedName(LibBlockNames.AVATAR);
|
||||
setBlockBounds(true);
|
||||
|
||||
setBlockBounds(EnumFacing.Axis.Z);
|
||||
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.CARDINALS, EnumFacing.SOUTH));
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
|
||||
TileAvatar avatar = (TileAvatar) world.getTileEntity(x, y, z);
|
||||
public BlockState createBlockState() {
|
||||
return new BlockState(this, BotaniaStateProps.CARDINALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing s, float xs, float ys, float zs) {
|
||||
TileAvatar avatar = (TileAvatar) world.getTileEntity(pos);
|
||||
ItemStack stackOnAvatar = avatar.getStackInSlot(0);
|
||||
ItemStack stackOnPlayer = player.getCurrentEquippedItem();
|
||||
if(stackOnAvatar != null) {
|
||||
@@ -76,25 +78,25 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable {
|
||||
}
|
||||
|
||||
@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 horiz) {
|
||||
float f = 1F / 16F;
|
||||
float w = f * 9;
|
||||
float l = f * 6;
|
||||
float ws = (1F - w) / 2;
|
||||
float ls = (1F - l) / 2;
|
||||
|
||||
if(horiz)
|
||||
if(horiz == EnumFacing.Axis.Z)
|
||||
setBlockBounds(ws, 0F, ls, 1F - ws, 1F + f, 1F - ls);
|
||||
else setBlockBounds(ls, 0F, ws, 1F - ls, 1F + f, 1F - ws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
|
||||
public void breakBlock(World par1World, BlockPos pos, IBlockState state) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(pos);
|
||||
|
||||
if (inv != null) {
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
|
||||
@@ -112,7 +114,7 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable {
|
||||
k1 = itemstack.stackSize;
|
||||
|
||||
itemstack.stackSize -= k1;
|
||||
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
entityitem = new EntityItem(par1World, pos.getX() + f, pos.getY() + f1, pos.getZ() + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
|
||||
@@ -124,26 +126,15 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable {
|
||||
}
|
||||
}
|
||||
|
||||
par1World.func_147453_f(par2, par3, par4, par5);
|
||||
par1World.updateComparatorOutputLevel(pos, state.getBlock());
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
super.breakBlock(par1World, pos, state);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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
|
||||
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
|
||||
@@ -157,7 +148,7 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
public boolean isFullCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user