mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 23:13:21 +00:00
- Added 'Capture Mode' to powered spawners to allow automated filling of Soul Vials
- Increased max stack size for Soul Vials and Broken Spawners to 64
This commit is contained in:
1 parent
44e3252757
commit
9418e6fe77
9 files changed
+260
-55
No files matched your search
@@ -44,7 +44,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
|
||||
protected ItemSoulVessel() {
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName(ModObject.itemSoulVessel.unlocalisedName);
|
||||
setMaxStackSize(1);
|
||||
setMaxStackSize(64);
|
||||
blackList = new ArrayList<String>();
|
||||
for (String ent : Config.soulVesselBlackList) {
|
||||
blackList.add(ent);
|
||||
@@ -156,9 +156,12 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
|
||||
if(entity instanceof EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
if(item.stackSize > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String entityId = EntityList.getEntityString(entity);
|
||||
// System.out.println("ItemSoulVessel.itemInteractionForEntity: " + entityId);
|
||||
// System.out.println("ItemSoulVessel.itemInteractionForEntity: " + entityId);
|
||||
if(isBlackListed(entityId)) {
|
||||
return false;
|
||||
}
|
||||
@@ -185,6 +188,18 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack createVesselWithEntity(Entity ent) {
|
||||
|
||||
String entityId = EntityList.getEntityString(ent);
|
||||
NBTTagCompound root = new NBTTagCompound();
|
||||
root.setString("id", entityId);
|
||||
ent.writeToNBT(root);
|
||||
|
||||
ItemStack res = new ItemStack(this);
|
||||
res.stackTagCompound = root;
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean containsSoul(ItemStack item) {
|
||||
if(item == null) {
|
||||
return false;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockMobSpawner;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,6 +23,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
@@ -30,6 +33,7 @@ import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.waila.IWailaInfoProvider;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.Util;
|
||||
@@ -67,6 +71,8 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
public static BlockPoweredSpawner create() {
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPoweredSpawner.unlocalisedName, new DummyRecipe());
|
||||
|
||||
PacketHandler.INSTANCE.registerMessage(PacketMode.class, PacketMode.class, PacketHandler.nextID(), Side.SERVER);
|
||||
|
||||
//Ensure costs are loaded at startup
|
||||
PoweredSpawnerConfig.getInstance();
|
||||
|
||||
@@ -232,6 +238,22 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
return IWailaInfoProvider.BIT_DETAILED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
super.getSubBlocks(item, tab, list);
|
||||
list.add(createItemStackForMob("Enderman"));
|
||||
list.add(createItemStackForMob("Chicken"));
|
||||
}
|
||||
|
||||
protected ItemStack createItemStackForMob(String mob) {
|
||||
ItemStack stack = new ItemStack(this);
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setBoolean("eio.abstractMachine", true);
|
||||
writeMobTypeToNBT(stack.stackTagCompound, mob);
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static class DropInfo {
|
||||
|
||||
BlockEvent.BreakEvent evt;
|
||||
@@ -240,7 +262,7 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
DropInfo(BreakEvent evt, ItemStack stack) {
|
||||
super();
|
||||
this.evt = evt;
|
||||
this.drop = stack;
|
||||
drop = stack;
|
||||
}
|
||||
|
||||
void doDrop() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package crazypants.enderio.machine.spawner;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
|
||||
@@ -12,6 +14,18 @@ public class ContainerPoweredSpawner extends AbstractMachineContainer {
|
||||
|
||||
@Override
|
||||
protected void addMachineSlots(InventoryPlayer playerInv) {
|
||||
addSlotToContainer(new Slot(tileEntity, 0, 54, 42) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(0, itemStack);
|
||||
}
|
||||
});
|
||||
addSlotToContainer(new Slot(tileEntity, 1, 105, 42) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,51 @@
|
||||
package crazypants.enderio.machine.spawner;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.gui.IconButtonEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class GuiPoweredSpawner extends GuiMachineBase {
|
||||
|
||||
private IconButtonEIO modeB;
|
||||
|
||||
private TilePoweredSpawner spawner;
|
||||
|
||||
public GuiPoweredSpawner(InventoryPlayer par1InventoryPlayer, TilePoweredSpawner te) {
|
||||
super(te, new ContainerPoweredSpawner(par1InventoryPlayer, te));
|
||||
|
||||
spawner = te;
|
||||
|
||||
modeB = new IconButtonEIO(this, 8888, 115, 10, IconEIO.RIGHT_ARROW);
|
||||
modeB.setSize(10, 16);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
modeB.onGuiInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton == modeB) {
|
||||
spawner.setSpawnMode(!spawner.isSpawnMode());
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketMode(spawner));
|
||||
} else {
|
||||
super.actionPerformed(par1GuiButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
@@ -20,13 +53,43 @@ public class GuiPoweredSpawner extends GuiMachineBase {
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, xSize, ySize);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
int left = getGuiLeft();
|
||||
int top = getGuiTop();
|
||||
|
||||
String txt = "Spawn";
|
||||
if(!spawner.isSpawnMode()) {
|
||||
txt = "Capture";
|
||||
}
|
||||
FontRenderer fr = getFontRenderer();
|
||||
int x = left + xSize / 2 - fr.getStringWidth(txt) / 2;
|
||||
int y = top + fr.FONT_HEIGHT + 6;
|
||||
fr.drawStringWithShadow(txt, x, y, ColorUtil.getRGB(Color.WHITE));
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/poweredSpawner.png");
|
||||
|
||||
if(spawner.isSpawnMode()) {
|
||||
int yOff = 34;
|
||||
drawTexturedModalRect(left + 80, top + yOff, 207, 0, 17, 15);
|
||||
if(spawner.getProgress() < 1 && spawner.getProgress() > 0) {
|
||||
int scaled = spawner.getProgressScaled(14) + 1;
|
||||
drawTexturedModalRect(left + 81, top + yOff + 14 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
}
|
||||
} else {
|
||||
drawTexturedModalRect(left + 52, top + 40, 52, 170, 72, 21);
|
||||
if(spawner.getProgress() < 1 && spawner.getProgress() > 0) {
|
||||
int scaled = spawner.getProgressScaled(24);
|
||||
drawTexturedModalRect(left + 76, top + 43, 176, 14, scaled + 1, 16);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showRecipeButton() {
|
||||
protected boolean showRecipeButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ public class ItemBrokenSpawner extends Item {
|
||||
"Zombie",
|
||||
"Spider",
|
||||
"CaveSpider",
|
||||
"Blaze"
|
||||
"Blaze",
|
||||
"Enderman",
|
||||
"Chicken"
|
||||
};
|
||||
|
||||
public static String getMobTypeFromStack(ItemStack stack) {
|
||||
@@ -57,7 +59,7 @@ public class ItemBrokenSpawner extends Item {
|
||||
setUnlocalizedName(ModObject.itemBrokenSpawner.unlocalisedName);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setMaxStackSize(1);
|
||||
setMaxStackSize(64);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package crazypants.enderio.machine.spawner;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketMode implements IMessage, IMessageHandler<PacketMode, IMessage> {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
private boolean isSpawnMode;
|
||||
|
||||
public PacketMode() {
|
||||
|
||||
}
|
||||
|
||||
public PacketMode(TilePoweredSpawner tile) {
|
||||
x = tile.xCoord;
|
||||
y = tile.yCoord;
|
||||
z = tile.zCoord;
|
||||
isSpawnMode = tile.isSpawnMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeBoolean(isSpawnMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
isSpawnMode = buf.readBoolean();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketMode message, MessageContext ctx) {
|
||||
TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
if(te instanceof TilePoweredSpawner) {
|
||||
TilePoweredSpawner me = (TilePoweredSpawner) te;
|
||||
me.setSpawnMode(message.isSpawnMode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
package crazypants.enderio.machine.spawner;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
@@ -23,7 +19,6 @@ import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
|
||||
@@ -44,44 +39,70 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
public static final int MIN_PLAYER_DISTANCE = Config.poweredSpawnerMaxPlayerDistance;
|
||||
public static final boolean USE_VANILLA_SPAWN_CHECKS = Config.poweredSpawnerUseVanillaSpawChecks;
|
||||
|
||||
private final MobSpawnerBaseLogic logic = new SpawnerLogic();
|
||||
private final SpawnerLogic logic = new SpawnerLogic();
|
||||
|
||||
private static final String NULL_ENTITY_NAME = "None";
|
||||
|
||||
|
||||
private ICapacitor capacitor;
|
||||
|
||||
private boolean isSpawnMode = true;
|
||||
|
||||
public TilePoweredSpawner() {
|
||||
super(new SlotDefinition(0, 0));
|
||||
super(new SlotDefinition(1, 1, 1));
|
||||
logic.setEntityName(NULL_ENTITY_NAME);
|
||||
capacitor = CAP_ONE;
|
||||
}
|
||||
|
||||
public boolean isSpawnMode() {
|
||||
return isSpawnMode;
|
||||
}
|
||||
|
||||
public void setSpawnMode(boolean isSpawnMode) {
|
||||
if(isSpawnMode != this.isSpawnMode) {
|
||||
currentTask = null;
|
||||
}
|
||||
this.isSpawnMode = isSpawnMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void taskComplete() {
|
||||
super.taskComplete();
|
||||
logic.spawnDelay = 0;
|
||||
if(isSpawnMode) {
|
||||
logic.spawnDelay = 0;
|
||||
} else {
|
||||
if(getStackInSlot(0) == null || getStackInSlot(1) != null) {
|
||||
return;
|
||||
}
|
||||
Entity ent = logic.createEntity();
|
||||
if(ent == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack res = EnderIO.itemSoulVessel.createVesselWithEntity(ent);
|
||||
decrStackSize(0, 1);
|
||||
setInventorySlotContents(1, res);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapacitor(Capacitors capacitorType) {
|
||||
this.capacitorType = capacitorType;
|
||||
this.capacitorType = capacitorType;
|
||||
ICapacitor refCap;
|
||||
switch (capacitorType) {
|
||||
case BASIC_CAPACITOR:
|
||||
refCap = CAP_ONE;
|
||||
refCap = CAP_ONE;
|
||||
break;
|
||||
case ACTIVATED_CAPACITOR:
|
||||
refCap = CAP_TWO;
|
||||
refCap = CAP_TWO;
|
||||
break;
|
||||
case ENDER_CAPACITOR:
|
||||
refCap = CAP_THREE;
|
||||
refCap = CAP_THREE;
|
||||
break;
|
||||
default:
|
||||
refCap = CAP_ONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
double multuplier = PoweredSpawnerConfig.getInstance().getCostMultiplierFor(logic.getEntityNameToSpawn());
|
||||
capacitor = new BasicCapacitor((int)(refCap.getMaxEnergyExtracted() * multuplier), refCap.getMaxEnergyStored());
|
||||
capacitor = new BasicCapacitor((int) (refCap.getMaxEnergyExtracted() * multuplier), refCap.getMaxEnergyStored());
|
||||
forceClientUpdate = true;
|
||||
}
|
||||
|
||||
@@ -97,13 +118,25 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
|
||||
@Override
|
||||
protected boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
|
||||
if(itemstack == null || isSpawnMode) {
|
||||
return false;
|
||||
}
|
||||
if(slotDefinition.isInputSlot(i)) {
|
||||
return itemstack.getItem() == EnderIO.itemSoulVessel && !EnderIO.itemSoulVessel.containsSoul(itemstack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMachineRecipe canStartNextTask(float chance) {
|
||||
if(logic.getEntityNameToSpawn() == null || logic.getEntityNameToSpawn().equals(NULL_ENTITY_NAME)) {
|
||||
return null;
|
||||
if(isSpawnMode) {
|
||||
if(logic.getEntityNameToSpawn() == null || logic.getEntityNameToSpawn().equals(NULL_ENTITY_NAME)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if(getStackInSlot(0) == null || getStackInSlot(1) != null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new DummyRecipe();
|
||||
}
|
||||
@@ -117,11 +150,11 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
public int getPowerUsePerTick() {
|
||||
double multuplier = PoweredSpawnerConfig.getInstance().getCostMultiplierFor(logic.getEntityNameToSpawn());
|
||||
if(capacitorType.ordinal() == 0) {
|
||||
return (int)Math.round(POWER_PER_TICK_ONE * multuplier);
|
||||
return (int) Math.round(POWER_PER_TICK_ONE * multuplier);
|
||||
} else if(capacitorType.ordinal() == 1) {
|
||||
return (int)Math.round(POWER_PER_TICK_TWO * multuplier);
|
||||
return (int) Math.round(POWER_PER_TICK_TWO * multuplier);
|
||||
}
|
||||
return (int)Math.round(POWER_PER_TICK_THREE * multuplier);
|
||||
return (int) Math.round(POWER_PER_TICK_THREE * multuplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,13 +171,13 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
logic.readFromNBT(nbtRoot);
|
||||
super.readCustomNBT(nbtRoot);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
logic.writeToNBT(nbtRoot);
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
|
||||
}
|
||||
|
||||
@@ -156,17 +189,24 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
mobType = NULL_ENTITY_NAME;
|
||||
}
|
||||
logic.setEntityName(mobType);
|
||||
super.readCommon(nbtRoot);
|
||||
logic.resetTimer();
|
||||
if(!nbtRoot.hasKey("isSpawnMode")) {
|
||||
isSpawnMode = true;
|
||||
} else {
|
||||
isSpawnMode = nbtRoot.getBoolean("isSpawnMode");
|
||||
}
|
||||
super.readCommon(nbtRoot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
String mobType = logic.getEntityNameToSpawn();
|
||||
if(mobType == null || mobType.equals(NULL_ENTITY_NAME)) {
|
||||
BlockPoweredSpawner.writeMobTypeToNBT(nbtRoot, null);
|
||||
} else {
|
||||
BlockPoweredSpawner.writeMobTypeToNBT(nbtRoot, mobType);
|
||||
}
|
||||
nbtRoot.setBoolean("isSpawnMode", isSpawnMode);
|
||||
super.writeCommon(nbtRoot);
|
||||
}
|
||||
|
||||
@@ -189,14 +229,19 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
protected IPoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
|
||||
PoweredTask res = new PoweredTask(nextRecipe, chance, getRecipeInputs());
|
||||
|
||||
int ticksDelay = TilePoweredSpawner.MIN_SPAWN_DELAY_BASE
|
||||
+ (int) Math.round((TilePoweredSpawner.MAX_SPAWN_DELAY_BASE - TilePoweredSpawner.MIN_SPAWN_DELAY_BASE) * Math.random());
|
||||
int ticksDelay;
|
||||
if(isSpawnMode) {
|
||||
ticksDelay = TilePoweredSpawner.MIN_SPAWN_DELAY_BASE
|
||||
+ (int) Math.round((TilePoweredSpawner.MAX_SPAWN_DELAY_BASE - TilePoweredSpawner.MIN_SPAWN_DELAY_BASE) * Math.random());
|
||||
} else {
|
||||
ticksDelay = TilePoweredSpawner.MAX_SPAWN_DELAY_BASE - ((TilePoweredSpawner.MAX_SPAWN_DELAY_BASE - TilePoweredSpawner.MIN_SPAWN_DELAY_BASE) / 2);
|
||||
}
|
||||
if(capacitorType.ordinal() == 1) {
|
||||
ticksDelay /= 2;
|
||||
} else if(capacitorType.ordinal() == 2) {
|
||||
ticksDelay /= 4;
|
||||
}
|
||||
int powerPerTick = (int) getPowerUsePerTick();
|
||||
int powerPerTick = getPowerUsePerTick();
|
||||
res.setRequiredEnergy(powerPerTick * ticksDelay);
|
||||
return res;
|
||||
}
|
||||
@@ -210,7 +255,7 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
return spaceClear;
|
||||
}
|
||||
|
||||
|
||||
public String getEntityName() {
|
||||
return logic.getEntityNameToSpawn();
|
||||
}
|
||||
@@ -284,28 +329,18 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
if(spawnDelay > 0)
|
||||
{
|
||||
--spawnDelay;
|
||||
}
|
||||
|
||||
field_98284_d = field_98287_c;
|
||||
field_98287_c = (field_98287_c + 1000.0F / (spawnDelay + 200.0F)) % 360.0D;
|
||||
} else {
|
||||
|
||||
if(spawnDelay == -1) {
|
||||
resetTimer();
|
||||
}
|
||||
if(spawnDelay > 0) {
|
||||
--spawnDelay;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean doTimerReset = false;
|
||||
resetTimer();
|
||||
|
||||
for (int i = 0; i < spawnCount; ++i) {
|
||||
|
||||
Entity entity = EntityList.createEntityByName(getEntityNameToSpawn(), getSpawnerWorld());
|
||||
Entity entity = createEntity();
|
||||
if(entity == null) {
|
||||
return;
|
||||
}
|
||||
@@ -334,18 +369,16 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
{
|
||||
entityliving.spawnExplosionParticle();
|
||||
}
|
||||
|
||||
doTimerReset = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(doTimerReset) {
|
||||
resetTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Entity createEntity() {
|
||||
return EntityList.createEntityByName(getEntityNameToSpawn(), getSpawnerWorld());
|
||||
}
|
||||
|
||||
void resetTimer() {
|
||||
spawnDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user