mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
87 lines
2.0 KiB
Java
87 lines
2.0 KiB
Java
package com.hbm.blocks.network;
|
|
|
|
import com.hbm.entity.item.EntityMovingItem;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
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.MathHelper;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockConveyor extends Block {
|
|
|
|
public BlockConveyor(Material p_i45394_1_) {
|
|
super(p_i45394_1_);
|
|
}
|
|
|
|
@Override
|
|
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
|
|
|
if(!world.isRemote) {
|
|
|
|
if(entity instanceof EntityItem && entity.ticksExisted > 10 && !entity.isDead) {
|
|
|
|
EntityMovingItem item = new EntityMovingItem(world);
|
|
item.setItemStack(((EntityItem)entity).getEntityItem());
|
|
item.setPositionAndRotation(x + 0.5, y + 0.125, z + 0.5, 0, 0);
|
|
world.spawnEntityInWorld(item);
|
|
|
|
entity.setDead();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getRenderType() {
|
|
return 334086;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean renderAsNormalBlock() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
|
}
|
|
|
|
@Override
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
|
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
|
|
|
if(i == 0)
|
|
{
|
|
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
|
}
|
|
if(i == 1)
|
|
{
|
|
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
|
}
|
|
if(i == 2)
|
|
{
|
|
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
|
}
|
|
if(i == 3)
|
|
{
|
|
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
|
}
|
|
}
|
|
|
|
}
|