-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recipe Outputs in TOP + Separate RF Producer
- Loading branch information
1 parent
1d68717
commit d41d49e
Showing
12 changed files
with
456 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/nomiceu/nomilabs/gregtech/mixinhelper/AccessibleAbstractRecipeLogic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.nomiceu.nomilabs.gregtech.mixinhelper; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
|
||
public interface AccessibleAbstractRecipeLogic { | ||
|
||
List<ItemStack> labs$getOutputs(); | ||
|
||
List<FluidStack> labs$getFluidOutputs(); | ||
|
||
int labs$getEUt(); | ||
} |
98 changes: 98 additions & 0 deletions
98
src/main/java/com/nomiceu/nomilabs/integration/top/LabsFluidStackElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.nomiceu.nomilabs.integration.top; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import net.minecraft.client.renderer.texture.TextureMap; | ||
import net.minecraftforge.fluids.FluidStack; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import gregtech.api.util.TextFormattingUtil; | ||
import gregtech.client.utils.RenderUtil; | ||
import io.netty.buffer.ByteBuf; | ||
import mcjty.theoneprobe.api.IElement; | ||
import mcjty.theoneprobe.network.NetworkTools; | ||
|
||
/** | ||
* From <a href= | ||
* "https://github.com/Supernoobv/GregicProbeCEu/blob/master/src/main/java/vfyjxf/gregicprobe/element/FluidStackElement.java">GregicProbe</a>. | ||
*/ | ||
public class LabsFluidStackElement implements IElement { | ||
|
||
private final String location; | ||
private final int color; | ||
private final int amount; | ||
|
||
private TextureAtlasSprite sprite = null; | ||
|
||
public LabsFluidStackElement(@NotNull FluidStack stack) { | ||
this.location = stack.getFluid().getStill(stack).toString(); | ||
this.color = stack.getFluid().getColor(stack); | ||
this.amount = stack.amount; | ||
} | ||
|
||
public LabsFluidStackElement(@NotNull ByteBuf buf) { | ||
this.location = NetworkTools.readStringUTF8(buf); | ||
this.color = buf.readInt(); | ||
this.amount = buf.readInt(); | ||
} | ||
|
||
@Override | ||
public void render(int x, int y) { | ||
String actualLocation = location; | ||
|
||
// Gregtech fluids added by GRS do this for some reason | ||
// As a consequence the fluid texture from /dull will not show up on anything from GRS. | ||
if (location.contains("material_sets/fluid/") && (location.contains("/gas") || location.contains("/plasma"))) { | ||
actualLocation = location.replace("material_sets/fluid/", "material_sets/dull/"); | ||
} | ||
|
||
if (sprite == null) { | ||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(actualLocation); | ||
} | ||
|
||
GlStateManager.enableBlend(); | ||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); | ||
|
||
RenderUtil.setGlColorFromInt(color, 0xFF); | ||
RenderUtil.drawFluidTexture(x + 1, y - 1, sprite, 2, 2, 0); | ||
|
||
if (amount > 0) { | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.scale(0.5, 0.5, 1); | ||
Minecraft minecraft = Minecraft.getMinecraft(); | ||
String format = TextFormattingUtil.formatLongToCompactString(amount) + "L"; | ||
minecraft.fontRenderer.drawStringWithShadow( | ||
format, | ||
(x + 16) * 2 - minecraft.fontRenderer.getStringWidth(format), | ||
(y + 16) * 2 - minecraft.fontRenderer.FONT_HEIGHT, | ||
0xFFFFFF); | ||
GlStateManager.popMatrix(); | ||
} | ||
|
||
GlStateManager.disableBlend(); | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return 16; | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return 16; | ||
} | ||
|
||
@Override | ||
public void toBytes(@NotNull ByteBuf buf) { | ||
NetworkTools.writeStringUTF8(buf, location); | ||
buf.writeInt(color); | ||
buf.writeInt(amount); | ||
} | ||
|
||
@Override | ||
public int getID() { | ||
return LabsTOPManager.FLUID_STACK_ELEMENT; | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
src/main/java/com/nomiceu/nomilabs/integration/top/LabsRFInfoProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.nomiceu.nomilabs.integration.top; | ||
|
||
import static mcjty.theoneprobe.api.TextStyleClass.PROGRESS; | ||
|
||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.energy.CapabilityEnergy; | ||
import net.minecraftforge.energy.IEnergyStorage; | ||
import net.minecraftforge.fml.common.Loader; | ||
|
||
import com.nomiceu.nomilabs.LabsValues; | ||
import com.nomiceu.nomilabs.config.LabsConfig; | ||
|
||
import mcjty.lib.api.power.IBigPower; | ||
import mcjty.theoneprobe.api.IProbeHitData; | ||
import mcjty.theoneprobe.api.IProbeInfo; | ||
import mcjty.theoneprobe.api.IProbeInfoProvider; | ||
import mcjty.theoneprobe.api.ProbeMode; | ||
import mcjty.theoneprobe.apiimpl.elements.ElementProgress; | ||
import mcjty.theoneprobe.compat.RedstoneFluxTools; | ||
import mcjty.theoneprobe.config.Config; | ||
|
||
/** | ||
* A duplicate of TOP RF Info Provider Logic, but separate | ||
* Allows for rearranging the RF bar. | ||
*/ | ||
public class LabsRFInfoProvider implements IProbeInfoProvider { | ||
|
||
@Override | ||
public String getID() { | ||
return LabsValues.LABS_MODID + ":rf_provider"; | ||
} | ||
|
||
@Override | ||
public void addProbeInfo(ProbeMode mode, IProbeInfo info, EntityPlayer player, World world, IBlockState state, | ||
IProbeHitData data) { | ||
if (LabsConfig.topSettings.rfProviderMode == 0) return; | ||
|
||
TileEntity te = world.getTileEntity(data.getPos()); | ||
if (te == null) return; | ||
|
||
if (te instanceof IBigPower) { | ||
long energy = ((IBigPower) te).getStoredPower(); | ||
long maxEnergy = ((IBigPower) te).getCapacity(); | ||
addRFInfo(info, LabsConfig.topSettings.rfProviderMode, energy, maxEnergy); | ||
return; | ||
} | ||
|
||
if (Loader.isModLoaded(LabsValues.REDSTONE_FLUX_MODID) && RedstoneFluxTools.isEnergyHandler(te)) { | ||
int energy = RedstoneFluxTools.getEnergy(te); | ||
int maxEnergy = RedstoneFluxTools.getMaxEnergy(te); | ||
addRFInfo(info, LabsConfig.topSettings.rfProviderMode, energy, maxEnergy); | ||
return; | ||
} | ||
|
||
if (te.hasCapability(CapabilityEnergy.ENERGY, null)) { | ||
IEnergyStorage handler = te.getCapability(CapabilityEnergy.ENERGY, null); | ||
if (handler != null) { | ||
addRFInfo(info, LabsConfig.topSettings.rfProviderMode, handler.getEnergyStored(), | ||
handler.getMaxEnergyStored()); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Adds information about Redstone Flux energy based on the given configuration. | ||
* If the RF mode in the configuration is set to 1, a progress bar is displayed with specific styling. | ||
* Otherwise, a text representation of the RF energy is shown. | ||
* | ||
* @author McJty | ||
* | ||
* @param probeInfo The {@link IProbeInfo} object to which the RF information will be added. | ||
* @param rfMode Mode to display RF in. | ||
* @param energy The current amount of RF energy. | ||
* @param maxEnergy The maximum capacity of RF energy. | ||
*/ | ||
private void addRFInfo(IProbeInfo probeInfo, int rfMode, long energy, long maxEnergy) { | ||
if (rfMode == 1) { | ||
probeInfo.progress(energy, maxEnergy, | ||
probeInfo.defaultProgressStyle() | ||
.suffix("RF") | ||
.filledColor(Config.rfbarFilledColor) | ||
.alternateFilledColor(Config.rfbarAlternateFilledColor) | ||
.borderColor(Config.rfbarBorderColor) | ||
.numberFormat(Config.rfFormat)); | ||
} else { | ||
probeInfo.text(PROGRESS + "RF: " + ElementProgress.format(energy, Config.rfFormat, "RF")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.