Finished all Blocks
This commit is contained in:
parent
e5abfd03e5
commit
419f532502
45 changed files with 478 additions and 1293 deletions
|
@ -5,21 +5,19 @@ import java.util.Random;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEMimicBlock;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockMimic extends BlockContainer
|
||||
{
|
||||
|
@ -28,15 +26,14 @@ public class BlockMimic extends BlockContainer
|
|||
super(Material.water);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
this.setBlockName("blockMimic");
|
||||
// this.setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, BlockPos blockPos, EnumFacing side)
|
||||
{
|
||||
TileEntity TE = world.getTileEntity(x, y, z);
|
||||
TileEntity TE = world.getTileEntity(blockPos);
|
||||
if(!(TE instanceof TEMimicBlock))
|
||||
{
|
||||
return true;
|
||||
|
@ -45,36 +42,16 @@ public class BlockMimic extends BlockContainer
|
|||
|
||||
Block block = mimic.getBlock();
|
||||
|
||||
return block == null || block.shouldSideBeRendered(world, x, y, z, side);
|
||||
return block == null || block.shouldSideBeRendered(world, blockPos, side);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(int meta, boolean bool)
|
||||
public boolean canCollideCheck(IBlockState blockState, boolean bool)
|
||||
{
|
||||
return meta == 1;
|
||||
return blockState.getBlock().getMetaFromState(blockState) == 1;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity TE = blockAccess.getTileEntity(x, y, z);
|
||||
TEMimicBlock mimic = (TEMimicBlock)TE;
|
||||
Block block = mimic.getBlock();
|
||||
int meta = mimic.getMetaOfMimic();
|
||||
|
||||
return block != null ? block.getIcon(side, meta) : this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
|
@ -87,21 +64,21 @@ public class BlockMimic extends BlockContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
|
||||
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(int meta, int fortune, Random random)
|
||||
public int quantityDropped(Random random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockSolid(IBlockAccess world, int x, int y, int z, int meta)
|
||||
public boolean isBlockSolid(IBlockAccess world, BlockPos blockPos, EnumFacing side)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if(tile instanceof TEMimicBlock)
|
||||
{
|
||||
Block block = ((TEMimicBlock) tile).getBlock();
|
||||
|
@ -109,16 +86,16 @@ public class BlockMimic extends BlockContainer
|
|||
|
||||
if(block != null)
|
||||
{
|
||||
return block.isBlockSolid(world, x, y, z, mimicMeta);
|
||||
return block.isBlockSolid(world, blockPos, side); //side was mimicM
|
||||
}
|
||||
}
|
||||
return super.isBlockSolid(world, x, y, z, meta);
|
||||
return super.isBlockSolid(world, blockPos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(target.blockX, target.blockY, target.blockZ);
|
||||
TileEntity tile = world.getTileEntity(target.func_178782_a());
|
||||
|
||||
TEMimicBlock TE = (TEMimicBlock)tile;
|
||||
|
||||
|
@ -126,32 +103,33 @@ public class BlockMimic extends BlockContainer
|
|||
{
|
||||
Block block = TE.getBlock();
|
||||
|
||||
double xOffset = target.blockX + world.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - 0.1F * 2.0F) + 0.1F + block.getBlockBoundsMinX();
|
||||
double yOffset = target.blockY + world.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - 0.1F * 2.0F) + 0.1F + block.getBlockBoundsMinY();
|
||||
double zOffset = target.blockZ + world.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - 0.1F * 2.0F) + 0.1F + block.getBlockBoundsMinZ();
|
||||
double xOffset = target.func_178782_a().getX() + world.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - 0.1F * 2.0F) + 0.1F + block.getBlockBoundsMinX();
|
||||
double yOffset = target.func_178782_a().getY() + world.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - 0.1F * 2.0F) + 0.1F + block.getBlockBoundsMinY();
|
||||
double zOffset = target.func_178782_a().getZ() + world.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - 0.1F * 2.0F) + 0.1F + block.getBlockBoundsMinZ();
|
||||
|
||||
switch (target.sideHit) {
|
||||
switch (target.subHit)
|
||||
{
|
||||
case 0:
|
||||
yOffset = target.blockY + block.getBlockBoundsMinY() - 0.1D;
|
||||
yOffset = target.func_178782_a().getY() + block.getBlockBoundsMinY() - 0.1D;
|
||||
break;
|
||||
case 1:
|
||||
yOffset = target.blockY + block.getBlockBoundsMaxY() + 0.1D;
|
||||
yOffset = target.func_178782_a().getY() + block.getBlockBoundsMaxY() + 0.1D;
|
||||
break;
|
||||
case 2:
|
||||
zOffset = target.blockZ + block.getBlockBoundsMinZ() - 0.1D;
|
||||
zOffset = target.func_178782_a().getZ() + block.getBlockBoundsMinZ() - 0.1D;
|
||||
break;
|
||||
case 3:
|
||||
zOffset = target.blockZ + block.getBlockBoundsMaxZ() + 0.1D;
|
||||
zOffset = target.func_178782_a().getZ() + block.getBlockBoundsMaxZ() + 0.1D;
|
||||
break;
|
||||
case 4:
|
||||
xOffset = target.blockX + block.getBlockBoundsMinX() - 0.1D;
|
||||
xOffset = target.func_178782_a().getX() + block.getBlockBoundsMinX() - 0.1D;
|
||||
break;
|
||||
case 5:
|
||||
xOffset = target.blockX + block.getBlockBoundsMaxX() + 0.1D;
|
||||
xOffset = target.func_178782_a().getX() + block.getBlockBoundsMaxX() + 0.1D;
|
||||
break;
|
||||
}
|
||||
|
||||
BlockMimic.addHitEffect(TE, target, xOffset, yOffset, zOffset, null, effectRenderer);
|
||||
// BlockMimic.addHitEffect(TE, target, xOffset, yOffset, zOffset, null, effectRenderer);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -161,33 +139,33 @@ public class BlockMimic extends BlockContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
|
||||
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos blockPos, IBlockState blockState)
|
||||
{
|
||||
TEMimicBlock tile = (TEMimicBlock)world.getTileEntity(x, y, z);
|
||||
TEMimicBlock tile = (TEMimicBlock)world.getTileEntity(blockPos);
|
||||
Block block = tile.getBlock();
|
||||
|
||||
return block != null ? block.getCollisionBoundingBoxFromPool(world, x, y, z) : super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
return block != null ? block.getCollisionBoundingBox(world, blockPos, blockState) : super.getCollisionBoundingBox(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z)
|
||||
public int colorMultiplier(IBlockAccess blockAccess, BlockPos blockPos, int renderPass)
|
||||
{
|
||||
TEMimicBlock TE = (TEMimicBlock)blockAccess.getTileEntity(x, y, z);
|
||||
TEMimicBlock TE = (TEMimicBlock)blockAccess.getTileEntity(blockPos);
|
||||
if (TE != null)
|
||||
{
|
||||
Block block = TE.getBlock();
|
||||
if(block != null)
|
||||
{
|
||||
return block.colorMultiplier(blockAccess, x, y, z);
|
||||
return block.colorMultiplier(blockAccess, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
return super.colorMultiplier(blockAccess, x, y, z);
|
||||
return super.colorMultiplier(blockAccess, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec)
|
||||
/* @Override
|
||||
public void velocityToAddToEntity(World world, BlockPos, Entity entity, Vec3 vec)
|
||||
{
|
||||
TEMimicBlock TE = (TEMimicBlock)world.getTileEntity(x, y, z);
|
||||
if (TE != null)
|
||||
|
@ -199,20 +177,21 @@ public class BlockMimic extends BlockContainer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addHitEffect(TEMimicBlock TE, MovingObjectPosition target, double x, double y, double z, ItemStack itemStack, EffectRenderer effectRenderer)
|
||||
No longer in 1.8 apparently
|
||||
|
||||
public static void addHitEffect(TEMimicBlock TE, MovingObjectPosition target, double x, double y, double z, ItemStack itemStack, EffectRenderer effectRenderer)
|
||||
{
|
||||
EntityDiggingFX particle = new EntityDiggingFX(TE.getWorldObj(), x, y, z, 0.0D, 0.0D, 0.0D, TE.getBlock(), TE.getMetaOfMimic());
|
||||
effectRenderer.addEffect(particle.applyColourMultiplier(target.blockX, target.blockY, target.blockZ).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||
EntityDiggingFX particle = new EntityDiggingFX(TE.getWorld(), x, y, z, 0.0D, 0.0D, 0.0D, TE.getBlock(), TE.getMetaOfMimic());
|
||||
effectRenderer.addEffect(particle.func_174846_a(target.func_178782_a()).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||
}
|
||||
|
||||
*/
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos blockPos, Entity entity)
|
||||
{
|
||||
TEMimicBlock TE = (TEMimicBlock)world.getTileEntity(x, y, z);
|
||||
TEMimicBlock TE = (TEMimicBlock)world.getTileEntity(blockPos);
|
||||
if (TE != null)
|
||||
{
|
||||
if(TE.getBlockEffectWhileInside(entity, x, y, z))
|
||||
if(TE.getBlockEffectWhileInside(entity, blockPos))
|
||||
{
|
||||
return;
|
||||
}else
|
||||
|
@ -220,12 +199,12 @@ public class BlockMimic extends BlockContainer
|
|||
Block block = TE.getBlock();
|
||||
if(block != null)
|
||||
{
|
||||
block.onEntityCollidedWithBlock(world, x, y, z, entity);
|
||||
block.onEntityCollidedWithBlock(world, blockPos, entity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onEntityCollidedWithBlock(world, x, y, z, entity);
|
||||
super.onEntityCollidedWithBlock(world, blockPos, entity);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue