diff options
author | syeyoung <cyong06@naver.com> | 2021-02-10 17:58:54 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-10 17:58:54 +0900 |
commit | b6a7d4231a245a4d0ba772761319bd180c44944d (patch) | |
tree | e253ed6275ef87426e3de5f9b5529e6bdeba7901 /src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions | |
parent | 2223e55d5d9c61f4ab93d8dab0b5f9820272c8fe (diff) | |
download | Skyblock-Dungeons-Guide-b6a7d4231a245a4d0ba772761319bd180c44944d.tar.gz Skyblock-Dungeons-Guide-b6a7d4231a245a4d0ba772761319bd180c44944d.tar.bz2 Skyblock-Dungeons-Guide-b6a7d4231a245a4d0ba772761319bd180c44944d.zip |
lots of things
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions')
11 files changed, 191 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java new file mode 100644 index 00000000..16cd7ab0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java @@ -0,0 +1,32 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +public abstract class AbstractAction implements Action { + @Override + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event) { + + } + + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + + } + + @Override + public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event) { + + } + + @Override + public void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks) { + + } + + @Override + public void onTick(DungeonRoom dungeonRoom) { + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java index 7e3318c7..496439b8 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java @@ -1,9 +1,19 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import java.util.Set; public interface Action { Set<Action> getPreRequisites(DungeonRoom dungeonRoom); + + void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event); + void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event); + void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks); + void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks); + void onTick(DungeonRoom dungeonRoom); + + boolean isComplete(DungeonRoom dungeonRoom); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java new file mode 100755 index 00000000..b4986736 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java @@ -0,0 +1,44 @@ +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.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionBreakWithSuperBoom extends AbstractAction { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + + public ActionBreakWithSuperBoom(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return target.getBlock(dungeonRoom) == Blocks.air; + } + + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(255, 0,0,255),partialTicks, true); + } + + @Override + public String toString() { + return "Click\n- target: "+target.toString(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java index 37acd018..08246c2a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java @@ -9,7 +9,7 @@ import java.util.HashSet; import java.util.Set; @Data -public class ActionChangeState implements Action{ +public class ActionChangeState extends AbstractAction{ @EqualsAndHashCode.Exclude private Set<Action> preRequisite2 = new HashSet<Action>(); @@ -34,4 +34,12 @@ public class ActionChangeState implements Action{ public String toString() { return "ChangeState\n- target: "+mechanicName+"\n- state: "+state; } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + DungeonMechanic mechanic = dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName); + if (mechanic== null) + return false; + return mechanic.getCurrentState(dungeonRoom).equalsIgnoreCase(state); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java index 8c745385..d062cdd9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java @@ -7,16 +7,19 @@ 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 ActionClick implements Action { +public class ActionClick extends AbstractAction { private Set<Action> preRequisite = new HashSet<Action>(); private OffsetPoint target; private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); + private boolean clicked = false; + public ActionClick(OffsetPoint target) { this.target = target; } @@ -27,6 +30,20 @@ public class ActionClick implements Action { } @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return clicked; + } + + @Override + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event) { + if (clicked) return; + if (target.getBlockPos(dungeonRoom).equals(event.pos) && + (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { + clicked = true; + } + } + + @Override public String toString() { return "Click\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); } 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; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java index 80a39564..9fa87dad 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java @@ -6,16 +6,20 @@ import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import lombok.Data; import lombok.EqualsAndHashCode; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import java.util.HashSet; +import java.util.List; import java.util.Set; @Data -public class ActionDropItem implements Action { +public class ActionDropItem extends AbstractAction { private Set<Action> preRequisite = new HashSet<Action>(); private OffsetPoint target; - private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); + private Predicate<EntityItem> predicate = Predicates.alwaysTrue(); public ActionDropItem(OffsetPoint target) { this.target = target; @@ -27,6 +31,15 @@ public class ActionDropItem implements Action { } @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + BlockPos pos = target.getBlockPos(dungeonRoom); + List<EntityItem> item = dungeonRoom.getContext().getWorld().getEntitiesWithinAABB(EntityItem.class, + AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1, pos.getY() + 1, pos.getZ() + 1)); + if (item.size() == 0) return false; + return (predicate == null || predicate.apply(item.get(0))); + } + + @Override public String toString() { return "DropItem\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java index ff26fe20..26046201 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java @@ -2,17 +2,21 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.EntitySpawnManager; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.e; import lombok.Data; import lombok.EqualsAndHashCode; import net.minecraft.entity.Entity; +import net.minecraft.util.Vec3; +import net.minecraftforge.event.entity.living.LivingDeathEvent; import java.util.HashSet; import java.util.Set; @Data -public class ActionKill implements Action { +public class ActionKill extends AbstractAction { private Set<Action> preRequisite = new HashSet<Action>(); private OffsetPoint target; private Predicate<Entity> predicate = Predicates.alwaysFalse(); @@ -28,6 +32,23 @@ public class ActionKill implements Action { } @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return killed; + } + + private boolean killed = false; + @Override + public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event) { + if (killed) return; + + Vec3 spawnLoc = EntitySpawnManager.getSpawnLocation().get(event.entity.getEntityId()); + if (spawnLoc == null) return; + if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; + if (!predicate.apply(event.entity)) return; + killed = true; + } + + @Override public String toString() { return "KillEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java index a2aee8da..0eb1906a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -3,12 +3,13 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import lombok.Data; +import net.minecraft.client.Minecraft; import java.util.HashSet; import java.util.Set; @Data -public class ActionMove implements Action { +public class ActionMove extends AbstractAction { private Set<Action> preRequisite = new HashSet<Action>(); private OffsetPoint target; @@ -21,6 +22,11 @@ public class ActionMove implements Action { return preRequisite; } + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 10; + } + @Override public String toString() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java index 91bd79e7..52a63dba 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -3,12 +3,13 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import lombok.Data; +import net.minecraft.client.Minecraft; import java.util.HashSet; import java.util.Set; @Data -public class ActionMoveNearestAir implements Action { +public class ActionMoveNearestAir extends AbstractAction { private Set<Action> preRequisite = new HashSet<Action>(); private OffsetPoint target; @@ -22,6 +23,11 @@ public class ActionMoveNearestAir implements Action { } @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 10; + } + + @Override public String toString() { return "MoveNearestAir\n- target: "+target.toString(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java index 3d625371..f1228e81 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java @@ -7,7 +7,7 @@ import java.util.HashSet; import java.util.Set; @Data -public class ActionRoot implements Action { +public class ActionRoot extends AbstractAction { private Set<Action> preRequisite = new HashSet<Action>(); public ActionRoot() { @@ -19,6 +19,11 @@ public class ActionRoot implements Action { } @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return true; + } + + @Override public String toString() { return "Action Root"; } |