Fixed Portable Teleporter issue, fixed compounded Factory localization, add upgrades support to Solar Neutron Activator

This commit is contained in:
aidancbrady 2016-07-16 12:16:55 -04:00
parent ca52ba521b
commit 88ead85f0e
5 changed files with 75 additions and 47 deletions

View file

@ -12,6 +12,7 @@ import mekanism.client.gui.element.GuiSecurityTab;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.common.inventory.container.ContainerSolarNeutronActivator; import mekanism.common.inventory.container.ContainerSolarNeutronActivator;
import mekanism.common.tile.TileEntitySolarNeutronActivator; import mekanism.common.tile.TileEntitySolarNeutronActivator;
import mekanism.common.util.LangUtils; import mekanism.common.util.LangUtils;
@ -36,6 +37,7 @@ public class GuiSolarNeutronActivator extends GuiMekanism
guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 4, 55).with(SlotOverlay.MINUS)); guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 4, 55).with(SlotOverlay.MINUS));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 154, 55).with(SlotOverlay.PLUS)); guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 154, 55).with(SlotOverlay.PLUS));

View file

@ -101,31 +101,34 @@ public class PacketPortableTeleporter implements IMessageHandler<PortableTelepor
Coord4D coords = found.getClosestCoords(new Coord4D(player)); Coord4D coords = found.getClosestCoords(new Coord4D(player));
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId); if(coords != null)
TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
if(teleporter != null)
{ {
try { World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId);
teleporter.didTeleport.add(player.getPersistentID()); TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
teleporter.teleDelay = 5;
if(teleporter != null)
item.setEnergy(itemstack, item.getEnergy(itemstack) - item.calculateEnergyCost(player, coords)); {
try {
if(player instanceof EntityPlayerMP) teleporter.didTeleport.add(player.getPersistentID());
{ teleporter.teleDelay = 5;
MekanismUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
} item.setEnergy(itemstack, item.getEnergy(itemstack) - item.calculateEnergyCost(player, coords));
player.closeScreen(); if(player instanceof EntityPlayerMP)
{
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(new Coord4D(player)), coords.getTargetPoint(40D)); MekanismUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
TileEntityTeleporter.teleportPlayerTo((EntityPlayerMP)player, coords, teleporter); }
TileEntityTeleporter.alignPlayer((EntityPlayerMP)player, coords);
player.closeScreen();
world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F);
Mekanism.packetHandler.sendToReceivers(new PortalFXMessage(coords), new Range4D(coords)); Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(new Coord4D(player)), coords.getTargetPoint(40D));
} catch(Exception e) {} TileEntityTeleporter.teleportPlayerTo((EntityPlayerMP)player, coords, teleporter);
TileEntityTeleporter.alignPlayer((EntityPlayerMP)player, coords);
world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F);
Mekanism.packetHandler.sendToReceivers(new PortalFXMessage(coords), new Range4D(coords));
} catch(Exception e) {}
}
} }
break; break;

View file

@ -28,11 +28,11 @@ public class SolarNeutronRecipe extends MachineRecipe<GasInput, GasOutput, Solar
return getInput().useGas(inputTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1); return getInput().useGas(inputTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1);
} }
public void operate(GasTank inputTank, GasTank outputTank) public void operate(GasTank inputTank, GasTank outputTank, int scale)
{ {
if(getInput().useGas(inputTank, true, 1)) if(getInput().useGas(inputTank, true, scale))
{ {
getOutput().applyOutputs(outputTank, true, 1); getOutput().applyOutputs(outputTank, true, scale);
} }
} }
} }

View file

@ -54,11 +54,13 @@ import mekanism.common.tile.component.TileComponentSecurity;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StatUtils; import mekanism.common.util.StatUtils;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -923,6 +925,11 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
@Override @Override
public String getInventoryName() public String getInventoryName()
{ {
if(StatCollector.canTranslate("tile." + tier.getBaseTier().getName() + recipeType.getUnlocalizedName() + "Factory"))
{
return LangUtils.localize("tile." + tier.getBaseTier().getName() + recipeType.getUnlocalizedName() + "Factory");
}
return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getInventoryName(); return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getInventoryName();
} }

View file

@ -3,6 +3,7 @@ package mekanism.common.tile;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.Range4D; import mekanism.api.Range4D;
@ -14,17 +15,21 @@ import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection; import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.Upgrade;
import mekanism.common.Upgrade.IUpgradeInfoHandler;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.base.IBoundingBlock; import mekanism.common.base.IBoundingBlock;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISustainedData; import mekanism.common.base.ISustainedData;
import mekanism.common.base.ITankManager; import mekanism.common.base.ITankManager;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.machines.SolarNeutronRecipe; import mekanism.common.recipe.machines.SolarNeutronRecipe;
import mekanism.common.security.ISecurityTile; import mekanism.common.security.ISecurityTile;
import mekanism.common.tile.component.TileComponentSecurity; import mekanism.common.tile.component.TileComponentSecurity;
import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -35,13 +40,12 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, ITubeConnection, IActiveState, ISustainedData, ITankManager, ISecurityTile public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, ITubeConnection, IActiveState, ISustainedData, ITankManager, ISecurityTile, IUpgradeTile, IUpgradeInfoHandler
{ {
public GasTank inputTank = new GasTank(MAX_GAS); public GasTank inputTank = new GasTank(MAX_GAS);
public GasTank outputTank = new GasTank(MAX_GAS); public GasTank outputTank = new GasTank(MAX_GAS);
public static final int MAX_GAS = 10000; public static final int MAX_GAS = 10000;
public static final int TICKS_REQUIRED = 5;
public int updateDelay; public int updateDelay;
@ -51,19 +55,19 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
public int gasOutput = 256; public int gasOutput = 256;
public int recipeTicks = 0;
public SolarNeutronRecipe cachedRecipe; public SolarNeutronRecipe cachedRecipe;
/** This machine's current RedstoneControl type. */ /** This machine's current RedstoneControl type. */
public RedstoneControl controlType = RedstoneControl.DISABLED; public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3);
public TileComponentSecurity securityComponent = new TileComponentSecurity(this); public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
public TileEntitySolarNeutronActivator() public TileEntitySolarNeutronActivator()
{ {
super("SolarNeutronActivator"); super("SolarNeutronActivator");
inventory = new ItemStack[3]; upgradeComponent.setSupported(Upgrade.ENERGY, false);
inventory = new ItemStack[4];
} }
@Override @Override
@ -110,18 +114,10 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{ {
setActive(true); setActive(true);
if(recipeTicks == TICKS_REQUIRED) int operations = operate(recipe);
{
operate(recipe);
recipeTicks = 0;
}
else {
recipeTicks++;
}
} }
else { else {
setActive(false); setActive(false);
recipeTicks = 0;
} }
if(outputTank.getGas() != null) if(outputTank.getGas() != null)
@ -141,6 +137,14 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
} }
} }
public int getUpgradedUsage()
{
int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED));
possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess);
return possibleProcess;
}
public boolean isDesert() public boolean isDesert()
{ {
return worldObj.provider.getBiomeGenForCoords(xCoord >> 4, zCoord >> 4) instanceof BiomeGenDesert; return worldObj.provider.getBiomeGenForCoords(xCoord >> 4, zCoord >> 4) instanceof BiomeGenDesert;
@ -168,9 +172,13 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
return recipe != null && recipe.canOperate(inputTank, outputTank); return recipe != null && recipe.canOperate(inputTank, outputTank);
} }
public void operate(SolarNeutronRecipe recipe) public int operate(SolarNeutronRecipe recipe)
{ {
recipe.operate(inputTank, outputTank); int operations = getUpgradedUsage();
recipe.operate(inputTank, outputTank, operations);
return operations;
} }
@Override @Override
@ -181,7 +189,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
if(worldObj.isRemote) if(worldObj.isRemote)
{ {
isActive = dataStream.readBoolean(); isActive = dataStream.readBoolean();
recipeTicks = dataStream.readInt();
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
if(dataStream.readBoolean()) if(dataStream.readBoolean())
@ -210,7 +217,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
super.getNetworkedData(data); super.getNetworkedData(data);
data.add(isActive); data.add(isActive);
data.add(recipeTicks);
data.add(controlType.ordinal()); data.add(controlType.ordinal());
if(inputTank.getGas() != null) if(inputTank.getGas() != null)
@ -242,7 +248,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
super.readFromNBT(nbtTags); super.readFromNBT(nbtTags);
isActive = nbtTags.getBoolean("isActive"); isActive = nbtTags.getBoolean("isActive");
recipeTicks = nbtTags.getInteger("recipeTicks");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
inputTank.read(nbtTags.getCompoundTag("inputTank")); inputTank.read(nbtTags.getCompoundTag("inputTank"));
@ -255,7 +260,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
super.writeToNBT(nbtTags); super.writeToNBT(nbtTags);
nbtTags.setBoolean("isActive", isActive); nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("recipeTicks", recipeTicks);
nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound())); nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound()));
@ -417,6 +421,18 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
return securityComponent; return securityComponent;
} }
@Override
public TileComponentUpgrade getComponent()
{
return upgradeComponent;
}
@Override
public List<String> getInfo(Upgrade upgrade)
{
return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() public AxisAlignedBB getRenderBoundingBox()