2012-12-17 21:21:53 +01:00
|
|
|
package com.pahimar.ee3.block;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockContainer;
|
|
|
|
import net.minecraft.block.material.Material;
|
2013-02-25 05:03:45 +01:00
|
|
|
import net.minecraft.entity.EntityLiving;
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2012-12-17 21:21:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* BlockEE
|
|
|
|
*
|
|
|
|
* Parent block class for Equivalent Exchange blocks
|
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public abstract class BlockEE extends BlockContainer {
|
2012-12-19 19:09:56 +01:00
|
|
|
|
|
|
|
public BlockEE(int id, Material material) {
|
|
|
|
|
|
|
|
super(id, material);
|
|
|
|
}
|
2013-02-25 05:03:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the direction of the block when placed
|
|
|
|
*/
|
|
|
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityLiving) {
|
|
|
|
|
|
|
|
int direction = 0;
|
|
|
|
int facing = MathHelper.floor_double((double)(entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
2012-12-17 21:21:53 +01:00
|
|
|
|
2013-02-25 05:03:45 +01:00
|
|
|
if (facing == 0) {
|
|
|
|
direction = ForgeDirection.NORTH.ordinal();
|
|
|
|
}
|
|
|
|
else if (facing == 1) {
|
|
|
|
direction = ForgeDirection.EAST.ordinal();
|
|
|
|
}
|
|
|
|
else if (facing == 2) {
|
|
|
|
direction = ForgeDirection.SOUTH.ordinal();
|
|
|
|
}
|
|
|
|
else if (facing == 3) {
|
|
|
|
direction = ForgeDirection.WEST.ordinal();
|
|
|
|
}
|
|
|
|
|
2013-03-04 17:40:40 +01:00
|
|
|
world.setBlockMetadataWithNotify(x, y, z, direction, 3);
|
2013-02-25 05:03:45 +01:00
|
|
|
}
|
2012-12-17 21:21:53 +01:00
|
|
|
}
|