GUI Rendering and various fixes

This commit is contained in:
Sebastian Hartte
2020-06-07 03:29:57 +02:00
parent 97f04922b9
commit 46b1d1ffdc
72 changed files with 650 additions and 552 deletions
+1 -21
View File
@@ -19,7 +19,6 @@
package appeng.client;
import java.io.IOException;
import java.util.*;
import appeng.client.render.effects.*;
@@ -27,7 +26,6 @@ import appeng.core.AEConfig;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
@@ -39,22 +37,17 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import appeng.api.parts.CableRenderMode;
import appeng.api.util.AEColor;
import appeng.block.AEBaseBlock;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.helpers.IMouseWheelItem;
import appeng.server.ServerHelper;
import appeng.util.Platform;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
public class ClientHelper extends ServerHelper
@@ -63,24 +56,11 @@ public class ClientHelper extends ServerHelper
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>( ActionKey.class );
@Override
public void preinit()
public void clientInit()
{
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientInit);
MinecraftForge.EVENT_BUS.addListener(this::postPlayerRender);
MinecraftForge.EVENT_BUS.addListener(this::wheelEvent);
// Do not register the Fullbright hacks if Optifine is present or if the Forge lighting is disabled
// FIXME if( !FMLClientHandler.instance().hasOptifine() && ForgeModContainer.forgeLightPipelineEnabled )
// FIXME {
// FIXME ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
// FIXME }
// FIXME RenderingRegistry.registerEntityRenderingHandler( EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed( manager ) );
// FIXME RenderingRegistry.registerEntityRenderingHandler( EntityFloatingItem.class, manager -> new RenderFloatingItem( manager ) );
}
private void clientInit(FMLClientSetupEvent event)
{
for( ActionKey key : ActionKey.values() )
{
final KeyBinding binding = new KeyBinding( key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY );
+33 -66
View File
@@ -92,26 +92,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
super(container, playerInventory, title);
}
protected static String join( final Collection<String> toolTip, final String delimiter )
{
final Joiner joiner = Joiner.on( delimiter );
return joiner.join( toolTip );
}
protected int getQty( final Button btn )
{
try
{
final DecimalFormat df = new DecimalFormat( "+#;-#" );
return df.parse( btn.getMessage() ).intValue();
}
catch( final ParseException e )
{
return 0;
}
}
@Override
public void init()
{
@@ -157,6 +137,7 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
this.drawTooltip( c, mouseX - this.guiLeft, mouseY - this.guiTop );
}
RenderSystem.popMatrix();
RenderSystem.enableDepthTest();
this.renderHoveredToolTip( mouseX, mouseY );
@@ -182,11 +163,9 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
if( this.isPointInRegion( left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY ) && slot.canClick( this.minecraft.player ) )
{
RenderSystem.disableLighting();
RenderSystem.colorMask( true, true, true, false );
this.fillGradient( left, top, right, bottom, -2130706433, -2130706433 );
RenderSystem.colorMask( true, true, true, true );
RenderSystem.enableLighting();
}
}
}
@@ -390,45 +369,38 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
return;
}
// FIXME if( slot instanceof SlotPatternTerm )
// FIXME {
// FIXME if( mouseButton == 6 )
// FIXME {
// FIXME return; // prevent weird double clicks..
// FIXME }
// FIXME
// FIXME try
// FIXME {
// FIXME NetworkHandler.instance().sendToServer( ( (SlotPatternTerm) slot ).getRequest( hasShiftDown() ) );
// FIXME }
// FIXME catch( final IOException e )
// FIXME {
// FIXME AELog.debug( e );
// FIXME }
// FIXME }
// FIXME else if( slot instanceof SlotCraftingTerm )
// FIXME {
// FIXME if( mouseButton == 6 )
// FIXME {
// FIXME return; // prevent weird double clicks..
// FIXME }
// FIXME
// FIXME InventoryAction action = null;
// FIXME if( hasShiftDown() )
// FIXME {
// FIXME action = InventoryAction.CRAFT_SHIFT;
// FIXME }
// FIXME else
// FIXME {
// FIXME // Craft stack on right-click, craft single on left-click
// FIXME action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
// FIXME }
// FIXME
// FIXME final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
// FIXME NetworkHandler.instance().sendToServer( p );
// FIXME
// FIXME return;
// FIXME }
if( slot instanceof SlotPatternTerm )
{
if( mouseButton == 6 )
{
return; // prevent weird double clicks..
}
NetworkHandler.instance().sendToServer( ( (SlotPatternTerm) slot ).getRequest( hasShiftDown() ) );
}
else if( slot instanceof SlotCraftingTerm )
{
if( mouseButton == 6 )
{
return; // prevent weird double clicks..
}
InventoryAction action = null;
if( hasShiftDown() )
{
action = InventoryAction.CRAFT_SHIFT;
}
else
{
// Craft stack on right-click, craft single on left-click
action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance().sendToServer( p );
return;
}
if( InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE) )
{
@@ -777,7 +749,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
if( fs != null && this.isPowered() )
{
RenderSystem.disableLighting();
RenderSystem.disableBlend();
final Fluid fluid = fs.getFluid();
FluidAttributes fluidAttributes = fluid.getAttributes();
@@ -793,7 +764,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
RenderSystem.color3f( red, green, blue );
blit(s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16, sprite);
RenderSystem.enableLighting();
RenderSystem.enableBlend();
this.fluidStackSizeRenderer.renderStackSize( this.font, fs, s.xPos, s.yPos );
@@ -823,7 +793,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
final int uv_x = aes.getIcon() - uv_y * 16;
RenderSystem.enableBlend();
RenderSystem.disableLighting();
RenderSystem.enableTexture();
RenderSystem.blendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
@@ -897,9 +866,7 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
// FIXME this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
RenderSystem.disableLighting();
fill( s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666 );
RenderSystem.enableLighting();
// FIXME this.zLevel = 0.0F;
this.itemRenderer.zLevel = 0.0F;
@@ -19,7 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.util.List;
import appeng.container.implementations.ContainerCraftingStatus;
@@ -107,6 +106,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.repo = new ItemRepo( scrollbar, this );
setScrollBar();
this.xSize = 185;
this.ySize = 204;
@@ -333,11 +333,11 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for( final Object s : this.container.inventorySlots )
for( final Slot s : this.container.inventorySlots )
{
if( s instanceof AppEngSlot )
{
if( ( (Slot) s ).xPos < 197 )
if( s.xPos < 197 )
{
this.repositionSlot( (AppEngSlot) s );
}
@@ -345,11 +345,10 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
{
final Slot g = (Slot) s;
if( g.xPos > 0 && g.yPos > 0 )
if( s.xPos > 0 && s.yPos > 0 )
{
craftingGridOffsetX = Math.min( craftingGridOffsetX, g.xPos );
craftingGridOffsetY = Math.min( craftingGridOffsetY, g.yPos );
craftingGridOffsetX = Math.min( craftingGridOffsetX, s.xPos );
craftingGridOffsetY = Math.min( craftingGridOffsetY, s.yPos );
}
}
}
@@ -457,8 +456,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
protected void repositionSlot( final AppEngSlot s )
{
// FIXME .... it's final now, WHAT DO WE DO ARGH
// s.yPos = s.getY() + this.ySize - 78 - 5;
s.yPos = s.getY() + this.ySize - 78 - 5;
}
@Override
@@ -149,6 +149,6 @@ public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
{
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
// FIXME OH NOOOOO WE CANNOT, ITS FINAL s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
}
}
@@ -163,6 +163,7 @@ public class MEGuiTextField extends TextFieldWidget
tessellator.draw();
RenderSystem.disableColorLogicOp();
RenderSystem.enableTexture();
RenderSystem.color4f( 1, 1, 1, 1 );
}
}
@@ -19,6 +19,7 @@
package appeng.client.me;
import appeng.items.misc.ItemEncodedPattern;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -62,15 +63,15 @@ public class SlotDisconnected extends AppEngSlot
if( Platform.isClient() )
{
final ItemStack is = super.getStack();
// FIXME if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern )
// FIXME {
// FIXME final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
// FIXME final ItemStack out = iep.getOutput( is );
// FIXME if( !out.isEmpty() )
// FIXME {
// FIXME return out;
// FIXME }
// FIXME }
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern)
{
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
final ItemStack out = iep.getOutput( is );
if( !out.isEmpty() )
{
return out;
}
}
}
return super.getStack();
}
@@ -53,7 +53,6 @@ public class StackSizeRenderer
{
final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft
.getLocal();
RenderSystem.disableLighting();
RenderSystem.disableDepthTest();
RenderSystem.disableBlend();
RenderSystem.pushMatrix();
@@ -62,7 +61,6 @@ public class StackSizeRenderer
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
fontRenderer.drawStringWithShadow( craftLabelText, X, Y, 16777215 );
RenderSystem.popMatrix();
RenderSystem.enableLighting();
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
}
@@ -71,7 +69,6 @@ public class StackSizeRenderer
{
final String stackSize = this.getToBeRenderedStackSize( aeStack.getStackSize() );
RenderSystem.disableLighting();
RenderSystem.disableDepthTest();
RenderSystem.disableBlend();
RenderSystem.pushMatrix();
@@ -80,7 +77,6 @@ public class StackSizeRenderer
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
RenderSystem.popMatrix();
RenderSystem.enableLighting();
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
}