From 6a9cfb3acbe35d3c256cd6ff04e2612edd305258 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Nov 2018 12:24:37 -0500 Subject: [PATCH] Cubot drill module now functional --- .../java/net/simon987/cubotplugin/CubotDrill.java | 12 +++++++++--- .../net/simon987/server/game/item/ItemCopper.java | 2 +- .../net/simon987/server/game/item/ItemIron.java | 2 +- Server/src/main/resources/static/js/mar.js | 13 ++++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java index 965aa3d..884fe90 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java @@ -1,8 +1,10 @@ package net.simon987.cubotplugin; import net.simon987.server.assembly.Status; +import net.simon987.server.game.item.Item; import net.simon987.server.game.objects.Action; import net.simon987.server.game.objects.ControllableUnit; +import net.simon987.server.game.world.Tile; import org.bson.Document; public class CubotDrill extends CubotHardwareModule { @@ -43,9 +45,13 @@ public class CubotDrill extends CubotHardwareModule { if (cubot.spendEnergy(1400)) { if (cubot.getCurrentAction() == Action.IDLE) { - //TODO: Get Tile instance and call onDig() - //int tile = cubot.getWorld().getTileMap().getTileIdAt(cubot.getX(), cubot.getY()); - //cubot.setCurrentAction(Action.DIGGING); + Tile tile = cubot.getWorld().getTileMap().getTileAt(cubot.getX(), cubot.getY()); + + Item newItem = tile.drill(); + if (newItem != null) { + cubot.setCurrentAction(Action.DIGGING); + cubot.giveItem(newItem); + } } } } diff --git a/Server/src/main/java/net/simon987/server/game/item/ItemCopper.java b/Server/src/main/java/net/simon987/server/game/item/ItemCopper.java index 5d3ce18..d7c6bef 100644 --- a/Server/src/main/java/net/simon987/server/game/item/ItemCopper.java +++ b/Server/src/main/java/net/simon987/server/game/item/ItemCopper.java @@ -5,7 +5,7 @@ import org.bson.Document; public class ItemCopper extends Item { - public static final int ID = 0x0003; + public static final int ID = 0x0004; @Override public int getId() { diff --git a/Server/src/main/java/net/simon987/server/game/item/ItemIron.java b/Server/src/main/java/net/simon987/server/game/item/ItemIron.java index 4033101..3b27b3a 100644 --- a/Server/src/main/java/net/simon987/server/game/item/ItemIron.java +++ b/Server/src/main/java/net/simon987/server/game/item/ItemIron.java @@ -4,7 +4,7 @@ import org.bson.Document; public class ItemIron extends Item { - public static final int ID = 0x0004; + public static final int ID = 0x0003; @Override public int getId() { diff --git a/Server/src/main/resources/static/js/mar.js b/Server/src/main/resources/static/js/mar.js index db8e881..bda0f9b 100644 --- a/Server/src/main/resources/static/js/mar.js +++ b/Server/src/main/resources/static/js/mar.js @@ -1,7 +1,14 @@ var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({__proto__: []} instanceof Array && function (d, b) { + d.__proto__ = b; + }) || + function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; }