Files
CatServer/patches/net/minecraft/item/ItemFlintAndSteel.java.patch
2018-07-15 13:26:53 +08:00

35 lines
1.7 KiB
Diff

--- ../src-base/minecraft/net/minecraft/item/ItemFlintAndSteel.java
+++ ../src-work/minecraft/net/minecraft/item/ItemFlintAndSteel.java
@@ -11,6 +11,10 @@
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockIgniteEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
public class ItemFlintAndSteel extends Item
{
@@ -33,8 +37,20 @@
{
if (worldIn.isAirBlock(pos))
{
+ // CraftBukkit start - Store the clicked block
+ if(CraftEventFactory.callBlockIgniteEvent(worldIn,pos.getX(),pos.getY(),pos.getZ(), BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, playerIn).isCancelled()){
+ stack.damageItem(1,playerIn);
+ return EnumActionResult.PASS;
+ }
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState(), 11);
+ CraftBlockState blockState = CraftBlockState.getBlockState(worldIn,pos.getX(),pos.getY(),pos.getZ());
+ BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(worldIn,playerIn,hand,blockState,pos.getX(),pos.getY(),pos.getZ());
+ if(placeEvent.isCancelled() || !placeEvent.canBuild()){
+ placeEvent.getBlockPlaced().setTypeIdAndData(0,(byte)0,false);
+ return EnumActionResult.PASS;
+ }
+
}
stack.damageItem(1, playerIn);