forked from xjboss/KCauldronX
修复方块事件中部分参数错误的问题
This commit is contained in:
parent
043313ffb8
commit
1811737e6a
@ -1,18 +1,23 @@
|
|||||||
--- ../src-base/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
--- ../src-base/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
||||||
+++ ../src-work/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
+++ ../src-work/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
||||||
@@ -16,6 +16,11 @@
|
@@ -16,6 +16,16 @@
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
|
||||||
|
+import org.bukkit.block.BlockState;
|
||||||
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
+// Cauldron start
|
+// Cauldron start
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
|
+import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
+import org.bukkit.event.block.BlockMultiPlaceEvent;
|
||||||
|
+
|
||||||
+import net.minecraft.entity.player.EntityPlayerMP;
|
+import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
+// Cauldron end
|
+// Cauldron end
|
||||||
+
|
+
|
||||||
public class BlockEvent extends Event {
|
public class BlockEvent extends Event {
|
||||||
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
|
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
|
||||||
|
|
||||||
@@ -80,17 +85,18 @@
|
@@ -80,17 +90,18 @@
|
||||||
super(x, y, z, world, block, blockMetadata);
|
super(x, y, z, world, block, blockMetadata);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
@ -37,20 +42,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayer getPlayer()
|
public EntityPlayer getPlayer()
|
||||||
@@ -140,6 +146,16 @@
|
@@ -140,6 +151,16 @@
|
||||||
this.blockSnapshot = blockSnapshot;
|
this.blockSnapshot = blockSnapshot;
|
||||||
this.placedBlock = blockSnapshot.getCurrentBlock();
|
this.placedBlock = blockSnapshot.getCurrentBlock();
|
||||||
this.placedAgainst = placedAgainst;
|
this.placedAgainst = placedAgainst;
|
||||||
+ // Cauldron start - handle event on bukkit side
|
+ // Cauldron start - handle event on bukkit side
|
||||||
+ org.bukkit.craftbukkit.block.CraftBlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(super.world, super.x, super.y,
|
+ if(!(this instanceof MultiPlaceEvent)){
|
||||||
+ super.z);
|
+ org.bukkit.craftbukkit.block.CraftBlockState blockstate=new org.bukkit.craftbukkit.block.CraftBlockState(blockSnapshot);
|
||||||
+ org.bukkit.event.block.BlockPlaceEvent bukkitEvent = CraftEventFactory.callBlockPlaceEvent(super.world, player, blockstate, super.x, super.y,
|
+ org.bukkit.event.block.BlockPlaceEvent bukkitEvent=CraftEventFactory.callBlockPlaceEvent(super.world,player,blockstate,super.x,super.y,
|
||||||
+ super.z);
|
+ super.z);
|
||||||
+ if (bukkitEvent.isCancelled() || !bukkitEvent.canBuild())
|
+ if(bukkitEvent.isCancelled()||!bukkitEvent.canBuild()){
|
||||||
+ {
|
+ this.setCanceled(true);
|
||||||
+ this.setCanceled(true);
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Cauldron end
|
+ // Cauldron end
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
{
|
{
|
||||||
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.getCurrentEquippedItem(), player);
|
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.getCurrentEquippedItem(), player);
|
||||||
|
@@ -160,7 +181,17 @@
|
||||||
|
|
||||||
|
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, Block placedAgainst, EntityPlayer player) {
|
||||||
|
super(blockSnapshots.get(0), placedAgainst, player);
|
||||||
|
+
|
||||||
|
this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
|
||||||
|
+
|
||||||
|
+ //bukkit start
|
||||||
|
+ ArrayList<BlockState> tStates=new ArrayList<BlockState>(blockSnapshots.size());
|
||||||
|
+ for(BlockSnapshot sSnapshot : this.blockSnapshots){
|
||||||
|
+ tStates.add(new CraftBlockState(sSnapshot));
|
||||||
|
+ }
|
||||||
|
+ BlockMultiPlaceEvent tEvent=CraftEventFactory.callBlockMultiPlaceEvent(super.world,player,tStates,super.x,super.y,super.z);
|
||||||
|
+ this.setCanceled(tEvent.isCancelled()||!tEvent.canBuild());
|
||||||
|
+
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.itemInHand, player);
|
||||||
|
Loading…
Reference in New Issue
Block a user