I broke everything pt. 1: Moved helditem into CubotInventory, added debug commands for CubotInventory, Added vault complete GameEvent, moved CPU to Cubot, renamed CpuHardware to HardwareModule, moved HardwareModule to Cubot & added HardwareHost interface, removed getParent() in ControllableUnit, moved items to the Item class, started moving tiles to Tile classes, renamed Programmable to MessageReceiver

This commit is contained in:
Simon
2018-05-31 22:13:07 -04:00
parent ee9eeeef55
commit a7bdbd2513
60 changed files with 858 additions and 295 deletions

View File

@@ -1,5 +1,6 @@
package net.simon987.biomassplugin;
import net.simon987.server.game.item.Item;
import net.simon987.server.game.objects.GameObject;
import net.simon987.server.game.objects.InventoryHolder;
import org.bson.Document;
@@ -13,12 +14,6 @@ public class BiomassBlob extends GameObject implements InventoryHolder {
* Yield of the blob, in biomass units
*/
private int biomassCount;
/**
* Style of the blob (Only visual)
*/
// private int style;
private static final int ITM_BIOMASS = 1;
public BiomassBlob() {
}
@@ -66,31 +61,28 @@ public class BiomassBlob extends GameObject implements InventoryHolder {
/**
* Called when an object attempts to place an item in this BiomassBlob
*
* @param item item id (see MarConstants.ITEM_*)
* @return Always returns false
*/
@Override
public boolean placeItem(int item) {
public boolean placeItem(Item item) {
//Why would you want to place an item in a blob?
return false;
}
@Override
public boolean canTakeItem(int item) {
return item == ITM_BIOMASS && biomassCount >= 1;
public boolean canTakeItem(int itemId) {
return itemId == ItemBiomass.ID && biomassCount >= 1;
}
/**
* Called when an object attempts to take an item from this BiomassBlob.
* If the object requests biomass, it will be subtracted from biomassCount, and
* if it reaches 0, the plant is deleted
*
* @param item item id (see MarConstants.ITEM_*)
*/
@Override
public void takeItem(int item) {
public void takeItem(int itemId) {
if (item == ITM_BIOMASS) {
if (itemId == ItemBiomass.ID) {
if (biomassCount > 1) {
biomassCount--;
} else {
@@ -98,6 +90,5 @@ public class BiomassBlob extends GameObject implements InventoryHolder {
setDead(true);
}
}
}
}

View File

@@ -23,8 +23,8 @@ public class BiomassPlugin extends ServerPlugin {
LogManager.LOGGER.severe("(BiomassPlugin) NPC plugin is not loaded so biomass will not spawn on death of HarvesterNPC");
}
registry.registerGameObject(BiomassBlob.class);
registry.registerItem(ItemBiomass.ID, ItemBiomass.class);
LogManager.LOGGER.info("(BiomassPlugin) Initialised Biomass plugin");
}

View File

@@ -0,0 +1,35 @@
package net.simon987.biomassplugin;
import net.simon987.server.GameServer;
import net.simon987.server.game.item.Item;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.objects.Rechargeable;
import org.bson.Document;
public class ItemBiomass extends Item {
public static final int ID = 0x0001;
private static final int energy = GameServer.INSTANCE.getConfig().getInt("biomassEnergyValue");
@Override
public int getId() {
return ID;
}
public ItemBiomass(Document document) {
super(document);
}
@Override
public void clear(ControllableUnit unit) {
if (unit instanceof Rechargeable) {
((Rechargeable) unit).storeEnergy(energy);
}
}
@Override
public char poll() {
return ID;
}
}