You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
6.2 KiB
Java
165 lines
6.2 KiB
Java
package com.zivilon.cinder_loe.blocks;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockRotatedPillar;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import lotr.common.LOTRCreativeTabs;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import com.zivilon.cinder_loe.util.Utilities;
|
|
|
|
public abstract class RotatableBlockBase3 extends BlockRotatedPillar {
|
|
public String textureName;
|
|
public IIcon[] icons = new IIcon[6];
|
|
|
|
public RotatableBlockBase3(Material material, String blockName) {
|
|
super(material);
|
|
this.textureName = Utilities.toSnakeCase(blockName);
|
|
this.setBlockName(blockName);
|
|
// Get LOTRCreativeTabs.tabBlock without ForgeGradle incorrectly obfuscating it. Uses cached field, not real-time reflection
|
|
this.setCreativeTab((CreativeTabs)Utilities.reflected_tab_block);
|
|
|
|
/* Examples for block properties
|
|
this.setHardness(2.0F); // How long it takes to break the block
|
|
this.setResistance(10.0F); // Explosion resistance
|
|
this.setStepSound(soundTypePiston); // The sound made when walking on the block
|
|
this.setLightLevel(0.5F); // Light emitted by the block, 0.0 - 1.0
|
|
this.setLightOpacity(255); // How much light is blocked, 0 - 255
|
|
this.setBlockName("exampleBlock"); // The unique name of the block
|
|
this.setBlockTextureName("modid:exampleBlock"); // Texture for the block
|
|
this.setCreativeTab(CreativeTabs.tabBlock); // The creative tab it appears in
|
|
*/
|
|
}
|
|
|
|
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
|
|
// Default orientation (meta 0)
|
|
int orientation = 0;
|
|
|
|
// Determine orientation based on the side of the block the player is placing against
|
|
switch (side) {
|
|
case 0: // Bottom
|
|
orientation = 5; // Unique orientation for bottom
|
|
break;
|
|
case 1: // Top
|
|
orientation = 0; // Default vertical orientation
|
|
break;
|
|
case 2: // North
|
|
orientation = 1; // North-South horizontal
|
|
break;
|
|
case 3: // South
|
|
orientation = 2; // South-North horizontal
|
|
break;
|
|
case 4: // West
|
|
orientation = 3; // West-East horizontal
|
|
break;
|
|
case 5: // East
|
|
orientation = 4; // East-West horizontal
|
|
break;
|
|
}
|
|
|
|
return orientation;
|
|
}
|
|
|
|
public int damageDropped(int i) {
|
|
return 0;
|
|
}
|
|
|
|
|
|
@Override
|
|
public IIcon getIcon(int side, int meta) {
|
|
switch(meta) {
|
|
case 0: // Facing up
|
|
if(side == 0) return this.icons[0];
|
|
else if(side == 1) return this.icons[1];
|
|
else return this.icons[2];
|
|
case 1: // Facing North
|
|
if(side == 0) return this.icons[2];
|
|
else if(side == 1) return this.icons[2];
|
|
else if(side == 2) return this.icons[1];
|
|
else if(side == 3) return this.icons[0];
|
|
else if(side == 4) return this.icons[5];
|
|
else if(side == 5) return this.icons[3];
|
|
case 2: // Facing South
|
|
if(side == 0) return this.icons[4];
|
|
else if(side == 1) return this.icons[4];
|
|
else if(side == 2) return this.icons[0];
|
|
else if(side == 3) return this.icons[1];
|
|
else if(side == 4) return this.icons[3];
|
|
else if(side == 5) return this.icons[5];
|
|
case 3: // Facing West
|
|
if(side == 0) return this.icons[5];
|
|
else if(side == 1) return this.icons[5];
|
|
else if(side == 2) return this.icons[3];
|
|
else if(side == 3) return this.icons[5];
|
|
else if(side == 4) return this.icons[1];
|
|
else if(side == 5) return this.icons[0];
|
|
case 4: // Facing East
|
|
if(side == 4) return this.icons[0];
|
|
else if(side == 5) return this.icons[1];
|
|
else return this.icons[2];
|
|
case 5: // Facing down
|
|
if(side == 0) return this.icons[1];
|
|
else if(side == 1) return this.icons[0];
|
|
else if (side == 2) return this.icons[3];
|
|
else if (side == 3) return this.icons[3];
|
|
else return this.icons[4];
|
|
}
|
|
|
|
return this.blockIcon;
|
|
}
|
|
|
|
@Override
|
|
public void registerBlockIcons(IIconRegister reg) {
|
|
icons[0] = reg.registerIcon(this.textureName + "_bottom");
|
|
icons[1] = reg.registerIcon(this.textureName + "_top");
|
|
icons[2] = reg.registerIcon(this.textureName + "_side_0");
|
|
icons[3] = reg.registerIcon(this.textureName + "_side_90");
|
|
icons[4] = reg.registerIcon(this.textureName + "_side_180");
|
|
icons[5] = reg.registerIcon(this.textureName + "_side_270");
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
protected IIcon getSideIcon(int i) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
/* Example method overrides for blocks
|
|
@Override
|
|
public void onBlockAdded(World world, int x, int y, int z) {
|
|
// Called when the block is placed in the world
|
|
}
|
|
|
|
@Override
|
|
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
|
// Called when the block is broken
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
|
// Called when the player right-clicks the block
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
|
|
// Called when an entity walks over the block
|
|
}
|
|
|
|
@Override
|
|
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
|
|
// Determines the redstone power output
|
|
return 15;
|
|
}
|
|
*/ |