aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
index 0aea2d97..8fd82501 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
@@ -2,17 +2,19 @@ package kr.syeyoung.dungeonsguide.dungeon.actions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import java.util.HashSet;
import java.util.Set;
@Data
-public class ActionClickSet implements Action {
+public class ActionClickSet extends AbstractAction {
private Set<Action> preRequisite = new HashSet<Action>();
private OffsetPointSet target;
private Predicate<ItemStack> predicate = Predicates.alwaysTrue();
@@ -30,4 +32,22 @@ public class ActionClickSet implements Action {
public String toString() {
return "ClickSet\n- targets size: "+target.getOffsetPointList().size()+"\n- predicate: "+predicate.getClass().getSimpleName();
}
+
+ private boolean clicked = false;
+ @Override
+ public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event) {
+ if (clicked) return;
+ for (OffsetPoint pt2: target.getOffsetPointList()) {
+ if (pt2.getBlockPos(dungeonRoom).equals(event.pos) &&
+ (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) {
+ clicked = true;
+ }
+ }
+
+ }
+
+ @Override
+ public boolean isComplete(DungeonRoom dungeonRoom) {
+ return clicked;
+ }
}