Fix #923
This commit is contained in:
parent
33ecb3861a
commit
0335d00d66
1 changed files with 63 additions and 0 deletions
|
@ -12,18 +12,24 @@ import gregtech.api.objects.MaterialStack;
|
|||
import gregtech.api.util.GT_LanguageManager;
|
||||
import gregtech.api.util.GT_ModHandler;
|
||||
import gregtech.api.util.GT_OreDictUnificator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -31,6 +37,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class GT_Block_Reinforced extends GT_Generic_Block {
|
||||
|
@ -180,6 +187,62 @@ public class GT_Block_Reinforced extends GT_Generic_Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||
if(!world.isRemote && state.getValue(METADATA) == 5){
|
||||
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, player);
|
||||
world.spawnEntityInWorld(entitytntprimed);
|
||||
world.playSound((EntityPlayer)null, pos, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
|
||||
world.setBlockToAir(pos);
|
||||
return false;
|
||||
}
|
||||
return super.removedByPlayer(state, world, pos, player, willHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
if (worldIn.isBlockPowered(pos) && state.getValue(METADATA) == 5) {
|
||||
this.removedByPlayer(state, worldIn, pos, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) {
|
||||
if (worldIn.isBlockPowered(pos) && state.getValue(METADATA) == 5) {
|
||||
this.removedByPlayer(state, worldIn, pos, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockExploded(World world, BlockPos pos, Explosion explosion) {
|
||||
if (!world.isRemote && world.getBlockState(pos).getValue(METADATA) == 5) {
|
||||
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), explosion.getExplosivePlacedBy());
|
||||
entitytntprimed.setFuse(world.rand.nextInt(entitytntprimed.getFuse() / 4) + entitytntprimed.getFuse() / 8);
|
||||
world.spawnEntityInWorld(entitytntprimed);
|
||||
}
|
||||
super.onBlockExploded(world, pos, explosion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (heldItem != null && (heldItem.getItem() == Items.FLINT_AND_STEEL || heldItem.getItem() == Items.FIRE_CHARGE) && state.getValue(METADATA) == 5) {
|
||||
removedByPlayer(state, worldIn, pos, playerIn, true);
|
||||
|
||||
if (heldItem.getItem() == Items.FLINT_AND_STEEL)
|
||||
{
|
||||
heldItem.damageItem(1, playerIn);
|
||||
}
|
||||
else if (!playerIn.capabilities.isCreativeMode)
|
||||
{
|
||||
--heldItem.stackSize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
|
Loading…
Reference in a new issue