2013-09-05 12:39:18 -07:00
|
|
|
package tconstruct.blocks;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
|
import net.minecraft.util.Icon;
|
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import tconstruct.client.block.SlimePadRender;
|
|
|
|
|
import tconstruct.common.TContent;
|
|
|
|
|
import tconstruct.library.TConstructRegistry;
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
|
|
public class SlimePad extends Block
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public SlimePad(int par1, Material par2Material)
|
|
|
|
|
{
|
|
|
|
|
super(par1, par2Material);
|
|
|
|
|
setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.625F, 0.875F);
|
|
|
|
|
this.setCreativeTab(TConstructRegistry.blockTab);
|
|
|
|
|
}
|
2013-11-10 13:57:35 -08:00
|
|
|
|
2013-09-05 12:39:18 -07:00
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
|
|
|
|
{
|
|
|
|
|
double moveX = 0;
|
|
|
|
|
double moveZ = 0;
|
2013-11-10 13:57:35 -08:00
|
|
|
|
2013-09-05 12:39:18 -07:00
|
|
|
double speed = 0.25;
|
|
|
|
|
|
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
|
switch (meta % 8)
|
|
|
|
|
{
|
|
|
|
|
case 6:
|
|
|
|
|
moveX += speed;
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
moveX += speed;
|
|
|
|
|
moveZ += speed;
|
2013-11-10 13:57:35 -08:00
|
|
|
break;
|
2013-09-05 12:39:18 -07:00
|
|
|
case 0:
|
|
|
|
|
moveZ += speed;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
moveZ += speed;
|
|
|
|
|
moveX -= speed;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
moveX -= speed;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
moveX -= speed;
|
|
|
|
|
moveZ -= speed;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
moveZ -= speed;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
moveZ -= speed;
|
|
|
|
|
moveX += speed;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entity instanceof EntityItem)
|
|
|
|
|
{
|
|
|
|
|
entity.posY += 1;
|
|
|
|
|
}
|
2013-11-10 13:57:35 -08:00
|
|
|
entity.addVelocity(moveX, speed * 2, moveZ);
|
2013-09-05 12:39:18 -07:00
|
|
|
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, this.stepSound.getStepSound(), (this.stepSound.getVolume()) / 2.0F, this.stepSound.getPitch() * 0.65F);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-10 13:57:35 -08:00
|
|
|
|
|
|
|
|
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
int face = MathHelper.floor_double((double) (entity.rotationYaw * 8.0F / 360.0F) + 0.5D) + (entity.isSneaking() ? 4 : 0) & 7;
|
|
|
|
|
int meta = world.getBlockMetadata(x, y, z) & 8;
|
|
|
|
|
world.setBlockMetadataWithNotify(x, y, z, face | meta, 2);
|
|
|
|
|
}
|
2013-11-10 13:57:35 -08:00
|
|
|
|
2013-09-05 12:39:18 -07:00
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public boolean renderAsNormalBlock ()
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public boolean isOpaqueCube ()
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public int getRenderBlockPass ()
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public int getRenderType ()
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return SlimePadRender.model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-11-10 13:57:35 -08:00
|
|
|
public void registerIcons (IconRegister iconRegister)
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-09-05 12:39:18 -07:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-11-10 13:57:35 -08:00
|
|
|
public Icon getIcon (int side, int meta)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return TContent.slimeGel.getIcon(side, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-10 13:57:35 -08:00
|
|
|
public Icon getFluidIcon (int meta)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return TContent.slimeChannel.getIcon(2, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-10 13:57:35 -08:00
|
|
|
public Icon getNubIcon (int meta)
|
2013-09-05 12:39:18 -07:00
|
|
|
{
|
|
|
|
|
return TContent.slimeGel.getIcon(0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|