mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Beta 2 + Particles
Fixed #261 AE2-RV3-Beta-2 issue Added particle effects to Knowledge Inscriber.
This commit is contained in:
1 parent
9f338f4239
commit
bafb097aab
9 files changed
+298
-45
No files matched your search
+5
-1
@@ -1,4 +1,8 @@
|
||||
12/28/2015 0.9.1.2 - Beta
|
||||
12/29/2015 0.9.1.2 - Beta
|
||||
Fixed #261 AE2-RV3-Beta-2 issue
|
||||
Added particle effects to Knowledge Inscriber.
|
||||
|
||||
12/28/2015 0.9.1.2 - Beta
|
||||
Complete network code overhaul.
|
||||
|
||||
12/28/2015 0.9.1.1 - Beta
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ContainerKnowledgeInscriber
|
||||
/**
|
||||
* Knowledge core slot.
|
||||
*/
|
||||
private static final int KCORE_SLOT_X = 186, KCORE_SLOT_Y = 8;
|
||||
public static final int KCORE_SLOT_X = 186, KCORE_SLOT_Y = 8;
|
||||
|
||||
/**
|
||||
* Pattern slots.
|
||||
@@ -61,7 +61,7 @@ public class ContainerKnowledgeInscriber
|
||||
/**
|
||||
* Crafting slots
|
||||
*/
|
||||
private static final int CRAFTING_SLOT_X = 26, CRAFTING_SLOT_Y = 90, CRAFTING_ROWS = 3, CRAFTING_COLS = 3, CRAFTING_SLOT_SPACING = 18;
|
||||
public static final int CRAFTING_SLOT_X = 26, CRAFTING_SLOT_Y = 90, CRAFTING_ROWS = 3, CRAFTING_COLS = 3, CRAFTING_SLOT_SPACING = 18;
|
||||
|
||||
/**
|
||||
* Maximum number of patterns.
|
||||
@@ -418,7 +418,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( this.player );
|
||||
this.onClientRequestFullUpdate( this.player, false );
|
||||
|
||||
// Mark the inscriber as dirty
|
||||
this.inscriber.markDirty();
|
||||
@@ -432,10 +432,10 @@ public class ContainerKnowledgeInscriber
|
||||
/**
|
||||
* Sends the save-state to the client.
|
||||
*/
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player )
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player, final boolean justSaved )
|
||||
{
|
||||
// Update the client
|
||||
Packet_C_KnowledgeInscriber.sendSaveState( player, this.getSaveState() );
|
||||
Packet_C_KnowledgeInscriber.sendSaveState( player, this.getSaveState(), justSaved );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,7 +495,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.loadPattern( pattern );
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( player );
|
||||
this.onClientRequestFullUpdate( player, true );
|
||||
|
||||
// Mark the inscriber as dirty
|
||||
this.inscriber.markDirty();
|
||||
@@ -515,7 +515,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( player );
|
||||
this.onClientRequestFullUpdate( player, false );
|
||||
|
||||
// Mark the inscriber as dirty
|
||||
this.inscriber.markDirty();
|
||||
@@ -547,7 +547,7 @@ public class ContainerKnowledgeInscriber
|
||||
// Update the client
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
this.onClientRequestFullUpdate( this.player );
|
||||
this.onClientRequestFullUpdate( this.player, false );
|
||||
}
|
||||
|
||||
// Sync
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GuiEssentiaVibrationChamber
|
||||
/**
|
||||
* Dimensions and location of the power bar.
|
||||
*/
|
||||
private static final int POWER_POS_X = 96, POWER_POS_Y = 32, POWER_TEX_X = 51, POWER_TEX_Y = 83, POWER_WIDTH = 6, POWER_HEIGHT = 18;
|
||||
private static final int POWER_POS_X = 96, POWER_POS_Y = 32, POWER_TEX_U = 51, POWER_TEX_V = 83, POWER_WIDTH = 6, POWER_HEIGHT = 18;
|
||||
|
||||
/**
|
||||
* Dimensions and location of the essentia storage level bar.
|
||||
@@ -116,9 +116,12 @@ public class GuiEssentiaVibrationChamber
|
||||
int powerBarHeightOffset = (int)( GuiEssentiaVibrationChamber.POWER_HEIGHT * this.container.getPowerPercent() );
|
||||
|
||||
// Draw the power bar
|
||||
this.drawTexturedModalRect( this.guiLeft + GuiEssentiaVibrationChamber.POWER_POS_X, this.guiTop + GuiEssentiaVibrationChamber.POWER_POS_Y +
|
||||
powerBarHeightOffset, GuiEssentiaVibrationChamber.POWER_TEX_X,
|
||||
GuiEssentiaVibrationChamber.POWER_TEX_Y + powerBarHeightOffset, GuiEssentiaVibrationChamber.POWER_WIDTH,
|
||||
this.drawTexturedModalRect(
|
||||
this.guiLeft + GuiEssentiaVibrationChamber.POWER_POS_X,
|
||||
this.guiTop + GuiEssentiaVibrationChamber.POWER_POS_Y + powerBarHeightOffset,
|
||||
GuiEssentiaVibrationChamber.POWER_TEX_U,
|
||||
GuiEssentiaVibrationChamber.POWER_TEX_V + powerBarHeightOffset,
|
||||
GuiEssentiaVibrationChamber.POWER_WIDTH,
|
||||
GuiEssentiaVibrationChamber.POWER_HEIGHT - powerBarHeightOffset );
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package thaumicenergistics.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -15,11 +16,88 @@ import thaumicenergistics.network.packet.server.Packet_S_KnowledgeInscriber;
|
||||
import thaumicenergistics.registries.ThEStrings;
|
||||
import thaumicenergistics.texture.GuiTextureManager;
|
||||
|
||||
// TODO: QOL: Knowledge Inscriber GUI: add particles like focal manipulator
|
||||
|
||||
public class GuiKnowledgeInscriber
|
||||
extends AbstractGuiBase
|
||||
{
|
||||
private class SaveParticle
|
||||
{
|
||||
private int startX, startY;
|
||||
private int distX, distY;
|
||||
private float percent;
|
||||
private int slot;
|
||||
|
||||
public SaveParticle( final int slotNumber )
|
||||
{
|
||||
// Set percentage
|
||||
this.percent = 1.0f;
|
||||
|
||||
// Set slot
|
||||
this.slot = slotNumber;
|
||||
|
||||
// Calculate starting postion
|
||||
this.startX = ContainerKnowledgeInscriber.CRAFTING_SLOT_X + (
|
||||
( slotNumber % ContainerKnowledgeInscriber.CRAFTING_COLS )
|
||||
* ContainerKnowledgeInscriber.CRAFTING_SLOT_SPACING );
|
||||
|
||||
this.startY = ContainerKnowledgeInscriber.CRAFTING_SLOT_Y + (
|
||||
( slotNumber / ContainerKnowledgeInscriber.CRAFTING_COLS )
|
||||
* ContainerKnowledgeInscriber.CRAFTING_SLOT_SPACING );
|
||||
|
||||
// Calculate distances
|
||||
this.distX = ContainerKnowledgeInscriber.KCORE_SLOT_X - this.startX;
|
||||
this.distY = ContainerKnowledgeInscriber.KCORE_SLOT_Y - this.startY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the particle. Assumes prepare and finish are called elsewhere.
|
||||
*
|
||||
* @param gui
|
||||
* @param percentDelta
|
||||
* @param frame
|
||||
*/
|
||||
public void draw( final Gui gui, final float percentDelta, final int frame )
|
||||
{
|
||||
// Add delta
|
||||
this.percent += percentDelta;
|
||||
|
||||
// Bounds check
|
||||
if( this.percent >= 1.0f )
|
||||
{
|
||||
this.percent = 1.0f;
|
||||
}
|
||||
else if( this.percent < 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate X and Y
|
||||
int X = this.startX + (int)( this.distX * this.percent );
|
||||
int Y = this.startY + (int)( this.distY * this.percent );
|
||||
|
||||
// Draw
|
||||
GuiParticle.Knowledge.drawParticle( gui, X, Y, frame, 0.2f, 0.5f, 1.0f, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the particle is not finished drawing
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean notFinished()
|
||||
{
|
||||
return( this.percent < 1.0f );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the particle to be draw again.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
// Set percentage
|
||||
this.percent = -( this.slot / 8.0f );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gui size.
|
||||
*/
|
||||
@@ -50,6 +128,16 @@ public class GuiKnowledgeInscriber
|
||||
*/
|
||||
private CoreSaveState saveState = CoreSaveState.Disabled_MissingCore;
|
||||
|
||||
/**
|
||||
* Save particles
|
||||
*/
|
||||
private SaveParticle[] particles;
|
||||
|
||||
/**
|
||||
* True if particles need to be drawn.
|
||||
*/
|
||||
private boolean hasParticlesToDraw = false;
|
||||
|
||||
/**
|
||||
* Player viewing the GUI.
|
||||
*/
|
||||
@@ -69,6 +157,39 @@ public class GuiKnowledgeInscriber
|
||||
|
||||
// Set title
|
||||
this.title = ThEStrings.Block_KnowledgeInscriber.getLocalized();
|
||||
|
||||
// Setup the particles
|
||||
this.particles = new SaveParticle[ContainerKnowledgeInscriber.CRAFTING_COLS * ContainerKnowledgeInscriber.CRAFTING_ROWS];
|
||||
for( int index = 0; index < this.particles.length; ++index )
|
||||
{
|
||||
this.particles[index] = new SaveParticle( index );
|
||||
}
|
||||
}
|
||||
|
||||
private void drawSaveParticles()
|
||||
{
|
||||
int time = (int)( System.currentTimeMillis() % Integer.MAX_VALUE );
|
||||
|
||||
// Calculate frame number
|
||||
int frame = ( time / 125 );
|
||||
|
||||
// Set percent delta
|
||||
// NOTE: This should be time based, not FPS based. But lazy.
|
||||
float percentDelta = 0.03f;
|
||||
|
||||
// Assume all particles are drawn
|
||||
this.hasParticlesToDraw = false;
|
||||
|
||||
GuiParticle.Knowledge.prepareDraw();
|
||||
for( int index = 0; index < this.particles.length; ++index )
|
||||
{
|
||||
// Draw the particle
|
||||
this.particles[index].draw( this, percentDelta, frame );
|
||||
|
||||
// Is the particle not done?
|
||||
this.hasParticlesToDraw |= this.particles[index].notFinished();
|
||||
}
|
||||
GuiParticle.finishDraw();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,6 +241,12 @@ public class GuiKnowledgeInscriber
|
||||
// Draw the tooltip
|
||||
this.drawTooltip( mouseX - this.guiLeft, mouseY - this.guiTop, true );
|
||||
}
|
||||
|
||||
// Any particles to draw?
|
||||
if( this.hasParticlesToDraw )
|
||||
{
|
||||
this.drawSaveParticles();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,8 +282,9 @@ public class GuiKnowledgeInscriber
|
||||
* functionality.
|
||||
*
|
||||
* @param saveState
|
||||
* @param justSaved
|
||||
*/
|
||||
public void onReceiveSaveState( final CoreSaveState saveState )
|
||||
public void onReceiveSaveState( final CoreSaveState saveState, final boolean justSaved )
|
||||
{
|
||||
// Set the state
|
||||
this.saveState = saveState;
|
||||
@@ -166,5 +294,16 @@ public class GuiKnowledgeInscriber
|
||||
{
|
||||
this.saveButton.setSaveState( saveState );
|
||||
}
|
||||
|
||||
// Was a pattern just saved?
|
||||
if( justSaved )
|
||||
{
|
||||
// Reset all particles
|
||||
for( int index = 0; index < this.particles.length; ++index )
|
||||
{
|
||||
this.particles[index].reset();
|
||||
}
|
||||
this.hasParticlesToDraw = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package thaumicenergistics.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum GuiParticle
|
||||
{
|
||||
Orb (thaumcraft.client.fx.ParticleEngine.particleTexture, 0, 128, 16, 16, 16, 0, 16),
|
||||
Rune (thaumcraft.client.fx.ParticleEngine.particleTexture, 0, 96, 16, 16, 16, 0, 16),
|
||||
Wispy (thaumcraft.client.fx.ParticleEngine.particleTexture, 0, 80, 16, 16, 16, 0, 16),
|
||||
Knowledge (thaumcraft.client.fx.ParticleEngine.particleTexture, 0, 64, 16, 16, 16, 0, 4);
|
||||
|
||||
/**
|
||||
* Location of the particle in the texture.
|
||||
*/
|
||||
private int txU, txV, width, height;
|
||||
|
||||
/**
|
||||
* Amount that U and V change during each animation step.
|
||||
*/
|
||||
private int animationUStep, animationVStep;
|
||||
|
||||
/**
|
||||
* Number of frames in the animation.
|
||||
* Can not be 0.
|
||||
*/
|
||||
private int FrameCount;
|
||||
|
||||
/**
|
||||
* Texture used to draw the particle.
|
||||
*/
|
||||
private ResourceLocation texture;
|
||||
|
||||
private GuiParticle( final ResourceLocation textureLocation, final int U, final int V, final int width, final int height,
|
||||
final int UStep, final int VStep, final int Frames )
|
||||
{
|
||||
this.texture = textureLocation;
|
||||
this.txU = U;
|
||||
this.txV = V;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.animationUStep = UStep;
|
||||
this.animationVStep = VStep;
|
||||
this.FrameCount = Frames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the engine state.
|
||||
*/
|
||||
public static void finishDraw()
|
||||
{
|
||||
// Set color to white
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
// Disable blending
|
||||
GL11.glDisable( GL11.GL_BLEND );
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the particle.
|
||||
* If settings "needsPrepare" to false, prepare and finish must be called manually.
|
||||
* However this can be useful if drawing multiple of the same particle.
|
||||
*
|
||||
* @param gui
|
||||
* @param positionX
|
||||
* @param positionY
|
||||
* @param frameNumber
|
||||
* @param red
|
||||
* @param green
|
||||
* @param blue
|
||||
* @param needsPrepare
|
||||
*/
|
||||
public void drawParticle( final Gui gui, final int positionX, final int positionY, final int frameNumber, final float red, final float green,
|
||||
final float blue, final boolean needsPrepare )
|
||||
{
|
||||
if( needsPrepare )
|
||||
{
|
||||
this.prepareDraw();
|
||||
}
|
||||
|
||||
// Wrap the frame number
|
||||
int frameIndex = frameNumber % this.FrameCount;
|
||||
|
||||
// Calculate the U position
|
||||
int U = this.txU + ( this.animationUStep * frameIndex );
|
||||
|
||||
// Calculate the V position
|
||||
int V = this.txV + ( this.animationVStep * frameIndex );
|
||||
|
||||
// Set tint color
|
||||
GL11.glColor4f( red, green, blue, 0.90f );
|
||||
|
||||
// Draw the particle
|
||||
gui.drawTexturedModalRect( positionX, positionY, U, V, this.width, this.height );
|
||||
|
||||
if( needsPrepare )
|
||||
{
|
||||
GuiParticle.finishDraw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the engine to draw this particle.
|
||||
* Must be called before drawing, but can be called once then
|
||||
* draw called multiple times for the same particle.
|
||||
*/
|
||||
public void prepareDraw()
|
||||
{
|
||||
// Bind the texture
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture( this.texture );
|
||||
|
||||
// Enable alpha blending
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE );
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -21,7 +21,9 @@ public class Packet_C_KnowledgeInscriber
|
||||
|
||||
private CoreSaveState saveState;
|
||||
|
||||
public static void sendSaveState( final EntityPlayer player, final CoreSaveState saveState )
|
||||
private boolean justSaved;
|
||||
|
||||
public static void sendSaveState( final EntityPlayer player, final CoreSaveState saveState, final boolean justSaved )
|
||||
{
|
||||
Packet_C_KnowledgeInscriber packet = new Packet_C_KnowledgeInscriber();
|
||||
|
||||
@@ -33,6 +35,7 @@ public class Packet_C_KnowledgeInscriber
|
||||
|
||||
// Set the state
|
||||
packet.saveState = saveState;
|
||||
packet.justSaved = justSaved;
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToClient( packet );
|
||||
@@ -42,6 +45,7 @@ public class Packet_C_KnowledgeInscriber
|
||||
protected void readData( final ByteBuf stream )
|
||||
{
|
||||
this.saveState = Packet_C_KnowledgeInscriber.SAVE_STATES[stream.readInt()];
|
||||
this.justSaved = stream.readBoolean();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -54,7 +58,7 @@ public class Packet_C_KnowledgeInscriber
|
||||
// Ensure it is the knowledge inscriber
|
||||
if( gui instanceof GuiKnowledgeInscriber )
|
||||
{
|
||||
( (GuiKnowledgeInscriber)gui ).onReceiveSaveState( this.saveState );
|
||||
( (GuiKnowledgeInscriber)gui ).onReceiveSaveState( this.saveState, this.justSaved );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,6 +67,7 @@ public class Packet_C_KnowledgeInscriber
|
||||
protected void writeData( final ByteBuf stream )
|
||||
{
|
||||
stream.writeInt( this.saveState.ordinal() );
|
||||
stream.writeBoolean( this.justSaved );
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class Packet_S_KnowledgeInscriber
|
||||
{
|
||||
case Packet_S_KnowledgeInscriber.MODE_FULL_UPDATE:
|
||||
// Request full update
|
||||
( (ContainerKnowledgeInscriber)this.player.openContainer ).onClientRequestFullUpdate( this.player );
|
||||
( (ContainerKnowledgeInscriber)this.player.openContainer ).onClientRequestFullUpdate( this.player, false );
|
||||
break;
|
||||
|
||||
case Packet_S_KnowledgeInscriber.MODE_SAVEDELETE:
|
||||
|
||||
@@ -87,10 +87,6 @@ public class AEPartEssentiaLevelEmitter
|
||||
*/
|
||||
private IEssentiaWatcher essentiaWatcher;
|
||||
|
||||
// TODO: Remove debug
|
||||
//private int debugTrackingStage = 0;
|
||||
//private int debugMonID = 0;
|
||||
|
||||
/**
|
||||
* Creates the part
|
||||
*/
|
||||
@@ -475,15 +471,6 @@ public class AEPartEssentiaLevelEmitter
|
||||
// Read the activity state
|
||||
this.isEmitting = stream.readBoolean();
|
||||
|
||||
// TODO: Remove debug code
|
||||
/*
|
||||
this.currentAmount = stream.readLong();
|
||||
this.wantedAmount = stream.readLong();
|
||||
this.trackedEssentia = AbstractPacket.readAspect( stream );
|
||||
this.debugTrackingStage = stream.readInt();
|
||||
this.debugMonID = stream.readInt();
|
||||
*/
|
||||
|
||||
// Redraw if changed
|
||||
redraw |= ( this.isEmitting != oldEmit );
|
||||
|
||||
@@ -562,7 +549,6 @@ public class AEPartEssentiaLevelEmitter
|
||||
|
||||
// Mark that we need to be saved and updated
|
||||
this.markForSave();
|
||||
//this.markForUpdate(); // TODO: Remove debug
|
||||
|
||||
// Update the watcher
|
||||
this.configureWatcher();
|
||||
@@ -656,14 +642,5 @@ public class AEPartEssentiaLevelEmitter
|
||||
|
||||
// Write the activity state
|
||||
stream.writeBoolean( this.isEmitting );
|
||||
|
||||
// TODO: Remove debug code
|
||||
/*
|
||||
stream.writeLong( this.currentAmount );
|
||||
stream.writeLong( this.wantedAmount );
|
||||
AbstractPacket.writeAspect( this.trackedEssentia, stream );
|
||||
stream.writeInt( this.debugTrackingStage );
|
||||
stream.writeInt( this.debugMonID );
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -549,13 +549,17 @@ public abstract class AbstractAEPartEssentiaIOBus
|
||||
{
|
||||
if( data.hasKey( AbstractAEPartEssentiaIOBus.NBT_KEY_FILTER_NUMBER + index ) )
|
||||
{
|
||||
String aspectTag = data.getString( AbstractAEPartEssentiaIOBus.NBT_KEY_FILTER_NUMBER + index );
|
||||
Aspect filterAspect = null;
|
||||
|
||||
// TODO: Remove legacy check in a few versions....
|
||||
// Get the name of the aspect
|
||||
String aspectTag = data.getString( AbstractAEPartEssentiaIOBus.NBT_KEY_FILTER_NUMBER + index );
|
||||
if( !aspectTag.equals( "" ) )
|
||||
{
|
||||
this.filteredAspects.set( index, Aspect.aspects.get( aspectTag ) );
|
||||
filterAspect = Aspect.aspects.get( aspectTag );
|
||||
|
||||
}
|
||||
|
||||
this.filteredAspects.set( index, filterAspect );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user