Files
BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockMasterStone.java
T
koolkrafter5andgithub-actions[bot] 3b2b31f733 Spring Cleaning (#127)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-05-12 20:52:29 +02:00

92 lines
3.0 KiB
Java

package WayofTime.alchemicalWizardry.common.block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
import WayofTime.alchemicalWizardry.common.items.ActivationCrystal;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockMasterStone extends BlockContainer {
public BlockMasterStone() {
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("blockMasterStone");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:MasterStone");
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEMasterStone) {
((TEMasterStone) tile).useOnRitualBroken();
}
super.onBlockHarvested(world, x, y, z, meta, player);
}
@Override
public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) {
super.onBlockDestroyedByExplosion(world, x, y, z, explosion);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEMasterStone) {
((TEMasterStone) tile).useOnRitualBrokenExplosion();
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what,
float these, float are) {
TEMasterStone tileEntity = (TEMasterStone) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking()) {
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem == null) {
return false;
}
Item item = playerItem.getItem();
if (!(item instanceof ActivationCrystal acItem)) {
return false;
}
// tileEntity.setOwner(acItem.getOwnerName(playerItem));
tileEntity.activateRitual(
world,
acItem.getCrystalLevel(playerItem),
playerItem,
player,
IBindable.getOwnerName(playerItem));
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TEMasterStone();
}
}