From cb42ce164ca5b54afef6f68e814b942560fe86ba Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 19 Apr 2014 20:41:43 -0500 Subject: [PATCH 1/4] Move RenderManager interaction to Post Init ( fixes some kind of weird conflict with a key bind mod ) --- client/ClientHelper.java | 4 ++++ core/AppEng.java | 1 + core/CommonHelper.java | 2 ++ server/ServerHelper.java | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/client/ClientHelper.java b/client/ClientHelper.java index 7eb03528..7c0017c2 100644 --- a/client/ClientHelper.java +++ b/client/ClientHelper.java @@ -139,7 +139,11 @@ public class ClientHelper extends ServerHelper public void init() { MinecraftForge.EVENT_BUS.register( this ); + } + @Override + public void postinit() + { RenderingRegistry.registerBlockHandler( WorldRender.instance ); RenderManager.instance.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed() ); } diff --git a/core/AppEng.java b/core/AppEng.java index e4e2dc9d..a8c7df04 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -158,6 +158,7 @@ public class AppEng Registration.instance.PostInit( event ); IntegrationRegistry.instance.postinit(); + CommonHelper.proxy.postinit(); AEConfig.instance.save(); NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler ); diff --git a/core/CommonHelper.java b/core/CommonHelper.java index 344c320b..e1b9a0e1 100644 --- a/core/CommonHelper.java +++ b/core/CommonHelper.java @@ -37,4 +37,6 @@ public abstract class CommonHelper public abstract void doRenderItem(ItemStack sis, TileEntity tile); + public abstract void postinit(); + } diff --git a/server/ServerHelper.java b/server/ServerHelper.java index 144fd430..7e8ae23b 100644 --- a/server/ServerHelper.java +++ b/server/ServerHelper.java @@ -72,6 +72,12 @@ public class ServerHelper extends CommonHelper } + @Override + public void postinit() + { + + } + @Override public World getWorld() { From c5f2a3914ec2cf28bc89321058b794a18b42e685 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 19 Apr 2014 23:12:25 -0500 Subject: [PATCH 2/4] Fixed Bug: #0347 - 'Search Box Mode' and 'Terminal Style' are not saved/loaded --- core/AEConfig.java | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/AEConfig.java b/core/AEConfig.java index 901850ea..62baae28 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -166,7 +166,20 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo for (Enum e : settings.getSettings()) { String Category = e.getClass().getSimpleName(); - this.get( Category, e.name(), settings.getSetting( e ).name() ); + + Enum value = settings.getSetting( e ); + Property p = this.get( Category, e.name(), value.name() ); + + try + { + value = Enum.valueOf( value.getClass(), p.getString() ); + } + catch (IllegalArgumentException er) + { + AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" ); + } + + settings.putSetting( e, value ); } try @@ -208,8 +221,12 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo { for (Enum e : settings.getSettings()) { - String Category = e.getClass().getSimpleName(); - this.get( Category, e.name(), settings.getSetting( e ).name() ); + if ( e == setting ) + { + String Category = e.getClass().getSimpleName(); + Property p = this.get( Category, e.name(), settings.getSetting( e ).name() ); + p.set( newValue.name() ); + } } save(); From 2e71a6530e5b4ebc1a4fbd9daceeea648cd164d1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 19 Apr 2014 23:35:13 -0500 Subject: [PATCH 3/4] Added NEI Sync. --- .../gui/implementations/GuiMEMonitorable.java | 17 +++++++--- client/me/ItemRepo.java | 34 +++++++++++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 67316434..e3e7b06e 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -30,6 +30,7 @@ import appeng.container.implementations.ContainerMEMonitorable; import appeng.container.slot.AppEngSlot; import appeng.core.AEConfig; import appeng.core.AELog; +import appeng.core.AppEng; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; @@ -132,8 +133,11 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi maxRows = getMaxRows(); perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ((width - standardSize) / 18); - int NEI = 0; - int top = 4; + boolean hasNEI = AppEng.instance.isIntegrationEnabled( "NEI" ); + + int NEI = hasNEI ? 4 : 0; + int top = hasNEI ? 22 : 4; + int magicNumber = 114 + 1; int extraSpace = height - magicNumber - NEI - top - reservedSpace; @@ -144,6 +148,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi rows = maxRows; } + if ( hasNEI ) + rows--; + meSlots.clear(); for (int y = 0; y < rows; y++) { @@ -181,12 +188,12 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi .getSetting( Settings.SEARCH_MODE ) ) ); offset += 20; - if ( !(this instanceof GuiMEPortableCell ) ) + if ( !(this instanceof GuiMEPortableCell) ) { buttonList.add( terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings .getSetting( Settings.TERMINAL_STYLE ) ) ); } - + searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT ); searchField.setEnableBackgroundDrawing( false ); searchField.setMaxStringLength( 25 ); @@ -299,7 +306,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi bindTexture( getBackground() ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 ); - if ( viewCell || ( this instanceof GuiSecurity)) + if ( viewCell || (this instanceof GuiSecurity) ) this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 ); for (int x = 0; x < rows; x++) diff --git a/client/me/ItemRepo.java b/client/me/ItemRepo.java index 914b1f7a..ffd3d7ba 100644 --- a/client/me/ItemRepo.java +++ b/client/me/ItemRepo.java @@ -1,5 +1,7 @@ package appeng.client.me; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.regex.Pattern; @@ -8,6 +10,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import appeng.api.AEApi; import appeng.api.config.FuzzyMode; +import appeng.api.config.SearchBoxMode; import appeng.api.config.Settings; import appeng.api.config.SortOrder; import appeng.api.config.Upgrades; @@ -26,6 +29,7 @@ import appeng.util.prioitylist.FuzzyPriorityList; import appeng.util.prioitylist.IPartitionList; import appeng.util.prioitylist.MergedPriorityList; import appeng.util.prioitylist.PrecisePriorityList; +import cpw.mods.fml.relauncher.ReflectionHelper; public class ItemRepo { @@ -151,6 +155,32 @@ public class ItemRepo updateView(); } + private String NEIWord = null; + + private void updateNEI(String filter) + { + try + { + if ( NEIWord == null || !NEIWord.equals( filter ) ) + { + Class c = ReflectionHelper.getClass( getClass().getClassLoader(), "codechicken.nei.LayoutManager" ); + Field fldSearchField = c.getField( "searchField" ); + Object searchField = fldSearchField.get( c ); + + Method a = searchField.getClass().getMethod( "setText", String.class ); + Method b = searchField.getClass().getMethod( "onTextChange", String.class ); + + NEIWord = filter; + a.invoke( searchField, filter ); + b.invoke( searchField, "" ); + } + } + catch (Throwable _) + { + + } + } + public void updateView() { view.clear(); @@ -159,6 +189,10 @@ public class ItemRepo view.ensureCapacity( list.size() ); dsp.ensureCapacity( list.size() ); + Enum mode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ); + if ( mode == SearchBoxMode.NEI_AUTOSEARCH || mode == SearchBoxMode.NEI_MANUAL_SEARCH ) + updateNEI( searchString ); + boolean terminalSearchToolTips = AEConfig.instance.settings.getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO; // boolean terminalSearchMods = Configuration.instance.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO; From fa307b467e396e71e42b18d0477166066233e505 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 19 Apr 2014 23:35:48 -0500 Subject: [PATCH 4/4] Facades and FMP parts can no longer overlap. --- fmp/CableBusPart.java | 26 ++++++++++++++++++++++++++ parts/CableBusContainer.java | 14 +++++++++++++- parts/PartPlacement.java | 19 +++++++++++-------- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/fmp/CableBusPart.java b/fmp/CableBusPart.java index a4a6af0f..63d25db2 100644 --- a/fmp/CableBusPart.java +++ b/fmp/CableBusPart.java @@ -23,6 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection; import powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType; import appeng.api.networking.IGridNode; import appeng.api.parts.IFacadeContainer; +import appeng.api.parts.IFacadePart; import appeng.api.parts.IPart; import appeng.api.parts.IPartCollsionHelper; import appeng.api.parts.IPartHost; @@ -34,6 +35,7 @@ import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.api.util.DimensionalCoord; import appeng.core.AELog; +import appeng.facade.IFacadeItem; import appeng.helpers.AEMultiTile; import appeng.parts.BusCollisionHelper; import appeng.parts.CableBusContainer; @@ -282,6 +284,30 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds @Override public boolean canAddPart(ItemStack is, ForgeDirection side) { + if ( is.getItem() instanceof IFacadeItem ) + { + IFacadeItem bi = (IFacadeItem) is.getItem(); + + is = is.copy(); + is.stackSize = 1; + + IFacadePart bp = bi.createPartFromItemStack( is, side ); + if ( !(side == null || side == ForgeDirection.UNKNOWN || tile() == null) ) + { + List boxes = new ArrayList(); + IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true ); + bp.getBoxes( bch ); + for (AxisAlignedBB bb : boxes) + { + if ( !tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) ) ) + { + return false; + } + } + } + return true; + } + if ( is.getItem() instanceof IPartItem ) { IPartItem bi = (IPartItem) is.getItem(); diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index 08ecc954..04f76723 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -41,6 +41,7 @@ import appeng.api.util.DimensionalCoord; import appeng.client.render.BusRenderHelper; import appeng.client.render.CableRenderHelper; import appeng.facade.FacadeContainer; +import appeng.facade.IFacadeItem; import appeng.helpers.AEMultiTile; import appeng.me.GridConnection; import appeng.util.Platform; @@ -140,6 +141,9 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer @Override public boolean canAddPart(ItemStack is, ForgeDirection side) { + if ( is.getItem() instanceof IFacadeItem ) + return true; + if ( is.getItem() instanceof IPartItem ) { IPartItem bi = (IPartItem) is.getItem(); @@ -390,6 +394,13 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer { IPartCollsionHelper bch = new BusCollisionHelper( boxes, s, e, visual ); + if ( s != ForgeDirection.UNKNOWN ) + { + IFacadePart fpa = fc.getFacade( s ); + if ( fpa != null ) + fpa.getBoxes( bch ); + } + IPart part = getPart( s ); if ( part != null ) { @@ -969,7 +980,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer } @Override - public void cleanup() { + public void cleanup() + { tcb.cleanup(); } diff --git a/parts/PartPlacement.java b/parts/PartPlacement.java index bff7ff4b..f57c0df7 100644 --- a/parts/PartPlacement.java +++ b/parts/PartPlacement.java @@ -148,19 +148,22 @@ public class PartPlacement if ( host.getPart( ForgeDirection.UNKNOWN ) == null ) return false; - if ( host.getFacadeContainer().addFacade( fp ) ) + if ( host.canAddPart( held, side ) ) { - host.markForUpdate(); - if ( !player.capabilities.isCreativeMode ) + if ( host.getFacadeContainer().addFacade( fp ) ) { - held.stackSize--; - if ( held.stackSize == 0 ) + host.markForUpdate(); + if ( !player.capabilities.isCreativeMode ) { - player.inventory.mainInventory[player.inventory.currentItem] = null; - MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) ); + held.stackSize--; + if ( held.stackSize == 0 ) + { + player.inventory.mainInventory[player.inventory.currentItem] = null; + MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) ); + } } + return true; } - return true; } } else