Files
CustomNPC-Plus/src/main/java/noppes/npcs/blocks/BlockRotated.java
T

75 lines
2.1 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.blocks;
2023-01-12 21:33:06 -05:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2018-09-13 12:03:28 -04:00
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import noppes.npcs.blocks.tiles.TileColorable;
2025-02-12 17:39:33 -05:00
public abstract class BlockRotated extends BlockContainer {
2018-09-13 12:03:28 -04:00
private Block block;
protected BlockRotated(Block block) {
super(block.getMaterial());
this.block = block;
}
public int renderId = -1;
2025-02-12 17:39:33 -05:00
@Override
2018-09-13 12:03:28 -04:00
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * maxRotation() / 360.0F) + 0.5D) & (maxRotation() - 1);
l %= maxRotation();
TileColorable tile = (TileColorable) par1World.getTileEntity(par2, par3, par4);
2025-02-12 17:39:33 -05:00
tile.rotation = l;
2018-09-13 12:03:28 -04:00
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z){
setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
2025-02-12 17:39:33 -05:00
2018-09-13 12:03:28 -04:00
public int maxRotation(){
return 4;
}
2025-02-12 17:39:33 -05:00
@Override
2018-09-13 12:03:28 -04:00
public boolean isOpaqueCube(){
return false;
}
2025-02-12 17:39:33 -05:00
@Override
2018-09-13 12:03:28 -04:00
public boolean renderAsNormalBlock(){
return false;
}
2025-02-12 17:39:33 -05:00
@Override
2018-09-13 12:03:28 -04:00
public int getRenderType(){
2025-02-12 17:39:33 -05:00
return renderId;
2018-09-13 12:03:28 -04:00
}
2025-02-12 17:39:33 -05:00
@Override
2018-09-13 12:03:28 -04:00
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side){
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
2025-02-12 17:39:33 -05:00
2018-09-13 12:03:28 -04:00
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta){
return block.getIcon(p_149691_1_, meta);
}
}