Merge pull request #12 from ethug/master

Rewrote ObsidianReplaceModule
This commit is contained in:
Daniel E 2019-11-21 14:32:04 -07:00 committed by GitHub
commit 39c4d8d26e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 250 additions and 303 deletions

View File

@ -0,0 +1,15 @@
package me.rigamortis.seppuku.api.event.module;
import me.rigamortis.seppuku.api.module.Module;
public final class EventModulePostLoaded {
private final Module module;
public EventModulePostLoaded(final Module module) {
this.module = module;
}
public Module getModule() {
return module;
}
}

View File

@ -2,6 +2,7 @@ package me.rigamortis.seppuku.impl.management;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.module.EventModuleLoad;
import me.rigamortis.seppuku.api.event.module.EventModulePostLoaded;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.ReflectionUtil;
import me.rigamortis.seppuku.api.util.StringUtil;
@ -145,6 +146,9 @@ public final class ModuleManager {
add(new VisualRangeModule());
this.loadExternalModules();
for (final Module module : moduleList)
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventModulePostLoaded(module));
}
/**
@ -174,6 +178,7 @@ public final class ModuleManager {
if (module != null) {
//add the class to our list of modules
add(module);
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventModuleLoad(module));
System.out.println("[Seppuku] Found external module " + module.getDisplayName());
}

View File

@ -2,363 +2,286 @@ package me.rigamortis.seppuku.impl.module.combat;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.module.EventModulePostLoaded;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
import me.rigamortis.seppuku.api.event.render.EventRender3D;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.MathUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.value.OptionalValue;
import me.rigamortis.seppuku.impl.module.player.FreeCamModule;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockObsidian;
import net.minecraft.block.material.Material;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
import net.minecraft.network.play.server.SPacketBlockChange;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.BiFunction;
/**
* Author Seth
* 8/14/2019 @ 6:01 PM.
* @author Daniel E
*/
public final class ObsidianReplaceModule extends Module {
private static final int[][] BLOCK_DIRECTION_OFFSET = {
{0, 1, 0},
{0, -1, 0},
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"Manual", "Automatic"});
{0, 0, -1},
{0, 0, 1},
private final Minecraft mc = Minecraft.getMinecraft();
{1, 0, 0},
{-1, 0, 0}
};
private List<BlockPos> blocks = new CopyOnWriteArrayList<>();
private int lastSlot;
private final Queue<PlacementRequest> placementRequests = new ConcurrentLinkedQueue<>();
private FreeCamModule freeCamModule = null;
public ObsidianReplaceModule() {
super("ObsidianReplace", new String[]{"ObbyRep", "ObbyReplace", "ObbRep", "ObsidianRep"}, "Automatically replaces broken obsidian near you", "NONE", -1, ModuleType.COMBAT);
super("ObsidianReplace", new String[]{
"ObbyRep", "ObbyReplace", "ObbRep", "ObsidianRep"
}, "Automatically replaces broken obsidian near you",
"NONE", -1, ModuleType.COMBAT);
if (!Seppuku.INSTANCE.getEventManager().addEventListener(this))
throw new RuntimeException();
}
@Listener
public void onToggle() {
super.onToggle();
this.blocks.clear();
public void onWalkingUpdate(final EventUpdateWalkingPlayer event) {
if (placementRequests.isEmpty())
return;
if (event.getStage() != EventStageable.EventStage.PRE)
return;
if (freeCamModule != null && freeCamModule.isEnabled())
return;
final Minecraft minecraft = Minecraft.getMinecraft();
final EntityPlayerSP player = minecraft.player;
final int obisidanSlot = findObsidianInHotbar(player);
if (obisidanSlot == -1)
return;
final int currentSlot = player.inventory.currentItem;
final HandSwapContext handSwapContext = new HandSwapContext(currentSlot, obisidanSlot);
handleHandSwap(handSwapContext, false, minecraft);
final PlacementRequest placementRequest = placementRequests.poll();
assert placementRequest != null;
final BlockPos position = placementRequest.getStructurePosition();
final double playerToBlockDistance =
calculateVecDistance(player.getPositionEyes(1.0f),
position.getX(), position.getY(), position.getZ());
if (playerToBlockDistance <= getReachDistance(minecraft))
handlePlaceRequest(minecraft, placementRequest);
handleHandSwap(handSwapContext, true, minecraft);
}
@Listener
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
public void onReceivePacket(final EventReceivePacket event) {
if (event.getStage() != EventStageable.EventStage.POST)
return;
final FreeCamModule freeCam = (FreeCamModule) Seppuku.INSTANCE.getModuleManager().find(FreeCamModule.class);
if (freeCamModule != null && freeCamModule.isEnabled())
return;
if(freeCam != null && freeCam.isEnabled()) {
return;
final Minecraft minecraft = Minecraft.getMinecraft();
if (event.getPacket() instanceof SPacketBlockChange) {
final SPacketBlockChange blockChange = (SPacketBlockChange) event.getPacket();
if (blockChange.getBlockState().getBlock() instanceof BlockAir) {
final BlockPos position = blockChange.getBlockPosition();
final double playerToBlockDistance =
calculateVecDistance(minecraft.player.getPositionEyes(1.0f),
position.getX(), position.getY(), position.getZ());
if (playerToBlockDistance <= getReachDistance(minecraft))
buildPlacementRequest(minecraft, position);
}
}
}
if (this.hasStack(Blocks.OBSIDIAN)) {
boolean valid = false;
for (BlockPos pos : this.blocks) {
if (pos != null) {
final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
if (dist <= 5.0f) {
if (this.valid(pos)) {
this.place(pos);
valid = true;
}
}
}
}
if (valid) {
mc.player.inventory.currentItem = this.lastSlot;
mc.playerController.updateController();
}
} else {
if (this.canPlace()) {
final int slot = this.findStackHotbar(Blocks.OBSIDIAN);
if (slot != -1) {
this.lastSlot = mc.player.inventory.currentItem;
mc.player.inventory.currentItem = slot;
mc.playerController.updateController();
}
}
}
@Listener
public void onModulePostLoaded(final EventModulePostLoaded event) {
if (event.getModule() instanceof FreeCamModule) {
freeCamModule = (FreeCamModule) event.getModule();
if (!Seppuku.INSTANCE.getEventManager().removeEventListener(this))
throw new RuntimeException();
}
}
@Override
public String getMetaData() {
return this.mode.getSelectedOption();
public void onDisable() {
super.onDisable();
placementRequests.clear();
}
private boolean canPlace() {
for (BlockPos pos : this.blocks) {
if (pos != null) {
final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
if (dist <= 5.0f) {
if (this.valid(pos)) {
return true;
}
}
}
private void buildPlacementRequest(final Minecraft minecraft, final BlockPos position) {
for (final int[] directionOffset : BLOCK_DIRECTION_OFFSET) {
final BlockPos relativePosition = position.add(directionOffset[0], directionOffset[1],
directionOffset[2]);
final Block structureBlock = minecraft.world.getBlockState(relativePosition).getBlock();
if (structureBlock instanceof BlockAir || structureBlock instanceof BlockLiquid)
continue;
final EnumFacing blockPlacementFace = calculateFaceForPlacement(relativePosition, position);
if (blockPlacementFace != null && placementRequests.offer(new PlacementRequest(
relativePosition, blockPlacementFace)))
return;
}
}
private EnumFacing calculateFaceForPlacement(final BlockPos structurePosition,
final BlockPos blockPosition) {
final BiFunction<Integer, String, Integer> throwingClamp = (number, axis) -> {
if (number < -1 || number > 1)
throw new IllegalArgumentException(
String.format("Difference in %s is illegal, " +
"positions are too far apart.", axis));
return number;
};
final int diffX = throwingClamp.apply(
structurePosition.getX() - blockPosition.getX(), "x-axis");
switch (diffX) {
case 1:
return EnumFacing.WEST;
case -1:
return EnumFacing.EAST;
default:
break;
}
final int diffY = throwingClamp.apply(
structurePosition.getY() - blockPosition.getY(), "y-axis");
switch (diffY) {
case 1:
return EnumFacing.DOWN;
case -1:
return EnumFacing.UP;
default:
break;
}
final int diffZ = throwingClamp.apply(
structurePosition.getZ() - blockPosition.getZ(), "z-axis");
switch (diffZ) {
case 1:
return EnumFacing.NORTH;
case -1:
return EnumFacing.SOUTH;
default:
break;
}
return null;
}
private void handlePlaceRequest(final Minecraft minecraft, final PlacementRequest placementRequest) {
final EntityPlayerSP player = minecraft.player;
final BlockPos structurePosition = placementRequest.getStructurePosition();
final IBlockState structureBlockState = minecraft.world.getBlockState(structurePosition);
final Block structureBlock = structureBlockState.getBlock();
final boolean blockActivated = structureBlock.onBlockActivated(minecraft.world,
structurePosition, structureBlockState, player, EnumHand.MAIN_HAND,
EnumFacing.UP, 0.0f, 0.0f, 0.0f);
if (blockActivated)
player.connection.sendPacket(new CPacketEntityAction(player,
CPacketEntityAction.Action.START_SNEAKING));
if (minecraft.playerController.processRightClickBlock(player, minecraft.world,
structurePosition, placementRequest.getPlaceDirection(),
Vec3d.ZERO, EnumHand.MAIN_HAND) != EnumActionResult.FAIL)
player.swingArm(EnumHand.MAIN_HAND);
if (blockActivated)
player.connection.sendPacket(new CPacketEntityAction(player,
CPacketEntityAction.Action.STOP_SNEAKING));
}
private boolean isItemStackObsidian(final ItemStack itemStack) {
if (itemStack.getItem() instanceof ItemBlock)
return ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockObsidian;
return false;
}
@Listener
public void recievePacket(EventReceivePacket event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if (this.mode.getInt() == 1) {
if (event.getPacket() instanceof SPacketBlockChange) {
final SPacketBlockChange packet = (SPacketBlockChange) event.getPacket();
if (packet.getBlockState().getBlock() instanceof BlockAir) {
final double dist = mc.player.getDistance(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
if (dist <= 5.0f) {
if (!this.blocks.contains(packet.getBlockPosition())) {
this.blocks.add(packet.getBlockPosition());
}
}
}
}
}
}
}
private int findObsidianInHotbar(final EntityPlayer player) {
for (int index = 0; InventoryPlayer.isHotbar(index); index++)
if (isItemStackObsidian(player.inventory.getStackInSlot(index)))
return index;
@Listener
public void sendPacket(EventSendPacket event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if(this.mode.getInt() == 0) {
if (event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) {
final CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock) event.getPacket();
final ItemStack stack = mc.player.inventory.getCurrentItem();
if (stack != null && stack.getItem() != Items.AIR && stack.getItem() instanceof ItemBlock) {
final ItemBlock itemBlock = (ItemBlock) stack.getItem();
if (itemBlock.getBlock() instanceof BlockObsidian) {
BlockPos pos = packet.getPos();
switch (packet.getDirection()) {
case NORTH:
pos = pos.add(0, 0, -1);
break;
case SOUTH:
pos = pos.add(0, 0, 1);
break;
case EAST:
pos = pos.add(1, 0, 0);
break;
case WEST:
pos = pos.add(-1, 0, 0);
break;
case UP:
pos = pos.add(0, 1, 0);
break;
case DOWN:
pos = pos.add(0, -1, 0);
break;
}
if (!this.blocks.contains(pos)) {
this.blocks.add(pos);
}
}
}
}
}
}
}
@Listener
public void render3D(EventRender3D event) {
for (BlockPos pos : this.blocks) {
if (pos != null) {
final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
if (dist <= 5.0f) {
final IBlockState iblockstate = mc.world.getBlockState(pos);
if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(pos)) {
final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
RenderUtil.drawBoundingBox(iblockstate.getSelectedBoundingBox(mc.world, pos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z), 1.5f, 0xFF9900EE);
}
}
}
}
}
private boolean hasStack(Block type) {
if (mc.player.inventory.getCurrentItem().getItem() instanceof ItemBlock) {
final ItemBlock block = (ItemBlock) mc.player.inventory.getCurrentItem().getItem();
if (block.getBlock() == type) {
return true;
}
}
return false;
}
private void place(BlockPos pos) {
final Minecraft mc = Minecraft.getMinecraft();
final Block north = mc.world.getBlockState(pos.add(0, 0, -1)).getBlock();
final Block south = mc.world.getBlockState(pos.add(0, 0, 1)).getBlock();
final Block east = mc.world.getBlockState(pos.add(1, 0, 0)).getBlock();
final Block west = mc.world.getBlockState(pos.add(-1, 0, 0)).getBlock();
final Block up = mc.world.getBlockState(pos.add(0, 1, 0)).getBlock();
final Block down = mc.world.getBlockState(pos.add(0, -1, 0)).getBlock();
if (up != null && up != Blocks.AIR && !(up instanceof BlockLiquid)) {
final boolean activated = up.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.DOWN, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 1, 0), EnumFacing.DOWN, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (down != null && down != Blocks.AIR && !(down instanceof BlockLiquid)) {
final boolean activated = down.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, -1, 0), EnumFacing.UP, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (north != null && north != Blocks.AIR && !(north instanceof BlockLiquid)) {
final boolean activated = north.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 0, -1), EnumFacing.SOUTH, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (south != null && south != Blocks.AIR && !(south instanceof BlockLiquid)) {
final boolean activated = south.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 0, 1), EnumFacing.NORTH, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (east != null && east != Blocks.AIR && !(east instanceof BlockLiquid)) {
final boolean activated = east.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(1, 0, 0), EnumFacing.WEST, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (west != null && west != Blocks.AIR && !(west instanceof BlockLiquid)) {
final boolean activated = west.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(-1, 0, 0), EnumFacing.EAST, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
}
private int findStackHotbar(Block type) {
for (int i = 0; i < 9; i++) {
final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i);
if (stack.getItem() instanceof ItemBlock) {
final ItemBlock block = (ItemBlock) stack.getItem();
if (block.getBlock() == type) {
return i;
}
}
}
return -1;
}
private boolean valid(BlockPos pos) {
final Block block = mc.world.getBlockState(pos).getBlock();
private double getReachDistance(final Minecraft minecraft) {
// todo; this is just not right my guy, we should really be verifying
// placements on certain block faces with traces and stuff...
return minecraft.playerController.getBlockReachDistance();
}
if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid)) {
return false;
private double calculateVecDistance(final Vec3d vec, final int blockX,
final int blockY, final int blockZ) {
final double diffX = blockX - vec.x;
final double diffY = blockY - vec.y;
final double diffZ = blockZ - vec.z;
return MathHelper.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
}
private void handleHandSwap(final HandSwapContext context, final boolean restore,
final Minecraft minecraft) {
minecraft.player.inventory.currentItem =
restore ? context.getOldSlot() : context.getNewSlot();
minecraft.playerController.updateController();
}
private static final class HandSwapContext {
private final int oldSlot;
private final int newSlot;
HandSwapContext(int oldSlot, int newSlot) {
this.oldSlot = oldSlot;
this.newSlot = newSlot;
}
final List<Entity> invalidEntities = mc.world.getEntitiesInAABBexcluding(null,
new AxisAlignedBB(pos), entity -> !(entity instanceof EntityItem) &&
!(entity instanceof EntityXPOrb));
if (!invalidEntities.isEmpty())
return false;
int getOldSlot() {
return oldSlot;
}
final Block up = mc.world.getBlockState(pos.add(0, 1, 0)).getBlock();
final Block down = mc.world.getBlockState(pos.add(0, -1, 0)).getBlock();
final Block north = mc.world.getBlockState(pos.add(0, 0, -1)).getBlock();
final Block south = mc.world.getBlockState(pos.add(0, 0, 1)).getBlock();
final Block east = mc.world.getBlockState(pos.add(1, 0, 0)).getBlock();
final Block west = mc.world.getBlockState(pos.add(-1, 0, 0)).getBlock();
int getNewSlot() {
return newSlot;
}
}
return ((up != Blocks.AIR && !(up instanceof BlockLiquid))
|| (down != Blocks.AIR && !(down instanceof BlockLiquid))
|| (north != Blocks.AIR && !(north instanceof BlockLiquid))
|| (south != Blocks.AIR && !(south instanceof BlockLiquid))
|| (east != Blocks.AIR && !(east instanceof BlockLiquid))
|| (west != Blocks.AIR && !(west instanceof BlockLiquid)));
private static final class PlacementRequest {
private final BlockPos structurePosition;
private final EnumFacing placeDirection;
PlacementRequest(final BlockPos structurePosition,
final EnumFacing placeDirection) {
this.structurePosition = structurePosition;
this.placeDirection = placeDirection;
}
BlockPos getStructurePosition() {
return structurePosition;
}
EnumFacing getPlaceDirection() {
return placeDirection;
}
}
}

View File

@ -5,6 +5,7 @@ import team.stiff.pomelo.filter.EventFilterScanner;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ -19,6 +20,9 @@ public final class MethodFilterScanner implements EventFilterScanner<Method> {
@Override
public Set<EventFilter> scan(final Method listener) {
if (!listener.isAnnotationPresent(Listener.class))
return Collections.emptySet();
final Set<EventFilter> filters = new HashSet<>();
// iterate all filters in the annotation and instantiate them
for (final Class<? extends EventFilter> filter : listener