Fire BlockRedstoneEvent for PandaWire
This commit is contained in:
@@ -7,6 +7,8 @@ import java.util.Set;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -122,7 +124,7 @@ public abstract class PandaRedstoneWire extends Block {
|
|||||||
* usage but likely still worth it
|
* usage but likely still worth it
|
||||||
*/
|
*/
|
||||||
this.updatedRedstoneWire.clear();
|
this.updatedRedstoneWire.clear();
|
||||||
|
|
||||||
// Execute updates
|
// Execute updates
|
||||||
for (BlockPosition posi : blocksNeedingUpdate) {
|
for (BlockPosition posi : blocksNeedingUpdate) {
|
||||||
world.applyPhysics(posi, (BlockRedstoneWire) (Object) this, false);
|
world.applyPhysics(posi, (BlockRedstoneWire) (Object) this, false);
|
||||||
@@ -143,7 +145,7 @@ public abstract class PandaRedstoneWire extends Block {
|
|||||||
// In case this wire was removed, check the surrounding wires
|
// In case this wire was removed, check the surrounding wires
|
||||||
this.checkSurroundingWires(worldIn, position);
|
this.checkSurroundingWires(worldIn, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!turnOff.isEmpty()) {
|
while (!turnOff.isEmpty()) {
|
||||||
BlockPosition pos = turnOff.remove(0);
|
BlockPosition pos = turnOff.remove(0);
|
||||||
IBlockData state = worldIn.getType(pos);
|
IBlockData state = worldIn.getType(pos);
|
||||||
@@ -152,10 +154,19 @@ public abstract class PandaRedstoneWire extends Block {
|
|||||||
int blockPower = worldIn.z(pos); // PAIL: isBlockIndirectlyGettingPowered
|
int blockPower = worldIn.z(pos); // PAIL: isBlockIndirectlyGettingPowered
|
||||||
this.canProvidePower = true;
|
this.canProvidePower = true;
|
||||||
int wirePower = this.getSurroundingWirePower(worldIn, pos);
|
int wirePower = this.getSurroundingWirePower(worldIn, pos);
|
||||||
|
|
||||||
// Lower the strength as it moved a block
|
// Lower the strength as it moved a block
|
||||||
wirePower--;
|
wirePower--;
|
||||||
int newPower = Math.max(blockPower, wirePower);
|
int newPower = Math.max(blockPower, wirePower);
|
||||||
|
|
||||||
|
// Akarin start - BlockRedstoneEvent
|
||||||
|
if (oldPower != newPower) {
|
||||||
|
BlockRedstoneEvent event = new BlockRedstoneEvent(worldIn.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), oldPower, newPower);
|
||||||
|
worldIn.getServer().getPluginManager().callEvent(event);
|
||||||
|
newPower = event.getNewCurrent();
|
||||||
|
}
|
||||||
|
// Akarin end
|
||||||
|
|
||||||
// Power lowered?
|
// Power lowered?
|
||||||
if (newPower < oldPower) {
|
if (newPower < oldPower) {
|
||||||
// If it's still powered by a direct source (but weaker) mark for turn on
|
// If it's still powered by a direct source (but weaker) mark for turn on
|
||||||
@@ -184,7 +195,13 @@ public abstract class PandaRedstoneWire extends Block {
|
|||||||
// Lower the strength as it moved a block
|
// Lower the strength as it moved a block
|
||||||
wirePower--;
|
wirePower--;
|
||||||
int newPower = Math.max(blockPower, wirePower);
|
int newPower = Math.max(blockPower, wirePower);
|
||||||
|
|
||||||
|
// Akarin start - BlockRedstoneEvent
|
||||||
|
BlockRedstoneEvent event = new BlockRedstoneEvent(worldIn.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), oldPower, newPower);
|
||||||
|
worldIn.getServer().getPluginManager().callEvent(event);
|
||||||
|
newPower = event.getNewCurrent();
|
||||||
|
// Akarin end
|
||||||
|
|
||||||
if (newPower > oldPower) {
|
if (newPower > oldPower) {
|
||||||
setWireState(worldIn, pos, state, newPower);
|
setWireState(worldIn, pos, state, newPower);
|
||||||
} else if (newPower < oldPower) {
|
} else if (newPower < oldPower) {
|
||||||
@@ -473,7 +490,6 @@ public abstract class PandaRedstoneWire extends Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forge adds 2 params to canConnectTo so we need to copy method in order to access it
|
|
||||||
private static boolean canConnectToBlock(IBlockData blockState, @Nullable EnumDirection side) {
|
private static boolean canConnectToBlock(IBlockData blockState, @Nullable EnumDirection side) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.minecraft.server;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -11,10 +10,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -24,10 +20,8 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.WeatherType;
|
import org.bukkit.WeatherType;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.craftbukkit.util.HashTreeSet;
|
import org.bukkit.craftbukkit.util.HashTreeSet;
|
||||||
|
|
||||||
import org.bukkit.event.block.BlockFormEvent;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|||||||
Reference in New Issue
Block a user