mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Autocrafting essentia.
Began integrating essentia into crafting system, #53. Added "Essentia" item.
This commit is contained in:
1 parent
bafb097aab
commit
58b3cdd5fb
9 files changed
+373
-6
No files matched your search
+5
-1
@@ -1,4 +1,8 @@
|
||||
12/29/2015 0.9.1.2 - Beta
|
||||
12/29/2015 0.10.0.0 - Beta
|
||||
Began integrating essentia into crafting system.
|
||||
Added "Essentia" item.
|
||||
|
||||
12/29/2015 0.9.1.2 - Beta
|
||||
Fixed #261 AE2-RV3-Beta-2 issue
|
||||
Added particle effects to Knowledge Inscriber.
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "0.9.1.2"
|
||||
version = "0.10.0.0"
|
||||
group= "thaumicenergistics" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "thaumicenergistics"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ThaumicEnergistics
|
||||
/**
|
||||
* Current version of the mod.
|
||||
*/
|
||||
public static final String VERSION = "0.9.1.2"; // Note: don't forget to change the build.gradle file as well
|
||||
public static final String VERSION = "0.10.0.0"; // Note: don't forget to change the build.gradle file as well
|
||||
|
||||
/**
|
||||
* Singleton instance
|
||||
|
||||
@@ -2,16 +2,27 @@ package thaumicenergistics.grid;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.aspect.AspectStack;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.registries.ItemEnum;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridStorage;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPostCacheConstruction;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Creates an essentia monitor for the attached grid.
|
||||
@@ -207,6 +218,11 @@ public class GridEssentiaCache
|
||||
*/
|
||||
private final WatcherManager watcherManger;
|
||||
|
||||
/**
|
||||
* The 'result' of essentia crafting operations.
|
||||
*/
|
||||
private final ItemStack aspectItem;
|
||||
|
||||
public GridEssentiaCache( final IGrid grid )
|
||||
{
|
||||
// Set the grid
|
||||
@@ -214,6 +230,9 @@ public class GridEssentiaCache
|
||||
|
||||
// Create the watcher manager
|
||||
this.watcherManger = new WatcherManager();
|
||||
|
||||
// Set the aspect item
|
||||
this.aspectItem = ItemEnum.CRAFTING_ASPECT.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,6 +255,73 @@ public class GridEssentiaCache
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long injectEssentia( final Aspect aspect, final long amount, final Actionable mode, final BaseActionSource source, final boolean powered )
|
||||
{
|
||||
// Call super
|
||||
long amountRejected = super.injectEssentia( aspect, amount, mode, source, powered );
|
||||
|
||||
if( ( mode == Actionable.MODULATE ) && ( amountRejected < amount ) )
|
||||
{
|
||||
// Get the crafting grid
|
||||
ICraftingGrid craftingGrid = this.internalGrid.getCache( ICraftingGrid.class );
|
||||
|
||||
// Get the CPU list
|
||||
ImmutableSet<ICraftingCPU> cpus = craftingGrid.getCpus();
|
||||
|
||||
// Are there any crafting CPU's?
|
||||
if( cpus.size() > 0 )
|
||||
{
|
||||
// Set the aspect
|
||||
ItemCraftingAspect.setAspect( this.aspectItem, aspect );
|
||||
|
||||
// Delay creating this as long as possible
|
||||
IAEItemStack aspectAEItem = null;
|
||||
|
||||
// Set the amounts
|
||||
long amountToInject = amount - amountRejected;
|
||||
|
||||
// Are any CPU's waiting for this?
|
||||
for( ICraftingCPU cpu : cpus )
|
||||
{
|
||||
// Is the cpu crafting, and is it a cluster?
|
||||
if( cpu.isBusy() && ( cpu instanceof CraftingCPUCluster ) )
|
||||
{
|
||||
if( aspectAEItem == null )
|
||||
{
|
||||
// Create AE version
|
||||
aspectAEItem = AEApi.instance().storage().createItemStack( this.aspectItem );
|
||||
aspectAEItem.setStackSize( 1 );
|
||||
}
|
||||
|
||||
// Cast
|
||||
CraftingCPUCluster cluster = (CraftingCPUCluster)cpu;
|
||||
|
||||
// Is the cluster waiting for an aspect item?
|
||||
if( cluster.isMaking( aspectAEItem ) )
|
||||
{
|
||||
// Not a fan of the loop, but inject items doesn't return anything useful
|
||||
for( ; ( amountToInject > 0 ) && ( cluster.isBusy() ); --amountToInject )
|
||||
{
|
||||
// Inject the aspect item
|
||||
cluster.injectItems( aspectAEItem, mode, source );
|
||||
}
|
||||
|
||||
// Has everything been accounted for?
|
||||
if( amountToInject == 0 )
|
||||
{
|
||||
// All done
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return amountRejected;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onGridCacheReady( final MENetworkPostCacheConstruction event )
|
||||
{
|
||||
|
||||
@@ -3,9 +3,11 @@ package thaumicenergistics.gui.widget;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.aspect.AspectStack;
|
||||
import thaumicenergistics.registries.ThEStrings;
|
||||
import thaumicenergistics.util.GuiHelper;
|
||||
|
||||
public class WidgetAspectSelector
|
||||
@@ -208,10 +210,13 @@ public class WidgetAspectSelector
|
||||
{
|
||||
|
||||
// Add the name
|
||||
tooltip.add( this.aspectName );
|
||||
tooltip.add( ThEStrings.Gui_SelectedAspect.getLocalized() + ": " + this.aspectName );
|
||||
|
||||
// Add the amount
|
||||
tooltip.add( Long.toString( this.amount ) );
|
||||
tooltip.add( ThEStrings.Gui_SelectedAmount.getLocalized() + ": " + Long.toString( this.amount ) );
|
||||
|
||||
// Add aspect info
|
||||
tooltip.add( EnumChatFormatting.GRAY.toString() + this.getAspect().getLocalizedDescription() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
package thaumicenergistics.items;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCraftingAspect
|
||||
extends Item
|
||||
{
|
||||
private static final String NBTKEY_ASPECT = "Aspect";
|
||||
|
||||
public IIcon icon;
|
||||
|
||||
public ItemCraftingAspect()
|
||||
{
|
||||
this.setMaxStackSize( 64 );
|
||||
this.setHasSubtypes( true );
|
||||
this.setMaxDamage( 0 );
|
||||
this.setCreativeTab( ThaumicEnergistics.ThETab );
|
||||
this.setUnlocalizedName( "itemCraftingAspect" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the player has discovered the aspect.
|
||||
*
|
||||
* @param player
|
||||
* @param aspect
|
||||
* @return
|
||||
*/
|
||||
public static boolean canPlayerSeeAspect( @Nonnull final EntityPlayer player, @Nonnull final Aspect aspect )
|
||||
{
|
||||
return Thaumcraft.proxy.playerKnowledge.hasDiscoveredAspect( player.getCommandSenderName(), aspect );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the aspect associated with the item
|
||||
*
|
||||
* @param itemstack
|
||||
* @return
|
||||
*/
|
||||
public static Aspect getAspect( final ItemStack itemstack )
|
||||
{
|
||||
if( itemstack.hasTagCompound() )
|
||||
{
|
||||
// Get the tag
|
||||
NBTTagCompound tag = itemstack.getTagCompound();
|
||||
|
||||
if( tag.hasKey( NBTKEY_ASPECT ) )
|
||||
{
|
||||
// Get the aspect
|
||||
return Aspect.getAspect( tag.getString( NBTKEY_ASPECT ) );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setAspect( final ItemStack stack, final Aspect aspect )
|
||||
{
|
||||
// Null check
|
||||
if( aspect == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = null;
|
||||
|
||||
// Is there a tag?
|
||||
if( !stack.hasTagCompound() )
|
||||
{
|
||||
// Create the tag
|
||||
tag = new NBTTagCompound();
|
||||
|
||||
// Set the tag
|
||||
stack.setTagCompound( tag );
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = stack.getTagCompound();
|
||||
}
|
||||
|
||||
// Set the aspect
|
||||
tag.setString( NBTKEY_ASPECT, aspect.getTag() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( final ItemStack stack, final EntityPlayer player, final List list, final boolean advancedInfo )
|
||||
{
|
||||
// Call super
|
||||
super.addInformation( stack, player, list, advancedInfo );
|
||||
|
||||
// Is there an aspect associated?
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( stack );
|
||||
if( aspect != null )
|
||||
{
|
||||
// Has the player discovered this aspect?
|
||||
if( ItemCraftingAspect.canPlayerSeeAspect( player, aspect ) )
|
||||
{
|
||||
// Add the aspect info
|
||||
list.add( aspect.getLocalizedDescription() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show unknown
|
||||
list.add( StatCollector.translateToLocal( "tc.aspect.unknown" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack( final ItemStack stack, final int renderPass )
|
||||
{
|
||||
// Is there an aspect associated?
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( stack );
|
||||
if( aspect != null )
|
||||
{
|
||||
// Return it's color
|
||||
return aspect.getColor();
|
||||
}
|
||||
|
||||
// Pass to super
|
||||
return super.getColorFromItemStack( stack, renderPass );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName( final ItemStack stack )
|
||||
{
|
||||
return this.getUnlocalizedNameInefficiently( stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems( final Item item, final CreativeTabs par2CreativeTabs, final List itemList )
|
||||
{
|
||||
// Note: Don't show these
|
||||
/*
|
||||
for( Aspect aspect : Aspect.aspects.values() )
|
||||
{
|
||||
ItemStack stack = new ItemStack( this, 1, 0 );
|
||||
ItemCraftingAspect.setAspect( stack, aspect );
|
||||
itemList.add( stack );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getUnlocalizedName( final ItemStack stack )
|
||||
{
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( stack );
|
||||
|
||||
// Null check
|
||||
if( ( stack == null ) || ( aspect == null ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
// Get the player
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
// Has the player discovered the aspect?
|
||||
if( ( player != null ) && ItemCraftingAspect.canPlayerSeeAspect( player, aspect ) )
|
||||
{
|
||||
// Show name
|
||||
return aspect.getName();
|
||||
}
|
||||
|
||||
// Show unknown
|
||||
return StatCollector.translateToLocal( "tc.aspect.unknown" );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.items.ItemAEPart;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.items.ItemEssentiaCell;
|
||||
import thaumicenergistics.items.ItemFocusAEWrench;
|
||||
import thaumicenergistics.items.ItemKnowledgeCore;
|
||||
@@ -21,7 +22,8 @@ public enum ItemEnum
|
||||
MATERIAL ("material", new ItemMaterial()),
|
||||
WIRELESS_TERMINAL ("wireless.essentia.terminal", new ItemWirelessEssentiaTerminal()),
|
||||
KNOWLEDGE_CORE ("knowledge.core", new ItemKnowledgeCore()),
|
||||
FOCUS_AEWRENCH ("focus.aewrench", new ItemFocusAEWrench());
|
||||
FOCUS_AEWRENCH ("focus.aewrench", new ItemFocusAEWrench()),
|
||||
CRAFTING_ASPECT ("crafting.aspect", new ItemCraftingAspect());
|
||||
|
||||
/**
|
||||
* Internal name of the item.
|
||||
|
||||
@@ -6,6 +6,7 @@ import thaumicenergistics.render.RenderBlockEssentiaProvider;
|
||||
import thaumicenergistics.render.RenderBlockInfusionProvider;
|
||||
import thaumicenergistics.render.RenderTileArcaneAssembler;
|
||||
import thaumicenergistics.render.RenderTileGearbox;
|
||||
import thaumicenergistics.render.RendererItemCraftingAspect;
|
||||
import thaumicenergistics.render.TileAsItemRenderer;
|
||||
import thaumicenergistics.tileentities.TileArcaneAssembler;
|
||||
import thaumicenergistics.tileentities.TileGearBox;
|
||||
@@ -59,5 +60,8 @@ public class Renderers
|
||||
MinecraftForgeClient.registerItemRenderer( ThEApi.instance().blocks().ArcaneAssembler.getItem(), new TileAsItemRenderer(
|
||||
new RenderTileArcaneAssembler(), new TileArcaneAssembler() ) );
|
||||
|
||||
// Register crafting aspect item renderer
|
||||
MinecraftForgeClient.registerItemRenderer( ItemEnum.CRAFTING_ASPECT.getItem(), new RendererItemCraftingAspect() );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package thaumicenergistics.render;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
|
||||
public class RendererItemCraftingAspect
|
||||
implements IItemRenderer
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType( final ItemStack item, final ItemRenderType type )
|
||||
{
|
||||
// Handle only inventory
|
||||
return( type == ItemRenderType.INVENTORY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem( final ItemRenderType type, final ItemStack stack, final Object ... data )
|
||||
{
|
||||
boolean isKnown = false;
|
||||
Aspect aspect = null;
|
||||
|
||||
// Is the stack setup?
|
||||
if( ( stack.getItemDamage() == 0 ) && ( stack.hasTagCompound() ) )
|
||||
{
|
||||
// Get the player
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
// Get the aspect
|
||||
aspect = ItemCraftingAspect.getAspect( stack );
|
||||
|
||||
// Can the knowledge be checked?
|
||||
if( ( player != null ) && ( aspect != null ) )
|
||||
{
|
||||
isKnown = ItemCraftingAspect.canPlayerSeeAspect( player, aspect );
|
||||
}
|
||||
}
|
||||
|
||||
// Is the aspect known?
|
||||
if( isKnown )
|
||||
{
|
||||
// Render aspect
|
||||
UtilsFX.drawTag( 0, 0, aspect, 0.0F, 0, 0.0D );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Render unknown
|
||||
|
||||
// Disable standard lighting
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
|
||||
// Set the alpha function
|
||||
GL11.glAlphaFunc( GL11.GL_GREATER, 0.003921569F );
|
||||
|
||||
// Enable alpha blending
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE );
|
||||
|
||||
// Render
|
||||
UtilsFX.bindTexture( "textures/aspects/_unknown.png" );
|
||||
GL11.glColor4f( 0.5F, 0.5F, 0.5F, 0.5F );
|
||||
UtilsFX.drawTexturedQuadFull( 0, 0, 0.0D );
|
||||
|
||||
// Restore
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_BLEND );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper( final ItemRenderType type, final ItemStack item, final ItemRendererHelper helper )
|
||||
{
|
||||
// Do not use the helper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user