mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-24 05:54:27 +00:00
Merge branch 'master' into endercore
Conflicts: src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java src/main/java/crazypants/enderio/config/Config.java src/main/java/crazypants/enderio/item/darksteel/PacketUpgradeState.java src/main/java/crazypants/enderio/item/darksteel/upgrade/SolarUpgrade.java src/main/java/crazypants/enderio/machine/PacketProgress.java src/main/java/crazypants/enderio/machine/generator/zombie/TileZombieGenerator.java src/main/java/crazypants/enderio/machine/invpanel/GuiInventoryPanel.java src/main/java/crazypants/enderio/machine/invpanel/TileInventoryPanel.java src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java src/main/java/crazypants/enderio/machine/reservoir/TileReservoir.java src/main/java/crazypants/enderio/machine/tank/TankFluidRenderer.java src/main/java/crazypants/enderio/machine/tank/TileTank.java src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java src/main/java/crazypants/enderio/teleport/telepad/TelePadRenderer.java src/main/java/crazypants/enderio/teleport/telepad/TileTelePad.java src/main/java/crazypants/gui/GuiContainerBase.java src/main/java/crazypants/util/BlockCoord.java
This commit is contained in:
commit
6324c7ee69
61 files changed
+1006
-512
No files matched your search
@@ -198,7 +198,7 @@ public class EnderIO {
|
||||
//Teleporting
|
||||
public static BlockTravelAnchor blockTravelPlatform;
|
||||
public static BlockTelePad blockTelePad;
|
||||
public static ItemCoordSelector itemCoordsCard;
|
||||
public static ItemCoordSelector itemCoordSelector;
|
||||
public static ItemTravelStaff itemTravelStaff;
|
||||
|
||||
// Painter
|
||||
@@ -357,7 +357,7 @@ public class EnderIO {
|
||||
blockEnderIo = BlockEnderIO.create();
|
||||
blockTravelPlatform = BlockTravelAnchor.create();
|
||||
blockTelePad = BlockTelePad.create();
|
||||
itemCoordsCard = ItemCoordSelector.create();
|
||||
itemCoordSelector = ItemCoordSelector.create();
|
||||
|
||||
blockSliceAndSplice = BlockSliceAndSplice.create();
|
||||
blockSoulFuser = BlockSoulBinder.create();
|
||||
|
||||
@@ -32,23 +32,23 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
|
||||
protected IIcon[] icons;
|
||||
|
||||
protected AbstractItemConduit(ModObject modObj) {
|
||||
protected AbstractItemConduit(ModObject modObj, ItemConduitSubtype... subtypes) {
|
||||
this.modObj = modObj;
|
||||
this.subtypes = subtypes;
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName(modObj.unlocalisedName);
|
||||
setMaxStackSize(64);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
protected void init(ItemConduitSubtype[] subtypes) {
|
||||
this.subtypes = subtypes;
|
||||
icons = new IIcon[subtypes.length];
|
||||
protected void init() {
|
||||
GameRegistry.registerItem(this, modObj.unlocalisedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister IIconRegister) {
|
||||
icons = new IIcon[subtypes.length];
|
||||
int index = 0;
|
||||
for (ItemConduitSubtype subtype : subtypes) {
|
||||
icons[index] = IIconRegister.registerIcon(subtype.iconKey);
|
||||
|
||||
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade.FacadeType;
|
||||
import crazypants.enderio.conduit.gas.GasUtil;
|
||||
import crazypants.enderio.conduit.item.filter.ClearFilterRecipe;
|
||||
import crazypants.enderio.conduit.item.filter.CopyFilterRecipe;
|
||||
import crazypants.enderio.conduit.me.MEUtil;
|
||||
@@ -58,8 +59,11 @@ public class ConduitRecipes {
|
||||
Blocks.lever);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#',
|
||||
redstoneAlloy);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemGasConduit, numConduits, 0), "bbb", "#g#", "bbb", 'b', conduitBinder, '#',
|
||||
electricalSteel, 'g', fusedGlass);
|
||||
|
||||
if (GasUtil.isGasConduitEnabled()) {
|
||||
GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemGasConduit, numConduits, 0), "bbb", "#g#", "bbb", 'b', conduitBinder, '#', electricalSteel, 'g',
|
||||
fusedGlass);
|
||||
}
|
||||
|
||||
ItemStack itemConduit = new ItemStack(EnderIO.itemItemConduit, numConduits, 0);
|
||||
GameRegistry.addShapedRecipe(itemConduit, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIronNugget);
|
||||
|
||||
@@ -31,6 +31,7 @@ import crazypants.enderio.Log;
|
||||
import crazypants.enderio.api.tool.IHideFacades;
|
||||
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
|
||||
import crazypants.enderio.conduit.gas.GasConduitNetwork;
|
||||
import crazypants.enderio.conduit.gas.GasUtil;
|
||||
import crazypants.enderio.conduit.gas.IGasConduit;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.ItemConduitNetwork;
|
||||
@@ -42,6 +43,7 @@ import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.liquid.LiquidConduitNetwork;
|
||||
import crazypants.enderio.conduit.me.IMEConduit;
|
||||
import crazypants.enderio.conduit.me.MEConduitNetwork;
|
||||
import crazypants.enderio.conduit.me.MEUtil;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.power.PowerConduitNetwork;
|
||||
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
|
||||
@@ -329,7 +331,10 @@ public class ConduitUtil {
|
||||
if(typeName == null || conduitBody == null) {
|
||||
return null;
|
||||
}
|
||||
if(nbtVersion == 0 && "crazypants.enderio.conduit.liquid.LiquidConduit".equals(typeName)) {
|
||||
if ((typeName.contains("conduit.me") && !MEUtil.isMEEnabled()) || typeName.contains("conduit.gas") && !GasUtil.isGasConduitEnabled()) {
|
||||
return null;
|
||||
}
|
||||
if (nbtVersion == 0 && "crazypants.enderio.conduit.liquid.LiquidConduit".equals(typeName)) {
|
||||
Log.debug("ConduitUtil.readConduitFromNBT: Converted pre 0.7.3 fluid conduit to advanced fluid conduit.");
|
||||
typeName = "crazypants.enderio.conduit.liquid.AdvancedLiquidConduit";
|
||||
}
|
||||
|
||||
@@ -25,12 +25,14 @@ public class ItemGasConduit extends AbstractItemConduit implements IAdvancedTool
|
||||
|
||||
public static ItemGasConduit create() {
|
||||
ItemGasConduit result = new ItemGasConduit();
|
||||
result.init(subtypes);
|
||||
if (GasUtil.isGasConduitEnabled()) {
|
||||
result.init();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemGasConduit() {
|
||||
super(ModObject.itemGasConduit);
|
||||
super(ModObject.itemGasConduit, subtypes);
|
||||
if(!GasUtil.isGasConduitEnabled()) {
|
||||
setCreativeTab(null);
|
||||
}
|
||||
|
||||
@@ -64,12 +64,12 @@ public class ExternalConnectionContainer extends Container {
|
||||
|
||||
x = 10;
|
||||
y = 47;
|
||||
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(ui, 3, x, y));
|
||||
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(ui, 3, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
x = 10;
|
||||
y = 47;
|
||||
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(ui, 2, x, y));
|
||||
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(ui, 2, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
x = 28;
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
for (Target t : source.sendPriority) {
|
||||
IItemFilter f = t.inv.con.getOutputFilter(t.inv.conDir);
|
||||
if(input == null || f == null || f.doesItemPassFilter(t.inv, input)) {
|
||||
String s = EnderIO.lang.localizeExact(t.inv.getInventory().getInventoryName()) + " " + t.inv.location + " Distance [" + t.distance + "] ";
|
||||
String s = EnderIO.lang.localizeExact(t.inv.getInventory().getInventoryName()) + " " + t.inv.location.chatString() + " Distance [" + t.distance + "] ";
|
||||
result.add(s);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
if(inv.hasTarget(con, dir)) {
|
||||
IItemFilter f = inv.con.getInputFilter(inv.conDir);
|
||||
if(input == null || f == null || f.doesItemPassFilter(inv, input)) {
|
||||
result.add(EnderIO.lang.localizeExact(inv.getInventory().getInventoryName()) + " " + inv.location);
|
||||
result.add(EnderIO.lang.localizeExact(inv.getInventory().getInventoryName()) + " " + inv.location.chatString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ public class ItemItemConduit extends AbstractItemConduit {
|
||||
|
||||
public static ItemItemConduit create() {
|
||||
ItemItemConduit result = new ItemItemConduit();
|
||||
result.init(subtypes);
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemItemConduit() {
|
||||
super(ModObject.itemItemConduit);
|
||||
super(ModObject.itemItemConduit, subtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,12 +28,12 @@ public class ItemLiquidConduit extends AbstractItemConduit implements IAdvancedT
|
||||
|
||||
public static ItemLiquidConduit create() {
|
||||
ItemLiquidConduit result = new ItemLiquidConduit();
|
||||
result.init(subtypes);
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemLiquidConduit() {
|
||||
super(ModObject.itemLiquidConduit);
|
||||
super(ModObject.itemLiquidConduit, subtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,13 +18,13 @@ public class ItemMEConduit extends AbstractItemConduit {
|
||||
public static ItemMEConduit create() {
|
||||
ItemMEConduit result = new ItemMEConduit();
|
||||
if (MEUtil.isMEEnabled()) {
|
||||
result.init(subtypes);
|
||||
result.init();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemMEConduit() {
|
||||
super(ModObject.itemMEConduit);
|
||||
super(ModObject.itemMEConduit, subtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,4 +43,4 @@ public class ItemMEConduit extends AbstractItemConduit {
|
||||
public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,12 @@ public class ItemPowerConduit extends AbstractItemConduit {
|
||||
|
||||
public static ItemPowerConduit create() {
|
||||
ItemPowerConduit result = new ItemPowerConduit();
|
||||
result.init(subtypes);
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemPowerConduit() {
|
||||
super(ModObject.itemPowerConduit);
|
||||
super(ModObject.itemPowerConduit, subtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,12 +18,12 @@ public class ItemRedstoneConduit extends AbstractItemConduit {
|
||||
|
||||
public static ItemRedstoneConduit create() {
|
||||
ItemRedstoneConduit result = new ItemRedstoneConduit();
|
||||
result.init(subtypes);
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemRedstoneConduit() {
|
||||
super(ModObject.itemRedstoneConduit);
|
||||
super(ModObject.itemRedstoneConduit, subtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
@@ -15,10 +16,13 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.machine.obelisk.weather.TileWeatherObelisk.WeatherTask;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public final class Config {
|
||||
|
||||
@@ -470,6 +474,8 @@ public final class Config {
|
||||
|
||||
public static boolean telepadLockDimension = true;
|
||||
public static boolean telepadLockCoords = true;
|
||||
public static int telepadPowerCoefficient = 100000;
|
||||
public static int telepadPowerInterdimensional = 100000;
|
||||
|
||||
public static float inventoryPanelPowerPerMB = 800.0f;
|
||||
public static float inventoryPanelScanCostPerSlot = 0.1f;
|
||||
@@ -477,6 +483,7 @@ public final class Config {
|
||||
public static float inventoryPanelExtractCostPerOperation = 32.0f;
|
||||
|
||||
public static void load(FMLPreInitializationEvent event) {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketConfigSync.class, PacketConfigSync.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new Config());
|
||||
configDirectory = new File(event.getModConfigurationDirectory(), EnderIO.MODID.toLowerCase());
|
||||
@@ -507,7 +514,7 @@ public final class Config {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(OnConfigChangedEvent event) {
|
||||
if(event.modID.equals(EnderIO.MODID)) {
|
||||
if (event.modID.equals(EnderIO.MODID)) {
|
||||
Log.info("Updating config...");
|
||||
syncConfig(false);
|
||||
postInit();
|
||||
@@ -525,6 +532,11 @@ public final class Config {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerLoggon(PlayerLoggedInEvent evt) {
|
||||
PacketHandler.INSTANCE.sendTo(new PacketConfigSync(), (EntityPlayerMP) evt.player);
|
||||
}
|
||||
|
||||
public static void processConfig(Configuration config) {
|
||||
|
||||
capacitorBankMaxIoRF = config.get(sectionPower.name, "capacitorBankMaxIoRF", capacitorBankMaxIoRF, "The maximum IO for a single capacitor in RF/t")
|
||||
@@ -627,10 +639,10 @@ public final class Config {
|
||||
"Number of millibuckets per tick that can pass through a single connection to a fluid conduit.").getInt(fluidConduitMaxIoRate);
|
||||
|
||||
advancedFluidConduitExtractRate = config.get(sectionEfficiency.name, "advancedFluidConduitExtractRate", advancedFluidConduitExtractRate,
|
||||
"Number of millibuckets per tick extracted by pressurised fluid conduits auto extracting").getInt(advancedFluidConduitExtractRate);
|
||||
"Number of millibuckets per tick extracted by pressurized fluid conduits auto extracting").getInt(advancedFluidConduitExtractRate);
|
||||
|
||||
advancedFluidConduitMaxIoRate = config.get(sectionEfficiency.name, "advancedFluidConduitMaxIoRate", advancedFluidConduitMaxIoRate,
|
||||
"Number of millibuckets per tick that can pass through a single connection to an pressurised fluid conduit.").getInt(advancedFluidConduitMaxIoRate);
|
||||
"Number of millibuckets per tick that can pass through a single connection to an pressurized fluid conduit.").getInt(advancedFluidConduitMaxIoRate);
|
||||
|
||||
enderFluidConduitExtractRate = config.get(sectionEfficiency.name, "enderFluidConduitExtractRate", enderFluidConduitExtractRate,
|
||||
"Number of millibuckets per tick extracted by ender fluid conduits auto extracting").getInt(enderFluidConduitExtractRate);
|
||||
@@ -714,9 +726,9 @@ public final class Config {
|
||||
"Travel Anchors send a chat warning when skipping inaccessible anchors").getBoolean(travelAnchorSkipWarning);
|
||||
|
||||
travelStaffMaxDistance = config.get(sectionStaff.name, "travelStaffMaxDistance", travelStaffMaxDistance,
|
||||
"Maximum number of blocks that can be traveled using the Staff of the Traveling.").getInt(travelStaffMaxDistance);
|
||||
"Maximum number of blocks that can be traveled using the Staff of Traveling.").getInt(travelStaffMaxDistance);
|
||||
travelStaffPowerPerBlockRF = (float) config.get(sectionStaff.name, "travelStaffPowerPerBlockRF", travelStaffPowerPerBlockRF,
|
||||
"Number of RF required per block travelled using the Staff of the Traveling.").getDouble(travelStaffPowerPerBlockRF);
|
||||
"Number of RF required per block traveled using the Staff of Traveling.").getDouble(travelStaffPowerPerBlockRF);
|
||||
|
||||
travelStaffMaxBlinkDistance = config.get(sectionStaff.name, "travelStaffMaxBlinkDistance", travelStaffMaxBlinkDistance,
|
||||
"Max number of blocks teleported when shift clicking the staff.").getInt(travelStaffMaxBlinkDistance);
|
||||
@@ -1062,7 +1074,7 @@ public final class Config {
|
||||
"If true the magnet can be put into the 'amulet' Baubles slot even if switched off (requires Baubles to be installed and magnetAllowInBaublesSlot to be on)").getBoolean(magnetAllowDeactivatedInBaublesSlot);
|
||||
|
||||
magnetBaublesType = config.get(sectionMagnet.name, "magnetBaublesType", magnetBaublesType,
|
||||
"The BaulesType the magnet should be, 'AMULET', 'RING' or 'BELT' (requires Baubles to be installed and magnetAllowInBaublesSlot to be on)").getString();
|
||||
"The BaublesType the magnet should be, 'AMULET', 'RING' or 'BELT' (requires Baubles to be installed and magnetAllowInBaublesSlot to be on)").getString();
|
||||
|
||||
useCombustionGenModel = config.get(sectionAesthetic.name, "useCombustionGenModel", useCombustionGenModel,
|
||||
"If set to true: WIP Combustion Generator model will be used").getBoolean(useCombustionGenModel);
|
||||
@@ -1226,7 +1238,7 @@ public final class Config {
|
||||
lootTheEnder = config.getBoolean("lootTheEnder", sectionLootConfig.name, lootTheEnder, "Adds The Ender to loot tables");
|
||||
lootDarkSteelBoots = config.getBoolean("lootDarkSteelBoots", sectionLootConfig.name, lootDarkSteelBoots, "Adds Darksteel Boots to loot tables");
|
||||
|
||||
enderRailEnabled = config.getBoolean("enderRailEnabled", sectionRailConfig.name, enderRailEnabled, "Wether Ender Rails are enabled");
|
||||
enderRailEnabled = config.getBoolean("enderRailEnabled", sectionRailConfig.name, enderRailEnabled, "Whether Ender Rails are enabled");
|
||||
enderRailPowerRequireCrossDimensions = config.get(sectionRailConfig.name, "enderRailPowerRequireCrossDimensions", enderRailPowerRequireCrossDimensions,
|
||||
"The amount of power required to transport a cart across dimensions").getInt(enderRailPowerRequireCrossDimensions);
|
||||
enderRailPowerRequiredPerBlock = config.get(sectionRailConfig.name, "enderRailPowerRequiredPerBlock", enderRailPowerRequiredPerBlock,
|
||||
@@ -1241,7 +1253,7 @@ public final class Config {
|
||||
"When set to true a list of all registered mobs will be dumped to config/enderio/mobTypes.txt The names are in the format required by EIOs mob blacklists.");
|
||||
|
||||
xpObeliskMaxXpLevel = config.get(sectionMisc.name, "xpObeliskMaxXpLevel", xpObeliskMaxXpLevel, "Maximum level of XP the xp obelisk can contain.").getInt();
|
||||
xpJuiceName = config.getString("xpJuiceName", sectionMisc.name, xpJuiceName, "Id of liquid XP fluid (WARNING: only for users who know what they are doing - changing this id can break worlds) - this should match the with OpenBlocks when installed");
|
||||
xpJuiceName = config.getString("xpJuiceName", sectionMisc.name, xpJuiceName, "Id of liquid XP fluid (WARNING: only for users who know what they are doing - changing this id can break worlds) - this should match with OpenBlocks when installed");
|
||||
|
||||
clearGlassSameTexture = config.getBoolean("clearGlassSameTexture", sectionMisc.name, clearGlassSameTexture, "If true, quite clear glass will use the fused quartz border texture for the block instead of the white border.");
|
||||
clearGlassConnectToFusedQuartz = config.getBoolean("clearGlassConnectToFusedQuartz", sectionMisc.name, clearGlassConnectToFusedQuartz, "If true, quite clear glass will connect textures with fused quartz.");
|
||||
@@ -1268,6 +1280,10 @@ public final class Config {
|
||||
"If true, the dimension cannot be set via the GUI, the coord selector must be used.").getBoolean();
|
||||
telepadLockCoords = config.get(sectionTelepad.name, "lockCoords", telepadLockCoords,
|
||||
"If true, the coordinates cannot be set via the GUI, the coord selector must be used.").getBoolean();
|
||||
telepadPowerCoefficient = config.get(sectionTelepad.name, "powerCoefficient", telepadPowerCoefficient,
|
||||
"Power for a teleport is calculated by the formula:\npower = [this value] * ln(0.005*distance + 1)").getInt();
|
||||
telepadPowerInterdimensional = config.get(sectionTelepad.name, "powerInterdimensional", telepadPowerInterdimensional,
|
||||
"The amount of RF required for an interdimensional teleport.").getInt();
|
||||
|
||||
inventoryPanelPowerPerMB = config.getFloat("powerPerMB", sectionInventoryPanel.name, inventoryPanelPowerPerMB, 1.0f, 10000.0f,
|
||||
"Internal power generated per mB. The default of 800/mB matches the RF generation of the Zombie generator. A panel tries to refill only once every second - setting this value too low slows down the scanning speed.");
|
||||
|
||||
+9
-2
@@ -1,11 +1,14 @@
|
||||
package crazypants.enderio.teleport.packet;
|
||||
package crazypants.enderio.config;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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.config.Config;
|
||||
|
||||
/**
|
||||
* Syncs some configs that are only used clientside, but must use the serverside
|
||||
* value for balance purposes.
|
||||
*/
|
||||
public class PacketConfigSync implements IMessage, IMessageHandler<PacketConfigSync, IMessage> {
|
||||
|
||||
@Override
|
||||
@@ -20,6 +23,8 @@ public class PacketConfigSync implements IMessage, IMessageHandler<PacketConfigS
|
||||
buf.writeInt(Config.travelStaffMaxDistance);
|
||||
buf.writeInt(Config.travelStaffMaxBlinkDistance);
|
||||
buf.writeFloat(Config.travelStaffPowerPerBlockRF);
|
||||
buf.writeBoolean(Config.telepadLockCoords);
|
||||
buf.writeBoolean(Config.telepadLockDimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,6 +39,8 @@ public class PacketConfigSync implements IMessage, IMessageHandler<PacketConfigS
|
||||
Config.travelStaffMaxDistance = data.readInt();
|
||||
Config.travelStaffMaxBlinkDistance = data.readInt();
|
||||
Config.travelStaffPowerPerBlockRF = data.readFloat();
|
||||
Config.telepadLockCoords = data.readBoolean();
|
||||
Config.telepadLockDimension = data.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -8,8 +8,10 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -40,7 +42,7 @@ import crazypants.enderio.tool.ToolUtil;
|
||||
public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdvancedTooltipProvider, InvocationHandler {
|
||||
|
||||
public static ItemYetaWrench create() {
|
||||
if(Config.useSneakMouseWheelYetaWrench) {
|
||||
if (Config.useSneakMouseWheelYetaWrench) {
|
||||
PacketHandler.INSTANCE.registerMessage(YetaWrenchPacketProcessor.class, YetaWrenchPacketProcessor.class, PacketHandler.nextID(), Side.SERVER);
|
||||
}
|
||||
ItemYetaWrench result = new ItemYetaWrench();
|
||||
@@ -71,26 +73,41 @@ public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdv
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
boolean ret = false;
|
||||
if(block != null) {
|
||||
if (block != null) {
|
||||
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, x, y, z, side, world);
|
||||
if(MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY || e.useItem == Result.DENY) {
|
||||
if (MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY || e.useItem == Result.DENY) {
|
||||
return false;
|
||||
}
|
||||
if(player.isSneaking() && block instanceof IDismantleable && ((IDismantleable) block).canDismantle(player, world, x, y, z)) {
|
||||
if(!world.isRemote) {
|
||||
if (player.isSneaking() && block instanceof IDismantleable && ((IDismantleable) block).canDismantle(player, world, x, y, z)) {
|
||||
if (!world.isRemote) {
|
||||
((IDismantleable) block).dismantleBlock(player, world, x, y, z, false);
|
||||
}
|
||||
ret = true;
|
||||
} else if(!player.isSneaking() && block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) {
|
||||
} else if (!player.isSneaking() && block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) {
|
||||
if (block == Blocks.chest) {
|
||||
// This works around a forge bug where you can rotate double chests to invalid directions
|
||||
TileEntityChest te = (TileEntityChest) world.getTileEntity(x, y, z);
|
||||
if (te.adjacentChestXNeg != null || te.adjacentChestXPos != null || te.adjacentChestZNeg != null || te.adjacentChestZPos != null) {
|
||||
// Render master is always the chest to the negative direction
|
||||
TileEntityChest masterChest = te.adjacentChestXNeg == null && te.adjacentChestZNeg == null ? te : te.adjacentChestXNeg == null ? te.adjacentChestZNeg: te.adjacentChestXNeg;
|
||||
if (masterChest != te) {
|
||||
int meta = world.getBlockMetadata(masterChest.xCoord, masterChest.yCoord, masterChest.zCoord);
|
||||
world.setBlockMetadataWithNotify(masterChest.xCoord, masterChest.yCoord, masterChest.zCoord, meta ^ 1, 3);
|
||||
} else {
|
||||
// If this is the master chest, we can just rotate twice
|
||||
block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side));
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = true;
|
||||
} else if(block instanceof IRotatableFacade && !player.isSneaking()
|
||||
} else if (block instanceof IRotatableFacade && !player.isSneaking()
|
||||
&& (block != EnderIO.blockConduitBundle || ConduitDisplayMode.getDisplayMode(stack) == ConduitDisplayMode.NONE)) {
|
||||
if(((IRotatableFacade) block).tryRotateFacade(world, x, y, z, ForgeDirection.getOrientation(side))) {
|
||||
if (((IRotatableFacade) block).tryRotateFacade(world, x, y, z, ForgeDirection.getOrientation(side))) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
player.swingItem();
|
||||
}
|
||||
return ret && !world.isRemote;
|
||||
@@ -98,14 +115,14 @@ public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdv
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
|
||||
if(!Config.useSneakRightClickYetaWrench) {
|
||||
if (!Config.useSneakRightClickYetaWrench) {
|
||||
return equipped;
|
||||
}
|
||||
if(!player.isSneaking()) {
|
||||
if (!player.isSneaking()) {
|
||||
return equipped;
|
||||
}
|
||||
ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(equipped);
|
||||
if(curMode == null) {
|
||||
if (curMode == null) {
|
||||
curMode = ConduitDisplayMode.ALL;
|
||||
}
|
||||
ConduitDisplayMode newMode = curMode.next();
|
||||
@@ -168,7 +185,7 @@ public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdv
|
||||
ArrayList<String> tmp = new ArrayList<String>();
|
||||
SpecialTooltipHandler.addDetailedTooltipFromResources(tmp, getUnlocalizedName());
|
||||
String keyName = Keyboard.getKeyName(KeyTracker.instance.getYetaWrenchMode().getKeyCode());
|
||||
for(String line : tmp) {
|
||||
for (String line : tmp) {
|
||||
list.add(String.format(line, keyName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,17 @@ package crazypants.enderio.item.darksteel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.particle.EntityReddustFX;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
@@ -17,6 +20,7 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -34,6 +38,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.PacketUpgradeState.Type;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.GliderUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IDarkSteelUpgrade;
|
||||
@@ -79,8 +84,21 @@ public class DarkSteelController {
|
||||
private DarkSteelController() {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketDarkSteelPowerPacket.class, PacketDarkSteelPowerPacket.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketUpgradeState.class, PacketUpgradeState.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketUpgradeState.class, PacketUpgradeState.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
}
|
||||
|
||||
public boolean isActive(EntityPlayer player, Type type) {
|
||||
switch(type) {
|
||||
case GLIDE:
|
||||
return isGlideActive(player);
|
||||
case SPEED:
|
||||
return isSpeedActive(player);
|
||||
case STEP_ASSIST:
|
||||
return isStepAssistActive(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setGlideActive(EntityPlayer player, boolean isGlideActive) {
|
||||
if(player.getGameProfile().getId() != null) {
|
||||
glideActiveMap.put(player.getGameProfile().getId(), isGlideActive);
|
||||
@@ -362,6 +380,15 @@ public class DarkSteelController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onStartTracking(PlayerEvent.StartTracking event) {
|
||||
if (event.target instanceof EntityPlayerMP) {
|
||||
for (PacketUpgradeState.Type type : PacketUpgradeState.Type.values()) {
|
||||
PacketHandler.sendTo(new PacketUpgradeState(type, isActive((EntityPlayer) event.target, type), event.target.getEntityId()), (EntityPlayerMP) event.entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
@@ -405,6 +432,9 @@ public class DarkSteelController {
|
||||
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
if(player.isSneaking()) {
|
||||
GL11.glTranslatef(0, 0.0625f, 0);
|
||||
}
|
||||
GL11.glRotatef(yawOffset, 0, -1, 0);
|
||||
GL11.glRotatef(yaw - 270, 0, 1, 0);
|
||||
GL11.glRotatef(pitch, 0, 0, 1);
|
||||
@@ -453,6 +483,14 @@ public class DarkSteelController {
|
||||
ticksSinceLastJump = 0;
|
||||
usePlayerEnergy(player, DarkSteelItems.itemDarkSteelBoots, requiredPower);
|
||||
player.worldObj.playSound(player.posX, player.posY, player.posZ, EnderIO.MODID + ":ds.jump", 1.0f, player.worldObj.rand.nextFloat() * 0.5f + 0.75f, false);
|
||||
Random rand = player.worldObj.rand;
|
||||
for (int i = rand.nextInt(10) + 5; i >= 0; i--) {
|
||||
EntityReddustFX fx = new EntityReddustFX(player.worldObj, player.posX + (rand.nextDouble() * 0.5 - 0.25), player.posY - player.yOffset, player.posZ
|
||||
+ (rand.nextDouble() * 0.5 - 0.25), 1, 1, 1);
|
||||
fx.setVelocity(player.motionX + (rand.nextDouble() * 0.5 - 0.25), (player.motionY / 2) + (rand.nextDouble() * -0.05),
|
||||
player.motionZ + (rand.nextDouble() * 0.5 - 0.25));
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
|
||||
}
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketDarkSteelPowerPacket(requiredPower, DarkSteelItems.itemDarkSteelBoots.armorType));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.EnderIO;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class PacketUpgradeState implements IMessage, IMessageHandler<PacketUpgradeState, IMessage> {
|
||||
|
||||
@@ -19,28 +21,36 @@ public class PacketUpgradeState implements IMessage, IMessageHandler<PacketUpgra
|
||||
|
||||
private boolean isActive;
|
||||
private Type type;
|
||||
|
||||
private int entityID;
|
||||
|
||||
public PacketUpgradeState(Type type, boolean isActive) {
|
||||
this(type, isActive, 0);
|
||||
}
|
||||
|
||||
public PacketUpgradeState(Type type, boolean isActive, int entityID) {
|
||||
this.type = type;
|
||||
this.isActive = isActive;
|
||||
this.entityID = entityID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeShort(type.ordinal());
|
||||
buf.writeBoolean(isActive);
|
||||
buf.writeBoolean(isActive);
|
||||
buf.writeInt(entityID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
type = Type.values()[buf.readShort()];
|
||||
isActive = buf.readBoolean();
|
||||
isActive = buf.readBoolean();
|
||||
entityID = buf.readInt();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketUpgradeState message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
switch(message.type) {
|
||||
EntityPlayer player = (EntityPlayer) (ctx.side.isClient() ? EnderIO.proxy.getClientWorld().getEntityByID(message.entityID) : ctx.getServerHandler().playerEntity);
|
||||
switch (message.type) {
|
||||
case GLIDE:
|
||||
DarkSteelController.instance.setGlideActive(player, message.isActive);
|
||||
break;
|
||||
@@ -51,9 +61,12 @@ public class PacketUpgradeState implements IMessage, IMessageHandler<PacketUpgra
|
||||
DarkSteelController.instance.setStepAssistActive(player, message.isActive);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (ctx.side.isServer()) {
|
||||
message.entityID = player.getEntityId();
|
||||
PacketHandler.INSTANCE.sendToDimension(message, player.worldObj.provider.dimensionId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,6 +94,7 @@ public abstract class AbstractUpgrade implements IDarkSteelUpgrade {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IRenderUpgrade getRender() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ public class GliderUpgrade extends AbstractUpgrade {
|
||||
|
||||
public static final GliderUpgrade INSTANCE = new GliderUpgrade();
|
||||
|
||||
private final Render render = new Render();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Render render;
|
||||
|
||||
public static GliderUpgrade loadFromItem(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
@@ -62,8 +63,9 @@ public class GliderUpgrade extends AbstractUpgrade {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IRenderUpgrade getRender() {
|
||||
return render;
|
||||
return render == null ? render = new Render() : render;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,8 +88,9 @@ public class GliderUpgrade extends AbstractUpgrade {
|
||||
RenderUtil.bindItemTexture();
|
||||
glDepthMask(true);
|
||||
item.hoverStart = 0;
|
||||
Helper.rotateIfSneaking(event.entityPlayer);
|
||||
GL11.glTranslatef(-0, 1, 0.25f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 1, 0, 0);
|
||||
GL11.glScalef(3, 3, 3);
|
||||
RenderManager.instance.renderEntityWithPosYaw(item, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,34 @@
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public interface IRenderUpgrade {
|
||||
|
||||
void render(RenderPlayerEvent event, ItemStack stack, boolean head);
|
||||
|
||||
/**
|
||||
* A few helper methods for rendering. Credit to Vazkii, used from Botania.
|
||||
* {@link #translateToHeadLevel(EntityPlayer)} edited to remove sneaking
|
||||
* translation.
|
||||
*/
|
||||
public static class Helper {
|
||||
|
||||
public static void rotateIfSneaking(EntityPlayer player) {
|
||||
if (player.isSneaking())
|
||||
applySneakingRotation();
|
||||
}
|
||||
|
||||
public static void applySneakingRotation() {
|
||||
GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public static void translateToHeadLevel(EntityPlayer player) {
|
||||
GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.7F : 0) - player.getDefaultEyeHeight(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
public static final SolarUpgrade SOLAR_ONE = new SolarUpgrade("enderio.darksteel.upgrade.solar_one", (byte) 1, Config.darkSteelSolarOneCost);
|
||||
public static final SolarUpgrade SOLAR_TWO = new SolarUpgrade("enderio.darksteel.upgrade.solar_two", (byte) 2, Config.darkSteelSolarTwoCost);
|
||||
|
||||
private Render render = new Render();
|
||||
private Render render;
|
||||
|
||||
public static SolarUpgrade loadFromItem(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
@@ -104,10 +104,11 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IRenderUpgrade getRender() {
|
||||
return render;
|
||||
return render == null ? render = new Render() : render;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class Render implements IRenderUpgrade {
|
||||
|
||||
@@ -121,8 +122,8 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
RenderUtil.bindItemTexture();
|
||||
glDepthMask(true);
|
||||
item.hoverStart = 0;
|
||||
GL11.glTranslated(0, -0.08, 0);
|
||||
GL11.glTranslated(0, (event.entityPlayer != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - event.entityPlayer.getDefaultEyeHeight() + (event.entityPlayer.isSneaking() ? 0.0625 : 0), 0);
|
||||
Helper.translateToHeadLevel(event.entityPlayer);
|
||||
GL11.glTranslated(0, -0.155, 0);
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScalef(2.1f, 2.1f, 2.1f);
|
||||
byte level = loadFromItem(stack).level;
|
||||
|
||||
@@ -213,11 +213,15 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
public float getPitch() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
protected boolean shouldPlaySound() {
|
||||
return isActive() && !isInvalid();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateSound() {
|
||||
if(Config.machineSoundsEnabled && hasSound()) {
|
||||
if(isActive() && !isInvalid()) {
|
||||
if(shouldPlaySound()) {
|
||||
if(sound == null) {
|
||||
sound = new MachineSound(soundRes, xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, getVolume(), getPitch());
|
||||
FMLClientHandler.instance().getClient().getSoundHandler().playSound(sound);
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return currentTask == null ? 0 : currentTask.getProgress();
|
||||
return currentTask == null ? -1 : currentTask.getProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,11 +134,11 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
|
||||
// this chance value has been used up
|
||||
nextChance = Float.NaN;
|
||||
}
|
||||
sendTaskProgressPacket();
|
||||
startFailed = !started;
|
||||
} else {
|
||||
startFailed = true;
|
||||
}
|
||||
sendTaskProgressPacket();
|
||||
|
||||
return requiresClientSync;
|
||||
}
|
||||
@@ -183,7 +183,6 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
|
||||
markDirty();
|
||||
currentTask = null;
|
||||
lastProgressScaled = 0;
|
||||
sendTaskProgressPacket();
|
||||
}
|
||||
|
||||
protected void mergeResults(ResultStack[] results) {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.enderio.core.api.common.util.IProgressTile;
|
||||
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.EnderIO;
|
||||
|
||||
public class PacketProgress extends MessageTileEntity<TileEntity> implements IMessageHandler<PacketProgress, IMessage> {
|
||||
|
||||
private float progress;
|
||||
|
||||
public PacketProgress() {
|
||||
}
|
||||
|
||||
public PacketProgress(IProgressTile tile) {
|
||||
super(tile.getTileEntity());
|
||||
progress = tile.getProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeFloat(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
progress = buf.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketProgress message, MessageContext ctx) {
|
||||
TileEntity tile = message.getTileEntity(EnderIO.proxy.getClientWorld());
|
||||
if(tile instanceof IProgressTile) {
|
||||
((IProgressTile) tile).setProgress(message.progress);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
public interface IHasNutrientTank {
|
||||
|
||||
NutrientTank getNutrientTank();
|
||||
SmartTank getNutrientTank();
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import crazypants.enderio.EnderIO;
|
||||
|
||||
public class NutrientTank extends FluidTank {
|
||||
|
||||
public NutrientTank(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public boolean canFill(Fluid fluid) {
|
||||
return fluid != null && fluid.getID() == EnderIO.fluidNutrientDistillation.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if(resource == null || !canFill(resource.getFluid())) {
|
||||
return 0;
|
||||
}
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
|
||||
public float getFilledRatio() {
|
||||
return (float) getFluidAmount() / getCapacity();
|
||||
}
|
||||
|
||||
public void setFluidAmount(int amount) {
|
||||
if(amount > 0) {
|
||||
setFluid(new FluidStack(EnderIO.fluidNutrientDistillation, Math.min(capacity, amount)));
|
||||
} else {
|
||||
setFluid(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCommon(String name, NBTTagCompound nbtRoot) {
|
||||
if(getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
writeToNBT(tankRoot);
|
||||
nbtRoot.setTag(name, tankRoot);
|
||||
}
|
||||
}
|
||||
|
||||
public void readCommon(String name, NBTTagCompound nbtRoot) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag(name);
|
||||
if(tankRoot != null) {
|
||||
readFromNBT(tankRoot);
|
||||
} else {
|
||||
setFluid(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,13 @@ import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.machine.generator.AbstractGeneratorEntity;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.PowerDistributor;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
public class TileZombieGenerator extends AbstractGeneratorEntity implements IFluidHandler, ITankAccess, IHasNutrientTank {
|
||||
|
||||
private static int IO_MB_TICK = 250;
|
||||
|
||||
final NutrientTank fuelTank = new NutrientTank(FluidContainerRegistry.BUCKET_VOLUME * 2);
|
||||
final SmartTank fuelTank = new SmartTank(EnderIO.fluidNutrientDistillation, FluidContainerRegistry.BUCKET_VOLUME * 2);
|
||||
|
||||
int outputPerTick = Config.zombieGeneratorRfPerTick;
|
||||
int tickPerBucketOfFuel = Config.zombieGeneratorTicksPerBucketFuel;
|
||||
@@ -276,7 +277,7 @@ public class TileZombieGenerator extends AbstractGeneratorEntity implements IFlu
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutrientTank getNutrientTank() {
|
||||
public SmartTank getNutrientTank() {
|
||||
return fuelTank;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,18 @@ package crazypants.enderio.machine.invpanel;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ClientProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
@@ -26,6 +30,7 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
PacketHandler.INSTANCE.registerMessage(PacketFetchItem.class, PacketFetchItem.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketMoveItems.class, PacketMoveItems.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketDatabaseReset.class, PacketDatabaseReset.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketGuiSettings.class, PacketGuiSettings.class, PacketHandler.nextID(), Side.SERVER);
|
||||
|
||||
BlockInventoryPanel panel = new BlockInventoryPanel();
|
||||
panel.init();
|
||||
@@ -36,6 +41,13 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
super(ModObject.blockInventoryPanel, TileInventoryPanel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
GameRegistry.registerBlock(this, BlockItemInventoryPanel.class, modObject.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(teClass, modObject.unlocalisedName + "TileEntity");
|
||||
EnderIO.guiHandler.registerGuiHandler(getGuiId(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return 0;
|
||||
@@ -72,6 +84,12 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
int facing = getFacing(world, x, y, z);
|
||||
switch (facing) {
|
||||
case 0:
|
||||
setBlockBounds(0.0f, 1.0f - BLOCK_SIZE, 0.0f, 1.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
case 1:
|
||||
setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, BLOCK_SIZE, 1.0f);
|
||||
break;
|
||||
case 2:
|
||||
setBlockBounds(0.0f, 0.0f, 1.0f - BLOCK_SIZE, 1.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
@@ -98,6 +116,11 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
// this is handled by BlockItemInventoryPanel.placeBlockAt
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package crazypants.enderio.machine.invpanel;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockItemInventoryPanel extends ItemBlock {
|
||||
|
||||
public BlockItemInventoryPanel(Block b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
|
||||
if(!super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) {
|
||||
return false;
|
||||
}
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileInventoryPanel) {
|
||||
TileInventoryPanel teInvPanel = (TileInventoryPanel) te;
|
||||
teInvPanel.setFacing((short) side);
|
||||
teInvPanel.readFromItemStack(stack);
|
||||
if(!world.isRemote) {
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,18 @@ package crazypants.enderio.machine.invpanel;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -26,19 +29,21 @@ import com.enderio.core.client.render.EnderWidget;
|
||||
import com.enderio.core.client.render.RenderUtil;
|
||||
import com.enderio.core.common.util.ItemUtil;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.fluid.Fluids;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.machine.generator.zombie.NutrientTank;
|
||||
import crazypants.enderio.machine.gui.GuiMachineBase;
|
||||
import crazypants.enderio.machine.invpanel.client.CraftingHelper;
|
||||
import crazypants.enderio.machine.invpanel.client.DatabaseView;
|
||||
import crazypants.enderio.machine.invpanel.client.ICraftingHelper;
|
||||
import crazypants.enderio.machine.invpanel.client.InventoryDatabaseClient;
|
||||
import crazypants.enderio.machine.invpanel.client.ItemEntry;
|
||||
import crazypants.enderio.machine.invpanel.client.SortOrder;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
@@ -59,8 +64,10 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
private final GuiToolTip ttRefill;
|
||||
private final VScrollbar scrollbar;
|
||||
private final MultiIconButton btnClear;
|
||||
private final GuiToolTip ttSetReceipe;
|
||||
|
||||
private int scrollPos;
|
||||
private int ghostSlotTooltipStacksize;
|
||||
|
||||
private final String headerCrafting;
|
||||
private final String headerReturn;
|
||||
@@ -83,10 +90,18 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
|
||||
this.view = new DatabaseView();
|
||||
|
||||
int sortMode = te.getGuiSortMode();
|
||||
int sortOrderIdx = sortMode >> 1;
|
||||
SortOrder[] orders = SortOrder.values();
|
||||
if(sortOrderIdx >= 0 && te.getGuiSortMode() < orders.length) {
|
||||
view.setSortOrder(orders[sortOrderIdx], (sortMode & 1) != 0);
|
||||
}
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
tfFilter = new TextFieldEnder(fr, 108, 11, 106, 10);
|
||||
tfFilter.setEnableBackgroundDrawing(false);
|
||||
tfFilter.setText(te.getGuiFilterString());
|
||||
btnSort = new IconButton(this, ID_SORT, 233, 27, getSortOrderIcon()) {
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int x, int y) {
|
||||
@@ -132,6 +147,17 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
ttRefill.setVisible(false);
|
||||
addToolTip(ttRefill);
|
||||
|
||||
list.clear();
|
||||
|
||||
SpecialTooltipHandler.addTooltipFromResources(list, "enderio.gui.inventorypanel.tooltip.setrecipe.line");
|
||||
ttSetReceipe = new GuiToolTip(btnRefill, list) {
|
||||
@Override
|
||||
public boolean shouldDraw() {
|
||||
return super.shouldDraw() && getContainer().hasCraftingRecipe();
|
||||
}
|
||||
};
|
||||
addToolTip(ttSetReceipe);
|
||||
|
||||
list.clear();
|
||||
SpecialTooltipHandler.addTooltipFromResources(list, "enderio.gui.inventorypanel.tooltip.clear.line");
|
||||
btnClear.setToolTip(list.toArray(new String[list.size()]));
|
||||
@@ -146,9 +172,20 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
int sortMode = (view.getSortOrder().ordinal() << 1);
|
||||
if(view.isSortOrderInverted()) {
|
||||
sortMode |= 1;
|
||||
}
|
||||
getTileEntity().setGuiParameter(sortMode, tfFilter.getText());
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
public void setCraftingHelper(ICraftingHelper craftingHelper) {
|
||||
this.craftingHelper = craftingHelper;
|
||||
ttRefill.setVisible(craftingHelper != null);
|
||||
ttSetReceipe.setVisible(craftingHelper == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,7 +209,7 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
if(getContainer().clearCraftingGrid()) {
|
||||
if(craftingHelper != null) {
|
||||
craftingHelper.remove();
|
||||
craftingHelper = null;
|
||||
setCraftingHelper(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,6 +228,10 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
boolean hover = btnRefill.contains(mouseX - sx, mouseY - sy);
|
||||
int iconX = hover ? (isShiftKeyDown() ? 48 : 24) : 0;
|
||||
drawTexturedModalRect(sx + btnRefill.x - 2, sy + btnRefill.y - 2, iconX, 232, 24, 24);
|
||||
} else if(getContainer().hasCraftingRecipe()) {
|
||||
boolean hover = btnRefill.contains(mouseX - sx, mouseY - sy);
|
||||
int iconX = hover ? 96 : 72;
|
||||
drawTexturedModalRect(sx + btnRefill.x - 2, sy + btnRefill.y - 2, iconX, 232, 24, 24);
|
||||
}
|
||||
|
||||
int headerColor = 0x404040;
|
||||
@@ -200,7 +241,7 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
fr.drawString(headerInventory, sx + 38, sy + 120, headerColor);
|
||||
|
||||
TileInventoryPanel te = getTileEntity();
|
||||
NutrientTank fuelTank = te.fuelTank;
|
||||
SmartTank fuelTank = te.fuelTank;
|
||||
if(fuelTank.getFluidAmount() > 0) {
|
||||
RenderUtil.renderGuiTank(fuelTank.getFluid(), fuelTank.getCapacity(), fuelTank.getFluidAmount(), sx + 12, sy + 132, zLevel, 16, 47);
|
||||
}
|
||||
@@ -236,13 +277,40 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
font = fontRendererObj;
|
||||
}
|
||||
String str = null;
|
||||
if(stack.stackSize > 999) {
|
||||
str = (stack.stackSize / 1000) + "k";
|
||||
if(stack.stackSize >= 1000) {
|
||||
int value = stack.stackSize / 1000;
|
||||
String unit = "k";
|
||||
if(value >= 1000) {
|
||||
value /= 1000;
|
||||
unit = "m";
|
||||
}
|
||||
str = value + unit;
|
||||
}
|
||||
itemRender.renderItemAndEffectIntoGUI(font, mc.renderEngine, stack, x, y);
|
||||
itemRender.renderItemOverlayIntoGUI(font, mc.renderEngine, stack, x, y, str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGhostSlotTooltip(GhostSlot slot, int mouseX, int mouseY) {
|
||||
ItemStack stack = slot.getStack();
|
||||
if(stack != null) {
|
||||
ghostSlotTooltipStacksize = stack.stackSize;
|
||||
try {
|
||||
renderToolTip(stack, mouseX, mouseY);
|
||||
} finally {
|
||||
ghostSlotTooltipStacksize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawHoveringText(List list, int mouseX, int mouseY, FontRenderer font) {
|
||||
if(ghostSlotTooltipStacksize >= 1000) {
|
||||
list.add(EnumChatFormatting.WHITE + EnderIO.lang.localize("gui.inventorypanel.tooltip.itemsstored", Integer.toString(ghostSlotTooltipStacksize)));
|
||||
}
|
||||
super.drawHoveringText(list, mouseX, mouseY, font);
|
||||
}
|
||||
|
||||
public InventoryPanelContainer getContainer() {
|
||||
return (InventoryPanelContainer) inventorySlots;
|
||||
}
|
||||
@@ -323,6 +391,19 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
return 212;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public boolean hideItemPanelSlot(GuiContainer gc, int x, int y, int w, int h) {
|
||||
// NEI seems to have an issue with the shifted GUI position - so let's work around it
|
||||
if(x+w >= guiLeft && x < guiLeft+xSize && y+h >= guiTop && y < guiTop+49) {
|
||||
return true;
|
||||
}
|
||||
if(x+w >= guiLeft && x < guiLeft+232 && x+h >= guiTop+49 && y < guiTop+ySize) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
super.mouseClicked(x, y, button);
|
||||
@@ -330,12 +411,21 @@ public class GuiInventoryPanel extends GuiMachineBase<TileInventoryPanel> {
|
||||
x -= guiLeft;
|
||||
y -= guiTop;
|
||||
|
||||
if(craftingHelper != null && btnRefill.contains(x, y)) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
craftingHelper.refill(this, isShiftKeyDown() ? 64 : 1);
|
||||
if(btnRefill.contains(x, y)) {
|
||||
if(craftingHelper != null) {
|
||||
playClickSound();
|
||||
craftingHelper.refill(this, isShiftKeyDown() ? 64 : 1);
|
||||
} else if(getContainer().hasCraftingRecipe()) {
|
||||
playClickSound();
|
||||
setCraftingHelper(CraftingHelper.createFromSlots(getContainer().getCraftingGridSlots()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playClickSound() {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseWheel(int x, int y, int delta) {
|
||||
super.mouseWheel(x, y, delta);
|
||||
|
||||
@@ -240,6 +240,10 @@ public class InventoryPanelContainer extends AbstractMachineContainer implements
|
||||
return cleared;
|
||||
}
|
||||
|
||||
public boolean hasCraftingRecipe() {
|
||||
return getSlot(slotCraftResult).getHasStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<SlotRange> getTargetSlotsForTransfer(int slotIndex, Slot slot) {
|
||||
if((slotIndex == slotCraftResult) || (slotIndex >= firstSlotReturn && slotIndex < endSlotReturn)) {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package crazypants.enderio.machine.invpanel;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
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;
|
||||
|
||||
public class PacketGuiSettings extends MessageTileEntity<TileInventoryPanel> implements IMessageHandler<PacketGuiSettings, IMessage> {
|
||||
|
||||
private int sortMode;
|
||||
private String filterString;
|
||||
|
||||
public PacketGuiSettings() {
|
||||
filterString = "";
|
||||
}
|
||||
|
||||
public PacketGuiSettings(TileInventoryPanel tile, int sortMode, String filterString) {
|
||||
super(tile);
|
||||
this.sortMode = sortMode;
|
||||
this.filterString = filterString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
sortMode = buf.readInt();
|
||||
int len = buf.readUnsignedShort();
|
||||
if(len > 0) {
|
||||
byte[] utf8 = new byte[len];
|
||||
buf.readBytes(utf8);
|
||||
try {
|
||||
filterString = new String(utf8, "UTF8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
// should not happen - if it does we can't do anything
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(sortMode);
|
||||
if(filterString.isEmpty()) {
|
||||
buf.writeShort(0);
|
||||
} else {
|
||||
try {
|
||||
byte[] utf8 = filterString.getBytes("UTF8");
|
||||
buf.writeShort((short) utf8.length);
|
||||
buf.writeBytes(utf8);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
// should not happen - if it does we can't do anything
|
||||
buf.writeShort(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketGuiSettings message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
if(te instanceof TileInventoryPanel) {
|
||||
TileInventoryPanel teInvPanel = (TileInventoryPanel) te;
|
||||
teInvPanel.setGuiParameter(message.sortMode, message.filterString);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.enderio.core.api.common.util.ITankAccess;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.item.FilterRegister;
|
||||
@@ -23,12 +24,12 @@ import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.machine.generator.zombie.IHasNutrientTank;
|
||||
import crazypants.enderio.machine.generator.zombie.NutrientTank;
|
||||
import crazypants.enderio.machine.generator.zombie.PacketNutrientTank;
|
||||
import crazypants.enderio.machine.invpanel.client.ClientDatabaseManager;
|
||||
import crazypants.enderio.machine.invpanel.client.InventoryDatabaseClient;
|
||||
import crazypants.enderio.machine.invpanel.server.InventoryDatabaseServer;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
public class TileInventoryPanel extends AbstractMachineEntity implements IFluidHandler, ITankAccess, IHasNutrientTank {
|
||||
|
||||
@@ -37,7 +38,7 @@ public class TileInventoryPanel extends AbstractMachineEntity implements IFluidH
|
||||
public static final int SLOT_VIEW_FILTER = 10;
|
||||
public static final int SLOT_RETURN_START = 11;
|
||||
|
||||
protected final NutrientTank fuelTank;
|
||||
protected final SmartTank fuelTank;
|
||||
protected boolean tanksDirty;
|
||||
|
||||
private InventoryDatabaseServer dbServer;
|
||||
@@ -48,9 +49,12 @@ public class TileInventoryPanel extends AbstractMachineEntity implements IFluidH
|
||||
public Container eventHandler;
|
||||
private IItemFilter itemFilter;
|
||||
|
||||
private int guiSortMode;
|
||||
private String guiFilterString = "";
|
||||
|
||||
public TileInventoryPanel() {
|
||||
super(new SlotDefinition(0, 8, 11, 20, 21, 20));
|
||||
this.fuelTank = new NutrientTank(2000);
|
||||
this.fuelTank = new SmartTank(EnderIO.fluidNutrientDistillation, 2000);
|
||||
}
|
||||
|
||||
public InventoryDatabaseServer getDatabaseServer() {
|
||||
@@ -202,16 +206,38 @@ public class TileInventoryPanel extends AbstractMachineEntity implements IFluidH
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getGuiSortMode() {
|
||||
return guiSortMode;
|
||||
}
|
||||
|
||||
public String getGuiFilterString() {
|
||||
return guiFilterString;
|
||||
}
|
||||
|
||||
public void setGuiParameter(int sortMode, String filterString) {
|
||||
this.guiSortMode = sortMode;
|
||||
this.guiFilterString = filterString;
|
||||
if(worldObj != null && worldObj.isRemote) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketGuiSettings(this, sortMode, filterString));
|
||||
} else {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
fuelTank.writeCommon("fuelTank", nbtRoot);
|
||||
nbtRoot.setInteger("guiSortMode", guiSortMode);
|
||||
nbtRoot.setString("guiFilterString", guiFilterString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
fuelTank.readCommon("fuelTank", nbtRoot);
|
||||
guiSortMode = nbtRoot.getInteger("guiSortMode");
|
||||
guiFilterString = nbtRoot.getString("guiFilterString");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,7 +322,7 @@ public class TileInventoryPanel extends AbstractMachineEntity implements IFluidH
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutrientTank getNutrientTank() {
|
||||
public SmartTank getNutrientTank() {
|
||||
return fuelTank;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
package crazypants.enderio.machine.invpanel.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.enderio.core.common.util.ItemUtil;
|
||||
|
||||
import crazypants.enderio.machine.invpanel.GuiInventoryPanel;
|
||||
import crazypants.enderio.machine.invpanel.InventoryPanelContainer;
|
||||
import crazypants.enderio.machine.invpanel.PacketFetchItem;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class CraftingHelper implements ICraftingHelper {
|
||||
final ItemStack[][] ingredients;
|
||||
|
||||
public CraftingHelper(ItemStack[][] ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
public static ICraftingHelper createFromSlots(List<Slot> slots) {
|
||||
if (slots.size() != 9) {
|
||||
return null;
|
||||
}
|
||||
ItemStack[][] ingredients = new ItemStack[9][];
|
||||
int count = 0;
|
||||
for (int idx = 0; idx < 9; idx++) {
|
||||
Slot slot = slots.get(idx);
|
||||
ItemStack stack = slot.getStack();
|
||||
if(stack != null) {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
ingredients[idx] = new ItemStack[] { stack };
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
return new CraftingHelper(ingredients);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refill(GuiInventoryPanel gui, int amount) {
|
||||
InventoryPanelContainer container = gui.getContainer();
|
||||
InventoryDatabaseClient db = gui.getDatabase();
|
||||
List<Slot> craftingGrid = container.getCraftingGridSlots();
|
||||
int slotsToProcess = (1 << 9) - 1;
|
||||
boolean madeProgress;
|
||||
int maxAmount = 64;
|
||||
do {
|
||||
Candidate[] candidates = new Candidate[9];
|
||||
for (int idx = 0; idx < 9; idx++) {
|
||||
if ((slotsToProcess & (1 << idx)) != 0) {
|
||||
ItemStack[] pstack = ingredients[idx];
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
ItemStack stack = slot.getStack();
|
||||
if (pstack == null) {
|
||||
if (stack != null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Candidate candidate;
|
||||
if (stack != null) {
|
||||
if (!isStackCompatible(pstack, stack)) {
|
||||
return;
|
||||
}
|
||||
candidate = findCandidates(stack, gui, db, candidates);
|
||||
} else {
|
||||
candidate = findAllCandidates(pstack, gui, db, candidates);
|
||||
}
|
||||
if (candidate == null) {
|
||||
return;
|
||||
}
|
||||
candidate.used++;
|
||||
candidates[idx] = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
int targetAmount = maxAmount;
|
||||
int currentAmount = 0;
|
||||
for (int idx = 0; idx < 9; idx++) {
|
||||
Candidate candidate = candidates[idx];
|
||||
if (candidate != null) {
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
int current = getSlotStackSize(slot);
|
||||
int maxStackSize = candidate.stack.getMaxStackSize();
|
||||
currentAmount = Math.max(currentAmount, current);
|
||||
if (candidate.stack.isStackable() && maxStackSize > 1) {
|
||||
targetAmount = Math.min(targetAmount, current + Math.min(maxStackSize, candidate.getAvailable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
targetAmount = Math.min(targetAmount, currentAmount + amount);
|
||||
madeProgress = false;
|
||||
for (int idx = 0; idx < 9; idx++) {
|
||||
final int mask = 1 << idx;
|
||||
Candidate candidate = candidates[idx];
|
||||
if (candidate != null) {
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
for (Slot srcSlot : candidate.sourceSlots) {
|
||||
int current = getSlotStackSize(slot);
|
||||
if (current >= targetAmount) {
|
||||
break;
|
||||
}
|
||||
if (container.moveItems(srcSlot.slotNumber, slot.slotNumber, slot.slotNumber + 1, targetAmount - current)) {
|
||||
slotsToProcess &= ~mask;
|
||||
madeProgress = true;
|
||||
}
|
||||
}
|
||||
int current = getSlotStackSize(slot);
|
||||
if (candidate.entry != null) {
|
||||
if (current < targetAmount) {
|
||||
int toMove = Math.min(candidate.entry.getCount(), targetAmount - current);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFetchItem(db.getGeneration(), candidate.entry, slot.slotNumber, toMove));
|
||||
slotsToProcess &= ~mask;
|
||||
current += toMove;
|
||||
}
|
||||
}
|
||||
if (current > 0) {
|
||||
maxAmount = Math.min(maxAmount, current);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (madeProgress && slotsToProcess != 0);
|
||||
}
|
||||
|
||||
private static int getSlotStackSize(Slot slot) {
|
||||
ItemStack stack = slot.getStack();
|
||||
return (stack != null) ? stack.stackSize : 0;
|
||||
}
|
||||
|
||||
private static boolean isStackCompatible(ItemStack[] pstack, ItemStack stack) {
|
||||
for (ItemStack istack : pstack) {
|
||||
if (ItemUtil.areStackMergable(stack, istack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Candidate findAllCandidates(ItemStack[] pstack, GuiInventoryPanel gui, InventoryDatabaseClient db, Candidate[] candidates) {
|
||||
Candidate bestInventory = null;
|
||||
Candidate bestNetwork = null;
|
||||
for (ItemStack istack : pstack) {
|
||||
Candidate candidate = findCandidates(istack, gui, db, candidates);
|
||||
if (candidate.available > 0) {
|
||||
if (bestInventory == null || bestInventory.available < candidate.available) {
|
||||
bestInventory = candidate;
|
||||
}
|
||||
}
|
||||
if (candidate.entry != null) {
|
||||
if (bestNetwork == null || bestNetwork.entry.getCount() < candidate.entry.getCount()) {
|
||||
bestNetwork = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestInventory != null) {
|
||||
return bestInventory;
|
||||
} else {
|
||||
return bestNetwork;
|
||||
}
|
||||
}
|
||||
|
||||
private Candidate findCandidates(ItemStack stack, GuiInventoryPanel gui, InventoryDatabaseClient db, Candidate[] candidates) {
|
||||
for (Candidate candidate : candidates) {
|
||||
if (candidate != null && ItemUtil.areStackMergable(candidate.stack, stack)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
Candidate candidate = new Candidate(stack);
|
||||
InventoryPanelContainer container = gui.getContainer();
|
||||
findCandidates(candidate, stack, container.getReturnAreaSlots());
|
||||
findCandidates(candidate, stack, container.getPlayerInventorySlots());
|
||||
findCandidates(candidate, stack, container.getPlayerHotbarSlots());
|
||||
if (candidate.available == 0 && db != null) {
|
||||
candidate.entry = db.lookupItem(stack, null, false);
|
||||
if (candidate.entry != null && candidate.entry.getCount() <= 0) {
|
||||
candidate.entry = null;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private void findCandidates(Candidate candidates, ItemStack stack, Collection<Slot> slots) {
|
||||
for (Slot slot : slots) {
|
||||
ItemStack slotStack = slot.getStack();
|
||||
if (slotStack != null && ItemUtil.areStackMergable(slotStack, stack)) {
|
||||
candidates.sourceSlots.add(slot);
|
||||
candidates.available += slotStack.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Candidate {
|
||||
final ItemStack stack;
|
||||
final ArrayList<Slot> sourceSlots = new ArrayList<Slot>();
|
||||
ItemEntry entry;
|
||||
int available;
|
||||
int used;
|
||||
|
||||
public Candidate(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public int getAvailable() {
|
||||
int avail = available;
|
||||
if(entry != null) {
|
||||
avail += entry.getCount();
|
||||
}
|
||||
if(avail > 0 && used > 1) {
|
||||
avail = Math.max(1, avail / used);
|
||||
}
|
||||
return avail;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-203
@@ -1,6 +1,5 @@
|
||||
package crazypants.enderio.machine.invpanel.client;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.OffsetPositioner;
|
||||
import codechicken.nei.PositionedStack;
|
||||
@@ -10,10 +9,6 @@ import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import crazypants.enderio.machine.invpanel.GuiInventoryPanel;
|
||||
import crazypants.enderio.machine.invpanel.InventoryPanelContainer;
|
||||
import crazypants.enderio.machine.invpanel.PacketFetchItem;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -40,9 +35,15 @@ public class InventoryPanelNEIOverlayHandler implements IOverlayHandler {
|
||||
shift = guiInvPanel.getContainer().clearCraftingGrid();
|
||||
}
|
||||
|
||||
PositionedStack[] slots = mapSlots(ingredients, guiInvPanel.getContainer());
|
||||
ItemStack[][] slots = mapSlots(ingredients, guiInvPanel.getContainer());
|
||||
if(slots != null) {
|
||||
CraftingHelper helper = new CraftingHelper(slots);
|
||||
CraftingHelper helper = new CraftingHelper(slots) {
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
LayoutManager.overlayRenderer = null;
|
||||
}
|
||||
};
|
||||
guiInvPanel.setCraftingHelper(helper);
|
||||
if(shift) {
|
||||
helper.refill(guiInvPanel, 64);
|
||||
@@ -52,15 +53,15 @@ public class InventoryPanelNEIOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private PositionedStack[] mapSlots(List<PositionedStack> ingredients, InventoryPanelContainer c) {
|
||||
PositionedStack[] slots = new PositionedStack[9];
|
||||
private ItemStack[][] mapSlots(List<PositionedStack> ingredients, InventoryPanelContainer c) {
|
||||
ItemStack[][] slots = new ItemStack[9][];
|
||||
List<Slot> craftingGrid = c.getCraftingGridSlots();
|
||||
int found = 0;
|
||||
for(PositionedStack pstack : ingredients) {
|
||||
for(int idx = 0; idx < 9 ; idx++) {
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
if(slot.xDisplayPosition == pstack.relx + CRAFTING_GRID_OFFSET_X && slot.yDisplayPosition == pstack.rely + CRAFTING_GRID_OFFSET_Y) {
|
||||
slots[idx] = pstack;
|
||||
slots[idx] = pstack.items;
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
@@ -71,197 +72,4 @@ public class InventoryPanelNEIOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
static class CraftingHelper implements ICraftingHelper {
|
||||
final PositionedStack[] ingredients;
|
||||
|
||||
public CraftingHelper(PositionedStack[] ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
LayoutManager.overlayRenderer = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refill(GuiInventoryPanel gui, int amount) {
|
||||
InventoryPanelContainer container = gui.getContainer();
|
||||
InventoryDatabaseClient db = gui.getDatabase();
|
||||
List<Slot> craftingGrid = container.getCraftingGridSlots();
|
||||
int slotsToProcess = (1<<9)-1;
|
||||
boolean madeProgress;
|
||||
int maxAmount = 64;
|
||||
do {
|
||||
Candidate[] candidates = new Candidate[9];
|
||||
for(int idx = 0; idx < 9; idx++) {
|
||||
if((slotsToProcess & (1 << idx)) != 0) {
|
||||
PositionedStack pstack = ingredients[idx];
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
ItemStack stack = slot.getStack();
|
||||
if(pstack == null) {
|
||||
if(stack != null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Candidate candidate;
|
||||
if(stack != null) {
|
||||
if(!isStackCompatible(pstack, stack)) {
|
||||
return;
|
||||
}
|
||||
candidate = findCandidates(stack, gui, db, candidates);
|
||||
} else {
|
||||
candidate = findAllCandidates(pstack, gui, db, candidates);
|
||||
}
|
||||
|
||||
if(candidate == null) {
|
||||
return;
|
||||
}
|
||||
candidate.used++;
|
||||
candidates[idx] = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int targetAmount = maxAmount;
|
||||
int currentAmount = 0;
|
||||
for(int idx = 0; idx < 9; idx++) {
|
||||
Candidate candidate = candidates[idx];
|
||||
if(candidate != null) {
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
int current = getSlotStackSize(slot);
|
||||
int maxStackSize = candidate.stack.getMaxStackSize();
|
||||
currentAmount = Math.max(currentAmount, current);
|
||||
if(candidate.stack.isStackable() && maxStackSize > 1) {
|
||||
targetAmount = Math.min(targetAmount, current + Math.min(maxStackSize, candidate.getAvailable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetAmount = Math.min(targetAmount, currentAmount + amount);
|
||||
madeProgress = false;
|
||||
for(int idx = 0; idx < 9; idx++) {
|
||||
final int mask = 1 << idx;
|
||||
Candidate candidate = candidates[idx];
|
||||
if(candidate != null) {
|
||||
Slot slot = craftingGrid.get(idx);
|
||||
for(Slot srcSlot : candidate.sourceSlots) {
|
||||
int current = getSlotStackSize(slot);
|
||||
if(current >= targetAmount) {
|
||||
break;
|
||||
}
|
||||
if(container.moveItems(srcSlot.slotNumber, slot.slotNumber, slot.slotNumber+1, targetAmount - current)) {
|
||||
slotsToProcess &= ~mask;
|
||||
madeProgress = true;
|
||||
}
|
||||
}
|
||||
|
||||
int current = getSlotStackSize(slot);
|
||||
if(candidate.entry != null) {
|
||||
if(current < targetAmount) {
|
||||
int toMove = Math.min(candidate.entry.getCount(), targetAmount - current);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFetchItem(db.getGeneration(), candidate.entry, slot.slotNumber, toMove));
|
||||
slotsToProcess &= ~mask;
|
||||
current += toMove;
|
||||
}
|
||||
}
|
||||
|
||||
if(current > 0) {
|
||||
maxAmount = Math.min(maxAmount, current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}while(madeProgress && slotsToProcess != 0);
|
||||
}
|
||||
|
||||
private static int getSlotStackSize(Slot slot) {
|
||||
ItemStack stack = slot.getStack();
|
||||
return (stack != null) ? stack.stackSize : 0;
|
||||
}
|
||||
|
||||
private static boolean isStackCompatible(PositionedStack pstack, ItemStack stack) {
|
||||
for(ItemStack istack : pstack.items) {
|
||||
if(InventoryUtils.canStack(stack, istack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Candidate findAllCandidates(PositionedStack pstack, GuiInventoryPanel gui, InventoryDatabaseClient db, Candidate[] candidates) {
|
||||
Candidate bestInventory = null;
|
||||
Candidate bestNetwork = null;
|
||||
for(ItemStack istack : pstack.items) {
|
||||
Candidate candidate = findCandidates(istack, gui, db, candidates);
|
||||
if(candidate.available > 0) {
|
||||
if(bestInventory == null || bestInventory.available < candidate.available) {
|
||||
bestInventory = candidate;
|
||||
}
|
||||
}
|
||||
if(candidate.entry != null) {
|
||||
if(bestNetwork == null || bestNetwork.entry.getCount() < candidate.entry.getCount()) {
|
||||
bestNetwork = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bestInventory != null) {
|
||||
return bestInventory;
|
||||
} else {
|
||||
return bestNetwork;
|
||||
}
|
||||
}
|
||||
|
||||
private Candidate findCandidates(ItemStack stack, GuiInventoryPanel gui, InventoryDatabaseClient db, Candidate[] candidates) {
|
||||
for(Candidate candidate : candidates) {
|
||||
if(candidate != null && InventoryUtils.canStack(candidate.stack, stack)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
Candidate candidate = new Candidate(stack);
|
||||
InventoryPanelContainer container = gui.getContainer();
|
||||
findCandidates(candidate, stack, container.getReturnAreaSlots());
|
||||
findCandidates(candidate, stack, container.getPlayerInventorySlots());
|
||||
findCandidates(candidate, stack, container.getPlayerHotbarSlots());
|
||||
if(candidate.available == 0 && db != null) {
|
||||
candidate.entry = db.lookupItem(stack, null, false);
|
||||
if(candidate.entry != null && candidate.entry.getCount() <= 0) {
|
||||
candidate.entry = null;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private void findCandidates(Candidate candidates, ItemStack stack, Collection<Slot> slots) {
|
||||
for(Slot slot : slots) {
|
||||
ItemStack slotStack = slot.getStack();
|
||||
if(slotStack != null && InventoryUtils.canStack(slotStack, stack)) {
|
||||
candidates.sourceSlots.add(slot);
|
||||
candidates.available += slotStack.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Candidate {
|
||||
final ItemStack stack;
|
||||
final ArrayList<Slot> sourceSlots = new ArrayList<Slot>();
|
||||
ItemEntry entry;
|
||||
int available;
|
||||
int used;
|
||||
|
||||
public Candidate(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public int getAvailable() {
|
||||
int avail = available;
|
||||
if(entry != null) {
|
||||
avail += entry.getCount();
|
||||
}
|
||||
if(avail > 0 && used > 1) {
|
||||
avail = Math.max(1, avail / used);
|
||||
}
|
||||
return avail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,10 @@ import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.machine.generator.zombie.IHasNutrientTank;
|
||||
import crazypants.enderio.machine.generator.zombie.NutrientTank;
|
||||
import crazypants.enderio.machine.generator.zombie.PacketNutrientTank;
|
||||
import crazypants.enderio.machine.wireless.WirelessChargedLocation;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
import crazypants.enderio.xp.ExperienceContainer;
|
||||
import crazypants.enderio.xp.IHaveExperience;
|
||||
import crazypants.enderio.xp.PacketExperianceContainer;
|
||||
@@ -63,7 +63,7 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
|
||||
|
||||
protected WirelessChargedLocation chargedLocation;
|
||||
|
||||
final NutrientTank fuelTank = new NutrientTank(FluidContainerRegistry.BUCKET_VOLUME * 2);
|
||||
final SmartTank fuelTank = new SmartTank(EnderIO.fluidNutrientDistillation, FluidContainerRegistry.BUCKET_VOLUME * 2);
|
||||
|
||||
int lastFluidLevelUpdate;
|
||||
|
||||
@@ -569,7 +569,7 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutrientTank getNutrientTank() {
|
||||
public SmartTank getNutrientTank() {
|
||||
return fuelTank;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
import com.enderio.core.common.TileEntityEnder;
|
||||
import com.enderio.core.common.util.Util;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -186,7 +187,7 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
|
||||
}
|
||||
return Blocks.anvil.getIcon(world, x, y, z, blockSide);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister IIconRegister) {
|
||||
@@ -240,6 +241,11 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
|
||||
super(Blocks.glowstone, BlockPaintedGlowstone.this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPaintSource(ItemStack paintSource) {
|
||||
return super.isValidPaintSource(paintSource) && Util.getBlockFromItemId(paintSource).isOpaqueCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -171,7 +172,7 @@ public class ReservoirRenderer extends TileEntitySpecialRenderer implements IRes
|
||||
|
||||
private IIcon getLiquidTexture() {
|
||||
if(tex == null) {
|
||||
tex = ReservoirTank.WATER.getFluid().getStillIcon();
|
||||
tex = FluidRegistry.WATER.getStillIcon();
|
||||
}
|
||||
return tex;
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
package crazypants.enderio.machine.reservoir;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public class ReservoirTank extends FluidTank {
|
||||
|
||||
static final FluidStack WATER = FluidRegistry.getFluidStack("water", 0);
|
||||
|
||||
ReservoirTank(int quantity, int capacity) {
|
||||
super(WATER.getFluid(), quantity, capacity);
|
||||
}
|
||||
|
||||
ReservoirTank(int capacity) {
|
||||
this(0, capacity);
|
||||
}
|
||||
|
||||
ReservoirTank(FluidStack liquid, int capacity) {
|
||||
super(liquid, capacity);
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return getFluid().amount;
|
||||
}
|
||||
|
||||
public float getFilledRatio() {
|
||||
return (float) getAmount() / getCapacity();
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
return getAmount() >= getCapacity();
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
FluidStack newLiquid = WATER.copy();
|
||||
newLiquid.amount = Math.min(getCapacity(), amount);
|
||||
setFluid(newLiquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
FluidStack l = super.getFluid();
|
||||
if(l == null) {
|
||||
l = WATER.copy();
|
||||
setFluid(l);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public int getAvailableSpace() {
|
||||
return getCapacity() - getAmount();
|
||||
}
|
||||
|
||||
public void addAmount(int amount) {
|
||||
setAmount(getAmount() + amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapacity(int capacity) {
|
||||
super.setCapacity(capacity);
|
||||
if(getAmount() > capacity) {
|
||||
setAmount(capacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.enderio.core.common.vecmath.Vector3f;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
import static net.minecraftforge.fluids.FluidContainerRegistry.BUCKET_VOLUME;
|
||||
|
||||
@@ -68,9 +69,9 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
|
||||
// Position within multiblock
|
||||
Pos pos = Pos.UNKNOWN;
|
||||
|
||||
ReservoirTank tank = new ReservoirTank(BUCKET_VOLUME);
|
||||
SmartTank tank = new SmartTank(FluidRegistry.WATER, BUCKET_VOLUME);
|
||||
|
||||
ReservoirTank regenTank = null;
|
||||
SmartTank regenTank = null;
|
||||
|
||||
boolean autoEject;
|
||||
|
||||
@@ -107,8 +108,8 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
|
||||
if(autoEject && neighboursDirty) {
|
||||
doUpdateTankNeighbours();
|
||||
}
|
||||
if(autoEject && tankNeighbours != null && !tankNeighbours.isEmpty() && tank.getAmount() > 0) {
|
||||
int ejectable = tank.getAmount();
|
||||
if(autoEject && tankNeighbours != null && !tankNeighbours.isEmpty() && tank.getFluidAmount() > 0) {
|
||||
int ejectable = tank.getFluidAmount();
|
||||
int amountPerNeighbour = ejectable / tankNeighbours.size();
|
||||
FluidStack source = WATER_BUCKET.copy();
|
||||
int used = 0;
|
||||
@@ -258,13 +259,14 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
|
||||
if(liquid != null) {
|
||||
tank.setFluid(liquid);
|
||||
} else {
|
||||
tank.setAmount(0);
|
||||
tank.setFluidAmount(0);
|
||||
}
|
||||
|
||||
if(regenLiquid == null) {
|
||||
regenTank = null;
|
||||
} else {
|
||||
regenTank = new ReservoirTank(regenLiquid, BUCKET_VOLUME * 2);
|
||||
regenTank = new SmartTank(FluidRegistry.WATER, BUCKET_VOLUME * 2);
|
||||
regenTank.setFluidAmount(regenLiquid.amount);
|
||||
}
|
||||
|
||||
boolean wasMulti = isMultiblock();
|
||||
@@ -301,7 +303,7 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
|
||||
|
||||
nbtRoot.setBoolean("autoEject", autoEject);
|
||||
|
||||
if(tank.getFluid() != null && FluidRegistry.getFluidName(tank.getFluid().fluidID) != null) {
|
||||
if(tank.getFluid() != null && FluidRegistry.getFluidName(tank.getFluid()) != null) {
|
||||
nbtRoot.setTag("tank", tank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
if(regenTank != null) {
|
||||
@@ -418,19 +420,19 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
|
||||
|
||||
if(isMaster()) {
|
||||
|
||||
regenTank = new ReservoirTank(BUCKET_VOLUME * 2);
|
||||
regenTank = new SmartTank(FluidRegistry.WATER, BUCKET_VOLUME * 2);
|
||||
tank.setCapacity(BUCKET_VOLUME * 2);
|
||||
for (BlockCoord bc : multiblock) {
|
||||
TileReservoir res = getReservoir(bc);
|
||||
if(res != null) {
|
||||
FluidStack drained = res.doDrain(ForgeDirection.UNKNOWN, regenTank.getAvailableSpace(), true);
|
||||
if(drained != null) {
|
||||
regenTank.addAmount(drained.amount);
|
||||
regenTank.addFluidAmount(drained.amount);
|
||||
}
|
||||
// incase regen tank is full, add to normal tank
|
||||
drained = res.doDrain(ForgeDirection.UNKNOWN, tank.getAvailableSpace(), true);
|
||||
if(drained != null) {
|
||||
tank.addAmount(drained.amount);
|
||||
tank.addFluidAmount(drained.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -683,10 +685,10 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
|
||||
@Override
|
||||
public void setTanksDirty() {
|
||||
if (isMaster() && regenTank != null && tank != null) {
|
||||
if (!regenTank.isFull() && tank.getAmount() > 0) {
|
||||
int toMove = Math.min(tank.getAmount(), regenTank.getCapacity() - regenTank.getAmount());
|
||||
regenTank.setAmount(regenTank.getAmount() + toMove);
|
||||
tank.setAmount(tank.getAmount() - toMove);
|
||||
if (!regenTank.isFull() && tank.getFluidAmount() > 0) {
|
||||
int toMove = Math.min(tank.getFluidAmount(), regenTank.getCapacity() - regenTank.getFluidAmount());
|
||||
regenTank.setFluidAmount(regenTank.getFluidAmount() + toMove);
|
||||
tank.setFluidAmount(tank.getFluidAmount() - toMove);
|
||||
}
|
||||
}
|
||||
tankDirty = true;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package crazypants.enderio.machine.tank;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public class FluidTankEio extends FluidTank {
|
||||
|
||||
public FluidTankEio(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public float getFilledRatio() {
|
||||
return (float) getFluidAmount() / getCapacity();
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
return getFluidAmount() >= getCapacity();
|
||||
}
|
||||
|
||||
public boolean canDrainFluidType(FluidStack resource) {
|
||||
if(resource == null || resource.getFluid() == null || fluid == null) {
|
||||
return false;
|
||||
}
|
||||
return fluid.isFluidEqual(resource);
|
||||
}
|
||||
|
||||
public boolean canDrainFluidType(Fluid fl) {
|
||||
if(fl == null || fluid == null) {
|
||||
return false;
|
||||
}
|
||||
return fl.getID() == fluid.fluidID;
|
||||
}
|
||||
|
||||
public FluidStack drain(FluidStack resource, boolean doDrain) {
|
||||
if(!canDrainFluidType(resource)) {
|
||||
return null;
|
||||
}
|
||||
return drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.enderio.core.client.render.RenderUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TankFluidRenderer extends TileEntitySpecialRenderer {
|
||||
@@ -27,7 +28,7 @@ public class TankFluidRenderer extends TileEntitySpecialRenderer {
|
||||
renderTankFluid(tank.tank, (float)x, (float)y, (float)z);
|
||||
}
|
||||
|
||||
public static void renderTankFluid(FluidTankEio tank, float x, float y, float z) {
|
||||
public static void renderTankFluid(SmartTank tank, float x, float y, float z) {
|
||||
if(tank == null || tank.getFluid() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
public class TileTank extends AbstractMachineEntity implements IFluidHandler, ITankAccess {
|
||||
|
||||
private static int IO_MB_TICK = 100;
|
||||
|
||||
protected FluidTankEio tank;// = new FluidTankEio(16000);
|
||||
protected SmartTank tank;// = new FluidTankEio(16000);
|
||||
protected int lastUpdateLevel = -1;
|
||||
|
||||
private boolean tankDirty = false;
|
||||
@@ -38,9 +39,9 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler, IT
|
||||
public TileTank(int meta) {
|
||||
super(new SlotDefinition(0, 1, 2, 3, -1, -1));
|
||||
if(meta == 1) {
|
||||
tank = new FluidTankEio(32000);
|
||||
tank = new SmartTank(32000);
|
||||
} else {
|
||||
tank = new FluidTankEio(16000);
|
||||
tank = new SmartTank(16000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,9 +348,9 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler, IT
|
||||
int tankType = nbtRoot.getInteger("tankType");
|
||||
tankType = MathHelper.clamp_int(tankType, 0, 1);
|
||||
if(tankType == 1) {
|
||||
tank = new FluidTankEio(32000);
|
||||
tank = new SmartTank(32000);
|
||||
} else {
|
||||
tank = new FluidTankEio(16000);
|
||||
tank = new SmartTank(16000);
|
||||
}
|
||||
|
||||
if(nbtRoot.hasKey("tankContents")) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package crazypants.enderio.teleport;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.teleport.packet.PacketConfigSync;
|
||||
|
||||
public class ConnectionHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerLoggon(PlayerLoggedInEvent evt) {
|
||||
PacketHandler.INSTANCE.sendTo(new PacketConfigSync(), (EntityPlayerMP) evt.player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,5 +43,8 @@ public class TeleportRecipes {
|
||||
ItemStack fq = new ItemStack(EnderIO.blockFusedQuartz, 1, BlockFusedQuartz.Type.FUSED_QUARTZ.ordinal());
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(telepad, "gSg", "dAd", "dod", 'g', fq, 'S', staff, 'd', "ingotDarkSteel", 'A', travelBlock, 'o', octadic));
|
||||
}
|
||||
|
||||
ItemStack coordSelector = new ItemStack(EnderIO.itemCoordSelector);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(coordSelector, "sps", " cs", " s", 's', "ingotElectricalSteel", 'p', Items.ender_pearl, 'c', Items.compass));
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import net.minecraftforge.common.UsernameCache;
|
||||
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
|
||||
import com.enderio.core.common.TileEntityEnder;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -36,13 +35,11 @@ import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.painter.BasicPainterTemplate;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.teleport.ConnectionHandler;
|
||||
import crazypants.enderio.teleport.ContainerTravelAccessable;
|
||||
import crazypants.enderio.teleport.ContainerTravelAuth;
|
||||
import crazypants.enderio.teleport.GuiTravelAccessable;
|
||||
import crazypants.enderio.teleport.GuiTravelAuth;
|
||||
import crazypants.enderio.teleport.packet.PacketAccessMode;
|
||||
import crazypants.enderio.teleport.packet.PacketConfigSync;
|
||||
import crazypants.enderio.teleport.packet.PacketDrainStaff;
|
||||
import crazypants.enderio.teleport.packet.PacketLabel;
|
||||
import crazypants.enderio.teleport.packet.PacketOpenAuthGui;
|
||||
@@ -60,10 +57,6 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt
|
||||
PacketHandler.INSTANCE.registerMessage(PacketTravelEvent.class, PacketTravelEvent.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketDrainStaff.class, PacketDrainStaff.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketOpenAuthGui.class, PacketOpenAuthGui.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketConfigSync.class, PacketConfigSync.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
|
||||
ConnectionHandler ch = new ConnectionHandler();
|
||||
FMLCommonHandler.instance().bus().register(ch);
|
||||
|
||||
BlockTravelAnchor result = new BlockTravelAnchor();
|
||||
result.init();
|
||||
|
||||
@@ -9,10 +9,12 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.enderio.core.client.render.CubeRenderer;
|
||||
import com.enderio.core.client.render.TechneModelRenderer;
|
||||
import com.enderio.core.client.render.TechneUtil;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
@@ -38,21 +40,41 @@ public class TelePadRenderer extends TechneModelRenderer {
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
TileTelePad te = (TileTelePad) world.getTileEntity(x, y, z);
|
||||
IIcon cached = renderer.overrideBlockTexture;
|
||||
boolean ret = true;
|
||||
if(te.inNetwork()) {
|
||||
renderer.overrideBlockTexture = null;
|
||||
if(te.isMaster()) {
|
||||
super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
if (te.inNetwork()) {
|
||||
if (renderer.hasOverrideBlockTexture()) {
|
||||
IIcon icon = renderer.overrideBlockTexture;
|
||||
renderer.renderFaceYNeg(block, x, y, z, icon);
|
||||
renderer.renderFaceYPos(block, x, y, z, icon);
|
||||
BlockCoord bc = te.getLocation();
|
||||
if (!isTelepad(world, bc, ForgeDirection.EAST)) {
|
||||
renderer.renderFaceXPos(block, x, y, z, icon);
|
||||
}
|
||||
if (!isTelepad(world, bc, ForgeDirection.WEST)) {
|
||||
renderer.renderFaceXNeg(block, x, y, z, icon);
|
||||
}
|
||||
if (!isTelepad(world, bc, ForgeDirection.SOUTH)) {
|
||||
renderer.renderFaceZPos(block, x, y, z, icon);
|
||||
}
|
||||
if (!isTelepad(world, bc, ForgeDirection.NORTH)) {
|
||||
renderer.renderFaceZNeg(block, x, y, z, icon);
|
||||
}
|
||||
} else {
|
||||
ret = false;
|
||||
if (te.isMaster()) {
|
||||
super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
renderer.overrideBlockTexture = cached;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean isTelepad(IBlockAccess world, BlockCoord pos, ForgeDirection dir) {
|
||||
return pos.getLocation(dir).getTileEntity(world) instanceof TileTelePad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
|
||||
private boolean inNetwork;
|
||||
|
||||
private EnumSet<ForgeDirection> connections = EnumSet.noneOf(ForgeDirection.class);
|
||||
EnumSet<ForgeDirection> connections = EnumSet.noneOf(ForgeDirection.class);
|
||||
|
||||
private EnergyStorage energy = new EnergyStorage(100000, 1000, 1000);
|
||||
|
||||
@@ -343,9 +343,12 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
|
||||
private int calculateTeleportPower() {
|
||||
if (worldObj.provider.dimensionId == targetDim) {
|
||||
this.maxPower = new BlockCoord(this).getDist(target) * 1000;
|
||||
int distance = new BlockCoord(this).getDist(target);
|
||||
double base = Math.log((0.005 * distance) + 1);
|
||||
this.maxPower = (int) (base * Config.telepadPowerCoefficient);
|
||||
|
||||
} else {
|
||||
this.maxPower = 100000;
|
||||
this.maxPower = Config.telepadPowerInterdimensional;
|
||||
}
|
||||
return this.maxPower;
|
||||
}
|
||||
@@ -390,6 +393,11 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
public float getProgress() {
|
||||
return ((float) powerUsed) / ((float) maxPower);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getProgressUpdateFreq() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(float progress) {
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public class SmartTank extends FluidTank {
|
||||
|
||||
protected Fluid restriction;
|
||||
|
||||
public SmartTank(FluidStack liquid, int capacity) {
|
||||
super(liquid, capacity);
|
||||
if (liquid != null) {
|
||||
restriction = liquid.getFluid();
|
||||
} else {
|
||||
restriction = null;
|
||||
}
|
||||
}
|
||||
|
||||
public SmartTank(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public SmartTank(Fluid liquid, int capacity) {
|
||||
super(capacity);
|
||||
restriction = liquid;
|
||||
}
|
||||
|
||||
public void setRestriction(Fluid restriction) {
|
||||
this.restriction = restriction;
|
||||
}
|
||||
|
||||
public float getFilledRatio() {
|
||||
return (float) getFluidAmount() / getCapacity();
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
return getFluidAmount() >= getCapacity();
|
||||
}
|
||||
|
||||
public boolean canDrainFluidType(FluidStack resource) {
|
||||
if(resource == null || resource.getFluid() == null || fluid == null) {
|
||||
return false;
|
||||
}
|
||||
return fluid.isFluidEqual(resource);
|
||||
}
|
||||
|
||||
public boolean canDrainFluidType(Fluid fl) {
|
||||
if(fl == null || fluid == null) {
|
||||
return false;
|
||||
}
|
||||
return fl.getID() == fluid.fluidID;
|
||||
}
|
||||
|
||||
public FluidStack drain(FluidStack resource, boolean doDrain) {
|
||||
if(!canDrainFluidType(resource)) {
|
||||
return null;
|
||||
}
|
||||
return drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
public boolean canFill(FluidStack resource) {
|
||||
if (fluid != null) {
|
||||
return fluid.isFluidEqual(resource);
|
||||
} else if (restriction != null) {
|
||||
return resource.getFluid() != null && restriction.getID() == resource.getFluid().getID();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canFill(Fluid fl) {
|
||||
if (fluid != null) {
|
||||
return fluid.getFluid().getID() == fl.getID();
|
||||
} else if (restriction != null) {
|
||||
return restriction.getID() == fl.getID();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFluidAmount(int amount) {
|
||||
if(amount > 0) {
|
||||
if (fluid != null) {
|
||||
fluid.amount = Math.min(capacity, amount);
|
||||
} else if (restriction != null) {
|
||||
setFluid(new FluidStack(restriction, Math.min(capacity, amount)));
|
||||
} else {
|
||||
throw new RuntimeException("Cannot set fluid amount of an empty tank");
|
||||
}
|
||||
} else {
|
||||
setFluid(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if(!canFill(resource)) {
|
||||
return 0;
|
||||
}
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
if (fluid != null) {
|
||||
return fluid;
|
||||
} else if (restriction != null) {
|
||||
return new FluidStack(restriction, 0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getAvailableSpace() {
|
||||
return getCapacity() - getFluidAmount();
|
||||
}
|
||||
|
||||
public void addFluidAmount(int amount) {
|
||||
setFluidAmount(getFluidAmount() + amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapacity(int capacity) {
|
||||
super.setCapacity(capacity);
|
||||
if(getFluidAmount() > capacity) {
|
||||
setFluidAmount(capacity);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCommon(String name, NBTTagCompound nbtRoot) {
|
||||
if(getFluidAmount() > 0 || restriction != null) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
writeToNBT(tankRoot);
|
||||
if (restriction != null) {
|
||||
tankRoot.setString("FluidRestriction", FluidRegistry.getFluidName(restriction.getID()));
|
||||
}
|
||||
nbtRoot.setTag(name, tankRoot);
|
||||
} else {
|
||||
nbtRoot.removeTag(name);
|
||||
}
|
||||
}
|
||||
|
||||
public void readCommon(String name, NBTTagCompound nbtRoot) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag(name);
|
||||
if(tankRoot != null) {
|
||||
readFromNBT(tankRoot);
|
||||
restriction = null;
|
||||
if (tankRoot.hasKey("FluidRestriction")) {
|
||||
String fluidName = tankRoot.getString("FluidRestriction");
|
||||
if (!Strings.isNullOrEmpty(fluidName)) {
|
||||
restriction = FluidRegistry.getFluid(fluidName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setFluid(null);
|
||||
// not reseting 'restriction' here on purpose
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user