reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
@@ -1,10 +1,13 @@
package appeng.fluids.client.gui.widgets;
import java.util.Collections;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.container.slot.IJEITargetSlot;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketFluidSlot;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -16,98 +19,78 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketFluidSlot;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank;
import java.util.Collections;
public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot
{
private final IAEFluidTank fluids;
private final int slot;
public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot {
private final IAEFluidTank fluids;
private final int slot;
public GuiFluidSlot( final IAEFluidTank fluids, final int slot, final int id, final int x, final int y )
{
super( id, x, y );
this.fluids = fluids;
this.slot = slot;
}
public GuiFluidSlot(final IAEFluidTank fluids, final int slot, final int id, final int x, final int y) {
super(id, x, y);
this.fluids = fluids;
this.slot = slot;
}
@Override
public void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks )
{
final IAEFluidStack fs = this.getFluidStack();
if( fs != null )
{
GlStateManager.disableLighting();
GlStateManager.disableBlend();
final Fluid fluid = fs.getFluid();
mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() );
@Override
public void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) {
final IAEFluidStack fs = this.getFluidStack();
if (fs != null) {
GlStateManager.disableLighting();
GlStateManager.disableBlend();
final Fluid fluid = fs.getFluid();
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(fluid.getStill().toString());
// Set color for dynamic fluids
// Convert int color to RGB
final float red = ( fluid.getColor() >> 16 & 255 ) / 255.0F;
final float green = ( fluid.getColor() >> 8 & 255 ) / 255.0F;
final float blue = ( fluid.getColor() & 255 ) / 255.0F;
GlStateManager.color( red, green, blue );
// Set color for dynamic fluids
// Convert int color to RGB
final float red = (fluid.getColor() >> 16 & 255) / 255.0F;
final float green = (fluid.getColor() >> 8 & 255) / 255.0F;
final float blue = (fluid.getColor() & 255) / 255.0F;
GlStateManager.color(red, green, blue);
this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() );
}
}
this.drawTexturedModalRect(this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight());
}
}
@Override
public boolean canClick( final EntityPlayer player )
{
final ItemStack mouseStack = player.inventory.getItemStack();
return mouseStack.isEmpty() || mouseStack.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
}
@Override
public boolean canClick(final EntityPlayer player) {
final ItemStack mouseStack = player.inventory.getItemStack();
return mouseStack.isEmpty() || mouseStack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
}
@Override
public void slotClicked( final ItemStack clickStack, int mouseButton )
{
if( clickStack.isEmpty() || mouseButton == 1 )
{
this.setFluidStack( null );
}
else if( mouseButton == 0 )
{
final FluidStack fluid = FluidUtil.getFluidContained( clickStack );
if( fluid != null )
{
this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) );
}
}
}
@Override
public void slotClicked(final ItemStack clickStack, int mouseButton) {
if (clickStack.isEmpty() || mouseButton == 1) {
this.setFluidStack(null);
} else if (mouseButton == 0) {
final FluidStack fluid = FluidUtil.getFluidContained(clickStack);
if (fluid != null) {
this.setFluidStack(AEFluidStack.fromFluidStack(fluid));
}
}
}
@Override
public String getMessage()
{
final IAEFluidStack fluid = this.getFluidStack();
if( fluid != null )
{
return fluid.getFluidStack().getLocalizedName();
}
return null;
}
@Override
public String getMessage() {
final IAEFluidStack fluid = this.getFluidStack();
if (fluid != null) {
return fluid.getFluidStack().getLocalizedName();
}
return null;
}
@Override
public boolean isVisible()
{
return true;
}
@Override
public boolean isVisible() {
return true;
}
public IAEFluidStack getFluidStack()
{
return this.fluids.getFluidInSlot( this.slot );
}
public IAEFluidStack getFluidStack() {
return this.fluids.getFluidInSlot(this.slot);
}
public void setFluidStack( final IAEFluidStack stack )
{
this.fluids.setFluidInSlot( this.slot, stack );
NetworkHandler.instance().sendToServer( new PacketFluidSlot( Collections.singletonMap( this.getId(), this.getFluidStack() ) ) );
}
public void setFluidStack(final IAEFluidStack stack) {
this.fluids.setFluidInSlot(this.slot, stack);
NetworkHandler.instance().sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
}
}
@@ -19,9 +19,12 @@
package appeng.fluids.client.gui.widgets;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.client.gui.widgets.ITooltip;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.fluids.util.IAEFluidTank;
import appeng.helpers.InventoryAction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
@@ -31,127 +34,104 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.ITooltip;
import appeng.fluids.util.IAEFluidTank;
@SideOnly(Side.CLIENT)
public class GuiFluidTank extends GuiCustomSlot implements ITooltip {
private final IAEFluidTank tank;
private final int slot;
private final int width;
private final int height;
@SideOnly( Side.CLIENT )
public class GuiFluidTank extends GuiCustomSlot implements ITooltip
{
private final IAEFluidTank tank;
private final int slot;
private final int width;
private final int height;
public GuiFluidTank(IAEFluidTank tank, int slot, int id, int x, int y, int w, int h) {
super(id, x, y);
this.tank = tank;
this.slot = slot;
this.width = w;
this.height = h;
}
public GuiFluidTank( IAEFluidTank tank, int slot, int id, int x, int y, int w, int h )
{
super( id, x, y );
this.tank = tank;
this.slot = slot;
this.width = w;
this.height = h;
}
@Override
public void drawContent(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
final IAEFluidStack fs = this.getFluidStack();
if (fs != null) {
GlStateManager.disableBlend();
GlStateManager.disableLighting();
@Override
public void drawContent( Minecraft mc, int mouseX, int mouseY, float partialTicks )
{
final IAEFluidStack fs = this.getFluidStack();
if( fs != null )
{
GlStateManager.disableBlend();
GlStateManager.disableLighting();
//drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
//drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot);
if (fluid != null && fluid.getStackSize() > 0) {
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
if( fluid != null && fluid.getStackSize() > 0 )
{
mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
float red = (fluid.getFluid().getColor() >> 16 & 255) / 255.0F;
float green = (fluid.getFluid().getColor() >> 8 & 255) / 255.0F;
float blue = (fluid.getFluid().getColor() & 255) / 255.0F;
GlStateManager.color(red, green, blue);
float red = ( fluid.getFluid().getColor() >> 16 & 255 ) / 255.0F;
float green = ( fluid.getFluid().getColor() >> 8 & 255 ) / 255.0F;
float blue = ( fluid.getFluid().getColor() & 255 ) / 255.0F;
GlStateManager.color( red, green, blue );
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill().toString());
final int scaledHeight = (int) (this.height * ((float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity()));
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() );
final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) );
int iconHeightRemainder = scaledHeight % 16;
if (iconHeightRemainder > 0) {
this.drawTexturedModalRect(this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder, sprite, 16, iconHeightRemainder);
}
for (int i = 0; i < scaledHeight / 16; i++) {
this.drawTexturedModalRect(this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder - (i + 1) * 16, sprite, 16, 16);
}
}
}
}
int iconHeightRemainder = scaledHeight % 16;
if( iconHeightRemainder > 0 )
{
this.drawTexturedModalRect( this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder, sprite, 16, iconHeightRemainder );
}
for( int i = 0; i < scaledHeight / 16; i++ )
{
this.drawTexturedModalRect( this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 );
}
}
}
}
@Override
public String getMessage() {
final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot);
if (fluid != null && fluid.getStackSize() > 0) {
String desc = fluid.getFluid().getLocalizedName(fluid.getFluidStack());
String amountToText = fluid.getStackSize() + "mB";
@Override
public String getMessage()
{
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
if( fluid != null && fluid.getStackSize() > 0 )
{
String desc = fluid.getFluid().getLocalizedName( fluid.getFluidStack() );
String amountToText = fluid.getStackSize() + "mB";
return desc + "\n" + amountToText;
}
return null;
}
return desc + "\n" + amountToText;
}
return null;
}
@Override
public int xPos() {
return this.x - 1;
}
@Override
public int xPos()
{
return this.x - 1;
}
@Override
public int yPos() {
return this.y - 4;
}
@Override
public int yPos()
{
return this.y - 4;
}
@Override
public int getWidth() {
return this.width;
}
@Override
public int getWidth()
{
return this.width;
}
@Override
public int getHeight() {
return this.height + 4;
}
@Override
public int getHeight()
{
return this.height + 4;
}
@Override
public boolean isVisible() {
return true;
}
@Override
public boolean isVisible()
{
return true;
}
public IAEFluidStack getFluidStack() {
return this.tank.getFluidInSlot(this.slot);
}
public IAEFluidStack getFluidStack()
{
return this.tank.getFluidInSlot( this.slot );
}
@Override
public void slotClicked(ItemStack clickStack, final int mouseButton) {
@Override
public void slotClicked( ItemStack clickStack, final int mouseButton )
{
if (getFluidStack() != null) {
NetworkHandler.instance().sendToServer(new PacketInventoryAction(InventoryAction.FILL_ITEM, slot, 0));
} else {
NetworkHandler.instance().sendToServer(new PacketInventoryAction(InventoryAction.EMPTY_ITEM, slot, 0));
}
if( getFluidStack() != null )
{
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot, 0 ) );
}
else
{
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot, 0 ) );
}
}
}
}
@@ -1,63 +1,51 @@
package appeng.fluids.client.gui.widgets;
import net.minecraft.client.renderer.GlStateManager;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.IOptionalSlotHost;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.client.renderer.GlStateManager;
public class GuiOptionalFluidSlot extends GuiFluidSlot
{
private final IOptionalSlotHost containerBus;
private final int groupNum;
private final int srcX;
private final int srcY;
public class GuiOptionalFluidSlot extends GuiFluidSlot {
private final IOptionalSlotHost containerBus;
private final int groupNum;
private final int srcX;
private final int srcY;
public GuiOptionalFluidSlot( IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs )
{
super( fluids, slot, id, x + xoffs * 18, y + yoffs * 18 );
this.containerBus = containerBus;
this.groupNum = groupNum;
this.srcX = x;
this.srcY = y;
}
public GuiOptionalFluidSlot(IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs) {
super(fluids, slot, id, x + xoffs * 18, y + yoffs * 18);
this.containerBus = containerBus;
this.groupNum = groupNum;
this.srcX = x;
this.srcY = y;
}
@Override
public boolean isSlotEnabled()
{
if( this.containerBus == null )
{
return false;
}
return this.containerBus.isSlotEnabled( this.groupNum );
}
@Override
public boolean isSlotEnabled() {
if (this.containerBus == null) {
return false;
}
return this.containerBus.isSlotEnabled(this.groupNum);
}
@Override
public IAEFluidStack getFluidStack()
{
if( !this.isSlotEnabled() && super.getFluidStack() != null )
{
this.setFluidStack( null );
}
return super.getFluidStack();
}
@Override
public IAEFluidStack getFluidStack() {
if (!this.isSlotEnabled() && super.getFluidStack() != null) {
this.setFluidStack(null);
}
return super.getFluidStack();
}
@Override
public void drawBackground( int guileft, int guitop )
{
GlStateManager.enableBlend();
if( this.isSlotEnabled() )
{
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
}
else
{
GlStateManager.color( 1.0F, 1.0F, 1.0F, 0.4F );
}
this.drawTexturedModalRect( guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2,
this.getHeight() + 2 );
}
@Override
public void drawBackground(int guileft, int guitop) {
GlStateManager.enableBlend();
if (this.isSlotEnabled()) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
} else {
GlStateManager.color(1.0F, 1.0F, 1.0F, 0.4F);
}
this.drawTexturedModalRect(guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2,
this.getHeight() + 2);
}
}