Skip to content

Instantly share code, notes, and snippets.

@sirsavary
Last active March 5, 2016 09:08
Show Gist options
  • Select an option

  • Save sirsavary/4e02e81713d8c611a596 to your computer and use it in GitHub Desktop.

Select an option

Save sirsavary/4e02e81713d8c611a596 to your computer and use it in GitHub Desktop.
import com.mordrum.metallurgy.Metal;
import com.mordrum.metallurgy.mMetals;
import net.malisis.core.block.BoundingBoxType;
import net.malisis.core.block.MalisisBlock;
import net.malisis.core.block.component.DirectionalComponent;
import net.malisis.core.util.AABBUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.List;
import java.util.Random;
public class OreBlock extends MalisisBlock {
private final Metal metal;
private final String name;
public OreBlock(Metal metal) {
super(Material.rock);
this.metal = metal;
this.name = (metal.name + "_ore").toLowerCase();
this.setStepSound(Block.soundTypeStone);
this.setCreativeTab(mMetals.oresTab);
this.setHarvestLevel("pickaxe", metal.blockLvl);
this.setUnlocalizedName(this.name);
this.setHardness(4.0f); // Time to mine
this.setResistance(2.0f); // Explosion resistance
}
@Override
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) {
AxisAlignedBB[] aabbs = getBoundingBoxes(world, pos, BoundingBoxType.COLLISION);
aabbs = AABBUtils.rotate(aabbs, DirectionalComponent.getDirection(state));
for (AxisAlignedBB aabb : AABBUtils.offset(pos, aabbs)) {
if (aabb != null && mask.intersectsWith(aabb))
list.add(aabb);
}
}
public String getName() {
return name;
}
public Metal getMetal() {
return metal;
}
@Override
public Item getItemDropped(IBlockState metadata, Random random, int fortune) {
return Item.getItemFromBlock(Block.getBlockById(1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment