Compare commits

...
16 Commits
8 changed files with 140 additions and 35 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.4.6:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.7:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.7.38-GTNH:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.7.40-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.6.20:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.42:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
@@ -74,7 +74,6 @@ public final class Config {
public static final Section sectionMobConfig = new Section("Mob Config", "mobconfig");
public static final Section sectionRailConfig = new Section("Rail", "railconfig");
public static final Section sectionEnchantments = new Section("Enchantments", "enchantments");
public static final Section sectionWeather = new Section("Weather", "weather");
public static final Section sectionTelepad = new Section("Telepad", "telepad");
public static final Section sectionInventoryPanel = new Section("InventoryPanel", "inventorypanel");
public static final Section sectionMisc = new Section("Misc", "misc");
@@ -544,10 +543,6 @@ public final class Config {
public static boolean spawnGuardStopAllSlimesDebug = false;
public static boolean spawnGuardStopAllSquidSpawning = false;
public static int weatherObeliskClearFluid = 2000;
public static int weatherObeliskRainFluid = 500;
public static int weatherObeliskThunderFluid = 1000;
// Loot Defaults
public static boolean lootDarkSteel = true;
public static boolean lootItemConduitProbe = true;
@@ -2746,22 +2741,6 @@ public final class Config {
spawnGuardStopAllSquidSpawning,
"When true no squid will be spawned.");
weatherObeliskClearFluid = config.get(
sectionWeather.name,
"weatherObeliskClearFluid",
weatherObeliskClearFluid,
"The fluid required (in mB) to set the world to clear weather").getInt();
weatherObeliskRainFluid = config.get(
sectionWeather.name,
"weatherObeliskRainFluid",
weatherObeliskRainFluid,
"The fluid required (in mB) to set the world to rainy weather").getInt();
weatherObeliskThunderFluid = config.get(
sectionWeather.name,
"weatherObeliskThunderFluid",
weatherObeliskThunderFluid,
"The fluid required (in mB) to set the world to thundering weather").getInt();
// Loot Config
lootDarkSteel = config.getBoolean(
"lootDarkSteel",
@@ -31,6 +31,11 @@ public class BlockWeatherObelisk extends BlockObeliskAbstract<TileWeatherObelisk
Side.CLIENT);
PacketHandler.INSTANCE
.registerMessage(PacketWeatherTank.class, PacketWeatherTank.class, PacketHandler.nextID(), Side.CLIENT);
PacketHandler.INSTANCE.registerMessage(
PacketControlModeWeather.class,
PacketControlModeWeather.class,
PacketHandler.nextID(),
Side.SERVER);
EntityRegistry
.registerModEntity(EntityWeatherRocket.class, "weather_rocket", 33, EnderIO.instance, 64, 3, false);
@@ -11,6 +11,7 @@ import net.minecraftforge.fluids.FluidTank;
import org.lwjgl.opengl.GL11;
import com.enderio.core.client.gui.button.IconButton;
import com.enderio.core.client.gui.button.ToggleButton;
import com.enderio.core.client.gui.widget.GuiToolTip;
import com.enderio.core.client.render.RenderUtil;
@@ -24,6 +25,7 @@ import crazypants.enderio.network.PacketHandler;
public class GuiWeatherObelisk extends GuiPoweredMachineBase<TileWeatherObelisk> {
private IconButton buttonStart;
private ToggleButton buttonMode;
public GuiWeatherObelisk(InventoryPlayer inventory, TileWeatherObelisk tileEntity) {
super(tileEntity, new ContainerWeatherObelisk(inventory, tileEntity), "weatherObelisk");
@@ -50,10 +52,23 @@ public class GuiWeatherObelisk extends GuiPoweredMachineBase<TileWeatherObelisk>
public void initGui() {
super.initGui();
int x = (xSize / 2) - (BUTTON_SIZE / 2);
int x_mode = xSize - 5 - BUTTON_SIZE;
int x_start = (xSize / 2) - (BUTTON_SIZE / 2);
int y = 58;
addButton(buttonStart = new IconButton(this, 0, x, y, IconEIO.TICK));
buttonMode = new ToggleButton(this, 1, x_mode, y, IconEIO.ROUND_ROBIN_OFF, IconEIO.REDSTONE_MODE_WITH_SIGNAL);
buttonMode.setToolTip(EnderIO.lang.localize("gui.machine.weather.control"));
buttonMode.setSelectedToolTip(EnderIO.lang.localize("gui.machine.weather.redstone"));
buttonMode.setUnselectedToolTip(EnderIO.lang.localize("gui.machine.weather.manual"));
buttonMode.setSelected(getTileEntity().getLaunchOnRedstone());
addButton(buttonMode);
buttonMode.onGuiInit();
buttonStart = new IconButton(this, 0, x_start, y, IconEIO.TICK);
buttonStart.setToolTip(EnderIO.lang.localize("gui.machine.weather.run"));
addButton(buttonStart);
buttonStart.onGuiInit();
refreshButtons();
@@ -68,6 +83,9 @@ public class GuiWeatherObelisk extends GuiPoweredMachineBase<TileWeatherObelisk>
}
private void refreshButtons() {
boolean pulseControl = getTileEntity().getLaunchOnRedstone();
pulseControlAction(pulseControl);
FluidStack fs = getTileEntity().getInputTank().getFluid();
if (fs == null) {
buttonStart.enabled = false;
@@ -143,9 +161,22 @@ public class GuiWeatherObelisk extends GuiPoweredMachineBase<TileWeatherObelisk>
@Override
protected void actionPerformed(GuiButton b) {
super.actionPerformed(b);
if (b.id >= 0 && b.id <= 2) {
if (b.id == 0) {
// Start Button
getTileEntity().startTask();
PacketHandler.INSTANCE.sendToServer(new PacketActivateWeather(getTileEntity()));
PacketHandler.INSTANCE.sendToServer(new PacketActivateWeather(getTileEntity(), true));
} else if (b.id == 1) {
// Control Mode Button
boolean pulseControl = buttonMode.isSelected();
getTileEntity().setLaunchOnRedstone(pulseControl);
pulseControlAction(pulseControl);
PacketControlModeWeather packet = new PacketControlModeWeather(getTileEntity());
PacketHandler.INSTANCE.sendToServer(packet);
}
}
protected void pulseControlAction(boolean pulseControl) {
redstoneButton.setVisible(!pulseControl);
buttonStart.setVisible(!pulseControl);
}
}
@@ -7,14 +7,30 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.EnderIO;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketActivateWeather extends MessageTileEntity<TileWeatherObelisk>
implements IMessageHandler<PacketActivateWeather, IMessage> {
private boolean start;
public PacketActivateWeather() {}
public PacketActivateWeather(TileWeatherObelisk te) {
public PacketActivateWeather(TileWeatherObelisk te, boolean start) {
super(te);
this.start = start;
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeBoolean(start);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
start = buf.readBoolean();
}
@Override
@@ -24,6 +40,8 @@ public class PacketActivateWeather extends MessageTileEntity<TileWeatherObelisk>
if (te != null) {
if (ctx.side.isServer()) {
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
}
if (message.start) {
te.startTask();
} else {
te.stopTask();
@@ -0,0 +1,44 @@
package crazypants.enderio.machine.obelisk.weather;
import com.enderio.core.common.network.MessageTileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketControlModeWeather extends MessageTileEntity<TileWeatherObelisk>
implements IMessageHandler<PacketControlModeWeather, IMessage> {
private boolean pulse;
public PacketControlModeWeather() {}
public PacketControlModeWeather(TileWeatherObelisk te) {
super(te);
this.pulse = te.getLaunchOnRedstone();
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeBoolean(pulse);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
pulse = buf.readBoolean();
}
@Override
public IMessage onMessage(PacketControlModeWeather message, MessageContext ctx) {
TileWeatherObelisk te = message.getTileEntity(message.getWorld(ctx));
if (te != null) {
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
te.setLaunchOnRedstone(message.pulse);
}
return null;
}
}
@@ -24,6 +24,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractPowerConsumerEntity;
import crazypants.enderio.machine.RedstoneControlMode;
import crazypants.enderio.machine.SlotDefinition;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.power.Capacitors;
@@ -100,6 +101,9 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
private boolean canBeActive = true;
private boolean tanksDirty;
private boolean launchOnRedstone = false;
private int cooldown = 0;
private static final ICapacitor cap = Capacitors.BASIC_CAPACITOR.capacitor;
private FluidTank inputTank = new FluidTank(8000);
@@ -230,7 +234,13 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
protected boolean processTasks(boolean redstoneCheckPassed) {
boolean res = false;
if (!redstoneCheckPassed) {
if (cooldown > 0) {
cooldown--;
res = true;
return res;
}
if (!redstoneCheckPassed && !launchOnRedstone) {
if (canBeActive) {
canBeActive = false;
res = true;
@@ -254,9 +264,13 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
EntityWeatherRocket e = new EntityWeatherRocket(worldObj, activeTask);
e.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
worldObj.spawnEntityInWorld(e);
cooldown = 200;
stopTask();
res = true;
}
} else if (launchOnRedstone && RedstoneControlMode.isConditionMet(RedstoneControlMode.ON, this)) {
startTask();
res = true;
}
}
@@ -280,20 +294,19 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
&& inputTank.getFluidAmount() >= 1000;
}
/**
* @return If the operation was successful.
*/
public boolean startTask() {
public void startTask() {
if (getActiveTask() == null && inputTank.getFluidAmount() > 0) {
fluidUsed = 0;
WeatherTask task = WeatherTask.fromFluid(inputTank.getFluid().getFluid());
if (canStartTask(task)) {
if (!worldObj.isRemote) {
PacketHandler.INSTANCE
.sendToDimension(new PacketActivateWeather(this, true), worldObj.provider.dimensionId);
}
decrStackSize(0, 1);
activeTask = task;
return true;
}
}
return false;
}
public void stopTask() {
@@ -301,7 +314,8 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
activeTask = null;
fluidUsed = 0;
if (!worldObj.isRemote) {
PacketHandler.INSTANCE.sendToDimension(new PacketActivateWeather(this), worldObj.provider.dimensionId);
PacketHandler.INSTANCE
.sendToDimension(new PacketActivateWeather(this, false), worldObj.provider.dimensionId);
} else {
playedFuse = false;
}
@@ -312,12 +326,14 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
public void writeCommon(NBTTagCompound nbtRoot) {
super.writeCommon(nbtRoot);
nbtRoot.setTag("tank", inputTank.writeToNBT(new NBTTagCompound()));
nbtRoot.setBoolean("weatherobeliskcontrolmode", launchOnRedstone);
}
@Override
public void readCommon(NBTTagCompound nbtRoot) {
super.readCommon(nbtRoot);
inputTank.readFromNBT(nbtRoot.getCompoundTag("tank"));
launchOnRedstone = nbtRoot.getBoolean("weatherobeliskcontrolmode");
}
private boolean isValidFluid(Fluid f) {
@@ -382,4 +398,12 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[] { inputTank.getInfo() };
}
public void setLaunchOnRedstone(boolean launchOnRedstone) {
this.launchOnRedstone = launchOnRedstone;
}
public boolean getLaunchOnRedstone() {
return this.launchOnRedstone;
}
}
@@ -1101,6 +1101,10 @@ enderio.gui.machine.side.west=West
enderio.gui.machine.side.east=East
enderio.gui.machine.side.up=Up
enderio.gui.machine.side.down=Down
enderio.gui.machine.weather.control=Control Mode
enderio.gui.machine.weather.redstone=Launch on Redstone
enderio.gui.machine.weather.manual=Default Control Mode
enderio.gui.machine.weather.run=Launch
#Power Monitor