mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Distillation Encoder
Implemented Distillation Encoder GUI Cleaned up tooltip code, and fixed underdraw issue.
This commit is contained in:
1 parent
383293c0e7
commit
69c5acc78c
22 files changed
+793
-511
No files matched your search
+3
-1
@@ -1,7 +1,9 @@
|
||||
12/30/2015 0.10.0.0 - Beta
|
||||
Added Distillation Encoder
|
||||
Added pattern handler
|
||||
Working on GUI
|
||||
Implemented Distillation Encoder GUI
|
||||
Cleaned up tooltip code, and fixed underdraw issue.
|
||||
|
||||
|
||||
12/29/2015 0.10.0.0 - Beta
|
||||
Began integrating essentia into crafting system.
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
package thaumicenergistics.container;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.lib.research.ScanManager;
|
||||
import thaumicenergistics.container.slot.SlotRestrictive;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.registries.ItemEnum;
|
||||
import thaumicenergistics.tileentities.TileDistillationEncoder;
|
||||
import thaumicenergistics.util.DistillationPatternHelper;
|
||||
import thaumicenergistics.util.EffectiveSide;
|
||||
import appeng.api.AEApi;
|
||||
import com.google.common.base.Optional;
|
||||
import appeng.container.slot.SlotFake;
|
||||
|
||||
public class ContainerDistillationEncoder
|
||||
extends ContainerWithPlayerInventory
|
||||
@@ -21,11 +29,71 @@ public class ContainerDistillationEncoder
|
||||
*/
|
||||
private static final int PLAYER_INV_POSITION_Y = 152, HOTBAR_INV_POSITION_Y = PLAYER_INV_POSITION_Y + 58;
|
||||
|
||||
/**
|
||||
* Position of the source item slot
|
||||
*/
|
||||
private static final int SLOT_SOURCE_ITEM_POS_X = 15, SLOT_SOURCE_ITEM_POS_Y = 69;
|
||||
|
||||
/**
|
||||
* Starting position of the source aspect slots
|
||||
*/
|
||||
private static final int SLOT_SOURCE_ASPECTS_POS_X = 65, SLOT_SOURCE_ASPECTS_POS_Y = 24;
|
||||
|
||||
/**
|
||||
* Position of the save aspect.
|
||||
*/
|
||||
private static final int SLOT_SELECTED_ASPECT_POS_X = 116, SLOT_SELECTED_ASPECT_POS_Y = 69;
|
||||
|
||||
/**
|
||||
* Position of the blank patterns.
|
||||
*/
|
||||
private static final int SLOT_PATTERNS_BLANK_POS_X = 146, SLOT_PATTERNS_BLANK_POS_Y = 75;
|
||||
|
||||
/**
|
||||
* Position of the encoded pattern.
|
||||
*/
|
||||
private static final int SLOT_PATTERN_ENCODED_POS_X = 146, SLOT_PATTERN_ENCODED_POS_Y = 113;
|
||||
|
||||
/**
|
||||
* Player who opened the GUI.
|
||||
*/
|
||||
protected EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Host encoder.
|
||||
*/
|
||||
protected TileDistillationEncoder hostTile;
|
||||
|
||||
/**
|
||||
* Slot holding the source item.
|
||||
*/
|
||||
protected SlotFake slotSourceItem;
|
||||
|
||||
/**
|
||||
* Slots holding the source item's aspects.
|
||||
*/
|
||||
protected SlotFake[] slotSourceAspects = new SlotFake[TileDistillationEncoder.SLOT_SOURCE_ASPECTS_COUNT];
|
||||
|
||||
/**
|
||||
* Slot holding the selected aspect.
|
||||
*/
|
||||
protected SlotFake slotSelectedAspect;
|
||||
|
||||
/**
|
||||
* Blank patterns slot.
|
||||
*/
|
||||
protected SlotRestrictive slotPatternsBlank;
|
||||
|
||||
/**
|
||||
* Encoded pattern slot.
|
||||
*/
|
||||
protected SlotRestrictive slotPatternEncoded;
|
||||
|
||||
/**
|
||||
* Pattern helper
|
||||
*/
|
||||
protected DistillationPatternHelper patternHelper;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -40,8 +108,194 @@ public class ContainerDistillationEncoder
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Get the encoder
|
||||
this.hostTile = (TileDistillationEncoder)world.getTileEntity( x, y, z );
|
||||
|
||||
// Get the encoder's inventory
|
||||
IInventory hostInv = this.hostTile.getInventory();
|
||||
|
||||
// Add the source item slot
|
||||
this.slotSourceItem = new SlotFake( hostInv, TileDistillationEncoder.SLOT_SOURCE_ITEM, SLOT_SOURCE_ITEM_POS_X, SLOT_SOURCE_ITEM_POS_Y );
|
||||
this.addSlotToContainer( this.slotSourceItem );
|
||||
|
||||
// Add the source aspect slots
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
{
|
||||
// Calculate Y
|
||||
int posY = SLOT_SOURCE_ASPECTS_POS_Y + ( index * 18 );
|
||||
|
||||
// Create the slot
|
||||
this.slotSourceAspects[index] = new SlotFake( hostInv, TileDistillationEncoder.SLOT_SOURCE_ASPECTS + index, SLOT_SOURCE_ASPECTS_POS_X,
|
||||
posY );
|
||||
|
||||
// Add it
|
||||
this.addSlotToContainer( this.slotSourceAspects[index] );
|
||||
}
|
||||
|
||||
// Add the selected aspect slot
|
||||
this.slotSelectedAspect = new SlotFake( hostInv, TileDistillationEncoder.SLOT_SELECTED_ASPECT, SLOT_SELECTED_ASPECT_POS_X,
|
||||
SLOT_SELECTED_ASPECT_POS_Y );
|
||||
this.addSlotToContainer( this.slotSelectedAspect );
|
||||
|
||||
// Add blank pattern slot
|
||||
this.slotPatternsBlank = new SlotRestrictive( hostInv, TileDistillationEncoder.SLOT_BLANK_PATTERNS,
|
||||
SLOT_PATTERNS_BLANK_POS_X, SLOT_PATTERNS_BLANK_POS_Y );
|
||||
this.addSlotToContainer( this.slotPatternsBlank );
|
||||
|
||||
// Add encoded pattern slot
|
||||
this.slotPatternEncoded = new SlotRestrictive( hostInv, TileDistillationEncoder.SLOT_ENCODED_PATTERN,
|
||||
SLOT_PATTERN_ENCODED_POS_X, SLOT_PATTERN_ENCODED_POS_Y );
|
||||
this.addSlotToContainer( this.slotPatternEncoded );
|
||||
|
||||
// Bind to the players inventory
|
||||
this.bindPlayerInventory( player.inventory, PLAYER_INV_POSITION_Y, HOTBAR_INV_POSITION_Y );
|
||||
|
||||
// Create the helper
|
||||
this.patternHelper = new DistillationPatternHelper();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a pattern is loaded from the encoded pattern slot.
|
||||
*/
|
||||
protected void onLoadedPattern()
|
||||
{
|
||||
// Set the source item
|
||||
this.setSourceItem( this.patternHelper.getInput() );
|
||||
|
||||
// Set the selected aspect
|
||||
this.setSelectedAspect( this.patternHelper.getOutput() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set's the selected aspect stack.
|
||||
*
|
||||
* @param aspectStack
|
||||
*/
|
||||
protected void setSelectedAspect( final ItemStack aspectStack )
|
||||
{
|
||||
// Clear the stack
|
||||
this.slotSelectedAspect.clearStack();
|
||||
|
||||
// Is there anything to put?
|
||||
if( aspectStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the stack have an aspect?
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( aspectStack );
|
||||
if( aspect == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Has the player discovered this aspect?
|
||||
if( !ItemCraftingAspect.canPlayerSeeAspect( this.player, aspect ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the aspect
|
||||
this.slotSelectedAspect.putStack( aspectStack.copy() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source item and updates aspects.
|
||||
*/
|
||||
protected void setSourceItem( final ItemStack sourceStack )
|
||||
{
|
||||
// Ignored on client side
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear slots
|
||||
this.slotSourceItem.clearStack();
|
||||
this.slotSelectedAspect.clearStack();
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
{
|
||||
this.slotSourceAspects[index].clearStack();
|
||||
}
|
||||
|
||||
// Null?
|
||||
if( sourceStack == null )
|
||||
{
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the itemstack
|
||||
ItemStack sourceItem = sourceStack.copy();
|
||||
|
||||
// Set size to 1
|
||||
sourceItem.stackSize = 1;
|
||||
|
||||
// Set the source item
|
||||
this.slotSourceItem.putStack( sourceItem );
|
||||
|
||||
// Get the aspects
|
||||
AspectList itemAspects = ThaumcraftApiHelper.getObjectAspects( sourceItem );
|
||||
Aspect[] sortedAspects = null;
|
||||
|
||||
// Does the item have any aspects?
|
||||
if( ( itemAspects == null ) || ( itemAspects.size() == 0 ) )
|
||||
{
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate hash
|
||||
int hash = ScanManager.generateItemHash( sourceItem.getItem(), sourceItem.getItemDamage() );
|
||||
|
||||
// Get the list of scanned objects
|
||||
List<String> list = Thaumcraft.proxy.getScannedObjects().get( this.player.getCommandSenderName() );
|
||||
|
||||
// Assume all slot will have an aspect
|
||||
int numOfAspects = this.slotSourceAspects.length;
|
||||
|
||||
// Has the player scanned the item?
|
||||
boolean playerScanned = ( ( list != null ) && ( ( list.contains( "@" + hash ) ) || ( list.contains( "#" + hash ) ) ) );
|
||||
if( playerScanned )
|
||||
{
|
||||
// Get sorted
|
||||
sortedAspects = itemAspects.getAspectsSortedAmount();
|
||||
|
||||
// Set number to display
|
||||
numOfAspects = Math.min( numOfAspects, sortedAspects.length );
|
||||
}
|
||||
|
||||
// Add each aspect
|
||||
Aspect aspect;
|
||||
for( int i = 0; i < numOfAspects; ++i )
|
||||
{
|
||||
// Create an itemstack
|
||||
ItemStack aspectItem = ItemEnum.CRAFTING_ASPECT.getStack();
|
||||
|
||||
if( sortedAspects != null )
|
||||
{
|
||||
// Get the aspect
|
||||
aspect = sortedAspects[i];
|
||||
|
||||
// Set the aspect
|
||||
ItemCraftingAspect.setAspect( aspectItem, aspect );
|
||||
|
||||
// Set the size
|
||||
aspectItem.stackSize = itemAspects.getAmount( aspect );
|
||||
}
|
||||
|
||||
// Put into slot
|
||||
this.slotSourceAspects[i].putStack( aspectItem );
|
||||
|
||||
// Selected aspect empty?
|
||||
if( playerScanned && ( !this.slotSelectedAspect.getHasStack() ) )
|
||||
{
|
||||
// Attempt to place into selected
|
||||
this.setSelectedAspect( aspectItem );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,42 +307,216 @@ public class ContainerDistillationEncoder
|
||||
return !( player instanceof FakePlayer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotID, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
/**
|
||||
* Returns the player for this container.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EntityPlayer getPlayer()
|
||||
{
|
||||
// Is this client side?
|
||||
if( EffectiveSide.isClientSide() )
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a pattern is to be encoded.
|
||||
*/
|
||||
public void onEncodePattern()
|
||||
{
|
||||
ItemStack pattern = null;
|
||||
boolean takeBlank = false;
|
||||
|
||||
// Is there anything in the encoded pattern slot?
|
||||
if( this.slotPatternEncoded.getHasStack() )
|
||||
{
|
||||
// Do nothing.
|
||||
// Set the pattern to it
|
||||
pattern = this.slotPatternEncoded.getStack();
|
||||
}
|
||||
// Is there a blank pattern to draw from?
|
||||
else if( this.slotPatternsBlank.getHasStack() )
|
||||
{
|
||||
// Create a new encoded pattern
|
||||
pattern = AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).orNull();
|
||||
if( pattern == null )
|
||||
{
|
||||
// Patterns are disabled?
|
||||
// How did you even get here?!
|
||||
return;
|
||||
}
|
||||
takeBlank = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing to save to
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the pattern items
|
||||
if( !this.patternHelper.setPatternItems( this.slotSourceItem.getDisplayStack(), this.slotSelectedAspect.getDisplayStack() ) )
|
||||
{
|
||||
// Nothing to save
|
||||
return;
|
||||
}
|
||||
|
||||
// Encode!
|
||||
this.patternHelper.encodePattern( pattern );
|
||||
|
||||
// Set the pattern slot
|
||||
this.slotPatternEncoded.putStack( pattern );
|
||||
|
||||
if( takeBlank )
|
||||
{
|
||||
// Decrement the blank patterns
|
||||
this.slotPatternsBlank.decrStackSize( 1 );
|
||||
}
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotNumber, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
{
|
||||
// Source item slot?
|
||||
if( this.slotSourceItem.slotNumber == slotNumber )
|
||||
{
|
||||
// Get the item the player is dragging
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
|
||||
// Set the source slot
|
||||
this.setSourceItem( heldItem );
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Debug code
|
||||
// Create a new pattern
|
||||
Optional<ItemStack> oStack = AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 );
|
||||
if( oStack.isPresent() )
|
||||
// One of the source aspect slots?
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
{
|
||||
DistillationPatternHelper h = new DistillationPatternHelper();
|
||||
h.input = new ItemStack( Item.getItemById( 331 ) );
|
||||
if( this.slotSourceAspects[index].slotNumber == slotNumber )
|
||||
{
|
||||
if( this.slotSourceAspects[index].getHasStack() )
|
||||
{
|
||||
// Place it into the selected
|
||||
this.setSelectedAspect( this.slotSourceAspects[index].getStack() );
|
||||
|
||||
h.output = ItemEnum.CRAFTING_ASPECT.getStack( 2 );
|
||||
ItemCraftingAspect.setAspect( h.output, Aspect.ENERGY );
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
ItemStack pattern = oStack.get();
|
||||
h.writeToPattern( pattern );
|
||||
|
||||
this.player.inventory.addItemStackToInventory( pattern );
|
||||
this.player.inventory.markDirty();
|
||||
this.detectAndSendChanges();
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
// Encoded pattern slot?
|
||||
if( this.slotPatternEncoded.slotNumber == slotNumber )
|
||||
{
|
||||
// Is the slot empty?
|
||||
if( !this.slotPatternEncoded.getHasStack() )
|
||||
{
|
||||
// Get the item the player is dragging
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
|
||||
// Attempt to load it
|
||||
this.patternHelper.readPattern( heldItem );
|
||||
|
||||
// Valid pattern?
|
||||
if( this.patternHelper.isValid() )
|
||||
{
|
||||
// Load the pattern
|
||||
this.onLoadedPattern();
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't allow this pattern
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.slotClick( slotNumber, buttonPressed, flag, player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
boolean handled = false;
|
||||
|
||||
// Get the slot
|
||||
Slot clickedSlot = this.getSlot( slotNumber );
|
||||
|
||||
// Slot empty?
|
||||
if( !clickedSlot.getHasStack() )
|
||||
{
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the stack
|
||||
ItemStack slotStack = clickedSlot.getStack();
|
||||
|
||||
// Is the slot in the player inventory?
|
||||
if( clickedSlot.inventory == this.player.inventory )
|
||||
{
|
||||
// Will the blank pattern slot take this?
|
||||
if( this.slotPatternsBlank.isItemValid( slotStack ) )
|
||||
{
|
||||
handled = this.mergeItemStack( slotStack, this.slotPatternsBlank.slotNumber, this.slotPatternsBlank.slotNumber + 1, false );
|
||||
}
|
||||
|
||||
// Will the encoded pattern take this?
|
||||
if( !handled && this.slotPatternEncoded.isItemValid( slotStack ) )
|
||||
{
|
||||
// Attempt to load the pattern
|
||||
this.patternHelper.readPattern( slotStack );
|
||||
if( this.patternHelper.isValid() )
|
||||
{
|
||||
handled = this.mergeItemStack( slotStack, this.slotPatternEncoded.slotNumber, this.slotPatternEncoded.slotNumber + 1, false );
|
||||
if( handled )
|
||||
{
|
||||
this.onLoadedPattern();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !handled )
|
||||
{
|
||||
// Set the source slot
|
||||
this.setSourceItem( slotStack );
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pattern slot?
|
||||
if( ( !handled ) && ( ( this.slotPatternsBlank.slotNumber == slotNumber ) || ( this.slotPatternEncoded.slotNumber == slotNumber ) ) )
|
||||
{
|
||||
handled = this.mergeSlotWithHotbarInventory( slotStack );
|
||||
|
||||
if( !handled )
|
||||
{
|
||||
handled = this.mergeSlotWithPlayerInventory( slotStack );
|
||||
}
|
||||
}
|
||||
|
||||
// Was this handled?
|
||||
if( handled )
|
||||
{
|
||||
if( slotStack.stackSize <= 0 )
|
||||
{
|
||||
clickedSlot.putStack( null );
|
||||
}
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -126,6 +126,7 @@ public abstract class ContainerWithPlayerInventory
|
||||
*/
|
||||
public final void bindPlayerInventory( final IInventory playerInventory, final int inventoryOffsetY, final int hotbarPositionY )
|
||||
{
|
||||
// TODO: Make the argument offsets on x an y.
|
||||
|
||||
// Hot-bar ID's 0-8
|
||||
Slot hotbarSlot = null;
|
||||
|
||||
@@ -174,9 +174,6 @@ public class GuiArcaneAssembler
|
||||
float discount = ( (ContainerArcaneAssembler)this.inventorySlots ).assembler.getVisDiscountForAspect( aspect );
|
||||
this.tooltip.add( String.format( "%.0f%% %s", ( discount * 100.0F ), StatCollector.translateToLocal( "tc.vis.costavg" ) ) );
|
||||
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
|
||||
// Stop searching
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,7 @@ import thaumcraft.common.config.Config;
|
||||
import thaumicenergistics.container.ContainerPartArcaneCraftingTerminal;
|
||||
import thaumicenergistics.container.ContainerPartArcaneCraftingTerminal.ArcaneCrafingCost;
|
||||
import thaumicenergistics.gui.abstraction.AbstractGuiConstantsACT;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonClearCraftingGrid;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonSearchMode;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonSortingDirection;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonSortingMode;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonSwapArmor;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonTerminalStyle;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonViewType;
|
||||
import thaumicenergistics.gui.buttons.*;
|
||||
import thaumicenergistics.gui.widget.AbstractWidget;
|
||||
import thaumicenergistics.gui.widget.WidgetAEItem;
|
||||
import thaumicenergistics.integration.tc.MEItemAspectBridgeContainer;
|
||||
@@ -32,12 +26,7 @@ import thaumicenergistics.registries.ThEStrings;
|
||||
import thaumicenergistics.texture.AEStateIconsEnum;
|
||||
import thaumicenergistics.texture.GuiTextureManager;
|
||||
import thaumicenergistics.util.GuiHelper;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
@@ -171,6 +160,11 @@ public class GuiArcaneCraftingTerminal
|
||||
*/
|
||||
private boolean viewNeedsUpdate = true;
|
||||
|
||||
/**
|
||||
* Holds the cached tooltip of an item.
|
||||
*/
|
||||
private ArrayList<String> cachedItemTooltip = new ArrayList<String>();
|
||||
|
||||
public GuiArcaneCraftingTerminal( final AEPartArcaneCraftingTerminal part, final EntityPlayer player )
|
||||
{
|
||||
// Call super
|
||||
@@ -537,7 +531,7 @@ public class GuiArcaneCraftingTerminal
|
||||
}
|
||||
|
||||
// Clear any tooltip
|
||||
this.tooltip.clear();
|
||||
this.cachedItemTooltip.clear();
|
||||
|
||||
}
|
||||
|
||||
@@ -727,26 +721,15 @@ public class GuiArcaneCraftingTerminal
|
||||
if( forceTooltipUpdate || ( widgetUnderMouse != this.previousWidgetUnderMouse ) )
|
||||
{
|
||||
// Clear the tooltip
|
||||
this.tooltip.clear();
|
||||
this.cachedItemTooltip.clear();
|
||||
|
||||
// Get the tooltip from the widget
|
||||
widgetUnderMouse.getTooltip( this.tooltip );
|
||||
widgetUnderMouse.getTooltip( this.cachedItemTooltip );
|
||||
|
||||
// Set the time
|
||||
this.lastTooltipUpdateTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear the tooltip
|
||||
this.tooltip.clear();
|
||||
|
||||
// Set the time
|
||||
this.lastTooltipUpdateTime = System.currentTimeMillis();
|
||||
|
||||
// Get the tooltip from the buttons
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
// Set the previous position
|
||||
this.previousMouseX = mouseX;
|
||||
@@ -756,8 +739,11 @@ public class GuiArcaneCraftingTerminal
|
||||
this.previousWidgetUnderMouse = widgetUnderMouse;
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, false );
|
||||
// Add cached tooltip
|
||||
if( !this.cachedItemTooltip.isEmpty() )
|
||||
{
|
||||
this.tooltip.addAll( this.cachedItemTooltip );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -981,7 +967,7 @@ public class GuiArcaneCraftingTerminal
|
||||
this.btnSearchMode.setSearchMode( searchBoxMode );
|
||||
|
||||
// Clear the tooltip
|
||||
this.tooltip.clear();
|
||||
this.cachedItemTooltip.clear();
|
||||
this.lastTooltipUpdateTime = 0;
|
||||
|
||||
break;
|
||||
@@ -1008,7 +994,7 @@ public class GuiArcaneCraftingTerminal
|
||||
this.updateMEWidgets();
|
||||
|
||||
// Clear the tooltip
|
||||
this.tooltip.clear();
|
||||
this.cachedItemTooltip.clear();
|
||||
this.lastTooltipUpdateTime = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumicenergistics.container.ContainerDistillationEncoder;
|
||||
import thaumicenergistics.gui.abstraction.AbstractGuiBase;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonEncodePattern;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_DistillationEncoder;
|
||||
import thaumicenergistics.registries.ThEStrings;
|
||||
import thaumicenergistics.texture.AEStateIconsEnum;
|
||||
import thaumicenergistics.texture.GuiTextureManager;
|
||||
|
||||
public class GuiDistillationEncoder
|
||||
@@ -23,11 +26,21 @@ public class GuiDistillationEncoder
|
||||
*/
|
||||
private static final int TITLE_POS_X = 6, TITLE_POS_Y = 6;
|
||||
|
||||
/**
|
||||
* Position of the encode button
|
||||
*/
|
||||
private static final int BUTTON_ENCODE_POS_X = 146, BUTTON_ENCODE_POS_Y = 94;
|
||||
|
||||
/**
|
||||
* Title of the gui.
|
||||
*/
|
||||
private final String title;
|
||||
|
||||
/**
|
||||
* The encode button.
|
||||
*/
|
||||
private GuiButtonEncodePattern buttonEncode;
|
||||
|
||||
public GuiDistillationEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Call super
|
||||
@@ -71,7 +84,11 @@ public class GuiDistillationEncoder
|
||||
@Override
|
||||
protected void onButtonClicked( final GuiButton button, final int mouseButton )
|
||||
{
|
||||
|
||||
if( button == this.buttonEncode )
|
||||
{
|
||||
Packet_S_DistillationEncoder.sendEncodePattern(
|
||||
( (ContainerDistillationEncoder)this.inventorySlots ).getPlayer() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,5 +96,11 @@ public class GuiDistillationEncoder
|
||||
{
|
||||
// Call super
|
||||
super.initGui();
|
||||
|
||||
// Create the encode button
|
||||
this.buttonEncode = new GuiButtonEncodePattern( 0, BUTTON_ENCODE_POS_X + this.guiLeft, BUTTON_ENCODE_POS_Y + this.guiTop,
|
||||
AEStateIconsEnum.STANDARD_ICON_SIZE,
|
||||
AEStateIconsEnum.STANDARD_ICON_SIZE );
|
||||
this.buttonList.add( this.buttonEncode );
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.aspect.AspectStack;
|
||||
import thaumicenergistics.aspect.AspectStackComparator.ComparatorMode;
|
||||
import thaumicenergistics.container.AbstractContainerCellTerminalBase;
|
||||
import thaumicenergistics.container.ContainerEssentiaCell;
|
||||
import thaumicenergistics.container.ContainerEssentiaTerminal;
|
||||
import thaumicenergistics.container.ContainerWirelessEssentiaTerminal;
|
||||
import thaumicenergistics.container.IAspectSelectorContainer;
|
||||
import thaumicenergistics.container.*;
|
||||
import thaumicenergistics.gui.abstraction.AbstractGuiWithScrollbar;
|
||||
import thaumicenergistics.gui.buttons.GuiButtonSortingMode;
|
||||
import thaumicenergistics.gui.widget.AbstractWidget;
|
||||
@@ -444,15 +440,6 @@ public class GuiEssentiaCellTerminal
|
||||
this.fontRendererObj.drawString( this.selectedInfoAmountPrefix + this.cacheAmountDisplay, GuiEssentiaCellTerminal.SELECTED_INFO_POS_X,
|
||||
GuiEssentiaCellTerminal.SELECTED_INFO_AMOUNT_POS_Y, 0 );
|
||||
}
|
||||
|
||||
// Get the tooltip from the buttons
|
||||
if( this.tooltip.isEmpty() )
|
||||
{
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -195,17 +195,6 @@ public class GuiEssentiaCellWorkbench
|
||||
// Get the widgets tooltip
|
||||
widgetUnderMouse.getTooltip( this.tooltip );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add tooltip from buttons
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
if( this.tooltip.size() > 0 )
|
||||
{
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -265,14 +265,6 @@ public class GuiEssentiaIO
|
||||
// Add the tooltip from the widget
|
||||
slotUnderMouse.getTooltip( this.tooltip );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the tooltip from the buttons
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,18 +248,6 @@ public class GuiEssentiaLevelEmitter
|
||||
|
||||
// Draw the text field
|
||||
this.amountField.drawTextBox();
|
||||
|
||||
if( this.tooltip.size() == 0 )
|
||||
{
|
||||
// Add the tooltip from the buttons
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
if( this.tooltip.size() > 0 )
|
||||
{
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -223,14 +223,6 @@ public class GuiEssentiaStorageBus
|
||||
// Add the tooltip from the widget
|
||||
slotUnderMouse.getTooltip( this.tooltip );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the tooltip from the buttons
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -192,9 +192,6 @@ public class GuiEssentiaVibrationChamber
|
||||
// Add the power per tick
|
||||
this.tooltip.add( String.format( "%.0f AE/t", this.container.getPowerPerTick() ) );
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -235,13 +235,6 @@ public class GuiKnowledgeInscriber
|
||||
// Draw the title
|
||||
this.fontRendererObj.drawString( this.title, GuiKnowledgeInscriber.TITLE_POS_X, GuiKnowledgeInscriber.TITLE_POS_Y, 0 );
|
||||
|
||||
// Get the tooltip from the buttons
|
||||
if( this.addTooltipFromButtons( mouseX, mouseY ) )
|
||||
{
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
|
||||
// Any particles to draw?
|
||||
if( this.hasParticlesToDraw )
|
||||
{
|
||||
|
||||
@@ -251,13 +251,6 @@ public class GuiPriority
|
||||
|
||||
// Draw the text field
|
||||
this.amountField.drawTextBox();
|
||||
|
||||
// Get the tooltip from the buttons
|
||||
if( this.addTooltipFromButtons( mouseX, mouseY ) )
|
||||
{
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import thaumicenergistics.container.ContainerWithNetworkTool;
|
||||
import thaumicenergistics.container.slot.SlotNetworkTool;
|
||||
import thaumicenergistics.gui.buttons.AbstractGuiButtonBase;
|
||||
@@ -31,101 +29,6 @@ public abstract class AbstractGuiBase
|
||||
extends GuiContainer
|
||||
implements IWidgetHost
|
||||
{
|
||||
/**
|
||||
* Pixel area represented by the top-left and bottom-right corners of a
|
||||
* rectangle.
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*/
|
||||
private class Bounds
|
||||
{
|
||||
/**
|
||||
* Top Y position.
|
||||
*/
|
||||
public int T;
|
||||
|
||||
/**
|
||||
* Left X position.
|
||||
*/
|
||||
public int L;
|
||||
|
||||
/**
|
||||
* Bottom Y position.
|
||||
*/
|
||||
public int B;
|
||||
|
||||
/**
|
||||
* Right X position.
|
||||
*/
|
||||
public int R;
|
||||
|
||||
/**
|
||||
* Creates the boundary
|
||||
*
|
||||
* @param t
|
||||
* Top Y position.
|
||||
* @param l
|
||||
* Left X position.
|
||||
* @param b
|
||||
* Bottom Y position.
|
||||
* @param r
|
||||
* Right X position.
|
||||
*/
|
||||
public Bounds( final int t, final int l, final int b, final int r )
|
||||
{
|
||||
this.T = t;
|
||||
this.L = l;
|
||||
this.B = b;
|
||||
this.R = r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tooltip offset from the mouse.
|
||||
*/
|
||||
private static final int TOOLTIP_OFFSET = 12;
|
||||
|
||||
/**
|
||||
* Height of a tooltip with no text.
|
||||
*/
|
||||
private static final int TOOLTIP_EMPTY_HEIGHT = 8;
|
||||
|
||||
/**
|
||||
* (Top) Margin from the borders to start drawing text.
|
||||
*/
|
||||
private static final int TOOLTIP_HEIGHT_MARGIN = 2;
|
||||
|
||||
/**
|
||||
* Height of each line of text.
|
||||
*/
|
||||
private static final int TOOLTIP_LINE_HEIGHT = 10;
|
||||
|
||||
/**
|
||||
* Color of the tooltip's outer borders.
|
||||
*/
|
||||
private static final int TOOLTIP_COLOR_OUTER = 0xFF000000;
|
||||
|
||||
/**
|
||||
* Color of the tooltip background.
|
||||
*/
|
||||
private static final int TOOLTIP_COLOR_BACKGROUND = 0xF0100010;
|
||||
|
||||
/**
|
||||
* Starting color of the tooltip's inner borders.
|
||||
*/
|
||||
private static final int TOOLTIP_COLOR_INNER_BEGIN = 0xC05000FF;
|
||||
|
||||
/**
|
||||
* Ending color of the tooltip's inner borders.
|
||||
*/
|
||||
private static final int TOOLTIP_COLOR_INNER_END = 0xC05000FF;
|
||||
|
||||
/**
|
||||
* Thickness of the tooltip's borders.
|
||||
*/
|
||||
private static final int TOOLTIP_BORDER_SIZE = 3;
|
||||
|
||||
private static final int upgradeU = AEStateIconsEnum.UPGRADE_CARD_BACKGROUND.getU();
|
||||
private static final int upgradeV = AEStateIconsEnum.UPGRADE_CARD_BACKGROUND.getV();
|
||||
private static final int upgradeWidth = AEStateIconsEnum.UPGRADE_CARD_BACKGROUND.getWidth();
|
||||
@@ -142,57 +45,36 @@ public abstract class AbstractGuiBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background, outer borders, and inner borders for a tooltip.
|
||||
* Adds to the tooltip based on which button the mouse is over.
|
||||
*
|
||||
* @param guiObject
|
||||
* @param drawGradientRect
|
||||
* @param bounds
|
||||
* @throws Exception
|
||||
* @param mouseX
|
||||
* @param mouseY
|
||||
* @return True when a tooltip was added, false otherwise.
|
||||
*/
|
||||
private final void drawTooltipBackground( final Bounds bounds )
|
||||
private final boolean addTooltipFromButtons( final int mouseX, final int mouseY )
|
||||
{
|
||||
// Background
|
||||
this.drawGradientRect( bounds.L, bounds.T, bounds.R, bounds.B, AbstractGuiBase.TOOLTIP_COLOR_BACKGROUND,
|
||||
AbstractGuiBase.TOOLTIP_COLOR_BACKGROUND );
|
||||
// Is the mouse over any buttons?
|
||||
for( Object obj : this.buttonList )
|
||||
{
|
||||
// Is it a base button?
|
||||
if( obj instanceof AbstractGuiButtonBase )
|
||||
{
|
||||
// Cast
|
||||
AbstractGuiButtonBase currentButton = (AbstractGuiButtonBase)obj;
|
||||
|
||||
// Draw outer borders
|
||||
this.drawTooltipBorders( bounds, AbstractGuiBase.TOOLTIP_COLOR_OUTER, AbstractGuiBase.TOOLTIP_COLOR_OUTER, 0 );
|
||||
// Is the mouse over it?
|
||||
if( currentButton.isMouseOverButton( mouseX, mouseY ) )
|
||||
{
|
||||
// Get the tooltip
|
||||
currentButton.getTooltip( this.tooltip );
|
||||
|
||||
// Adjust bounds for inner borders
|
||||
bounds.T++ ;
|
||||
bounds.L++ ;
|
||||
bounds.B-- ;
|
||||
bounds.R-- ;
|
||||
// And stop searching
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw inner borders
|
||||
this.drawTooltipBorders( bounds, AbstractGuiBase.TOOLTIP_COLOR_INNER_BEGIN, AbstractGuiBase.TOOLTIP_COLOR_INNER_END, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the vertical and horizontal borders for a tooltip
|
||||
*
|
||||
* @param guiObject
|
||||
* @param drawGradientRect
|
||||
* @param bounds
|
||||
* @param colorStart
|
||||
* @param colorEnd
|
||||
* @param cornerExpansion
|
||||
* 1 to connect corners, 0 to leave notches.
|
||||
* @throws Exception
|
||||
*/
|
||||
private final void drawTooltipBorders( final Bounds bounds, final int colorStart, final int colorEnd, final int cornerExpansion )
|
||||
{
|
||||
// Left
|
||||
this.drawGradientRect( bounds.L - 1, bounds.T - cornerExpansion, bounds.L, bounds.B + cornerExpansion, colorStart, colorEnd );
|
||||
|
||||
// Top
|
||||
this.drawGradientRect( bounds.L, bounds.T - 1, bounds.R, bounds.T, colorStart, colorEnd );
|
||||
|
||||
// Right
|
||||
this.drawGradientRect( bounds.R, bounds.T - cornerExpansion, bounds.R + 1, bounds.B + cornerExpansion, colorStart, colorEnd );
|
||||
|
||||
// Bottom
|
||||
this.drawGradientRect( bounds.L, bounds.B, bounds.R, bounds.B + 1, colorStart, colorEnd );
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,39 +126,6 @@ public abstract class AbstractGuiBase
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the tooltip based on which button the mouse is over.
|
||||
*
|
||||
* @param mouseX
|
||||
* @param mouseY
|
||||
* @return True when a tooltip was added, false otherwise.
|
||||
*/
|
||||
protected final boolean addTooltipFromButtons( final int mouseX, final int mouseY )
|
||||
{
|
||||
// Is the mouse over any buttons?
|
||||
for( Object obj : this.buttonList )
|
||||
{
|
||||
// Is it a base button?
|
||||
if( obj instanceof AbstractGuiButtonBase )
|
||||
{
|
||||
// Cast
|
||||
AbstractGuiButtonBase currentButton = (AbstractGuiButtonBase)obj;
|
||||
|
||||
// Is the mouse over it?
|
||||
if( currentButton.isMouseOverButton( mouseX, mouseY ) )
|
||||
{
|
||||
// Get the tooltip
|
||||
currentButton.getTooltip( this.tooltip );
|
||||
|
||||
// And stop searching
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the slot backgrounds for the network tool and upgrade slots.
|
||||
*
|
||||
@@ -304,121 +153,6 @@ public abstract class AbstractGuiBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an on-screen tooltip box based on the string in this.tooltip.
|
||||
* The tooltip is cleared after being drawn.
|
||||
*
|
||||
* @param posX
|
||||
* X anchor position to draw the tooltip. Generally the mouse's X position.
|
||||
* @param posY
|
||||
* Y anchor position to draw the tooltip. Generally the mouse's Y position.
|
||||
*/
|
||||
protected final void drawTooltip( int posX, int posY, final boolean clearTooltipAfterDraw )
|
||||
{
|
||||
if( !this.tooltip.isEmpty() )
|
||||
{
|
||||
// Disable rescaling
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
|
||||
// Disable lighting
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
|
||||
// Disable depth testing
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
|
||||
// Bounds check the position
|
||||
if( posY < 0 )
|
||||
{
|
||||
posY = 0;
|
||||
}
|
||||
|
||||
// Assume string length is zero
|
||||
int maxStringLength_px = 0;
|
||||
|
||||
// Get max string length from lines in the list
|
||||
for( String string : this.tooltip )
|
||||
{
|
||||
// Get the length of the string
|
||||
int stringLen = this.mc.fontRenderer.getStringWidth( string );
|
||||
|
||||
// Is it larger than the previous length?
|
||||
if( stringLen > maxStringLength_px )
|
||||
{
|
||||
// Set it to maximum
|
||||
maxStringLength_px = stringLen;
|
||||
}
|
||||
}
|
||||
|
||||
// Offset the tooltip slightly
|
||||
posX = posX + AbstractGuiBase.TOOLTIP_OFFSET;
|
||||
posY = posY - AbstractGuiBase.TOOLTIP_OFFSET;
|
||||
|
||||
// Base height of 8
|
||||
int tooltipHeight = AbstractGuiBase.TOOLTIP_EMPTY_HEIGHT;
|
||||
|
||||
// Adjust height based on the number of lines
|
||||
if( this.tooltip.size() > 1 )
|
||||
{
|
||||
// Calculate the line height
|
||||
int lineHeight = ( this.tooltip.size() - 1 ) * AbstractGuiBase.TOOLTIP_LINE_HEIGHT;
|
||||
|
||||
// Adjust the height
|
||||
tooltipHeight += ( AbstractGuiBase.TOOLTIP_HEIGHT_MARGIN + lineHeight );
|
||||
}
|
||||
|
||||
// Get the current z level
|
||||
float prevZlevel = this.zLevel;
|
||||
|
||||
// Set the new level to some high number
|
||||
this.zLevel = 300;
|
||||
|
||||
// Tooltip boundary
|
||||
Bounds bounds = new Bounds( posY - AbstractGuiBase.TOOLTIP_BORDER_SIZE, posX - AbstractGuiBase.TOOLTIP_BORDER_SIZE, posY + tooltipHeight +
|
||||
AbstractGuiBase.TOOLTIP_BORDER_SIZE, posX + maxStringLength_px + AbstractGuiBase.TOOLTIP_BORDER_SIZE );
|
||||
|
||||
// Draw the background and borders
|
||||
this.drawTooltipBackground( bounds );
|
||||
|
||||
// Draw each line
|
||||
for( int index = 0; index < this.tooltip.size(); index++ )
|
||||
{
|
||||
// Get the line
|
||||
String line = this.tooltip.get( index );
|
||||
|
||||
// Draw the line
|
||||
this.mc.fontRenderer.drawStringWithShadow( line, posX, posY, -1 );
|
||||
|
||||
// Is this the first line?
|
||||
if( index == 0 )
|
||||
{
|
||||
// Add the margin
|
||||
posY += AbstractGuiBase.TOOLTIP_HEIGHT_MARGIN;
|
||||
}
|
||||
|
||||
// Add the line height
|
||||
posY += AbstractGuiBase.TOOLTIP_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
// Return the z level to what it was before
|
||||
this.zLevel = prevZlevel;
|
||||
|
||||
// Reenable lighting
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
|
||||
// Reenable depth testing
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
|
||||
// Reenable scaling
|
||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||
|
||||
// Clear the tooltip
|
||||
if( clearTooltipAfterDraw )
|
||||
{
|
||||
this.tooltip.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slot who contains the specified point.
|
||||
*
|
||||
@@ -503,6 +237,30 @@ public abstract class AbstractGuiBase
|
||||
this.onButtonClicked( button, GuiHelper.MOUSE_BUTTON_LEFT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen( final int mouseX, final int mouseY, final float mouseButton )
|
||||
{
|
||||
// Call super
|
||||
super.drawScreen( mouseX, mouseY, mouseButton );
|
||||
|
||||
// Empty tooltip?
|
||||
if( this.tooltip.isEmpty() )
|
||||
{
|
||||
// Get the tooltip from the buttons
|
||||
this.addTooltipFromButtons( mouseX, mouseY );
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
if( !this.tooltip.isEmpty() )
|
||||
{
|
||||
// Draw
|
||||
this.drawHoveringText( this.tooltip, mouseX, mouseY, this.fontRendererObj );
|
||||
|
||||
// Clear the tooltip
|
||||
this.tooltip.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the starting X position for the Gui.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package thaumicenergistics.gui.buttons;
|
||||
|
||||
import java.util.List;
|
||||
import thaumicenergistics.texture.AEStateIconsEnum;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class GuiButtonEncodePattern
|
||||
extends AbstractStateGuiButton
|
||||
{
|
||||
|
||||
public GuiButtonEncodePattern( final int ID, final int posX, final int posY, final int width, final int height )
|
||||
{
|
||||
// Call super
|
||||
super( ID, posX, posY, width, height, AEStateIconsEnum.ARROW_DOWN, 0, 0, AEStateIconsEnum.REGULAR_BUTTON );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip( final List<String> tooltip )
|
||||
{
|
||||
this.addAboutToTooltip( tooltip, ButtonToolTips.Encode.getLocal(), ButtonToolTips.EncodeDescription.getLocal() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package thaumicenergistics.items;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -68,6 +69,8 @@ public class ItemCraftingAspect
|
||||
// Null check
|
||||
if( aspect == null )
|
||||
{
|
||||
// Clear the aspect
|
||||
stack.setTagCompound( null );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,4 +181,11 @@ public class ItemCraftingAspect
|
||||
return StatCollector.translateToLocal( "tc.aspect.unknown" );
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons( final IIconRegister par1IconRegister )
|
||||
{
|
||||
// Handled by special renderer
|
||||
}
|
||||
}
|
||||
@@ -3,35 +3,9 @@ package thaumicenergistics.network;
|
||||
import java.util.HashMap;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.network.packet.ThEAreaPacket;
|
||||
import thaumicenergistics.network.packet.ThEBasePacket;
|
||||
import thaumicenergistics.network.packet.ThEClientPacket;
|
||||
import thaumicenergistics.network.packet.ThEServerPacket;
|
||||
import thaumicenergistics.network.packet.WrapperPacket;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_ArcaneCraftingTerminal;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_EssentiaCellTerminal;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_EssentiaEmitter;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_EssentiaIOBus;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_EssentiaStorageBus;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_EssentiaVibrationChamber;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_KnowledgeInscriber;
|
||||
import thaumicenergistics.network.packet.client.Packet_C_Priority;
|
||||
import thaumicenergistics.network.packet.client.Packet_R_ParticleFX;
|
||||
import thaumicenergistics.network.packet.client.WrapperPacket_C;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_ArcaneCraftingTerminal;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_AspectSlot;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_ChangeGui;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_ConfirmCraftingJob;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_EssentiaCellTerminal;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_EssentiaCellWorkbench;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_EssentiaEmitter;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_EssentiaIOBus;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_EssentiaStorageBus;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_KnowledgeInscriber;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_Priority;
|
||||
import thaumicenergistics.network.packet.server.Packet_S_WrenchFocus;
|
||||
import thaumicenergistics.network.packet.server.WrapperPacket_S;
|
||||
import thaumicenergistics.network.packet.*;
|
||||
import thaumicenergistics.network.packet.client.*;
|
||||
import thaumicenergistics.network.packet.server.*;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
@@ -153,6 +127,9 @@ public class NetworkHandler
|
||||
|
||||
// Confirm crafting
|
||||
registerPacket( Packet_S_ConfirmCraftingJob.class );
|
||||
|
||||
// Distillation encoder
|
||||
registerPacket( Packet_S_DistillationEncoder.class );
|
||||
}
|
||||
|
||||
public static void sendAreaPacketToClients( final ThEAreaPacket areaPacket, final int range )
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package thaumicenergistics.network.packet.server;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import thaumicenergistics.container.ContainerDistillationEncoder;
|
||||
import thaumicenergistics.network.NetworkHandler;
|
||||
import thaumicenergistics.network.packet.ThEServerPacket;
|
||||
|
||||
public class Packet_S_DistillationEncoder
|
||||
extends ThEServerPacket
|
||||
{
|
||||
private static final byte MODE_ENCODE = 1;
|
||||
|
||||
public static void sendEncodePattern( final EntityPlayer player )
|
||||
{
|
||||
// Create a new packet
|
||||
Packet_S_DistillationEncoder packet = new Packet_S_DistillationEncoder();
|
||||
|
||||
// Set the player
|
||||
packet.player = player;
|
||||
|
||||
// Set the mode
|
||||
packet.mode = MODE_ENCODE;
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData( final ByteBuf stream )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData( final ByteBuf stream )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
// Sanity check
|
||||
if( this.mode != MODE_ENCODE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the players open container
|
||||
if( this.player.openContainer instanceof ContainerDistillationEncoder )
|
||||
{
|
||||
// Send the encode
|
||||
( (ContainerDistillationEncoder)this.player.openContainer ).onEncodePattern();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,8 @@ public enum AEStateIconsEnum
|
||||
ENABLED (16, 128),
|
||||
SAVE (0, 176),
|
||||
DELETE (0, 192),
|
||||
CLEAR_GRID (96, 0);
|
||||
CLEAR_GRID (96, 0),
|
||||
ARROW_DOWN (128, 0);
|
||||
|
||||
/**
|
||||
* Location of the AE states texture
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.util.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.util.PrivateInventory;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.api.AEApi;
|
||||
|
||||
public class TileDistillationEncoder
|
||||
extends TileEntity
|
||||
@@ -22,18 +22,18 @@ public class TileDistillationEncoder
|
||||
* Slot counts
|
||||
*/
|
||||
public static int SLOT_SOURCE_ASPECTS_COUNT = 6,
|
||||
SLOT_SAVED_ASPECT_COUNT = 1,
|
||||
SLOT_SELECTED_ASPECT_COUNT = 1,
|
||||
SLOT_PATTERNS_COUNT = 2,
|
||||
SLOT_INPUT_ITEM_COUNT = 1,
|
||||
SLOT_TOTAL_COUNT = SLOT_INPUT_ITEM_COUNT + SLOT_SOURCE_ASPECTS_COUNT + SLOT_SAVED_ASPECT_COUNT + SLOT_PATTERNS_COUNT;
|
||||
SLOT_SOURCE_ITEM_COUNT = 1,
|
||||
SLOT_TOTAL_COUNT = SLOT_SOURCE_ITEM_COUNT + SLOT_SOURCE_ASPECTS_COUNT + SLOT_SELECTED_ASPECT_COUNT + SLOT_PATTERNS_COUNT;
|
||||
/**
|
||||
* Slot ID's
|
||||
*/
|
||||
public static int SLOT_SOURCE_ITEM = 0,
|
||||
SLOT_EMPTY_PATTERNS = 1,
|
||||
SLOT_BLANK_PATTERNS = 1,
|
||||
SLOT_ENCODED_PATTERN = 2,
|
||||
SLOT_SOURCE_ASPECTS = 3,
|
||||
SLOT_SAVED_ASPECT = SLOT_SOURCE_ASPECTS + SLOT_SOURCE_ASPECTS_COUNT;
|
||||
SLOT_SELECTED_ASPECT = SLOT_SOURCE_ASPECTS + SLOT_SOURCE_ASPECTS_COUNT;
|
||||
|
||||
/**
|
||||
* Stores the inventory for this tile.
|
||||
@@ -50,19 +50,19 @@ public class TileDistillationEncoder
|
||||
}
|
||||
|
||||
// Empty pattern slot?
|
||||
if( slotId == SLOT_EMPTY_PATTERNS )
|
||||
if( slotId == SLOT_BLANK_PATTERNS )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemEncodedPattern );
|
||||
return AEApi.instance().definitions().materials().blankPattern().isSameAs( itemStack );
|
||||
}
|
||||
|
||||
// Encoded pattern slot?
|
||||
if( slotId == SLOT_ENCODED_PATTERN )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemEncodedPattern );
|
||||
return AEApi.instance().definitions().items().encodedPattern().isSameAs( itemStack );
|
||||
}
|
||||
|
||||
// Aspect slot?
|
||||
if( ( slotId >= SLOT_SOURCE_ASPECTS ) && ( slotId <= SLOT_SAVED_ASPECT ) )
|
||||
if( ( slotId >= SLOT_SOURCE_ASPECTS ) && ( slotId <= SLOT_SELECTED_ASPECT ) )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemCraftingAspect );
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class TileDistillationEncoder
|
||||
{
|
||||
// Is there anything in the pattern slots?
|
||||
return( ( this.internalInventory.slots[SLOT_ENCODED_PATTERN] != null )
|
||||
|| ( this.internalInventory.slots[SLOT_EMPTY_PATTERNS] != null ) );
|
||||
|| ( this.internalInventory.slots[SLOT_BLANK_PATTERNS] != null ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
|
||||
public class DistillationPatternHelper
|
||||
{
|
||||
@@ -19,67 +20,21 @@ public class DistillationPatternHelper
|
||||
* Output of the pattern.
|
||||
* Must be ItemCraftingAspect patterns.
|
||||
*/
|
||||
public ItemStack output = null;
|
||||
protected ItemStack output = null;
|
||||
|
||||
/**
|
||||
* Input of the pattern.
|
||||
*/
|
||||
public ItemStack input = null;
|
||||
protected ItemStack input = null;
|
||||
|
||||
/**
|
||||
* Loads the values from the pattern
|
||||
*
|
||||
* @param pattern
|
||||
*/
|
||||
public void loadFromPattern( final ItemStack pattern )
|
||||
public void encodePattern( final ItemStack pattern )
|
||||
{
|
||||
// Reset
|
||||
this.reset();
|
||||
|
||||
if( !pattern.hasTagCompound() )
|
||||
// Valid pattern?
|
||||
if( pattern == null )
|
||||
{
|
||||
// Nothing to load
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the NBT tag
|
||||
NBTTagCompound data = pattern.getTagCompound();
|
||||
|
||||
// Get the input and output list
|
||||
NBTTagList inTags = data.getTagList( NBTKEY_AE_IN, NBT.TAG_COMPOUND );
|
||||
NBTTagList outTags = data.getTagList( NBTKEY_AE_OUT, NBT.TAG_COMPOUND );
|
||||
|
||||
// Empty check
|
||||
if( ( outTags.tagCount() < 1 ) || ( inTags.tagCount() < 1 ) )
|
||||
{
|
||||
// Nothing to load.
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the input and output
|
||||
this.output = ItemStack.loadItemStackFromNBT( outTags.getCompoundTagAt( 0 ) );
|
||||
this.input = ItemStack.loadItemStackFromNBT( inTags.getCompoundTagAt( 0 ) );
|
||||
|
||||
// Null check
|
||||
if( ( this.input == null ) || ( this.output == null ) )
|
||||
{
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the helper.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
this.output = null;
|
||||
this.input = null;
|
||||
}
|
||||
|
||||
public void writeToPattern( final ItemStack pattern )
|
||||
{
|
||||
// Check the input & output
|
||||
if( ( this.input == null ) || ( this.output == null ) )
|
||||
{
|
||||
@@ -110,4 +65,138 @@ public class DistillationPatternHelper
|
||||
pattern.setTagCompound( data );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input of the pattern.
|
||||
* May be null.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ItemStack getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output of the pattern.
|
||||
* May be null.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ItemStack getOutput()
|
||||
{
|
||||
return this.output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current items are valid.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isValid()
|
||||
{
|
||||
return( ( this.output != null ) && ( this.input != null ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the values from the pattern
|
||||
*
|
||||
* @param pattern
|
||||
*/
|
||||
public void readPattern( final ItemStack pattern )
|
||||
{
|
||||
// Reset
|
||||
this.reset();
|
||||
|
||||
// Valid pattern?
|
||||
if( pattern == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pattern.hasTagCompound() )
|
||||
{
|
||||
// Nothing to load
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the NBT tag
|
||||
NBTTagCompound data = pattern.getTagCompound();
|
||||
|
||||
// Get the input and output list
|
||||
NBTTagList inTags = data.getTagList( NBTKEY_AE_IN, NBT.TAG_COMPOUND );
|
||||
NBTTagList outTags = data.getTagList( NBTKEY_AE_OUT, NBT.TAG_COMPOUND );
|
||||
|
||||
// Empty check
|
||||
if( ( outTags.tagCount() < 1 ) || ( inTags.tagCount() < 1 ) )
|
||||
{
|
||||
// Nothing to load.
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the input and output
|
||||
this.setOutputItem( ItemStack.loadItemStackFromNBT( outTags.getCompoundTagAt( 0 ) ) );
|
||||
this.setInputItem( ItemStack.loadItemStackFromNBT( inTags.getCompoundTagAt( 0 ) ) );
|
||||
|
||||
// Null check
|
||||
if( ( this.input == null ) || ( this.output == null ) )
|
||||
{
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the helper.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
this.output = null;
|
||||
this.input = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input.
|
||||
*
|
||||
* @param inputItem
|
||||
*/
|
||||
public void setInputItem( final ItemStack inputItem )
|
||||
{
|
||||
this.input = inputItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the output.
|
||||
* Must be a crafting aspect.
|
||||
*
|
||||
* @param outputItem
|
||||
*/
|
||||
public void setOutputItem( final ItemStack outputItem )
|
||||
{
|
||||
// Crafting aspect?
|
||||
if( ( outputItem != null ) && !( outputItem.getItem() instanceof ItemCraftingAspect ) )
|
||||
{
|
||||
this.output = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.output = outputItem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input and output items.
|
||||
* Returns if the recipe is valid or not.
|
||||
*
|
||||
* @param inputItem
|
||||
* @param outputItem
|
||||
* @return
|
||||
*/
|
||||
public boolean setPatternItems( final ItemStack inputItem, final ItemStack outputItem )
|
||||
{
|
||||
this.setInputItem( inputItem );
|
||||
this.setOutputItem( outputItem );
|
||||
return this.isValid();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user