mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Bug Fixes + Java 8 Migration
Completely moved dev environment to Java 8, Java 7 and earlier is no longer supported. Updated forge to 10.13.4.1566 Fixes #294: Wand move targets for shift+click changed to favor player inventory over ME storage. Fixes #289: Only AE2 items have aspects applied. Fixes #299: Assembler no longer eats pearls.
This commit is contained in:
1 parent
c5f8ee7e9e
commit
fcb4947898
20 files changed
+441
-301
No files matched your search
+8
-1
@@ -1,4 +1,11 @@
|
||||
01/30/2016 1.0.0.2 - Beta
|
||||
04/14/2016 1.0.0.3 - Beta
|
||||
Completely moved dev environment to Java 8, Java 7 and earlier is no longer supported.
|
||||
Updated forge to 10.13.4.1566
|
||||
Fixes #294: Wand move targets for shift+click changed to favor player inventory over ME storage.
|
||||
Fixes #289: Only AE2 items have aspects applied.
|
||||
Fixes #299: Assembler no longer eats pearls.
|
||||
|
||||
01/30/2016 1.0.0.2 - Beta
|
||||
Fixes #270: Restored Java 7 compatibility.
|
||||
|
||||
01/26/2016 1.0.0.2 - Beta
|
||||
|
||||
+9
-2
@@ -16,13 +16,20 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
apply plugin: 'java'
|
||||
compileJava {
|
||||
options.compilerArgs << '-Xlint:unchecked'
|
||||
}
|
||||
|
||||
version = "1.0.0.2"
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
version = "1.0.0.3"
|
||||
group= "thaumicenergistics" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "thaumicenergistics"
|
||||
|
||||
minecraft {
|
||||
version = "1.7.10-10.13.4.1558-1.7.10"
|
||||
version = "1.7.10-10.13.4.1566-1.7.10"
|
||||
runDir = "eclipse/assets"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package thaumicenergistics.client.gui.widget;
|
||||
|
||||
import java.util.List;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
import thaumicenergistics.api.gui.IWidgetHost;
|
||||
@@ -13,10 +16,6 @@ import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.client.gui.ThEGuiHelper;
|
||||
import thaumicenergistics.common.integration.tc.AspectHooks;
|
||||
import thaumicenergistics.common.storage.AspectStack;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Base class of Aspect Widgets.
|
||||
@@ -162,7 +161,7 @@ public abstract class AspectWidgetBase
|
||||
this.aspectDescription = this.aspectStack.getAspectDescription();
|
||||
|
||||
// Get the mod
|
||||
ModContainer mod = ThEUtils.getOrDefault( AspectHooks.aspectToMod, this.aspectStack.getAspect(), null );
|
||||
ModContainer mod = AspectHooks.aspectToMod.getOrDefault( this.aspectStack.getAspect(), null );
|
||||
|
||||
// Set footnote
|
||||
if( mod != null )
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package thaumicenergistics.client.gui.widget;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import thaumicenergistics.api.gui.IWidgetHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import thaumicenergistics.api.gui.IWidgetHost;
|
||||
|
||||
/**
|
||||
* Widget displaying an AE item.
|
||||
@@ -65,26 +65,33 @@ public class WidgetAEItem
|
||||
@Override
|
||||
public void drawWidget()
|
||||
{
|
||||
if( this.aeItemStack != null )
|
||||
try
|
||||
{
|
||||
// Set the z level
|
||||
this.zLevel = 2.0F;
|
||||
this.aeItemRenderer.zLevel = 2.0F;
|
||||
if( this.aeItemStack != null )
|
||||
{
|
||||
// Set the z level
|
||||
this.zLevel = 2.0F;
|
||||
this.aeItemRenderer.zLevel = 2.0F;
|
||||
|
||||
// Set the item
|
||||
this.aeItemRenderer.setAeStack( this.aeItemStack );
|
||||
// Set the item
|
||||
this.aeItemRenderer.setAeStack( this.aeItemStack );
|
||||
|
||||
// Draw the item
|
||||
this.aeItemRenderer.renderItemAndEffectIntoGUI( WidgetAEItem.MC.fontRenderer, WidgetAEItem.TEXTURE_MANAGER,
|
||||
this.aeItemStack.getItemStack(), this.xPosition + 1, this.yPosition + 1 );
|
||||
// Draw the item
|
||||
this.aeItemRenderer.renderItemAndEffectIntoGUI( WidgetAEItem.MC.fontRenderer, WidgetAEItem.TEXTURE_MANAGER,
|
||||
this.aeItemStack.getItemStack(), this.xPosition + 1, this.yPosition + 1 );
|
||||
|
||||
// Draw the amount
|
||||
this.aeItemRenderer.renderItemOverlayIntoGUI( WidgetAEItem.MC.fontRenderer, WidgetAEItem.TEXTURE_MANAGER,
|
||||
this.aeItemStack.getItemStack(), this.xPosition + 1, this.yPosition + 1 );
|
||||
// Draw the amount
|
||||
this.aeItemRenderer.renderItemOverlayIntoGUI( WidgetAEItem.MC.fontRenderer, WidgetAEItem.TEXTURE_MANAGER,
|
||||
this.aeItemStack.getItemStack(), this.xPosition + 1, this.yPosition + 1 );
|
||||
|
||||
// Reset the z level
|
||||
this.zLevel = 0.0F;
|
||||
this.aeItemRenderer.zLevel = 0.0F;
|
||||
// Reset the z level
|
||||
this.zLevel = 0.0F;
|
||||
this.aeItemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Silently ignore.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
package thaumicenergistics.common;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,14 +24,6 @@ import thaumicenergistics.common.integration.tc.EssentiaTileContainerHelper;
|
||||
import thaumicenergistics.common.network.NetworkHandler;
|
||||
import thaumicenergistics.common.registries.AEAspectRegister;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
import appeng.api.AEApi;
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
/**
|
||||
* <strong>Thaumic Energistics</strong>
|
||||
@@ -47,7 +49,7 @@ public class ThaumicEnergistics
|
||||
/**
|
||||
* Current version of the mod.
|
||||
*/
|
||||
public static final String VERSION = "1.0.0.2"; // NOTE: don't forget to change the build.gradle file as well
|
||||
public static final String VERSION = "1.0.0.3"; // NOTE: don't forget to change the build.gradle file as well
|
||||
|
||||
/**
|
||||
* Singleton instance
|
||||
|
||||
+42
-21
@@ -2,6 +2,23 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -31,23 +48,6 @@ import thaumicenergistics.common.network.packet.client.Packet_C_Sync;
|
||||
import thaumicenergistics.common.parts.PartArcaneCraftingTerminal;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* {@link PartArcaneCraftingTerminal} container.
|
||||
@@ -237,7 +237,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
// Create the slot
|
||||
craftingSlot = new Slot( terminal, slotIndex, CRAFTING_SLOT_X_POS +
|
||||
( column * ContainerWithPlayerInventory.SLOT_SIZE ), CRAFTING_SLOT_Y_POS +
|
||||
( row * ContainerWithPlayerInventory.SLOT_SIZE ) );
|
||||
( row * ContainerWithPlayerInventory.SLOT_SIZE ) );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( craftingSlot );
|
||||
@@ -1222,7 +1222,8 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
* @param requestedStack
|
||||
* @param mouseButton
|
||||
*/
|
||||
public void onClientRequestExtract( final EntityPlayer player, final IAEItemStack requestedStack, final int mouseButton, final boolean isShiftHeld )
|
||||
public void onClientRequestExtract( final EntityPlayer player, final IAEItemStack requestedStack, final int mouseButton,
|
||||
final boolean isShiftHeld )
|
||||
{
|
||||
// Ensure there is a player and monitor
|
||||
if( ( player == null ) || ( this.monitor == null ) )
|
||||
@@ -1643,8 +1644,8 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
// Get the itemstack in the slot
|
||||
ItemStack slotStack = slot.getStack();
|
||||
|
||||
// Was the slot clicked in the crafting grid or wand?
|
||||
if( ( slot == this.wandSlot ) || this.slotClickedWasInCraftingInventory( slotNumber ) )
|
||||
// Was the slot clicked in the crafting grid?
|
||||
if( this.slotClickedWasInCraftingInventory( slotNumber ) )
|
||||
{
|
||||
// Attempt to merge with the ME network
|
||||
didMerge = this.mergeWithMENetwork( slotStack );
|
||||
@@ -1710,6 +1711,26 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
|
||||
return null;
|
||||
}
|
||||
// Wand?
|
||||
else if( slot == this.wandSlot )
|
||||
{
|
||||
// Attempt to merge with the hotbar
|
||||
didMerge = this.mergeSlotWithHotbarInventory( slotStack );
|
||||
|
||||
// Did we merge?
|
||||
if( !didMerge )
|
||||
{
|
||||
// Attempt to merge with the player inventory
|
||||
didMerge = this.mergeSlotWithPlayerInventory( slotStack );
|
||||
|
||||
// Did we merge?
|
||||
if( !didMerge )
|
||||
{
|
||||
// Attempt to merge with the ME network
|
||||
didMerge = this.mergeWithMENetwork( slotStack );
|
||||
}
|
||||
}
|
||||
}
|
||||
// Was the slot clicked a view cell?
|
||||
else if( ( slotNumber >= this.firstViewSlotNumber ) && ( slotNumber <= this.lastViewSlotNumber ) )
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
|
||||
/**
|
||||
* Base container for all ThE containers.
|
||||
@@ -89,7 +88,7 @@ public abstract class TheContainerBase
|
||||
@Nullable
|
||||
protected Slot getSlotOrNull( final int slotNumber )
|
||||
{
|
||||
return ThEUtils.getOrDefault( this.slotMap, slotNumber, null );
|
||||
return this.slotMap.getOrDefault( slotNumber, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,10 @@ package thaumicenergistics.common.integration.tc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -10,10 +14,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import thaumcraft.common.items.ItemEldritchObject;
|
||||
|
||||
public class ArcaneCraftingPattern
|
||||
implements ICraftingPatternDetails
|
||||
@@ -52,7 +53,12 @@ public class ArcaneCraftingPattern
|
||||
/**
|
||||
* Ingredients as AE itemstacks.
|
||||
*/
|
||||
protected IAEItemStack[] ingredientsAE;
|
||||
protected IAEItemStack[] ingredientsAE = null;
|
||||
|
||||
/**
|
||||
* List of all output items, results + containers
|
||||
*/
|
||||
protected IAEItemStack[] allResults = null;
|
||||
|
||||
/**
|
||||
* True if the recipe is valid.
|
||||
@@ -66,7 +72,7 @@ public class ArcaneCraftingPattern
|
||||
* @param craftingResult
|
||||
* @param craftingIngredients
|
||||
*/
|
||||
public ArcaneCraftingPattern( final ItemStack knowledgeCore, final AspectList aspects, final ItemStack craftingResult,
|
||||
public ArcaneCraftingPattern( final ItemStack knowledgeCore, final AspectList aspects, final ItemStack craftingResult,
|
||||
final Object[] craftingIngredients )
|
||||
{
|
||||
// Set the core
|
||||
@@ -186,6 +192,53 @@ public class ArcaneCraftingPattern
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up all results, including container items.
|
||||
*/
|
||||
private void setupAEResults()
|
||||
{
|
||||
// Ensure the ingredient list is made
|
||||
if( this.ingredientsAE == null )
|
||||
{
|
||||
this.setupAEIngredientList();
|
||||
}
|
||||
|
||||
ArrayList<IAEItemStack> results = new ArrayList<IAEItemStack>();
|
||||
|
||||
// Add any container items
|
||||
for( IAEItemStack stack : this.ingredientsAE )
|
||||
{
|
||||
if( stack == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Container?
|
||||
if( stack.getItem().hasContainerItem( stack.getItemStack() ) )
|
||||
{
|
||||
results.add( AEApi.instance().storage().createItemStack( stack.getItem().getContainerItem( stack.getItemStack() ) ) );
|
||||
}
|
||||
|
||||
// Multiplier?
|
||||
else if( stack.getStackSize() > 1 )
|
||||
{
|
||||
results.add( stack.copy().setStackSize( stack.getStackSize() - 1 ) );
|
||||
}
|
||||
// Primordial Pearl?
|
||||
else if( ( stack.getItem() instanceof ItemEldritchObject ) && ( stack.getItemDamage() == 3 ) )
|
||||
{
|
||||
results.add( stack );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add result
|
||||
results.add( this.result );
|
||||
|
||||
// Set the outputs
|
||||
this.allResults = results.toArray( new IAEItemStack[results.size()] );
|
||||
}
|
||||
|
||||
protected void setPatternValidity( final boolean valid )
|
||||
{
|
||||
// Set
|
||||
@@ -213,6 +266,20 @@ public class ArcaneCraftingPattern
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This includes container items.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IAEItemStack[] getAllResults()
|
||||
{
|
||||
if( this.allResults == null )
|
||||
{
|
||||
this.setupAEResults();
|
||||
}
|
||||
return this.allResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aspect cost for the specified aspect.
|
||||
*
|
||||
@@ -272,7 +339,6 @@ public class ArcaneCraftingPattern
|
||||
return new IAEItemStack[0];
|
||||
}
|
||||
|
||||
// Return the result
|
||||
return new IAEItemStack[] { this.result };
|
||||
}
|
||||
|
||||
@@ -296,7 +362,6 @@ public class ArcaneCraftingPattern
|
||||
@Override
|
||||
public IAEItemStack[] getOutputs()
|
||||
{
|
||||
// Return the result
|
||||
return new IAEItemStack[] { this.result };
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package thaumicenergistics.common.integration.tc;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import javax.annotation.Nonnull;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.DataWatcher;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -13,10 +15,7 @@ import thaumicenergistics.api.entities.IGolemHookHandler.InteractionLevel;
|
||||
import thaumicenergistics.api.entities.IGolemHookSyncRegistry;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import thaumicenergistics.fml.ThECore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Golem hook system.<br>
|
||||
@@ -42,7 +41,7 @@ public class GolemHooks
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bellLeftClicked( final EntityGolemBase golem, final Object handlerData, final ItemStack itemGolemPlacer,
|
||||
public void bellLeftClicked( final EntityGolemBase golem, final Object handlerData, final ItemStack itemGolemPlacer,
|
||||
final EntityPlayer player, final boolean dismantled,
|
||||
final Side side )
|
||||
{
|
||||
@@ -50,14 +49,14 @@ public class GolemHooks
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionLevel canHandleInteraction( final EntityGolemBase golem, final Object handlerData, final EntityPlayer player,
|
||||
public InteractionLevel canHandleInteraction( final EntityGolemBase golem, final Object handlerData, final EntityPlayer player,
|
||||
final Side side )
|
||||
{
|
||||
return InteractionLevel.NoInteraction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object customInteraction( final EntityGolemBase golem, final Object handlerData, final IGolemHookSyncRegistry syncData,
|
||||
public Object customInteraction( final EntityGolemBase golem, final Object handlerData, final IGolemHookSyncRegistry syncData,
|
||||
final EntityPlayer player, final Side side )
|
||||
{
|
||||
return null;
|
||||
@@ -87,7 +86,7 @@ public class GolemHooks
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderGolem( final EntityGolemBase golem, final Object clientHandlerData, final double x, final double y, final double z,
|
||||
public void renderGolem( final EntityGolemBase golem, final Object clientHandlerData, final double x, final double y, final double z,
|
||||
final float partialElaspsedTick )
|
||||
{
|
||||
|
||||
@@ -190,7 +189,7 @@ public class GolemHooks
|
||||
* @param player
|
||||
* @param golemHandlerData
|
||||
*/
|
||||
public static void hook_Bell_OnLeftClickGolem( final EntityGolemBase golem, final ItemStack dropped, final EntityPlayer player,
|
||||
public static void hook_Bell_OnLeftClickGolem( final EntityGolemBase golem, final ItemStack dropped, final EntityPlayer player,
|
||||
final HashMap<IGolemHookHandler, Object> golemHandlerData )
|
||||
{
|
||||
// Get the dismantled status
|
||||
@@ -202,7 +201,7 @@ public class GolemHooks
|
||||
try
|
||||
{
|
||||
// Get the current handler data
|
||||
Object handlerData = ThEUtils.getOrDefault( golemHandlerData, handler, null );
|
||||
Object handlerData = golemHandlerData.getOrDefault( handler, null );
|
||||
|
||||
// Call handler
|
||||
|
||||
@@ -225,7 +224,7 @@ public class GolemHooks
|
||||
* @param golemHandlerData
|
||||
* @return
|
||||
*/
|
||||
public static boolean hook_CustomInteraction( final EntityGolemBase golem, final EntityPlayer player,
|
||||
public static boolean hook_CustomInteraction( final EntityGolemBase golem, final EntityPlayer player,
|
||||
final HashMap<IGolemHookHandler, Object> golemHandlerData )
|
||||
{
|
||||
GolemSyncRegistry syncRegistry = ( (GolemSyncRegistry)golemHandlerData.get( internalHandler ) );
|
||||
@@ -240,7 +239,7 @@ public class GolemHooks
|
||||
for( IGolemHookHandler handler : registeredHandlers )
|
||||
{
|
||||
// Get the current handler data
|
||||
Object handlerData = ThEUtils.getOrDefault( golemHandlerData, handler, null );
|
||||
Object handlerData = golemHandlerData.getOrDefault( handler, null );
|
||||
|
||||
// Call handler
|
||||
try
|
||||
@@ -467,7 +466,7 @@ public class GolemHooks
|
||||
for( IGolemHookHandler handler : handlersToUpdate )
|
||||
{
|
||||
// Get the current handler data
|
||||
Object handlerData = ThEUtils.getOrDefault( golemHandlerData, handler, null );
|
||||
Object handlerData = golemHandlerData.getOrDefault( handler, null );
|
||||
boolean hadData = ( handlerData != null );
|
||||
try
|
||||
{
|
||||
@@ -504,7 +503,7 @@ public class GolemHooks
|
||||
* @param itemGolemPlacer
|
||||
* @param golemHandlerData
|
||||
*/
|
||||
public static void hook_Placer_SpawnGolem( final EntityGolemBase golem, final ItemStack itemGolemPlacer,
|
||||
public static void hook_Placer_SpawnGolem( final EntityGolemBase golem, final ItemStack itemGolemPlacer,
|
||||
final HashMap<IGolemHookHandler, Object> golemHandlerData )
|
||||
{
|
||||
// Ensure the stack has an NBT tag
|
||||
@@ -542,7 +541,7 @@ public class GolemHooks
|
||||
* @param golemHandlerData
|
||||
* @param nbt
|
||||
*/
|
||||
public static void hook_ReadEntityFromNBT( final EntityGolemBase golem, final HashMap<IGolemHookHandler, Object> golemHandlerData,
|
||||
public static void hook_ReadEntityFromNBT( final EntityGolemBase golem, final HashMap<IGolemHookHandler, Object> golemHandlerData,
|
||||
final NBTTagCompound nbt )
|
||||
{
|
||||
// Inform each handler
|
||||
@@ -551,7 +550,7 @@ public class GolemHooks
|
||||
try
|
||||
{
|
||||
// Get the current handler data
|
||||
Object handlerData = ThEUtils.getOrDefault( golemHandlerData, handler, null );
|
||||
Object handlerData = golemHandlerData.getOrDefault( handler, null );
|
||||
|
||||
// Call handler
|
||||
handlerData = handler.readEntityFromNBT( golem, nbt );
|
||||
@@ -583,7 +582,7 @@ public class GolemHooks
|
||||
* @param partialElaspsedTick
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void hook_RenderGolem( final EntityGolemBase golem, final HashMap<IGolemHookHandler, Object> golemHandlerData, final double x,
|
||||
public static void hook_RenderGolem( final EntityGolemBase golem, final HashMap<IGolemHookHandler, Object> golemHandlerData, final double x,
|
||||
final double y, final double z, final float partialElaspsedTick )
|
||||
{
|
||||
|
||||
@@ -620,7 +619,7 @@ public class GolemHooks
|
||||
try
|
||||
{
|
||||
// Get the current handler data
|
||||
Object handlerData = ThEUtils.getOrDefault( golemHandlerData, handler, null );
|
||||
Object handlerData = golemHandlerData.getOrDefault( handler, null );
|
||||
boolean hadData = ( handlerData != null );
|
||||
|
||||
// Call handler
|
||||
@@ -666,7 +665,7 @@ public class GolemHooks
|
||||
* @param golemHandlerData
|
||||
* @param nbt
|
||||
*/
|
||||
public static void hook_WriteEntityToNBT( final EntityGolemBase golem, final HashMap<IGolemHookHandler, Object> golemHandlerData,
|
||||
public static void hook_WriteEntityToNBT( final EntityGolemBase golem, final HashMap<IGolemHookHandler, Object> golemHandlerData,
|
||||
final NBTTagCompound nbt )
|
||||
{
|
||||
// Inform each handler
|
||||
@@ -675,7 +674,7 @@ public class GolemHooks
|
||||
try
|
||||
{
|
||||
// Get the current handler data
|
||||
Object handlerData = ThEUtils.getOrDefault( golemHandlerData, handler, null );
|
||||
Object handlerData = golemHandlerData.getOrDefault( handler, null );
|
||||
|
||||
// Call handler
|
||||
handler.writeEntityNBT( golem, handlerData, nbt );
|
||||
|
||||
@@ -4,11 +4,10 @@ import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import com.google.common.base.Charsets;
|
||||
import thaumicenergistics.api.entities.IGolemHookHandler;
|
||||
import thaumicenergistics.api.entities.IGolemHookSyncRegistry;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
class GolemSyncRegistry
|
||||
implements IGolemHookSyncRegistry
|
||||
@@ -61,7 +60,7 @@ class GolemSyncRegistry
|
||||
@Override
|
||||
public char getSyncCharOrDefault( final int id, final char defaultChar )
|
||||
{
|
||||
return ThEUtils.getOrDefault( this.dataMappings, Integer.valueOf( id ), defaultChar );
|
||||
return this.dataMappings.getOrDefault( Integer.valueOf( id ), defaultChar );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,12 +82,10 @@ class GolemSyncRegistry
|
||||
{
|
||||
this.hasDataChanged = false;
|
||||
|
||||
ByteArrayOutputStream baos = null;
|
||||
DataOutputStream stream = null;
|
||||
try
|
||||
// Write the data
|
||||
try( ByteArrayOutputStream baos = new ByteArrayOutputStream( ( this.dataMappings.size() * 6 ) + 4 );
|
||||
DataOutputStream stream = new DataOutputStream( baos ) )
|
||||
{
|
||||
baos = new ByteArrayOutputStream( ( this.dataMappings.size() * 6 ) + 4 );
|
||||
stream = new DataOutputStream( baos );
|
||||
|
||||
// Write count
|
||||
stream.writeInt( this.dataMappings.size() );
|
||||
@@ -108,14 +105,7 @@ class GolemSyncRegistry
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
ThELog.warning( "Unable to send golem sync data" );
|
||||
try
|
||||
{
|
||||
stream.close();
|
||||
}
|
||||
catch( IOException e1 )
|
||||
{
|
||||
}
|
||||
ThELog.error( e, "Unable to send golem sync data" );
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -151,12 +141,9 @@ class GolemSyncRegistry
|
||||
this.lastUpdatedFrom = data;
|
||||
|
||||
// Read the data
|
||||
ByteArrayInputStream bais = null;
|
||||
DataInputStream stream = null;
|
||||
try
|
||||
try( ByteArrayInputStream bais = new ByteArrayInputStream( data.getBytes( Charsets.UTF_8.name() ) );
|
||||
DataInputStream stream = new DataInputStream( bais ); )
|
||||
{
|
||||
bais = new ByteArrayInputStream( data.getBytes( Charsets.UTF_8.name() ) );
|
||||
stream = new DataInputStream( bais );
|
||||
|
||||
// Read the count
|
||||
int count = stream.readInt();
|
||||
@@ -181,17 +168,7 @@ class GolemSyncRegistry
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
ThELog.warning( "Malformed golem sync data received" );
|
||||
try
|
||||
{
|
||||
if( stream != null )
|
||||
{
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
catch( IOException e1 )
|
||||
{
|
||||
}
|
||||
ThELog.error( e, "Malformed golem sync data received" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,13 @@ package thaumicenergistics.common.items;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -13,13 +20,6 @@ import net.minecraft.world.World;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.parts.AEPartsEnum;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Base class for all ThE's AE2 cable parts.
|
||||
@@ -75,10 +75,7 @@ public class ItemAEPart
|
||||
catch( Throwable e )
|
||||
{
|
||||
// Bad stuff, log the error.
|
||||
ThELog.severe( "Unable to create cable-part from item: %s", itemStack.getDisplayName() );
|
||||
|
||||
// Print that stack-trace
|
||||
e.printStackTrace();
|
||||
ThELog.error( e, "Unable to create cable-part from item: %s", itemStack.getDisplayName() );
|
||||
}
|
||||
|
||||
// Return the part
|
||||
@@ -132,7 +129,7 @@ public class ItemAEPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse( final ItemStack itemStack, final EntityPlayer player, final World world, final int x, final int y, final int z,
|
||||
public boolean onItemUse( final ItemStack itemStack, final EntityPlayer player, final World world, final int x, final int y, final int z,
|
||||
final int side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
// Can we place the item on the bus?
|
||||
|
||||
@@ -2,6 +2,9 @@ package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -15,10 +18,6 @@ import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.tc.AspectHooks;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Item used to represent an {@link Aspect}
|
||||
@@ -153,7 +152,7 @@ public class ItemCraftingAspect
|
||||
// Add the aspect info
|
||||
list.add( aspect.getLocalizedDescription() );
|
||||
|
||||
ModContainer mod = ThEUtils.getOrDefault( AspectHooks.aspectToMod, aspect, null );
|
||||
ModContainer mod = AspectHooks.aspectToMod.getOrDefault( aspect, null );
|
||||
if( mod != null )
|
||||
{
|
||||
list.add( EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.ITALIC.toString() + mod.getName() );
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package thaumicenergistics.common.network;
|
||||
|
||||
import java.util.HashMap;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.network.packet.client.*;
|
||||
import thaumicenergistics.common.network.packet.server.*;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.network.packet.client.*;
|
||||
import thaumicenergistics.common.network.packet.server.*;
|
||||
|
||||
/**
|
||||
* Handles all server<->client network communication for ThE.
|
||||
@@ -59,7 +58,7 @@ public class NetworkHandler
|
||||
*/
|
||||
public static Class getPacketClassFromID( final Short id )
|
||||
{
|
||||
return ThEUtils.getOrDefault( NetworkHandler.IDToClass, id, null );
|
||||
return NetworkHandler.IDToClass.getOrDefault( id, null );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +69,7 @@ public class NetworkHandler
|
||||
*/
|
||||
public static short getPacketID( final ThEBasePacket packet )
|
||||
{
|
||||
return ThEUtils.getOrDefault( NetworkHandler.ClassToID, packet.getClass(), (short) -1 );
|
||||
return NetworkHandler.ClassToID.getOrDefault( packet.getClass(), (short) -1 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
package thaumicenergistics.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import com.google.common.base.Charsets;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,15 +26,7 @@ import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.parts.ThEPartBase;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Charsets;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
|
||||
/**
|
||||
* Base of all ThE Packets. Also includes packet utils.
|
||||
@@ -342,27 +343,28 @@ public abstract class ThEBasePacket
|
||||
// Create a new data stream
|
||||
ByteBuf decompressedStream = Unpooled.buffer( ThEBasePacket.COMPRESSED_BUFFER_SIZE );
|
||||
|
||||
GZIPInputStream decompressor = null;
|
||||
try
|
||||
try(
|
||||
InputStream inStream = new InputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
// Is there anymore data to read from the packet stream?
|
||||
if( packetStream.readableBytes() <= 0 )
|
||||
{
|
||||
// Return end marker
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return the byte
|
||||
return packetStream.readByte() & 0xFF;
|
||||
}
|
||||
};
|
||||
|
||||
// Create the decompressor
|
||||
GZIPInputStream decompressor = new GZIPInputStream( inStream ) )
|
||||
{
|
||||
// Create the decompressor
|
||||
decompressor = new GZIPInputStream( new InputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
// Is there anymore data to read from the packet stream?
|
||||
if( packetStream.readableBytes() <= 0 )
|
||||
{
|
||||
// Return end marker
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return the byte
|
||||
return packetStream.readByte() & 0xFF;
|
||||
}
|
||||
} );
|
||||
|
||||
// Create a temporary holding array
|
||||
byte[] holding = new byte[512];
|
||||
@@ -394,16 +396,7 @@ public abstract class ThEBasePacket
|
||||
catch( IOException e )
|
||||
{
|
||||
// Failed
|
||||
if( decompressor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
decompressor.close();
|
||||
}
|
||||
catch( IOException e1 )
|
||||
{
|
||||
}
|
||||
}
|
||||
ThELog.error( e, "Packet decompression failed." );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,25 +414,26 @@ public abstract class ThEBasePacket
|
||||
// Pass to subclass
|
||||
this.writeData( streamToCompress );
|
||||
|
||||
GZIPOutputStream compressor = null;
|
||||
try
|
||||
{
|
||||
// Create the compressor
|
||||
compressor = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
// Create the compressor
|
||||
try(
|
||||
OutputStream outStream = new OutputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void write( final int byteToWrite ) throws IOException
|
||||
{
|
||||
// Write the byte to the packet stream
|
||||
packetStream.writeByte( byteToWrite & 0xFF );
|
||||
}
|
||||
} )
|
||||
{
|
||||
{
|
||||
this.def.setLevel( Deflater.BEST_COMPRESSION );
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void write( final int byteToWrite ) throws IOException
|
||||
{
|
||||
// Write the byte to the packet stream
|
||||
packetStream.writeByte( byteToWrite & 0xFF );
|
||||
}
|
||||
};
|
||||
|
||||
GZIPOutputStream compressor = new GZIPOutputStream( outStream )
|
||||
{
|
||||
{
|
||||
this.def.setLevel( Deflater.BEST_COMPRESSION );
|
||||
}
|
||||
} )
|
||||
{
|
||||
|
||||
// Compress
|
||||
compressor.write( streamToCompress.array(), 0, streamToCompress.writerIndex() );
|
||||
@@ -450,17 +444,7 @@ public abstract class ThEBasePacket
|
||||
catch( IOException e )
|
||||
{
|
||||
// Failed
|
||||
|
||||
if( compressor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
compressor.close();
|
||||
}
|
||||
catch( IOException e1 )
|
||||
{
|
||||
}
|
||||
}
|
||||
ThELog.error( e, "Packet compression failed, packet will be incomplete or dropped." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,15 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.*;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.core.features.registries.entries.InscriberRecipe;
|
||||
import appeng.recipes.GroupIngredient;
|
||||
import appeng.recipes.Ingredient;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
@@ -15,15 +24,6 @@ import thaumcraft.api.aspects.AspectList;
|
||||
import thaumicenergistics.api.IThEItems;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.*;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.core.features.registries.entries.InscriberRecipe;
|
||||
import appeng.recipes.GroupIngredient;
|
||||
import appeng.recipes.Ingredient;
|
||||
|
||||
/**
|
||||
* Gives items from AE2 aspects when scanned.
|
||||
@@ -782,6 +782,13 @@ public class AEAspectRegister
|
||||
|
||||
if( this.itemStack != null )
|
||||
{
|
||||
// Skip anything that is not from AE
|
||||
if( !this.itemStack.getItem().getClass().getCanonicalName().startsWith( "appeng" ) )
|
||||
{
|
||||
//ThELog.info( "Skipping registration for non AE item: %s (%s) ", this.itemStack.getDisplayName(), this.itemStack.getItem().getClass().getCanonicalName() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to the dependency chain
|
||||
AEAspectRegister.this.DEPENDENCY_CHAIN.add( this );
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.api.storage.IEssentiaRepo;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
|
||||
/**
|
||||
* Manages a repository of essentia.
|
||||
@@ -72,7 +71,7 @@ public class EssentiaRepo
|
||||
@Override
|
||||
public IAspectStack get( final Aspect aspect )
|
||||
{
|
||||
return ThEUtils.getOrDefault( this.cache, aspect, null );
|
||||
return this.cache.getOrDefault( aspect, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +83,7 @@ public class EssentiaRepo
|
||||
@Override
|
||||
public IAspectStack getOrDefault( final Aspect aspect, final IAspectStack defaultValue )
|
||||
{
|
||||
return ThEUtils.getOrDefault( this.cache, aspect, defaultValue );
|
||||
return this.cache.getOrDefault( aspect, defaultValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,34 +1,10 @@
|
||||
package thaumicenergistics.common.tiles;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.api.grid.IDigiVisSource;
|
||||
import thaumicenergistics.client.gui.ThEGuiHelper;
|
||||
import thaumicenergistics.common.blocks.BlockArcaneAssembler;
|
||||
import thaumicenergistics.common.integration.IWailaSource;
|
||||
import thaumicenergistics.common.integration.tc.ArcaneCraftingPattern;
|
||||
import thaumicenergistics.common.integration.tc.DigiVisSourceData;
|
||||
import thaumicenergistics.common.integration.tc.VisCraftingHelper;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
@@ -63,6 +39,30 @@ import appeng.tile.inventory.InvOperation;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.api.grid.IDigiVisSource;
|
||||
import thaumicenergistics.client.gui.ThEGuiHelper;
|
||||
import thaumicenergistics.common.blocks.BlockArcaneAssembler;
|
||||
import thaumicenergistics.common.integration.IWailaSource;
|
||||
import thaumicenergistics.common.integration.tc.ArcaneCraftingPattern;
|
||||
import thaumicenergistics.common.integration.tc.DigiVisSourceData;
|
||||
import thaumicenergistics.common.integration.tc.VisCraftingHelper;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
|
||||
/**
|
||||
* Allows auto-crafting arcane recipes.
|
||||
@@ -361,14 +361,26 @@ public class TileArcaneAssembler
|
||||
IStorageGrid storageGrid = this.getProxy().getStorage();
|
||||
|
||||
// Simulate placing the items
|
||||
IAEItemStack rejected = storageGrid.getItemInventory().injectItems( this.currentPattern.getResult(), Actionable.SIMULATE,
|
||||
this.mySource );
|
||||
boolean rejected = false;
|
||||
for( IAEItemStack output : this.currentPattern.getAllResults() )
|
||||
{
|
||||
IAEItemStack rejectedResult = storageGrid.getItemInventory().injectItems( output, Actionable.SIMULATE,
|
||||
this.mySource );
|
||||
if( ( rejectedResult != null ) && ( rejectedResult.getStackSize() > 0 ) )
|
||||
{
|
||||
rejected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Was all items accepted?
|
||||
if( ( rejected == null ) || ( rejected.getStackSize() == 0 ) )
|
||||
// Were all items accepted?
|
||||
if( !rejected )
|
||||
{
|
||||
// Inject into the network
|
||||
storageGrid.getItemInventory().injectItems( this.currentPattern.getResult().copy(), Actionable.MODULATE, this.mySource );
|
||||
for( IAEItemStack output : this.currentPattern.getAllResults() )
|
||||
{
|
||||
storageGrid.getItemInventory().injectItems( output, Actionable.MODULATE, this.mySource );
|
||||
}
|
||||
|
||||
// Mark the assembler as no longer crafting
|
||||
this.isCrafting = false;
|
||||
@@ -433,7 +445,8 @@ public class TileArcaneAssembler
|
||||
*/
|
||||
private int getRequiredAmountForAspect( final Aspect aspect )
|
||||
{
|
||||
return (int)Math.ceil( this.visDiscount.get( aspect ) * ( this.currentPattern.getAspectCost( aspect ) * TileArcaneAssembler.CVIS_MULTIPLER ) );
|
||||
return (int)Math.ceil(
|
||||
this.visDiscount.get( aspect ) * ( this.currentPattern.getAspectCost( aspect ) * TileArcaneAssembler.CVIS_MULTIPLER ) );
|
||||
}
|
||||
|
||||
private boolean hasEnoughVisForCraft()
|
||||
@@ -603,7 +616,8 @@ public class TileArcaneAssembler
|
||||
}
|
||||
|
||||
// Set pattern slots
|
||||
for( int index = TileArcaneAssembler.PATTERN_SLOT_INDEX; index < ( TileArcaneAssembler.PATTERN_SLOT_INDEX + HandlerKnowledgeCore.MAXIMUM_STORED_PATTERNS ); index++ )
|
||||
for( int index = TileArcaneAssembler.PATTERN_SLOT_INDEX; index < ( TileArcaneAssembler.PATTERN_SLOT_INDEX +
|
||||
HandlerKnowledgeCore.MAXIMUM_STORED_PATTERNS ); index++ )
|
||||
{
|
||||
if( ( pIterator != null ) && ( pIterator.hasNext() ) )
|
||||
{
|
||||
@@ -1172,7 +1186,8 @@ public class TileArcaneAssembler
|
||||
NetworkRegistry.TargetPoint where = new NetworkRegistry.TargetPoint( this.worldObj.provider.dimensionId, this.xCoord, this.yCoord,
|
||||
this.zCoord, 32.0D );
|
||||
appeng.core.sync.network.NetworkHandler.instance.sendToAllAround( new PacketAssemblerAnimation( this.xCoord, this.yCoord,
|
||||
this.zCoord, (byte)( 10 + ( 9 * this.upgradeCount ) ), this.currentPattern.getResult() ), where );
|
||||
this.zCoord, (byte)( 10 + ( 9 * this.upgradeCount ) ), this.currentPattern.getResult() ),
|
||||
where );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
|
||||
@@ -41,6 +41,18 @@ public class ThELog
|
||||
log.info( String.format( "Finished (%s in %dms)", section, ( System.currentTimeMillis() - sectionStartTime ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an exception.
|
||||
*
|
||||
* @param e
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void error( final Throwable e, final String format, final Object ... data )
|
||||
{
|
||||
log.error( String.format( format, data ), e );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs basic info.
|
||||
*
|
||||
@@ -53,7 +65,8 @@ public class ThELog
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error.
|
||||
* Logs an error.<br>
|
||||
* If there is an exception available, use {@code error}.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package thaumicenergistics.common.utils;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -12,8 +13,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_Sync;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Houses commonly used methods.
|
||||
@@ -47,32 +46,11 @@ public final class ThEUtils
|
||||
*/
|
||||
public static final boolean canPlayerInteractWith( @Nonnull final EntityPlayer player, @Nonnull final TileEntity tile )
|
||||
{
|
||||
return ( tile.getWorldObj().getTileEntity( tile.xCoord, tile.yCoord, tile.zCoord ) == tile )
|
||||
&& ( player.getDistanceSq( tile.xCoord + 0.5D, tile.yCoord + 0.5D, tile.zCoord + 0.5D ) <= SQUARED_REACH );
|
||||
return ( tile.getWorldObj().getTileEntity( tile.xCoord, tile.yCoord, tile.zCoord ) == tile ) &&
|
||||
( player.getDistanceSq( tile.xCoord + 0.5D, tile.yCoord + 0.5D, tile.zCoord + 0.5D ) <= SQUARED_REACH );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value to which the specified key is mapped, or defaultValue if the map contains no mapping for the key.
|
||||
* <hr>
|
||||
* NOTE: This is included for java 7 compatibility.
|
||||
* <hr>
|
||||
*
|
||||
* @param map
|
||||
* @param key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public static final <K, V> V getOrDefault( final Map<K, V> map, final K key, final V defaultValue )
|
||||
{
|
||||
if( map.containsKey( key ) )
|
||||
{
|
||||
return map.get( key );
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the item stack is a wand, scepter, or staff if they are
|
||||
* allowed.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package thaumicenergistics.fml;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.*;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
/**
|
||||
* <strong>Modifications made by the transformer:</strong></br>
|
||||
@@ -253,6 +253,32 @@ public class ASMTransformer
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
private byte[] transformClass_CraftingTreeProcess( final byte[] classBytes )
|
||||
{
|
||||
// Create the class node and read in the class
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader( classBytes );
|
||||
classReader.accept( classNode, 0 );
|
||||
|
||||
// Transform methods
|
||||
for( MethodNode method : classNode.methods )
|
||||
{
|
||||
// Constructor
|
||||
if( method.name.equals( "<init>" ) )
|
||||
{
|
||||
this.transformMethod_CraftingTreeProcess_init( method );
|
||||
break; // Stop searching.
|
||||
}
|
||||
}
|
||||
|
||||
// Create the writer
|
||||
ClassWriter writer = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
classNode.accept( writer );
|
||||
|
||||
// Return the modified class
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
private byte[] transformClass_GolemBase( final byte[] classBytes )
|
||||
{
|
||||
|
||||
@@ -426,6 +452,29 @@ public class ASMTransformer
|
||||
|
||||
}
|
||||
|
||||
private void transformMethod_CraftingTreeProcess_init( final MethodNode method )
|
||||
{
|
||||
int opSequence[] = new int[] { Opcodes.ILOAD, Opcodes.PUTFIELD, Opcodes.ALOAD, Opcodes.INVOKEVIRTUAL, Opcodes.ASTORE };
|
||||
AbstractInsnNode insertionPoint = this.findSequence( method.instructions, opSequence, true );
|
||||
|
||||
// Insert this.world = world
|
||||
InsnList instructionList = new InsnList();
|
||||
|
||||
// this
|
||||
instructionList.add( new VarInsnNode( Opcodes.ALOAD, 0 ) );
|
||||
|
||||
// world
|
||||
instructionList.add( new VarInsnNode( Opcodes.ALOAD, 6 ) );
|
||||
|
||||
// this.world = world
|
||||
instructionList.add( new FieldInsnNode( Opcodes.PUTFIELD,
|
||||
"appeng/crafting/CraftingTreeProcess", "world", "Lnet/minecraft/world/World;" ) );
|
||||
|
||||
// Insert the new code
|
||||
method.instructions.insert( insertionPoint, instructionList );
|
||||
|
||||
}
|
||||
|
||||
private void transformMethod_GolemBase_CustomInteraction( final MethodNode method )
|
||||
{
|
||||
int opSequence[] = new int[] { Opcodes.ALOAD, Opcodes.INVOKEVIRTUAL, Opcodes.ICONST_M1 };
|
||||
@@ -453,8 +502,8 @@ public class ASMTransformer
|
||||
// GolemHooks.setupGolemHook( EntityGolemBase, Hashmap )
|
||||
instructionList.add( new MethodInsnNode( Opcodes.INVOKESTATIC,
|
||||
CLASS_GolemHooks, "hook_CustomInteraction",
|
||||
"(L" + CLASS_EntityGolemBase + ";Lnet/minecraft/entity/player/EntityPlayer;L"
|
||||
+ FIELDTYPE_EntityGolemBase_hookHandlers + ";)Z",
|
||||
"(L" + CLASS_EntityGolemBase + ";Lnet/minecraft/entity/player/EntityPlayer;L" + FIELDTYPE_EntityGolemBase_hookHandlers +
|
||||
";)Z",
|
||||
false ) );
|
||||
|
||||
// Insert the return check
|
||||
@@ -528,8 +577,9 @@ public class ASMTransformer
|
||||
// GolemHooks.hook_ReadEntityFromNBT( EntityGolemBase, Hashmap, NBTTagCompound )
|
||||
instructionList.add( new MethodInsnNode( Opcodes.INVOKESTATIC,
|
||||
CLASS_GolemHooks, "hook_ReadEntityFromNBT",
|
||||
"(L" + CLASS_EntityGolemBase + ";L" + FIELDTYPE_EntityGolemBase_hookHandlers + ";"
|
||||
+ "Lnet/minecraft/nbt/NBTTagCompound;" + ")V", false ) );
|
||||
"(L" + CLASS_EntityGolemBase + ";L" + FIELDTYPE_EntityGolemBase_hookHandlers + ";" + "Lnet/minecraft/nbt/NBTTagCompound;" +
|
||||
")V",
|
||||
false ) );
|
||||
|
||||
// Insert the static call
|
||||
method.instructions.insert( insertionPoint, instructionList );
|
||||
@@ -584,8 +634,9 @@ public class ASMTransformer
|
||||
// GolemHooks.hook_WriteEntityToNBT( EntityGolemBase, Hashmap, NBTTagCompound )
|
||||
instructionList.add( new MethodInsnNode( Opcodes.INVOKESTATIC,
|
||||
CLASS_GolemHooks, "hook_WriteEntityToNBT",
|
||||
"(L" + CLASS_EntityGolemBase + ";L" + FIELDTYPE_EntityGolemBase_hookHandlers + ";"
|
||||
+ "Lnet/minecraft/nbt/NBTTagCompound;" + ")V", false ) );
|
||||
"(L" + CLASS_EntityGolemBase + ";L" + FIELDTYPE_EntityGolemBase_hookHandlers + ";" + "Lnet/minecraft/nbt/NBTTagCompound;" +
|
||||
")V",
|
||||
false ) );
|
||||
|
||||
// Insert the static call
|
||||
method.instructions.insertBefore( insertionPoint, instructionList );
|
||||
@@ -618,8 +669,9 @@ public class ASMTransformer
|
||||
// GolemHooks.hook_Bell_OnLeftClickGolem( EntityGolemBase, ItemStack, EntityPlayer, Hashmap )
|
||||
instructionList.add( new MethodInsnNode( Opcodes.INVOKESTATIC,
|
||||
CLASS_GolemHooks, "hook_Bell_OnLeftClickGolem",
|
||||
"(L" + CLASS_EntityGolemBase + ";Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;L"
|
||||
+ FIELDTYPE_EntityGolemBase_hookHandlers + ";)V", false ) );
|
||||
"(L" + CLASS_EntityGolemBase + ";Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;L" +
|
||||
FIELDTYPE_EntityGolemBase_hookHandlers + ";)V",
|
||||
false ) );
|
||||
|
||||
// Insert the static call
|
||||
method.instructions.insert( insertionPoint, instructionList );
|
||||
@@ -696,19 +748,33 @@ public class ASMTransformer
|
||||
@Override
|
||||
public byte[] transform( final String name, final String transformedName, final byte[] basicClass )
|
||||
{
|
||||
// AE2 Crafting Process?
|
||||
if( transformedName.equals( "appeng.crafting.CraftingTreeProcess" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.log( "Transforming Class (appeng.crafting.CraftingTreeProcess)" );
|
||||
return this.transformClass_CraftingTreeProcess( basicClass );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
this.log( "Unable to transform (appeng.crafting.CraftingTreeProcess)" );
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// Thaumcraft class?
|
||||
if( transformedName.startsWith( "thaumcraft" ) )
|
||||
else if( transformedName.startsWith( "thaumcraft" ) )
|
||||
{
|
||||
if( transformedName.equals( "thaumcraft.common.entities.golems.EntityGolemBase" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.log( "Transforming Class (thaumcraft/common/entities/golems/EntityGolemBase)" );
|
||||
this.log( "Transforming Class (thaumcraft.common.entities.golems.EntityGolemBase)" );
|
||||
return this.transformClass_GolemBase( basicClass );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
this.log( "Unable to transform (thaumcraft/common/entities/golems/EntityGolemBase)" );
|
||||
this.log( "Unable to transform (thaumcraft.common.entities.golems.EntityGolemBase)" );
|
||||
ThECore.golemHooksTransformFailed = true;
|
||||
}
|
||||
}
|
||||
@@ -717,12 +783,12 @@ public class ASMTransformer
|
||||
{
|
||||
try
|
||||
{
|
||||
this.log( "Transforming Class (thaumcraft/common/entities/golems/ItemGolemBell)" );
|
||||
this.log( "Transforming Class (thaumcraft.common.entities.golems.ItemGolemBell)" );
|
||||
return this.transformClass_ItemGolemBell( basicClass );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
this.log( "Unable to transform (thaumcraft/common/entities/golems/ItemGolemBell)" );
|
||||
this.log( "Unable to transform (thaumcraft.common.entities.golems.ItemGolemBell)" );
|
||||
ThECore.golemHooksTransformFailed = true;
|
||||
}
|
||||
}
|
||||
@@ -731,12 +797,12 @@ public class ASMTransformer
|
||||
{
|
||||
try
|
||||
{
|
||||
this.log( "Transforming Class (thaumcraft/common/entities/golems/ItemGolemPlacer)" );
|
||||
this.log( "Transforming Class (thaumcraft.common.entities.golems.ItemGolemPlacer)" );
|
||||
return this.transformClass_ItemGolemPlacer( basicClass );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
this.log( "Unable to transform (thaumcraft/common/entities/golems/ItemGolemPlacer)" );
|
||||
this.log( "Unable to transform (thaumcraft.common.entities.golems.ItemGolemPlacer)" );
|
||||
ThECore.golemHooksTransformFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user