From befa8982a0a8d929e65a23b66040671a45181ef4 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 14 Feb 2021 19:31:46 +0900 Subject: new thins --- .../dungeon/DungeonActionManager.java | 20 ++++++++++ .../dungeonsguide/dungeon/EntitySpawnManager.java | 12 ------ .../dungeon/actions/ActionInteract.java | 4 +- .../dungeonsguide/dungeon/actions/ActionKill.java | 6 +-- .../dungeonsguide/dungeon/actions/ActionMove.java | 2 +- .../dungeon/actions/ActionMoveNearestAir.java | 2 +- .../dungeon/mechanics/DungeonBreakableWall.java | 22 ++++++++++- .../dungeon/mechanics/DungeonSecret.java | 20 ++++++++++ .../eventlistener/DungeonListener.java | 20 +++++----- .../roomedit/gui/GuiDungeonAddSet.java | 3 ++ .../roomprocessor/GeneralRoomProcessor.java | 44 ++++++++++++++++++---- 11 files changed, 115 insertions(+), 40 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/EntitySpawnManager.java (limited to 'src/main') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java new file mode 100644 index 00000000..d69303ea --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java @@ -0,0 +1,20 @@ +package kr.syeyoung.dungeonsguide.dungeon; + +import lombok.Getter; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DungeonActionManager { + @Getter + private static final Map spawnLocation = new HashMap(); + + @Getter + private static final List killeds = new ArrayList(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/EntitySpawnManager.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/EntitySpawnManager.java deleted file mode 100644 index 7bdf13cc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/EntitySpawnManager.java +++ /dev/null @@ -1,12 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon; - -import lombok.Getter; -import net.minecraft.util.Vec3; - -import java.util.HashMap; -import java.util.Map; - -public class EntitySpawnManager { - @Getter - private static final Map spawnLocation = new HashMap(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java index 96b4e874..2d1912c5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java @@ -2,7 +2,7 @@ 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.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; @@ -43,7 +43,7 @@ public class ActionInteract extends AbstractAction { System.out.println("eve"); if (interacted) return; - Vec3 spawnLoc = EntitySpawnManager.getSpawnLocation().get(event.getEntity().getEntityId()); + Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.getEntity().getEntityId()); if (spawnLoc == null) return; if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; if (!predicate.apply(event.getEntity())) return; 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 7d7c0488..b11cce84 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java @@ -2,13 +2,11 @@ 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.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; -import lombok.EqualsAndHashCode; import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; @@ -44,7 +42,7 @@ public class ActionKill extends AbstractAction { public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event) { if (killed) return; - Vec3 spawnLoc = EntitySpawnManager.getSpawnLocation().get(event.entity.getEntityId()); + Vec3 spawnLoc = DungeonActionManager.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; 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 e2d6b318..5079f4c9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -32,7 +32,7 @@ public class ActionMove extends AbstractAction { @Override public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 10; + return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; } @Override 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 19a515a0..994c7a7d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -32,7 +32,7 @@ public class ActionMoveNearestAir extends AbstractAction { @Override public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 10; + return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java index 5ba3f21c..5fa994e0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -27,7 +27,16 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { if (state.equalsIgnoreCase("navigate")) { Set base; Set preRequisites = base = new HashSet(); - ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + + int leastY = Integer.MAX_VALUE; + OffsetPoint thatPt = null; + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + if (offsetPoint.getY() < leastY) { + thatPt = offsetPoint; + leastY = offsetPoint.getY(); + } + } + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(thatPt); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); for (String str : preRequisite) { @@ -50,7 +59,16 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { preRequisites = actionClick.getPreRequisite(); } { - ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + + int leastY = Integer.MAX_VALUE; + OffsetPoint thatPt = null; + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + if (offsetPoint.getY() < leastY) { + thatPt = offsetPoint; + leastY = offsetPoint.getY(); + } + } + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(thatPt); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java index 182e0201..abedc705 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -1,10 +1,12 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateBat; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomedit.panes.SecretEditPane; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.AllArgsConstructor; import lombok.Data; @@ -13,6 +15,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; import java.awt.*; import java.util.*; @@ -40,6 +43,23 @@ public class DungeonSecret implements DungeonMechanic { return SecretStatus.CREATED; } } + } else if (secretType == SecretType.ESSENCE) { + BlockPos pos = secretPoint.getBlockPos(dungeonRoom); + IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + if (blockState.getBlock() == Blocks.skull) { + return SecretStatus.DEFINITELY_NOT; + } else { + return SecretStatus.NOT_SURE; + } + } else if (secretType == SecretType.BAT) { + Vec3 spawn = new Vec3(secretPoint.getBlockPos(dungeonRoom)); + for (Integer killed : DungeonActionManager.getKilleds()) { + if (DungeonActionManager.getSpawnLocation().get(killed) == null) continue; + if (DungeonActionManager.getSpawnLocation().get(killed).squareDistanceTo(spawn) < 100) { + return SecretStatus.FOUND; + } + } + return SecretStatus.NOT_SURE; } else { return SecretStatus.NOT_SURE; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java index 6ec18f73..adebf9d6 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java @@ -5,7 +5,7 @@ import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.EntitySpawnManager; +import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.e; @@ -27,11 +27,9 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiErrorScreen; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.entity.passive.EntityBat; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Vec3; -import net.minecraft.world.World; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; @@ -40,7 +38,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException; @@ -49,7 +46,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import javax.swing.text.html.parser.Entity; import java.awt.*; import java.io.IOException; import java.util.HashMap; @@ -63,7 +59,8 @@ public class DungeonListener { } catch (IOException e) { e.printStackTrace(); } - EntitySpawnManager.getSpawnLocation().clear(); + DungeonActionManager.getSpawnLocation().clear(); + DungeonActionManager.getKilleds().clear(); } @SubscribeEvent @@ -162,7 +159,7 @@ public class DungeonListener { MinecraftForge.EVENT_BUS.post(new SkyblockJoinedEvent()); } - if (isOnDungeon && !skyblockStatus.isOnDungeon()) { + if ((isOnDungeon && !skyblockStatus.isOnDungeon())) { MinecraftForge.EVENT_BUS.post(new DungeonLeftEvent()); skyblockStatus.setContext(null); MapUtils.clearMap(); @@ -479,12 +476,15 @@ public class DungeonListener { private Map entityIdToPosMap = new HashMap(); @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent spawn) { - EntitySpawnManager.getSpawnLocation().put(spawn.entity.getEntityId(), new Vec3(spawn.entity.posX, spawn.entity.posY, spawn.entity.posZ)); + DungeonActionManager.getSpawnLocation().put(spawn.entity.getEntityId(), new Vec3(spawn.entity.posX, spawn.entity.posY, spawn.entity.posZ)); } @SubscribeEvent public void onEntityDeSpawn(LivingDeathEvent deathEvent) { + if (deathEvent.entityLiving instanceof EntityBat) + DungeonActionManager.getKilleds().add(deathEvent.entity.getEntityId()); + try { SkyblockStatus skyblockStatus = (SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnDungeon()) return; @@ -514,7 +514,7 @@ public class DungeonListener { e.printStackTrace(); } - EntitySpawnManager.getSpawnLocation().remove(deathEvent.entity.getEntityId()); + DungeonActionManager.getSpawnLocation().remove(deathEvent.entity.getEntityId()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java index f0530cfa..d8cf391e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java @@ -6,6 +6,7 @@ import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Getter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -29,7 +30,9 @@ public class GuiDungeonAddSet extends GuiScreen { private MButton back; + @Getter private OffsetPoint start; + @Getter private OffsetPoint end; public void onWorldRender(float partialTicks) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index f7b26a1e..75d8c968 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -1,9 +1,7 @@ package kr.syeyoung.dungeonsguide.roomprocessor; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.EntitySpawnManager; +import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.actions.ActionComplete; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; @@ -14,6 +12,7 @@ import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; import lombok.Getter; import lombok.Setter; @@ -22,15 +21,14 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.passive.EntityBat; +import net.minecraft.init.Items; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; @@ -78,8 +76,8 @@ public class GeneralRoomProcessor implements RoomProcessor { if (en == null) return; ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - if (EntitySpawnManager.getSpawnLocation().containsKey(en.getEntityId())) { - fr.drawString("Spawned at " + EntitySpawnManager.getSpawnLocation().get(en.getEntityId()), sr.getScaledWidth() / 2, sr.getScaledHeight() / 2, 0xFFFFFFFF); + if (DungeonActionManager.getSpawnLocation().containsKey(en.getEntityId())) { + fr.drawString("Spawned at " + DungeonActionManager.getSpawnLocation().get(en.getEntityId()), sr.getScaledWidth() / 2, sr.getScaledHeight() / 2, 0xFFFFFFFF); } } } @@ -179,9 +177,29 @@ public class GeneralRoomProcessor implements RoomProcessor { if (path != null) path.getCurrentAction().onLivingInteract(getDungeonRoom(), event); } + private boolean last = false; @Override public void onInteractBlock(PlayerInteractEvent event) { if (path != null) path.onPlayerInteract(event); + + System.out.println(event.action); + if (event.entityPlayer.getHeldItem() != null && + event.entityPlayer.getHeldItem().getItem() == Items.stick && + FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && + FeatureRegistry.DEBUG.isEnabled()) { + EditingContext ec = EditingContext.getEditingContext(); + if (ec == null) return; + if (!(ec.getCurrent() instanceof GuiDungeonAddSet)) return; + GuiDungeonAddSet gdas = (GuiDungeonAddSet) ec.getCurrent(); + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + if (last) + gdas.getEnd().setPosInWorld(getDungeonRoom(), event.pos); + else + gdas.getStart().setPosInWorld(getDungeonRoom(), event.pos); + + last = !last; + } + } } @Override @@ -194,12 +212,22 @@ public class GeneralRoomProcessor implements RoomProcessor { DungeonSecret secret = new DungeonSecret(); secret.setSecretType(DungeonSecret.SecretType.BAT); secret.setSecretPoint(new OffsetPoint(dungeonRoom, - EntitySpawnManager.getSpawnLocation().get(deathEvent.entity.getEntityId()) + DungeonActionManager.getSpawnLocation().get(deathEvent.entity.getEntityId()) )); ((GuiDungeonRoomEdit) screen).getSep().createNewMechanic("BAT-"+UUID.randomUUID().toString(), secret); + return; } } + if (EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit) { + DungeonSecret secret = new DungeonSecret(); + secret.setSecretType(DungeonSecret.SecretType.BAT); + secret.setSecretPoint(new OffsetPoint(dungeonRoom, + DungeonActionManager.getSpawnLocation().get(deathEvent.entity.getEntityId()) + )); + ((GuiDungeonRoomEdit) EditingContext.getEditingContext().getCurrent()).getSep().createNewMechanic("BAT-"+UUID.randomUUID().toString(), + secret); + } } } } -- cgit