2
0
Fork 0
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.

45 lines
1.7 KiB
Java

package com.zivilon.cinder_loe.blocks;
import lotr.common.LOTRCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraft.block.BlockPressurePlate;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.lang.reflect.Field;
public class ShadowTile extends BlockPressurePlate {
public ShadowTile() {
super("lotr:shadow_tile", Material.rock, BlockPressurePlate.Sensitivity.players);
try {
Field tabField = LOTRCreativeTabs.class.getDeclaredField("tabMisc"); // Stupid workaround because ForgeGradle tries to obfuscate field LOTRCreativeTabs.tabBlock when it's not supposed to
LOTRCreativeTabs tab = (LOTRCreativeTabs)tabField.get(null);
setCreativeTab((CreativeTabs)tab);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
setBlockTextureName("lotr:shadow_tile");
setBlockName("lotr:shadowTile");
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)entity;
player.attackEntityFrom(new DamageSource("shadow"), 10.0F);
player.addPotionEffect(new PotionEffect(15, 6*20, 0, false));
world.setBlockToAir(x, y, z);
}
}
}