Compare commits

...

14 Commits

Author SHA1 Message Date
yueh d5372a5ff6 Added fingerprint 2018-07-14 21:48:52 +02:00
fscan c8eb792d38 Move some blocks to their own feature category and add some comments (#3618)
Start of a bigger cleanup happening in 1.13 to fix the worst issues.
2018-07-14 21:25:06 +02:00
fscan f4ef7edf86 InventoryTweak sorting support (#3603) 2018-07-14 21:07:00 +02:00
fscan 67c733b418 Cutting knife fixes (#3619)
Fixes #3226
2018-07-14 21:03:27 +02:00
yueh fe4db2eb98 Added a color code to the memory card. (#3609)
Can be used to encode the stored content as a 4x2 grid of AEColors
Currently used to indicate the P2P frequency.
2018-07-14 19:42:56 +02:00
fscan 2891014cf6 P2P tunnel frequency color indicators (#3610) 2018-07-14 17:05:07 +02:00
fscan e809c688df Performance improvements for saveChanges() and ICellInventory (#3586)
API break!
Fixes #3553
2018-07-14 16:53:49 +02:00
fscan 71a9bb2532 Change storage/conversion monitor interaction. (#3613)
Fixes #1480
2018-07-14 16:40:20 +02:00
fscan 3363acb7db Follow forges registration guidelines for entities and oredict. Remove ore camouflage (#3605) 2018-07-14 16:37:50 +02:00
fscan 8f6f35b9cf Cache current task in Inscriber, reduce amount of GL calls in TESR (#3604) 2018-07-14 16:35:56 +02:00
fscan ff75f34333 Fix shift-double click behavior (#3606) 2018-07-14 16:33:48 +02:00
fscan e2c0129037 Restore behaviour of ESCAPE always closing the GUI (#3601) 2018-07-14 16:32:21 +02:00
Brock 7fe7f4b1c2 Fixed unnecessary cell saving when cell is full (#3611) 2018-07-14 16:30:33 +02:00
yueh 693487504c Updated README.me 2018-07-11 19:23:00 +02:00
108 changed files with 2518 additions and 759 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ A Mod about Matter, Energy and using them to conquer the world..
* [Website](http://ae-mod.info/) * [Website](http://ae-mod.info/)
* [IRC #appliedenergistics on esper.net](http://webchat.esper.net/?channels=appliedenergistics&prompt=1) * [IRC #appliedenergistics on esper.net](http://webchat.esper.net/?channels=appliedenergistics&prompt=1)
* [GitHub](https://github.com/AppliedEnergistics/Applied-Energistics-2) * [GitHub](https://github.com/AppliedEnergistics/Applied-Energistics-2)
* [Discord](https://discord.gg/DJ9hVAN) * [Discord](https://discord.gg/GygKjjm)
## License ## License
+1
View File
@@ -25,6 +25,7 @@ ic2_version=2.8.73-ex112
top_version=1.12-1.4.23-16 top_version=1.12-1.4.23-16
cofhcore_version=1.12.2-4.5.2.19 cofhcore_version=1.12.2-4.5.2.19
crafttweaker_version=4.1.8.9 crafttweaker_version=4.1.8.9
inventorytweaks_version=1.63
######################################################### #########################################################
# Deployment # # Deployment #
+7 -1
View File
@@ -68,6 +68,11 @@ repositories {
name 'modmaven' name 'modmaven'
url "https://modmaven.k-4u.nl/" url "https://modmaven.k-4u.nl/"
} }
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
} }
configurations { configurations {
@@ -88,7 +93,8 @@ dependencies {
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api" compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf" compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}" compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
// at runtime, use the full JEI jar // at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}" runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
@@ -28,6 +28,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import appeng.api.util.AEColor;
/** /**
* Memory Card API * Memory Card API
@@ -41,13 +43,18 @@ public interface IMemoryCard
* Configures the data stored on the memory card, the SettingsName, will be * Configures the data stored on the memory card, the SettingsName, will be
* localized when displayed. * localized when displayed.
* *
* The data can contain an optional string with the key "tooltip", which will be used as
* unlocalized string to display it after the settings name.
*
* The data can contain an optional intArray using "colorCode" to be displayed on the model itself.
* It needs to have exactly 8 elements representing the ordinal of the matching {@link AEColor}.
* The first 4 values represent the top row, left to right. The second 4 the bottom row.
*
* @param is item * @param is item
* @param SettingsName unlocalized string that represents the tile entity. * @param settingsName unlocalized string that represents the tile entity.
* @param data may contain a String called "tooltip" which is is a * @param data the NBT tag, refer to the normal comment for special keys.
* unlocalized string displayed after the settings name, optional
* but can be used to add details to the card for later.
*/ */
void setMemoryCardContents( ItemStack is, String SettingsName, NBTTagCompound data ); void setMemoryCardContents( ItemStack is, String settingsName, NBTTagCompound data );
/** /**
* returns the settings name provided by a previous call to * returns the settings name provided by a previous call to
@@ -68,6 +75,17 @@ public interface IMemoryCard
*/ */
NBTTagCompound getData( ItemStack is ); NBTTagCompound getData( ItemStack is );
/**
* This represent as 4x2 grid of {@link AEColor} without transparent/fluix color.
*
* First 4 colors are used for the top row, second for the bottom one.
*
* @param is item
*
* @return a hash representation of the memory card content
*/
AEColor[] getColorCode( ItemStack is );
/** /**
* notify the user of a outcome related to the memory card. * notify the user of a outcome related to the memory card.
* *
+40
View File
@@ -209,6 +209,7 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
* Called when you right click the part, very similar to Block.onActivateBlock * Called when you right click the part, very similar to Block.onActivateBlock
* *
* @param player right clicking player * @param player right clicking player
* @param hand hand used
* @param pos position of block * @param pos position of block
* *
* @return if your activate method performed something. * @return if your activate method performed something.
@@ -219,12 +220,41 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
* Called when you right click the part, very similar to Block.onActivateBlock * Called when you right click the part, very similar to Block.onActivateBlock
* *
* @param player shift right clicking player * @param player shift right clicking player
* @param hand hand used
* @param pos position of block * @param pos position of block
* *
* @return if your activate method performed something, you should use false unless you really need it. * @return if your activate method performed something, you should use false unless you really need it.
*/ */
boolean onShiftActivate( EntityPlayer player, EnumHand hand, Vec3d pos ); boolean onShiftActivate( EntityPlayer player, EnumHand hand, Vec3d pos );
/**
* Called when you left click the part, very similar to Block.onBlockClicked
*
* @param player left clicking player
* @param hand hand used
* @param pos position of block
*
* @return if your activate method performed something, you should use false unless you really need it.
*/
default boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
{
return false;
}
/**
* Called when you shift-left click the part, very similar to Block.onBlockClicked
*
* @param player shift-left clicking player
* @param hand hand used
* @param pos position of block
*
* @return if your activate method performed something, you should use false unless you really need it.
*/
default boolean onShiftClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
{
return false;
}
/** /**
* Add drops to the items being dropped into the world, if your item stores its contents when wrenched use the * Add drops to the items being dropped into the world, if your item stores its contents when wrenched use the
* wrenched boolean to control what data is saved vs dropped when it is broken. * wrenched boolean to control what data is saved vs dropped when it is broken.
@@ -325,4 +355,14 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
return null; return null;
} }
/**
* Flag to be passed to the renderer.
*
* @return flag or null
*/
default Long getRenderFlag()
{
return null;
}
} }
@@ -0,0 +1,15 @@
package appeng.api.parts;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.block.model.BakedQuad;
public interface IPartBakedModel
{
List<BakedQuad> getPartQuads( @Nullable Long partFlags, long rand );
}
@@ -52,12 +52,12 @@ public interface ICellHandler
* *
* @param is a storage cell item. * @param is a storage cell item.
* @param host anytime the contents of your storage cell changes it should use this to request a save, please * @param host anytime the contents of your storage cell changes it should use this to request a save, please
* note, this value can be null. * note, this value can be null. If provided, the host is responsible for persisting the cell content.
* @param channel the storage channel requested. * @param channel the storage channel requested.
* *
* @return a new IMEHandler for the provided item * @return a new IMEHandler for the provided item
*/ */
<T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> channel ); <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> channel );
/** /**
* Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item * Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item
@@ -118,4 +118,9 @@ public interface ICellInventory<T extends IAEStack<T>> extends IMEInventory<T>
* @return the status number for this drive. * @return the status number for this drive.
*/ */
int getStatusForCell(); int getStatusForCell();
/**
* Tells the cell to persist to NBT
*/
void persist();
} }
@@ -34,7 +34,7 @@ public interface ICellInventoryHandler<T extends IAEStack<T>> extends IMEInvento
/** /**
* @return get access to the Cell Inventory. * @return get access to the Cell Inventory.
*/ */
ICellInventory getCellInv(); ICellInventory<T> getCellInv();
boolean isPreformatted(); boolean isPreformatted();
@@ -77,11 +77,11 @@ public interface ICellRegistry
* returns an IMEInventoryHandler for the provided item. * returns an IMEInventoryHandler for the provided item.
* *
* @param is item with inventory handler * @param is item with inventory handler
* @param host can be null, or the hosting tile / part. * @param host can be null. If provided, the host is responsible for persisting the cell content.
* @param chan the storage channel to request the handler for. * @param chan the storage channel to request the handler for.
* *
* @return new IMEInventoryHandler, or null if there isn't one. * @return new IMEInventoryHandler, or null if there isn't one.
*/ */
@Nullable @Nullable
<T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> chan ); <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> chan );
} }
@@ -24,8 +24,11 @@
package appeng.api.storage; package appeng.api.storage;
/**
* Tells the cell provider that changes have been made an the cell must be persisted
*
*/
public interface ISaveProvider public interface ISaveProvider
{ {
void saveChanges( ICellInventory<?> cellInventory );
void saveChanges( IMEInventory<?> cellInventory );
} }
@@ -37,17 +37,13 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
import appeng.core.AppEng;
import appeng.entity.EntityIds;
import appeng.entity.EntityTinyTNTPrimed; import appeng.entity.EntityTinyTNTPrimed;
import appeng.helpers.ICustomCollision; import appeng.helpers.ICustomCollision;
@@ -67,9 +63,6 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
this.setSoundType( SoundType.GROUND ); this.setSoundType( SoundType.GROUND );
this.setHardness( 0F ); this.setHardness( 0F );
EntityRegistry.registerModEntity( new ResourceLocation( AppEng.MOD_ID, EntityTinyTNTPrimed.class.getName() ), EntityTinyTNTPrimed.class,
"EntityTinyTNTPrimed", EntityIds.get( EntityTinyTNTPrimed.class ), AppEng.instance(), 16, 4, true );
} }
@Override @Override
@@ -49,6 +49,7 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -70,6 +71,8 @@ import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusRenderState; import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial; import appeng.helpers.AEGlassMaterial;
import appeng.parts.ICableBusContainer; import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer; import appeng.parts.NullCableBusContainer;
@@ -353,6 +356,31 @@ public class BlockCableBus extends AEBaseTileBlock
return out == null ? NULL_CABLE_BUS : out; return out == null ? NULL_CABLE_BUS : out;
} }
@Override
public void onBlockClicked( World worldIn, BlockPos pos, EntityPlayer playerIn )
{
if( Platform.isClient() )
{
final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
if( rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals( rtr.getBlockPos() ) )
{
final Vec3d hitVec = rtr.hitVec.subtract( new Vec3d( pos ) );
if( this.cb( worldIn, pos ).clicked( playerIn, EnumHand.MAIN_HAND, hitVec ) )
{
NetworkHandler.instance()
.sendToServer(
new PacketClick( pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true ) );
}
}
}
}
public void onBlockClickPacket( World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec )
{
this.cb( worldIn, pos ).clicked( playerIn, hand, hitVec );
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{ {
@@ -144,7 +144,7 @@ class ItemDefinitionBuilder implements IItemBuilder
item.setCreativeTab( this.creativeTab ); item.setCreativeTab( this.creativeTab );
// Register all extra handlers // Register all extra handlers
this.boostrapComponents.forEach( component -> component.apply( item ) ); this.boostrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( item ) ) );
// Register custom dispenser behavior if requested // Register custom dispenser behavior if requested
if( this.dispenserBehaviorSupplier != null ) if( this.dispenserBehaviorSupplier != null )
@@ -0,0 +1,12 @@
package appeng.bootstrap.components;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IEntityRegistrationComponent extends IBootstrapComponent
{
void entityRegistration( IForgeRegistry<EntityEntry> entityRegistry );
}
+16 -47
View File
@@ -26,10 +26,8 @@ import java.util.Random;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@@ -42,6 +40,7 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import appeng.api.parts.CableRenderMode; import appeng.api.parts.CableRenderMode;
@@ -85,30 +84,14 @@ public class ClientHelper extends ServerHelper
{ {
ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE ); ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
} }
RenderingRegistry.registerEntityRenderingHandler( EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed( manager ) );
RenderingRegistry.registerEntityRenderingHandler( EntityFloatingItem.class, manager -> new RenderFloatingItem( manager ) );
} }
@Override @Override
public void init() public void init()
{ {
// final Block fluixBlock = GameRegistry.findBlock( "appliedenergistics2", "fluix" );
// Item fluixItem = Item.getItemFromBlock( fluixBlock );
// ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation( "appliedenergistics2:fluix",
// "inventory" );
// final int DEFAULT_ITEM_SUBTYPE = 0;
// final ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
// // mesher.register( fluixItem, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation );
//
// final ResourceLocation resource = new ResourceLocation( "appliedenergistics2", "stair.fluix" );
// final ModelResourceLocation fluixStairModel = new ModelResourceLocation( resource, "inventory" );
// AELog.info( "FluixStairModel: " + fluixStairModel );
//
// final Set<Item> items = AEApi.instance().definitions().blocks().fluixStairs().maybeItem().asSet();
// for( Item item : items )
// {
// AELog.info( "Registering with %s with unlocalized %s", item, item.getUnlocalizedName() );
// mesher.register( item, DEFAULT_ITEM_SUBTYPE, fluixStairModel );
// }
} }
@Override @Override
@@ -199,11 +182,6 @@ public class ClientHelper extends ServerHelper
@Override @Override
public void postInit() public void postInit()
{ {
// RenderingRegistry.registerBlockHandler( WorldRender.INSTANCE );
final RenderManager inst = Minecraft.getMinecraft().getRenderManager();
inst.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed( inst ) );
inst.entityRenderMap.put( EntityFloatingItem.class, new RenderFloatingItem( inst ) );
} }
@Override @Override
@@ -330,29 +308,20 @@ public class ClientHelper extends ServerHelper
final EntityPlayer player = mc.player; final EntityPlayer player = mc.player;
if( player.isSneaking() ) if( player.isSneaking() )
{ {
final EnumHand hand; final boolean mainHand = player.getHeldItem( EnumHand.MAIN_HAND ).getItem() instanceof IMouseWheelItem;
if( !player.getHeldItem( EnumHand.MAIN_HAND ).isEmpty() && player.getHeldItem( EnumHand.MAIN_HAND ).getItem() instanceof IMouseWheelItem ) final boolean offHand = player.getHeldItem( EnumHand.OFF_HAND ).getItem() instanceof IMouseWheelItem;
{
hand = EnumHand.MAIN_HAND;
}
else if( !player.getHeldItem( EnumHand.OFF_HAND ).isEmpty() && player.getHeldItem( EnumHand.OFF_HAND ).getItem() instanceof IMouseWheelItem )
{
hand = EnumHand.OFF_HAND;
}
else
{
return;
}
final ItemStack is = player.getHeldItem( hand ); if( mainHand || offHand )
try
{ {
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getDwheel() > 0 ? "WheelUp" : "WheelDown" ) ); try
me.setCanceled( true ); {
} NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getDwheel() > 0 ? "WheelUp" : "WheelDown" ) );
catch( final IOException e ) me.setCanceled( true );
{ }
AELog.debug( e ); catch( final IOException e )
{
AELog.debug( e );
}
} }
} }
} }
@@ -555,11 +555,11 @@ public abstract class AEBaseGui extends GuiContainer
return; return;
} }
if( !this.disableShiftClick && isShiftKeyDown() ) if( !this.disableShiftClick && isShiftKeyDown() && mouseButton == 0 )
{ {
this.disableShiftClick = true; this.disableShiftClick = true;
if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 ) if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 250 )
{ {
// some simple double click logic. // some simple double click logic.
this.bl_clicked = slot; this.bl_clicked = slot;
@@ -581,12 +581,13 @@ public abstract class AEBaseGui extends GuiContainer
for( final Slot inventorySlot : slots ) for( final Slot inventorySlot : slots )
{ {
if( inventorySlot != null && inventorySlot.canTakeStack( if( inventorySlot != null && inventorySlot.canTakeStack(
this.mc.player ) && inventorySlot.getHasStack() && inventorySlot.inventory == slot.inventory && Container.canAddItemToSlot( this.mc.player ) && inventorySlot.getHasStack() && inventorySlot.isSameInventory( slot ) && Container.canAddItemToSlot(
inventorySlot, this.dbl_whichItem, true ) ) inventorySlot, this.dbl_whichItem, true ) )
{ {
this.handleMouseClick( inventorySlot, inventorySlot.slotNumber, 1, clickType ); this.handleMouseClick( inventorySlot, inventorySlot.slotNumber, 0, ClickType.QUICK_MOVE );
} }
} }
this.dbl_whichItem = ItemStack.EMPTY;
} }
this.disableShiftClick = false; this.disableShiftClick = false;
@@ -487,7 +487,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
return; return;
} }
if( this.searchField.isFocused() && ( key == Keyboard.KEY_ESCAPE || key == Keyboard.KEY_RETURN ) ) if( this.searchField.isFocused() && key == Keyboard.KEY_RETURN )
{ {
this.searchField.setFocused( false ); this.searchField.setFocused( false );
return; return;
@@ -44,6 +44,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.api.parts.IPartBakedModel;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
@@ -119,7 +120,15 @@ public class CableBusBakedModel implements IBakedModel
throw new IllegalStateException( "Trying to use an unregistered part model: " + model ); throw new IllegalStateException( "Trying to use an unregistered part model: " + model );
} }
List<BakedQuad> partQuads = bakedModel.getQuads( state, null, rand ); List<BakedQuad> partQuads;
if( bakedModel instanceof IPartBakedModel )
{
partQuads = ( (IPartBakedModel) bakedModel ).getPartQuads( renderState.getPartFlags().get( facing ), rand );
}
else
{
partQuads = bakedModel.getQuads( state, null, rand );
}
// Rotate quads accordingly // Rotate quads accordingly
QuadRotator rotator = new QuadRotator(); QuadRotator rotator = new QuadRotator();
@@ -74,6 +74,8 @@ public class CableBusRenderState
// facades on this cable bus // facades on this cable bus
private List<AxisAlignedBB> boundingBoxes = new ArrayList<>(); private List<AxisAlignedBB> boundingBoxes = new ArrayList<>();
private EnumMap<EnumFacing, Long> partFlags = new EnumMap<>( EnumFacing.class );
public CableCoreType getCoreType() public CableCoreType getCoreType()
{ {
return this.coreType; return this.coreType;
@@ -154,6 +156,11 @@ public class CableBusRenderState
return this.boundingBoxes; return this.boundingBoxes;
} }
public EnumMap<EnumFacing, Long> getPartFlags()
{
return this.partFlags;
}
@Override @Override
public int hashCode() public int hashCode()
{ {
@@ -166,6 +173,7 @@ public class CableBusRenderState
result = prime * result + ( ( this.channelsOnSide == null ) ? 0 : this.channelsOnSide.hashCode() ); result = prime * result + ( ( this.channelsOnSide == null ) ? 0 : this.channelsOnSide.hashCode() );
result = prime * result + ( ( this.connectionTypes == null ) ? 0 : this.connectionTypes.hashCode() ); result = prime * result + ( ( this.connectionTypes == null ) ? 0 : this.connectionTypes.hashCode() );
result = prime * result + ( ( this.coreType == null ) ? 0 : this.coreType.hashCode() ); result = prime * result + ( ( this.coreType == null ) ? 0 : this.coreType.hashCode() );
result = prime * result + ( ( this.partFlags == null ) ? 0 : this.partFlags.hashCode() );
return result; return result;
} }
@@ -190,7 +198,7 @@ public class CableBusRenderState
return this.cableColor == other.cableColor && this.cableType == other.cableType && this.coreType == other.coreType && Objects return this.cableColor == other.cableColor && this.cableType == other.cableType && this.coreType == other.coreType && Objects
.equals( this.attachmentConnections, other.attachmentConnections ) && Objects.equals( this.cableBusAdjacent, .equals( this.attachmentConnections, other.attachmentConnections ) && Objects.equals( this.cableBusAdjacent,
other.cableBusAdjacent ) && Objects.equals( this.channelsOnSide, other.channelsOnSide ) && Objects.equals( this.connectionTypes, other.cableBusAdjacent ) && Objects.equals( this.channelsOnSide, other.channelsOnSide ) && Objects.equals( this.connectionTypes,
other.connectionTypes ); other.connectionTypes ) && Objects.equals( this.partFlags, other.partFlags );
} }
} }
@@ -0,0 +1,142 @@
package appeng.client.render.cablebus;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.EnumFacing;
import appeng.api.parts.IPartBakedModel;
import appeng.api.util.AEColor;
import appeng.util.Platform;
public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedModel
{
private final VertexFormat format;
private final TextureAtlasSprite texture;
private final static Cache<Long, List<BakedQuad>> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build();
private static final int[][] QUAD_OFFSETS = new int[][] {
{ 4, 10, 2 },
{ 10, 10, 2 },
{ 4, 4, 2 },
{ 10, 4, 2 }
};
public P2PTunnelFrequencyBakedModel( final VertexFormat format, final TextureAtlasSprite texture )
{
this.format = format;
this.texture = texture;
}
@Override
public List<BakedQuad> getPartQuads( Long partFlags, long rand )
{
try
{
return modelCache.get( partFlags, () ->
{
short frequency = 0;
boolean active = false;
if( partFlags != null )
{
frequency = (short) ( partFlags.longValue() & 0xffffL );
active = ( partFlags.longValue() & 0x10000L ) != 0;
}
return getQuadsForFrequency( frequency, active );
} );
}
catch( ExecutionException e )
{
return Collections.emptyList();
}
}
@Override
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
{
if( side != null )
{
return Collections.emptyList();
}
return getPartQuads( null, rand );
}
private List<BakedQuad> getQuadsForFrequency( final short frequency, final boolean active )
{
final AEColor[] colors = Platform.p2p().toColors( frequency );
final CubeBuilder cb = new CubeBuilder( this.format );
cb.setTexture( this.texture );
cb.useStandardUV();
cb.setRenderFullBright( active );
for( int i = 0; i < 4; ++i )
{
final int[] offs = QUAD_OFFSETS[i];
for( int j = 0; j < 4; ++j )
{
final AEColor c = colors[j];
if( active )
{
cb.setColorRGB( c.dye.getColorValue() );
}
else
{
final float cv[] = c.dye.getColorComponentValues();
cb.setColorRGB( cv[0] * 0.5f, cv[1] * 0.5f, cv[2] * 0.5f );
}
final int startx = j % 2;
final int starty = 1 - j / 2;
cb.addCube( offs[0] + startx, offs[1] + starty, offs[2], offs[0] + startx + 1, offs[1] + starty + 1, offs[2] + 1 );
}
}
return cb.getOutput();
}
@Override
public boolean isAmbientOcclusion()
{
return false;
}
@Override
public boolean isGui3d()
{
return false;
}
@Override
public boolean isBuiltInRenderer()
{
return true;
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.texture;
}
@Override
public ItemOverrideList getOverrides()
{
return ItemOverrideList.NONE;
}
}
@@ -0,0 +1,43 @@
package appeng.client.render.cablebus;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.IModelState;
import appeng.core.AppEng;
public class P2PTunnelFrequencyModel implements IModel
{
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" );
@Override
public Collection<ResourceLocation> getTextures()
{
return Collections.singletonList( TEXTURE );
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
try
{
final TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
return new P2PTunnelFrequencyBakedModel( format, texture );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
}
@@ -28,7 +28,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.model.TRSRTransformation;
import appeng.api.implementations.items.IBiometricCard; import appeng.api.implementations.items.IBiometricCard;
@@ -216,9 +215,9 @@ class BiometricCardBakedModel implements IBakedModel
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type ) public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
{ {
// Delegate to the base model if possible // Delegate to the base model if possible
if( this.baseModel instanceof IModel ) if( this.baseModel instanceof IBakedModel )
{ {
IBakedModel pam = (IBakedModel) this.baseModel; IBakedModel pam = this.baseModel;
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type ); Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
return Pair.of( this, pair.getValue() ); return Pair.of( this, pair.getValue() );
} }
@@ -0,0 +1,228 @@
package appeng.client.render.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.AELog;
class MemoryCardBakedModel implements IBakedModel
{
private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] {
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
};
private final VertexFormat format;
private final IBakedModel baseModel;
private final TextureAtlasSprite texture;
private final AEColor[] colorCode;
private final Cache<CacheKey, MemoryCardBakedModel> modelCache;
private final ImmutableList<BakedQuad> generalQuads;
MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture )
{
this( format, baseModel, texture, DEFAULT_COLOR_CODE, createCache() );
}
private MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache<CacheKey, MemoryCardBakedModel> modelCache )
{
this.format = format;
this.baseModel = baseModel;
this.texture = texture;
this.colorCode = hash;
this.generalQuads = ImmutableList.copyOf( this.buildGeneralQuads() );
this.modelCache = modelCache;
}
private static Cache<CacheKey, MemoryCardBakedModel> createCache()
{
return CacheBuilder.newBuilder()
.maximumSize( 100 )
.build();
}
@Override
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
{
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand );
if( side != null )
{
return quads;
}
List<BakedQuad> result = new ArrayList<>( quads.size() + this.generalQuads.size() );
result.addAll( quads );
result.addAll( this.generalQuads );
return result;
}
private List<BakedQuad> buildGeneralQuads()
{
CubeBuilder builder = new CubeBuilder( this.format );
builder.setTexture( this.texture );
for( int x = 0; x < 4; x++ )
{
for( int y = 0; y < 2; y++ )
{
final AEColor color = this.colorCode[x + y * 4];
builder.setColorRGB( color.mediumVariant );
builder.addCube( 7 + x, 8 + ( 1 - y ), 7.5f, 7 + x + 1, 8 + ( 1 - y ) + 1, 8.5f );
}
}
return builder.getOutput();
}
@Override
public boolean isAmbientOcclusion()
{
return this.baseModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
return this.baseModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
return this.baseModel.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return this.baseModel.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides()
{
return new ItemOverrideList( Collections.emptyList() )
{
@Override
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity )
{
try
{
if( stack.getItem() instanceof IMemoryCard )
{
final IMemoryCard memoryCard = (IMemoryCard) stack.getItem();
final AEColor[] colors = memoryCard.getColorCode( stack );
return MemoryCardBakedModel.this.modelCache.get( new CacheKey( colors ),
() -> new MemoryCardBakedModel( MemoryCardBakedModel.this.format, MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) );
}
}
catch( ExecutionException e )
{
AELog.error( e );
}
return MemoryCardBakedModel.this;
}
};
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
{
// Delegate to the base model if possible
if( this.baseModel instanceof IBakedModel )
{
IBakedModel pam = this.baseModel;
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
return Pair.of( this, pair.getValue() );
}
return Pair.of( this, TRSRTransformation.identity().getMatrix() );
}
private static class CacheKey
{
private final AEColor[] key;
CacheKey( AEColor[] key )
{
this.key = key;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode( this.key );
return result;
}
@Override
public boolean equals( Object obj )
{
if( this == obj )
{
return true;
}
if( obj == null )
{
return false;
}
if( this.getClass() != obj.getClass() )
{
return false;
}
CacheKey other = (CacheKey) obj;
return Arrays.equals( this.key, other.key );
}
}
}
@@ -0,0 +1,70 @@
package appeng.client.render.model;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.core.AppEng;
/**
* Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile.
*/
public class MemoryCardModel implements IModel
{
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" );
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" );
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.singletonList( MODEL_BASE );
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Collections.singletonList( TEXTURE );
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter );
return new MemoryCardBakedModel( format, baseModel, texture );
}
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
// Load the base model
try
{
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity().toItemTransform();
}
}
@@ -4,7 +4,6 @@ package appeng.client.render.tesr;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@@ -15,7 +14,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
@@ -23,7 +22,6 @@ import net.minecraftforge.items.IItemHandler;
import appeng.api.features.IInscriberRecipe; import appeng.api.features.IInscriberRecipe;
import appeng.client.render.FacingToRotation; import appeng.client.render.FacingToRotation;
import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.tile.AEBaseTile; import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileInscriber; import appeng.tile.misc.TileInscriber;
@@ -32,7 +30,7 @@ import appeng.tile.misc.TileInscriber;
/** /**
* Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed) * Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed)
*/ */
public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber> public final class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
{ {
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f; private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
@@ -42,7 +40,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
private static TextureAtlasSprite textureInside; private static TextureAtlasSprite textureInside;
@Override @Override
public void render( TileInscriber tile, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ ) public void render( final TileInscriber tile, final double x, final double y, final double z, final float partialTicks, final int destroyStage, final float p_render_10_ )
{ {
// render inscriber // render inscriber
@@ -90,7 +88,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
float press = 0.2f; float press = 0.2f;
press -= progress / 5.0f; press -= progress / 5.0f;
BufferBuilder buffer = Tessellator.getInstance().getBuffer(); final BufferBuilder buffer = Tessellator.getInstance().getBuffer();
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX ); buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX );
float middle = 0.5f; float middle = 0.5f;
@@ -129,8 +127,6 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
Tessellator.getInstance().draw(); Tessellator.getInstance().draw();
GlStateManager.popMatrix();
// render items. // render items.
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F ); GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
@@ -150,8 +146,6 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
items++; items++;
} }
// buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.ITEM );
if( relativeProgress > 1.0f || items == 0 ) if( relativeProgress > 1.0f || items == 0 )
{ {
ItemStack is = tileInv.getStackInSlot( 3 ); ItemStack is = tileInv.getStackInSlot( 3 );
@@ -165,65 +159,40 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
} }
} }
this.renderItem( is, 0.0f, tile, buffer, x, y, z ); this.renderItem( is, 0.0f, tile, x, y, z );
} }
else else
{ {
this.renderItem( tileInv.getStackInSlot( 0 ), press, tile, buffer, x, y, z ); this.renderItem( tileInv.getStackInSlot( 0 ), press, tile, x, y, z );
this.renderItem( tileInv.getStackInSlot( 1 ), -press, tile, buffer, x, y, z ); this.renderItem( tileInv.getStackInSlot( 1 ), -press, tile, x, y, z );
this.renderItem( tileInv.getStackInSlot( 2 ), 0.0f, tile, buffer, x, y, z ); this.renderItem( tileInv.getStackInSlot( 2 ), 0.0f, tile, x, y, z );
} }
// Tessellator.getInstance().draw(); GlStateManager.popMatrix();
GlStateManager.enableLighting(); GlStateManager.enableLighting();
GlStateManager.enableRescaleNormal(); GlStateManager.enableRescaleNormal();
} }
private void renderItem( ItemStack sis, final float o, final AEBaseTile tile, final BufferBuilder tess, final double x, final double y, final double z ) private void renderItem( final ItemStack stack, final float o, final AEBaseTile tile, final double x, final double y, final double z )
{ {
if( !sis.isEmpty() ) if( !stack.isEmpty() )
{ {
sis = sis.copy(); final ItemStack sis = stack.copy();
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
// move to center
GlStateManager.translate( 0.5f, 0.5f + o, 0.5f );
GlStateManager.rotate( 90, 1, 0, 0 );
// set scale
GlStateManager.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
GlStateManager.translate( x, y, z ); // heuristic to scale items down much further than blocks
GlStateManager.translate( 0.5F, 0.5F, 0.5F ); if( !( sis.getItem() instanceof ItemBlock ) )
FacingToRotation.get( tile.getForward(), tile.getUp() ).glRotateCurrentMat();
GlStateManager.translate( -0.5F, -0.5F, -0.5F );
try
{ {
// move to center GlStateManager.scale( 0.5, 0.5, 0.5 );
GlStateManager.translate( 0.5f, 0.5f + o, 0.5f );
GlStateManager.rotate( 90, 1, 0, 0 );
// set scale
GlStateManager.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
// heuristic to scale items down much further than blocks
final Block blk = Block.getBlockFromItem( sis.getItem() );
if( blk == Blocks.AIR )
{
GlStateManager.scale( 0.5, 0.5, 0.5 );
}
// << 20 | light << 4;
final int br = tile.getWorld().getCombinedLight( tile.getPos(), 0 );
final int var11 = br % 65536;
final int var12 = br / 65536;
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
Minecraft.getMinecraft().getRenderItem().renderItem( sis, ItemCameraTransforms.TransformType.FIXED );
}
catch( final Exception err )
{
AELog.debug( err );
} }
Minecraft.getMinecraft().getRenderItem().renderItem( sis, ItemCameraTransforms.TransformType.FIXED );
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} }
} }
@@ -156,15 +156,22 @@ public class ContainerQuartzKnife extends AEBaseContainer
private void makePlate() private void makePlate()
{ {
if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() ) if( Platform.isServer() )
{ {
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack(); if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() )
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player );
if( item.getCount() == 0 )
{ {
ContainerQuartzKnife.this.getPlayerInv().mainInventory.add( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY ); final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, item, null ) ); final ItemStack before = item.copy();
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player );
if( item.getCount() == 0 )
{
ContainerQuartzKnife.this.getPlayerInv()
.setInventorySlotContents( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, before, null ) );
}
ContainerQuartzKnife.this.detectAndSendChanges();
} }
} }
} }
+1
View File
@@ -215,6 +215,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
this.clientSync(); this.clientSync();
this.addCustomCategoryComment( "features", "Warning: Disabling a feature may disable other features depending on it." );
for( final AEFeature feature : AEFeature.values() ) for( final AEFeature feature : AEFeature.values() )
{ {
if( feature.isVisible() ) if( feature.isVisible() )
+2 -12
View File
@@ -67,7 +67,7 @@ import appeng.services.version.VersionCheckerConfig;
import appeng.util.Platform; import appeng.util.Platform;
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.12.2]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory" ) @Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.12.2]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory", certificateFingerprint = "dfa4d3ac143316c6f32aa1a1beda1e34d42132e5" )
public final class AppEng public final class AppEng
{ {
@SidedProxy( clientSide = "appeng.client.ClientHelper", serverSide = "appeng.server.ServerHelper", modId = AppEng.MOD_ID ) @SidedProxy( clientSide = "appeng.client.ClientHelper", serverSide = "appeng.server.ServerHelper", modId = AppEng.MOD_ID )
@@ -78,17 +78,7 @@ public final class AppEng
public static final String ASSETS = "appliedenergistics2:"; public static final String ASSETS = "appliedenergistics2:";
public static final String MOD_DEPENDENCIES = public static final String MOD_DEPENDENCIES = "";
// a few mods, AE should load after, probably.
// required-after:AppliedEnergistics2API|all;
// "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" +
// depend on version of forge used for build.
"after:appliedenergistics2-core;";// + "required-after:Forge@[" // require forge.
// + net.minecraftforge.common.ForgeVersion.majorVersion + '.' // majorVersion
// + net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
// + net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
// + net.minecraftforge.common.ForgeVersion.buildVersion + ",)"; // buildVersion
@Nonnull @Nonnull
private static final AppEng INSTANCE = new AppEng(); private static final AppEng INSTANCE = new AppEng();
+15 -8
View File
@@ -53,6 +53,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@@ -76,10 +77,10 @@ import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.spatial.ISpatialCache; import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.networking.storage.IStorageGrid; import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.ITickManager; import appeng.api.networking.ticking.ITickManager;
import appeng.api.parts.IPartHelper;
import appeng.bootstrap.ICriterionTriggerRegistry; import appeng.bootstrap.ICriterionTriggerRegistry;
import appeng.bootstrap.IModelRegistry; import appeng.bootstrap.IModelRegistry;
import appeng.bootstrap.components.IBlockRegistrationComponent; import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IInitComponent; import appeng.bootstrap.components.IInitComponent;
import appeng.bootstrap.components.IItemRegistrationComponent; import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IModelRegistrationComponent; import appeng.bootstrap.components.IModelRegistrationComponent;
@@ -211,11 +212,9 @@ final class Registration
Preconditions.checkArgument( !recipeDirectory.isFile() ); Preconditions.checkArgument( !recipeDirectory.isFile() );
final Api api = Api.INSTANCE; final Api api = Api.INSTANCE;
final IPartHelper partHelper = api.partHelper();
final IRegistryContainer registries = api.registries(); final IRegistryContainer registries = api.registries();
ApiDefinitions definitions = api.definitions(); ApiDefinitions definitions = api.definitions();
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( event.getSide() ) );
definitions.getRegistry().getBootstrapComponents( IInitComponent.class ).forEachRemaining( b -> b.initialize( event.getSide() ) ); definitions.getRegistry().getBootstrapComponents( IInitComponent.class ).forEachRemaining( b -> b.initialize( event.getSide() ) );
MinecraftForge.EVENT_BUS.register( TickHandler.INSTANCE ); MinecraftForge.EVENT_BUS.register( TickHandler.INSTANCE );
@@ -286,6 +285,10 @@ final class Registration
final ApiDefinitions definitions = Api.INSTANCE.definitions(); final ApiDefinitions definitions = Api.INSTANCE.definitions();
final Side side = FMLCommonHandler.instance().getEffectiveSide(); final Side side = FMLCommonHandler.instance().getEffectiveSide();
definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( side, registry ) ); definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( side, registry ) );
// register oredicts
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( side ) );
ItemMaterial.instance.registerOredicts();
ItemPart.instance.registerOreDicts();
} }
@SubscribeEvent @SubscribeEvent
@@ -297,10 +300,6 @@ final class Registration
final ApiDefinitions definitions = api.definitions(); final ApiDefinitions definitions = api.definitions();
final Side side = FMLCommonHandler.instance().getEffectiveSide(); final Side side = FMLCommonHandler.instance().getEffectiveSide();
// Perform ore camouflage!
ItemMaterial.instance.makeUnique();
ItemPart.instance.registerOreDicts();
if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) ) if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) )
{ {
DisassembleRecipe r = new DisassembleRecipe(); DisassembleRecipe r = new DisassembleRecipe();
@@ -321,7 +320,15 @@ final class Registration
final AERecipeLoader ldr = new AERecipeLoader(); final AERecipeLoader ldr = new AERecipeLoader();
ldr.loadProcessingRecipes(); ldr.loadProcessingRecipes();
} }
@SubscribeEvent
public void registerEntities( RegistryEvent.Register<EntityEntry> event)
{
final IForgeRegistry<EntityEntry> registry = event.getRegistry();
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents( IEntityRegistrationComponent.class ).forEachRemaining( b -> b.entityRegistration( registry ) );
}
@SubscribeEvent @SubscribeEvent
public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event ) public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event )
{ {
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab; import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@@ -93,6 +94,7 @@ import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.FeatureFactory; import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IOreDictComponent; import appeng.bootstrap.components.IOreDictComponent;
import appeng.bootstrap.components.IPostInitComponent; import appeng.bootstrap.components.IPostInitComponent;
import appeng.bootstrap.components.IPreInitComponent; import appeng.bootstrap.components.IPreInitComponent;
@@ -126,6 +128,8 @@ import appeng.decorative.solid.BlockQuartzPillar;
import appeng.decorative.solid.BlockSkyStone; import appeng.decorative.solid.BlockSkyStone;
import appeng.decorative.solid.BlockSkyStone.SkystoneType; import appeng.decorative.solid.BlockSkyStone.SkystoneType;
import appeng.decorative.stair.BlockStairCommon; import appeng.decorative.stair.BlockStairCommon;
import appeng.entity.EntityIds;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.fluids.block.BlockFluidInterface; import appeng.fluids.block.BlockFluidInterface;
import appeng.fluids.tile.TileFluidInterface; import appeng.fluids.tile.TileFluidInterface;
import appeng.hooks.DispenserBehaviorTinyTNT; import appeng.hooks.DispenserBehaviorTinyTNT;
@@ -261,11 +265,13 @@ public final class ApiBlocks implements IBlocks
.build(); .build();
this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ).features( AEFeature.SPATIAL_IO ).build(); this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ).features( AEFeature.SPATIAL_IO ).build();
FeatureFactory deco = registry.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS ); FeatureFactory deco = registry.features( AEFeature.DECORATIVE_BLOCKS );
this.quartzBlock = deco.block( "quartz_block", BlockQuartz::new ).build(); this.quartzBlock = deco.block( "quartz_block", BlockQuartz::new ).build();
this.quartzPillar = deco.block( "quartz_pillar", BlockQuartzPillar::new ).build(); this.quartzPillar = deco.block( "quartz_pillar", BlockQuartzPillar::new ).build();
this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", BlockChiseledQuartz::new ).build(); this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", BlockChiseledQuartz::new ).build();
this.quartzGlass = deco.block( "quartz_glass", BlockQuartzGlass::new )
this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS )
.block( "quartz_glass", BlockQuartzGlass::new )
.useCustomItemModel() .useCustomItemModel()
.rendering( new BlockRenderingCustomizer() .rendering( new BlockRenderingCustomizer()
{ {
@@ -278,7 +284,7 @@ public final class ApiBlocks implements IBlocks
} ) } )
.build(); .build();
this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", BlockQuartzLamp::new ) this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", BlockQuartzLamp::new )
.addFeatures( AEFeature.DECORATIVE_LIGHTS ) .addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS )
.useCustomItemModel() .useCustomItemModel()
.build(); .build();
this.quartzFixture = registry.block( "quartz_fixture", BlockQuartzFixture::new ) this.quartzFixture = registry.block( "quartz_fixture", BlockQuartzFixture::new )
@@ -286,19 +292,28 @@ public final class ApiBlocks implements IBlocks
.useCustomItemModel() .useCustomItemModel()
.build(); .build();
this.fluixBlock = deco.block( "fluix_block", BlockFluix::new ).build(); this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", BlockFluix::new ).build();
this.skyStoneBlock = deco.block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE ) ).build();
this.smoothSkyStoneBlock = deco.block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK ) ).build(); this.skyStoneBlock = registry.features( AEFeature.SKY_STONE )
this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK ) ).build(); .block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE ) )
this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK ) ).build(); .build();
this.smoothSkyStoneBlock = registry.features( AEFeature.SKY_STONE )
.block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK ) )
.build();
this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK ) )
.addFeatures( AEFeature.SKY_STONE )
.build();
this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK ) )
.addFeatures( AEFeature.SKY_STONE )
.build();
this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( SkyChestType.STONE ) ) this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( SkyChestType.STONE ) )
.features( AEFeature.SKY_STONE_CHESTS ) .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
.tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) ) .tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) )
.rendering( new SkyChestRenderingCustomizer( SkyChestType.STONE ) ) .rendering( new SkyChestRenderingCustomizer( SkyChestType.STONE ) )
.build(); .build();
this.smoothSkyStoneChest = registry.block( "smooth_sky_stone_chest", () -> new BlockSkyChest( SkyChestType.BLOCK ) ) this.smoothSkyStoneChest = registry.block( "smooth_sky_stone_chest", () -> new BlockSkyChest( SkyChestType.BLOCK ) )
.features( AEFeature.SKY_STONE_CHESTS ) .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
.tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) ) .tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) )
.rendering( new SkyChestRenderingCustomizer( SkyChestType.BLOCK ) ) .rendering( new SkyChestRenderingCustomizer( SkyChestType.BLOCK ) )
.build(); .build();
@@ -345,6 +360,16 @@ public final class ApiBlocks implements IBlocks
.features( AEFeature.TINY_TNT ) .features( AEFeature.TINY_TNT )
.bootstrap( ( block, item ) -> (IPreInitComponent) side -> BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, .bootstrap( ( block, item ) -> (IPreInitComponent) side -> BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item,
new DispenserBehaviorTinyTNT() ) ) new DispenserBehaviorTinyTNT() ) )
.bootstrap( ( block, item ) -> (IEntityRegistrationComponent) r ->
{
r.register( EntityEntryBuilder.create()
.entity( EntityTinyTNTPrimed.class )
.id( new ResourceLocation( "appliedenergistics2", EntityTinyTNTPrimed.class.getName() ),
EntityIds.get( EntityTinyTNTPrimed.class ) )
.name( "EntityTinyTNTPrimed" )
.tracker( 16, 4, true )
.build() );
} )
.build(); .build();
this.securityStation = registry.block( "security_station", BlockSecurityStation::new ) this.securityStation = registry.block( "security_station", BlockSecurityStation::new )
.features( AEFeature.SECURITY ) .features( AEFeature.SECURITY )
@@ -557,7 +582,7 @@ public final class ApiBlocks implements IBlocks
Block block = blockDef.maybeBlock().get(); Block block = blockDef.maybeBlock().get();
IBlockDefinition slabDef = registry.block( slabId, () -> new BlockSlabCommon.Half( block ) ) IBlockDefinition slabDef = registry.block( slabId, () -> new BlockSlabCommon.Half( block ) )
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS ) .features( AEFeature.DECORATIVE_BLOCKS )
.disableItem() .disableItem()
.build(); .build();
@@ -570,7 +595,7 @@ public final class ApiBlocks implements IBlocks
// Reigster the double slab variant as well // Reigster the double slab variant as well
IBlockDefinition doubleSlabDef = registry.block( doubleSlabId, () -> new BlockSlabCommon.Double( slabBlock, block ) ) IBlockDefinition doubleSlabDef = registry.block( doubleSlabId, () -> new BlockSlabCommon.Double( slabBlock, block ) )
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS ) .features( AEFeature.DECORATIVE_BLOCKS )
.disableItem() .disableItem()
.build(); .build();
@@ -580,7 +605,7 @@ public final class ApiBlocks implements IBlocks
// Make the slab item // Make the slab item
IItemDefinition itemDef = registry.item( slabId, () -> new ItemSlab( slabBlock, slabBlock, doubleSlabBlock ) ) IItemDefinition itemDef = registry.item( slabId, () -> new ItemSlab( slabBlock, slabBlock, doubleSlabBlock ) )
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS ) .features( AEFeature.DECORATIVE_BLOCKS )
.build(); .build();
Verify.verify( itemDef.maybeItem().isPresent() ); Verify.verify( itemDef.maybeItem().isPresent() );
@@ -592,7 +617,7 @@ public final class ApiBlocks implements IBlocks
private static IBlockDefinition makeStairs( String registryName, FeatureFactory registry, IBlockDefinition block ) private static IBlockDefinition makeStairs( String registryName, FeatureFactory registry, IBlockDefinition block )
{ {
return registry.block( registryName, () -> new BlockStairCommon( block.maybeBlock().get(), block.identifier() ) ) return registry.block( registryName, () -> new BlockStairCommon( block.maybeBlock().get(), block.identifier() ) )
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS ) .features( AEFeature.DECORATIVE_BLOCKS )
.rendering( new BlockRenderingCustomizer() .rendering( new BlockRenderingCustomizer()
{ {
@Override @Override
@@ -19,10 +19,14 @@
package appeng.core.api.definitions; package appeng.core.api.definitions;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory; import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.client.render.crafting.ItemEncodedPatternRendering; import appeng.client.render.crafting.ItemEncodedPatternRendering;
import appeng.core.CreativeTabFacade; import appeng.core.CreativeTabFacade;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
@@ -30,6 +34,8 @@ import appeng.debug.ToolDebugCard;
import appeng.debug.ToolEraser; import appeng.debug.ToolEraser;
import appeng.debug.ToolMeteoritePlacer; import appeng.debug.ToolMeteoritePlacer;
import appeng.debug.ToolReplicatorCard; import appeng.debug.ToolReplicatorCard;
import appeng.entity.EntityGrowingCrystal;
import appeng.entity.EntityIds;
import appeng.fluids.items.BasicFluidStorageCell; import appeng.fluids.items.BasicFluidStorageCell;
import appeng.fluids.items.FluidDummyItem; import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.items.FluidDummyItemRendering; import appeng.fluids.items.FluidDummyItemRendering;
@@ -50,6 +56,7 @@ import appeng.items.storage.ItemViewCell;
import appeng.items.tools.ToolBiometricCard; import appeng.items.tools.ToolBiometricCard;
import appeng.items.tools.ToolBiometricCardRendering; import appeng.items.tools.ToolBiometricCardRendering;
import appeng.items.tools.ToolMemoryCard; import appeng.items.tools.ToolMemoryCard;
import appeng.items.tools.ToolMemoryCardRendering;
import appeng.items.tools.ToolNetworkTool; import appeng.items.tools.ToolNetworkTool;
import appeng.items.tools.powered.ToolChargedStaff; import appeng.items.tools.powered.ToolChargedStaff;
import appeng.items.tools.powered.ToolColorApplicator; import appeng.items.tools.powered.ToolColorApplicator;
@@ -199,7 +206,10 @@ public final class ApiItems implements IItems
.rendering( new ToolBiometricCardRendering() ) .rendering( new ToolBiometricCardRendering() )
.features( AEFeature.SECURITY ) .features( AEFeature.SECURITY )
.build(); .build();
this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new ).features( AEFeature.MEMORY_CARD ).build(); this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new )
.rendering( new ToolMemoryCardRendering() )
.features( AEFeature.MEMORY_CARD )
.build();
this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ).features( AEFeature.NETWORK_TOOL ).build(); this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ).features( AEFeature.NETWORK_TOOL ).build();
this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new ) this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new )
@@ -231,6 +241,16 @@ public final class ApiItems implements IItems
this.crystalSeed = registry.item( "crystal_seed", ItemCrystalSeed::new ) this.crystalSeed = registry.item( "crystal_seed", ItemCrystalSeed::new )
.features( AEFeature.CRYSTAL_SEEDS ) .features( AEFeature.CRYSTAL_SEEDS )
.rendering( new ItemCrystalSeedRendering() ) .rendering( new ItemCrystalSeedRendering() )
.bootstrap( item -> (IEntityRegistrationComponent) r ->
{
r.register( EntityEntryBuilder.create()
.entity( EntityGrowingCrystal.class )
.id( new ResourceLocation( "appliedenergistics2", EntityGrowingCrystal.class.getName() ),
EntityIds.get( EntityGrowingCrystal.class ) )
.name( EntityGrowingCrystal.class.getSimpleName() )
.tracker( 16, 4, true )
.build() );
} )
.build(); .build();
// rv1 // rv1
@@ -22,6 +22,8 @@ package appeng.core.api.definitions;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@@ -30,7 +32,11 @@ import appeng.api.definitions.IMaterials;
import appeng.bootstrap.FeatureFactory; import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer; import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.core.features.DamagedItemDefinition; import appeng.core.features.DamagedItemDefinition;
import appeng.entity.EntityChargedQuartz;
import appeng.entity.EntityIds;
import appeng.entity.EntitySingularity;
import appeng.items.materials.ItemMaterial; import appeng.items.materials.ItemMaterial;
import appeng.items.materials.MaterialType; import appeng.items.materials.MaterialType;
@@ -133,6 +139,22 @@ public final class ApiMaterials implements IMaterials
.collect( Collectors.toList() ) ); .collect( Collectors.toList() ) );
} }
} ) } )
.bootstrap( item -> (IEntityRegistrationComponent) r ->
{
r.register( EntityEntryBuilder.create()
.entity( EntitySingularity.class )
.id( new ResourceLocation( "appliedenergistics2", EntitySingularity.class.getName() ), EntityIds.get( EntitySingularity.class ) )
.name( EntitySingularity.class.getSimpleName() )
.tracker( 16, 4, true )
.build() );
r.register( EntityEntryBuilder.create()
.entity( EntityChargedQuartz.class )
.id( new ResourceLocation( "appliedenergistics2", EntityChargedQuartz.class.getName() ),
EntityIds.get( EntityChargedQuartz.class ) )
.name( EntityChargedQuartz.class.getSimpleName() )
.tracker( 16, 4, true )
.build() );
} )
.build(); .build();
this.cell2SpatialPart = new DamagedItemDefinition( "material.cell.spatial.2", materials.createMaterial( MaterialType.CELL2_SPATIAL_PART ) ); this.cell2SpatialPart = new DamagedItemDefinition( "material.cell.spatial.2", materials.createMaterial( MaterialType.CELL2_SPATIAL_PART ) );
@@ -36,20 +36,22 @@ public enum AEFeature
CERTUS_QUARTZ_WORLD_GEN( "CertusQuartzWorldGen", Constants.CATEGORY_WORLD ), CERTUS_QUARTZ_WORLD_GEN( "CertusQuartzWorldGen", Constants.CATEGORY_WORLD ),
METEORITE_WORLD_GEN( "MeteoriteWorldGen", Constants.CATEGORY_WORLD ), METEORITE_WORLD_GEN( "MeteoriteWorldGen", Constants.CATEGORY_WORLD ),
DECORATIVE_LIGHTS( "DecorativeLights", Constants.CATEGORY_WORLD ), DECORATIVE_LIGHTS( "DecorativeLights", Constants.CATEGORY_WORLD ),
DECORATIVE_QUARTZ_BLOCKS( "DecorativeQuartzBlocks", Constants.CATEGORY_WORLD ), DECORATIVE_BLOCKS( "DecorativeBlocks", Constants.CATEGORY_WORLD, "Blocks that are not used in any essential recipes, also slabs and stairs." ),
SKY_STONE_CHESTS( "SkyStoneChests", Constants.CATEGORY_WORLD ), SKY_STONE_CHESTS( "SkyStoneChests", Constants.CATEGORY_WORLD ),
SPAWN_PRESSES_IN_METEORITES( "SpawnPressesInMeteorites", Constants.CATEGORY_WORLD ), SPAWN_PRESSES_IN_METEORITES( "SpawnPressesInMeteorites", Constants.CATEGORY_WORLD ),
GRIND_STONE( "GrindStone", Constants.CATEGORY_WORLD ),
FLOUR( "Flour", Constants.CATEGORY_WORLD ), FLOUR( "Flour", Constants.CATEGORY_WORLD ),
INSCRIBER( "Inscriber", Constants.CATEGORY_WORLD ),
CHARGER( "Charger", Constants.CATEGORY_WORLD ),
CRYSTAL_GROWTH_ACCELERATOR( "CrystalGrowthAccelerator", Constants.CATEGORY_WORLD ),
CHEST_LOOT( "ChestLoot", Constants.CATEGORY_WORLD ), CHEST_LOOT( "ChestLoot", Constants.CATEGORY_WORLD ),
VILLAGER_TRADING( "VillagerTrading", Constants.CATEGORY_WORLD ), VILLAGER_TRADING( "VillagerTrading", Constants.CATEGORY_WORLD ),
TINY_TNT( "TinyTNT", Constants.CATEGORY_WORLD ), TINY_TNT( "TinyTNT", Constants.CATEGORY_WORLD ),
CERTUS_ORE( "CertusOre", Constants.CATEGORY_WORLD ), CERTUS_ORE( "CertusOre", Constants.CATEGORY_WORLD ),
CHARGED_CERTUS_ORE( "ChargedCertusOre", Constants.CATEGORY_WORLD ), CHARGED_CERTUS_ORE( "ChargedCertusOre", Constants.CATEGORY_WORLD ),
GRIND_STONE( "GrindStone", Constants.CATEGORY_MACHINES ),
INSCRIBER( "Inscriber", Constants.CATEGORY_MACHINES ),
CHARGER( "Charger", Constants.CATEGORY_MACHINES ),
CRYSTAL_GROWTH_ACCELERATOR( "CrystalGrowthAccelerator", Constants.CATEGORY_MACHINES ),
POWER_GEN( "VibrationChamber", Constants.CATEGORY_MACHINES ),
POWERED_TOOLS( "PoweredTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ), POWERED_TOOLS( "PoweredTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ),
CERTUS_QUARTZ_TOOLS( "CertusQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ), CERTUS_QUARTZ_TOOLS( "CertusQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ),
NETHER_QUARTZ_TOOLS( "NetherQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ), NETHER_QUARTZ_TOOLS( "NetherQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ),
@@ -68,7 +70,6 @@ public enum AEFeature
COLOR_APPLICATOR( "ColorApplicator", Constants.CATEGORY_TOOLS ), COLOR_APPLICATOR( "ColorApplicator", Constants.CATEGORY_TOOLS ),
METEORITE_COMPASS( "MeteoriteCompass", Constants.CATEGORY_TOOLS ), METEORITE_COMPASS( "MeteoriteCompass", Constants.CATEGORY_TOOLS ),
POWER_GEN( "PowerGen", Constants.CATEGORY_NETWORK_FEATURES ),
SECURITY( "Security", Constants.CATEGORY_NETWORK_FEATURES ), SECURITY( "Security", Constants.CATEGORY_NETWORK_FEATURES ),
SPATIAL_IO( "SpatialIO", Constants.CATEGORY_NETWORK_FEATURES ), SPATIAL_IO( "SpatialIO", Constants.CATEGORY_NETWORK_FEATURES ),
QUANTUM_NETWORK_BRIDGE( "QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES ), QUANTUM_NETWORK_BRIDGE( "QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES ),
@@ -114,12 +115,11 @@ public enum AEFeature
GLASS_CABLES( "GlassCables", Constants.CATEGORY_CABLES ), GLASS_CABLES( "GlassCables", Constants.CATEGORY_CABLES ),
COVERED_CABLES( "CoveredCables", Constants.CATEGORY_CABLES ), COVERED_CABLES( "CoveredCables", Constants.CATEGORY_CABLES ),
SMART_CABLES( "SmartCables", Constants.CATEGORY_CABLES ), SMART_CABLES( "SmartCables", Constants.CATEGORY_CABLES ),
DENSE_CABLES( "DenseCables", Constants.CATEGORY_CABLES ),
ENERGY_CELLS( "EnergyCells", Constants.CATEGORY_ENERGY ), ENERGY_CELLS( "EnergyCells", Constants.CATEGORY_ENERGY ),
ENERGY_ACCEPTOR( "EnergyAcceptor", Constants.CATEGORY_ENERGY ), ENERGY_ACCEPTOR( "EnergyAcceptor", Constants.CATEGORY_ENERGY ),
DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_ENERGY ),
DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_HIGHER_CAPACITY ),
DENSE_CABLES( "DenseCables", Constants.CATEGORY_HIGHER_CAPACITY ),
P2P_TUNNEL_ME( "P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS ), P2P_TUNNEL_ME( "P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ), P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ),
@@ -169,9 +169,6 @@ public enum AEFeature
ADVANCED_CARDS( "AdvancedCards", Constants.CATEGORY_UPGRADES ), ADVANCED_CARDS( "AdvancedCards", Constants.CATEGORY_UPGRADES ),
VIEW_CELL( "ViewCell", Constants.CATEGORY_UPGRADES ), VIEW_CELL( "ViewCell", Constants.CATEGORY_UPGRADES ),
PROCESSORS( "Processors", Constants.CATEGORY_MATERIALS ),
PRINTED_CIRCUITS( "PrintedCircuits", Constants.CATEGORY_MATERIALS ),
PRESSES( "Presses", Constants.CATEGORY_MATERIALS ),
CRYSTAL_SEEDS( "CrystalSeeds", Constants.CATEGORY_MATERIALS ), CRYSTAL_SEEDS( "CrystalSeeds", Constants.CATEGORY_MATERIALS ),
PURE_CRYSTALS( "PureCrystals", Constants.CATEGORY_MATERIALS ), PURE_CRYSTALS( "PureCrystals", Constants.CATEGORY_MATERIALS ),
CERTUS( "Certus", Constants.CATEGORY_MATERIALS ), CERTUS( "Certus", Constants.CATEGORY_MATERIALS ),
@@ -179,8 +176,14 @@ public enum AEFeature
SILICON( "Silicon", Constants.CATEGORY_MATERIALS ), SILICON( "Silicon", Constants.CATEGORY_MATERIALS ),
DUSTS( "Dusts", Constants.CATEGORY_MATERIALS ), DUSTS( "Dusts", Constants.CATEGORY_MATERIALS ),
NUGGETS( "Nuggets", Constants.CATEGORY_MATERIALS ), NUGGETS( "Nuggets", Constants.CATEGORY_MATERIALS ),
MATTER_BALL( "MatterBall", Constants.CATEGORY_MATERIALS ), QUARTZ_GLASS( "QuartzGlass", Constants.CATEGORY_MATERIALS ),
CORES( "Cores", Constants.CATEGORY_MATERIALS ), SKY_STONE( "SkyStone", Constants.CATEGORY_MATERIALS ),
PROCESSORS( "Processors", Constants.CATEGORY_COMPONENTS ),
PRINTED_CIRCUITS( "PrintedCircuits", Constants.CATEGORY_COMPONENTS ),
PRESSES( "Presses", Constants.CATEGORY_COMPONENTS ),
MATTER_BALL( "MatterBall", Constants.CATEGORY_COMPONENTS ),
CORES( "Cores", Constants.CATEGORY_COMPONENTS ),
CHUNK_LOGGER_TRACE( "ChunkLoggerTrace", Constants.CATEGORY_COMMANDS, false ); CHUNK_LOGGER_TRACE( "ChunkLoggerTrace", Constants.CATEGORY_COMMANDS, false );
@@ -249,6 +252,7 @@ public enum AEFeature
private static final String CATEGORY_MISC = "Misc"; private static final String CATEGORY_MISC = "Misc";
private static final String CATEGORY_CRAFTING = "Crafting"; private static final String CATEGORY_CRAFTING = "Crafting";
private static final String CATEGORY_WORLD = "World"; private static final String CATEGORY_WORLD = "World";
private static final String CATEGORY_MACHINES = "Machines";
private static final String CATEGORY_TOOLS = "Tools"; private static final String CATEGORY_TOOLS = "Tools";
private static final String CATEGORY_TOOLS_CLASSIFICATIONS = "ToolsClassifications"; private static final String CATEGORY_TOOLS_CLASSIFICATIONS = "ToolsClassifications";
private static final String CATEGORY_NETWORK_BUSES = "NetworkBuses"; private static final String CATEGORY_NETWORK_BUSES = "NetworkBuses";
@@ -257,7 +261,6 @@ public enum AEFeature
private static final String CATEGORY_CRAFTING_FEATURES = "CraftingFeatures"; private static final String CATEGORY_CRAFTING_FEATURES = "CraftingFeatures";
private static final String CATEGORY_STORAGE = "Storage"; private static final String CATEGORY_STORAGE = "Storage";
private static final String CATEGORY_CABLES = "Cables"; private static final String CATEGORY_CABLES = "Cables";
private static final String CATEGORY_HIGHER_CAPACITY = "HigherCapacity";
private static final String CATEGORY_NETWORK_FEATURES = "NetworkFeatures"; private static final String CATEGORY_NETWORK_FEATURES = "NetworkFeatures";
private static final String CATEGORY_COMMANDS = "Commands"; private static final String CATEGORY_COMMANDS = "Commands";
private static final String CATEGORY_RENDERING = "Rendering"; private static final String CATEGORY_RENDERING = "Rendering";
@@ -267,5 +270,6 @@ public enum AEFeature
private static final String CATEGORY_ENERGY = "Energy"; private static final String CATEGORY_ENERGY = "Energy";
private static final String CATEGORY_UPGRADES = "Upgrades"; private static final String CATEGORY_UPGRADES = "Upgrades";
private static final String CATEGORY_MATERIALS = "Materials"; private static final String CATEGORY_MATERIALS = "Materials";
private static final String CATEGORY_COMPONENTS = "CraftingComponents";
} }
} }
@@ -51,11 +51,11 @@ public class BasicItemCellHandler implements ICellHandler
} }
@Override @Override
public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel ) public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
{ {
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{ {
return ItemCellInventory.getCell( is, container ); return (ICellInventoryHandler<T>) ItemCellInventory.getCell( is, container );
} }
return null; return null;
@@ -28,8 +28,8 @@ import com.google.common.base.Verify;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ICellRegistry; import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
@@ -92,7 +92,7 @@ public class CellRegistry implements ICellRegistry
} }
@Override @Override
public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan ) public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan )
{ {
if( is.isEmpty() ) if( is.isEmpty() )
{ {
@@ -26,6 +26,7 @@ import net.minecraft.tileentity.TileEntity;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.implementations.tiles.IChestOrDrive; import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
@@ -48,7 +49,7 @@ public final class CreativeCellHandler implements ICellHandler
} }
@Override @Override
public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel ) public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
{ {
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
.getItem() instanceof ItemCreativeStorageCell ) .getItem() instanceof ItemCreativeStorageCell )
@@ -22,17 +22,20 @@ package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition; import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages; import appeng.api.implementations.items.MemoryCardMessages;
import appeng.block.networking.BlockCableBus;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.ToolNetworkTool; import appeng.items.tools.ToolNetworkTool;
@@ -50,6 +53,7 @@ public class PacketClick extends AppEngPacket
private final float hitY; private final float hitY;
private final float hitZ; private final float hitZ;
private EnumHand hand; private EnumHand hand;
private final boolean leftClick;
// automatic. // automatic.
public PacketClick( final ByteBuf stream ) public PacketClick( final ByteBuf stream )
@@ -70,10 +74,16 @@ public class PacketClick extends AppEngPacket
this.hitY = stream.readFloat(); this.hitY = stream.readFloat();
this.hitZ = stream.readFloat(); this.hitZ = stream.readFloat();
this.hand = EnumHand.values()[stream.readByte()]; this.hand = EnumHand.values()[stream.readByte()];
this.leftClick = stream.readBoolean();
} }
// api // api
public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand ) public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
{
this( pos, side, hitX, hitY, hitZ, hand, false );
}
public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand, boolean leftClick )
{ {
final ByteBuf data = Unpooled.buffer(); final ByteBuf data = Unpooled.buffer();
@@ -94,6 +104,7 @@ public class PacketClick extends AppEngPacket
data.writeFloat( this.hitY = hitY ); data.writeFloat( this.hitY = hitY );
data.writeFloat( this.hitZ = hitZ ); data.writeFloat( this.hitZ = hitZ );
data.writeByte( hand.ordinal() ); data.writeByte( hand.ordinal() );
data.writeBoolean( this.leftClick = leftClick );
this.configureWrite( data ); this.configureWrite( data );
} }
@@ -105,27 +116,38 @@ public class PacketClick extends AppEngPacket
final IItems items = AEApi.instance().definitions().items(); final IItems items = AEApi.instance().definitions().items();
final IComparableDefinition maybeMemoryCard = items.memoryCard(); final IComparableDefinition maybeMemoryCard = items.memoryCard();
final IComparableDefinition maybeColorApplicator = items.colorApplicator(); final IComparableDefinition maybeColorApplicator = items.colorApplicator();
final BlockPos pos = new BlockPos( this.x, this.y, this.z );
if( !is.isEmpty() ) if( this.leftClick )
{ {
if( is.getItem() instanceof ToolNetworkTool ) final Block block = player.world.getBlockState( pos ).getBlock();
if( block instanceof BlockCableBus )
{ {
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem(); ( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) );
tnt.serverSideToolLogic( is, player, this.hand, player.world, new BlockPos( this.x, this.y, this.z ), this.side, this.hitX, this.hitY,
this.hitZ );
} }
}
else if( maybeMemoryCard.isSameAs( is ) ) else
{
if( !is.isEmpty() )
{ {
final IMemoryCard mem = (IMemoryCard) is.getItem(); if( is.getItem() instanceof ToolNetworkTool )
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED ); {
is.setTagCompound( null ); final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
} tnt.serverSideToolLogic( is, player, this.hand, player.world, pos, this.side, this.hitX, this.hitY,
this.hitZ );
}
else if( maybeColorApplicator.isSameAs( is ) ) else if( maybeMemoryCard.isSameAs( is ) )
{ {
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem(); final IMemoryCard mem = (IMemoryCard) is.getItem();
mem.cycleColors( is, mem.getColor( is ), 1 ); mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
is.setTagCompound( null );
}
else if( maybeColorApplicator.isSameAs( is ) )
{
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
mem.cycleColors( is, mem.getColor( is ), 1 );
}
} }
} }
} }
@@ -25,7 +25,6 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@@ -33,7 +32,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public class RenderTinyTNTPrimed extends Render public class RenderTinyTNTPrimed extends Render<EntityTinyTNTPrimed>
{ {
public RenderTinyTNTPrimed( final RenderManager p_i46134_1_ ) public RenderTinyTNTPrimed( final RenderManager p_i46134_1_ )
@@ -43,12 +42,7 @@ public class RenderTinyTNTPrimed extends Render
} }
@Override @Override
public void doRender( final Entity tnt, final double x, final double y, final double z, final float unused, final float life ) public void doRender( final EntityTinyTNTPrimed tnt, final double x, final double y, final double z, final float unused, final float life )
{
this.renderPrimedTNT( (EntityTinyTNTPrimed) tnt, x, y, z, unused, life );
}
private void renderPrimedTNT( final EntityTinyTNTPrimed tnt, final double x, final double y, final double z, final float unused, final float life )
{ {
final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
@@ -105,7 +99,7 @@ public class RenderTinyTNTPrimed extends Render
} }
@Override @Override
protected ResourceLocation getEntityTexture( final Entity entity ) protected ResourceLocation getEntityTexture( final EntityTinyTNTPrimed entity )
{ {
return TextureMap.LOCATION_BLOCKS_TEXTURE; return TextureMap.LOCATION_BLOCKS_TEXTURE;
} }
@@ -577,7 +577,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
public void saveChanges() public void saveChanges()
{ {
this.iHost.getTileEntity().markDirty(); this.iHost.saveChanges();
} }
@Override @Override
@@ -36,4 +36,6 @@ public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgra
EnumSet<EnumFacing> getTargets(); EnumSet<EnumFacing> getTargets();
TileEntity getTileEntity(); TileEntity getTileEntity();
void saveChanges();
} }
@@ -185,18 +185,12 @@ public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluid
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_FORMATION_PLANE ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_FORMATION_PLANE );
return true;
} }
return false; return true;
} }
@Override @Override
@@ -136,11 +136,6 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
@Override @Override
public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos )
{ {
if( p.isSneaking() )
{
return false;
}
if( Platform.isServer() ) if( Platform.isServer() )
{ {
Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_FLUID_INTERFACE ); Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_FLUID_INTERFACE );
@@ -237,7 +232,7 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
{ {
return this.duality.getInventoryByName( name ); return this.duality.getInventoryByName( name );
} }
@Override @Override
public ItemStack getItemStackRepresentation() public ItemStack getItemStackRepresentation()
{ {
@@ -266,18 +266,11 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_LEVEL_EMITTER ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_LEVEL_EMITTER );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -222,17 +222,11 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS_FLUID ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS_FLUID );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -491,7 +485,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
return MODELS_OFF; return MODELS_OFF;
} }
} }
@Override @Override
public ItemStack getItemStackRepresentation() public ItemStack getItemStackRepresentation()
{ {
@@ -104,18 +104,12 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS_FLUID ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS_FLUID );
return true;
} }
return false; return true;
} }
@Override @Override
@@ -51,11 +51,11 @@ public class BasicFluidCellHandler implements ICellHandler
} }
@Override @Override
public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel ) public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
{ {
if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
{ {
return (IMEInventoryHandler<T>) FluidCellInventory.getCell( is, container ); return (ICellInventoryHandler<T>) FluidCellInventory.getCell( is, container );
} }
return null; return null;
@@ -29,7 +29,7 @@ import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException; import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IStorageCell; import appeng.api.implementations.items.IStorageCell;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
@@ -47,17 +47,12 @@ import appeng.me.storage.AbstractCellInventory;
*/ */
public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack> public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
{ {
protected FluidCellInventory( final NBTTagCompound data, final ISaveProvider container )
{
super( data, container, 8000 );
}
private FluidCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException private FluidCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
{ {
super( o, container, 8000 ); super( o, container, 8000 );
} }
public static IMEInventoryHandler<IAEFluidStack> getCell( final ItemStack o, final ISaveProvider container2 ) public static ICellInventoryHandler<IAEFluidStack> getCell( final ItemStack o, final ISaveProvider container2 )
{ {
try try
{ {
@@ -111,7 +106,7 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
if( l != null ) if( l != null )
{ {
final long remainingItemSlots = this.getRemainingItemCount(); final long remainingItemSlots = this.getRemainingItemCount();
if( remainingItemSlots < 0 ) if( remainingItemSlots <= 0 )
{ {
return input; return input;
} }
@@ -123,7 +118,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
l.setStackSize( l.getStackSize() + remainingItemSlots ); l.setStackSize( l.getStackSize() + remainingItemSlots );
this.updateItemCount( remainingItemSlots );
this.saveChanges(); this.saveChanges();
} }
return r; return r;
@@ -133,7 +127,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
l.setStackSize( l.getStackSize() + input.getStackSize() ); l.setStackSize( l.getStackSize() + input.getStackSize() );
this.updateItemCount( input.getStackSize() );
this.saveChanges(); this.saveChanges();
} }
return null; return null;
@@ -155,8 +148,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
toWrite.amount = remainingItemCount; toWrite.amount = remainingItemCount;
this.cellItems.add( AEFluidStack.fromFluidStack( toWrite ) ); this.cellItems.add( AEFluidStack.fromFluidStack( toWrite ) );
this.updateItemCount( toWrite.amount );
this.saveChanges(); this.saveChanges();
} }
return AEFluidStack.fromFluidStack( toReturn ); return AEFluidStack.fromFluidStack( toReturn );
@@ -164,7 +155,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
this.updateItemCount( input.getStackSize() );
this.cellItems.add( input ); this.cellItems.add( input );
this.saveChanges(); this.saveChanges();
} }
@@ -198,7 +188,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
results.setStackSize( l.getStackSize() ); results.setStackSize( l.getStackSize() );
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
this.updateItemCount( -l.getStackSize() );
l.setStackSize( 0 ); l.setStackSize( 0 );
this.saveChanges(); this.saveChanges();
} }
@@ -209,7 +198,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
l.setStackSize( l.getStackSize() - size ); l.setStackSize( l.getStackSize() - size );
this.updateItemCount( -size );
this.saveChanges(); this.saveChanges();
} }
} }
@@ -561,14 +561,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return this.storage; return this.storage;
} }
public void markDirty()
{
for( int slot = 0; slot < this.storage.getSlots(); slot++ )
{
this.storage.markDirty( slot );
}
}
@Override @Override
public TickingRequest getTickingRequest( final IGridNode node ) public TickingRequest getTickingRequest( final IGridNode node )
{ {
@@ -869,8 +861,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{ {
this.cancelCrafting(); this.cancelCrafting();
} }
this.iHost.saveChanges();
this.markDirty();
} }
private void cancelCrafting() private void cancelCrafting()
@@ -1251,8 +1242,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
public void setPriority( final int newValue ) public void setPriority( final int newValue )
{ {
this.priority = newValue; this.priority = newValue;
this.markDirty(); this.iHost.saveChanges();
try try
{ {
this.gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.gridProxy.getNode() ) ); this.gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.gridProxy.getNode() ) );
@@ -21,6 +21,7 @@ package appeng.integration;
import appeng.integration.modules.crafttweaker.CTModule; import appeng.integration.modules.crafttweaker.CTModule;
import appeng.integration.modules.ic2.IC2Module; import appeng.integration.modules.ic2.IC2Module;
import appeng.integration.modules.inventorytweaks.InventoryTweaksModule;
import appeng.integration.modules.jei.JEIModule; import appeng.integration.modules.jei.JEIModule;
import appeng.integration.modules.theoneprobe.TheOneProbeModule; import appeng.integration.modules.theoneprobe.TheOneProbeModule;
import appeng.integration.modules.waila.WailaModule; import appeng.integration.modules.waila.WailaModule;
@@ -50,7 +51,14 @@ public enum IntegrationType
} }
}, },
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" ), InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" )
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setInvTweaks( new InventoryTweaksModule() );
}
},
JEI( IntegrationSide.CLIENT, "Just Enough Items", "jei" ) JEI( IntegrationSide.CLIENT, "Just Enough Items", "jei" )
{ {
@@ -0,0 +1,41 @@
package appeng.integration.modules.inventorytweaks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import invtweaks.api.InvTweaksAPI;
import appeng.integration.abstraction.IInvTweaks;
public class InventoryTweaksModule implements IInvTweaks
{
InvTweaksAPI api = null;
public InventoryTweaksModule()
{
try
{
api = (InvTweaksAPI) Class.forName( "invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader() )
.getField( "instance" )
.get( null );
}
catch( Exception ex )
{
}
}
@Override
public boolean isEnabled()
{
return api != null;
}
@Override
public int compareItems( ItemStack i, ItemStack j )
{
return api.compareItems( i, j );
}
}
@@ -36,6 +36,7 @@ public enum TheOneProbeText
P2P_INPUT_ONE_OUTPUT, P2P_INPUT_ONE_OUTPUT,
P2P_INPUT_MANY_OUTPUTS, P2P_INPUT_MANY_OUTPUTS,
P2P_OUTPUT, P2P_OUTPUT,
P2P_FREQUENCY,
LOCKED, LOCKED,
UNLOCKED, UNLOCKED,
@@ -33,6 +33,7 @@ import appeng.api.parts.IPart;
import appeng.integration.modules.theoneprobe.TheOneProbeText; import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.parts.p2p.PartP2PTunnel; import appeng.parts.p2p.PartP2PTunnel;
import appeng.util.Platform;
public class P2PStateInfoProvider implements IPartProbInfoProvider public class P2PStateInfoProvider implements IPartProbInfoProvider
@@ -41,7 +42,6 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
private static final int STATE_UNLINKED = 0; private static final int STATE_UNLINKED = 0;
private static final int STATE_OUTPUT = 1; private static final int STATE_OUTPUT = 1;
private static final int STATE_INPUT = 2; private static final int STATE_INPUT = 2;
public static final String TAG_P2P_STATE = "p2p_state";
@Override @Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data ) public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
@@ -50,6 +50,11 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
{ {
final PartP2PTunnel tunnel = (PartP2PTunnel) part; final PartP2PTunnel tunnel = (PartP2PTunnel) part;
if( !tunnel.isPowered() )
{
return;
}
// The default state // The default state
int state = STATE_UNLINKED; int state = STATE_UNLINKED;
int outputCount = 0; int outputCount = 0;
@@ -84,6 +89,11 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
probeInfo.text( getOutputText( outputCount ) ); probeInfo.text( getOutputText( outputCount ) );
break; break;
} }
final short freq = tunnel.getFrequency();
final String freqTooltip = Platform.p2p().toHexString( freq );
probeInfo.text( freqTooltip );
} }
} }
@@ -27,6 +27,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World; import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -36,6 +37,7 @@ import appeng.api.parts.IPart;
import appeng.core.localization.WailaText; import appeng.core.localization.WailaText;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.parts.p2p.PartP2PTunnel; import appeng.parts.p2p.PartP2PTunnel;
import appeng.util.Platform;
/** /**
@@ -48,6 +50,7 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
private static final int STATE_OUTPUT = 1; private static final int STATE_OUTPUT = 1;
private static final int STATE_INPUT = 2; private static final int STATE_INPUT = 2;
public static final String TAG_P2P_STATE = "p2p_state"; public static final String TAG_P2P_STATE = "p2p_state";
public static final String TAG_P2P_FREQUENCY = "p2p_frequency";
/** /**
* Adds state to the tooltip * Adds state to the tooltip
@@ -86,6 +89,10 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
break; break;
} }
} }
final short freq = nbtData.getShort( TAG_P2P_FREQUENCY );
final String freqTooltip = Platform.p2p().toHexString( freq );
currentToolTip.add( I18n.translateToLocalFormatted( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
} }
} }
@@ -97,7 +104,16 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
{ {
if( part instanceof PartP2PTunnel ) if( part instanceof PartP2PTunnel )
{ {
PartP2PTunnel tunnel = (PartP2PTunnel) part; final PartP2PTunnel tunnel = (PartP2PTunnel) part;
if( !tunnel.isPowered() )
{
return tag;
}
// Frquency
final short frequency = tunnel.getFrequency();
tag.setShort( TAG_P2P_FREQUENCY, frequency );
// The default state // The default state
int state = STATE_UNLINKED; int state = STATE_UNLINKED;
@@ -125,6 +141,7 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
state, state,
outputCount outputCount
} ); } );
} }
return tag; return tag;
@@ -202,54 +202,17 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
return mat.getStackSrc(); return mat.getStackSrc();
} }
public void makeUnique() public void registerOredicts()
{ {
for( final MaterialType mt : ImmutableSet.copyOf( this.dmgToMaterial.values() ) ) for( final MaterialType mt : ImmutableSet.copyOf( this.dmgToMaterial.values() ) )
{ {
if( mt.getOreName() != null ) if( mt.getOreName() != null )
{ {
ItemStack replacement = ItemStack.EMPTY;
final String[] names = mt.getOreName().split( "," ); final String[] names = mt.getOreName().split( "," );
for( final String name : names ) for( final String name : names )
{ {
if( !replacement.isEmpty() ) OreDictionary.registerOre( name, mt.stack( 1 ) );
{
break;
}
final List<ItemStack> options = OreDictionary.getOres( name );
if( options != OreDictionary.EMPTY_LIST && options.size() > 0 )
{
for( final ItemStack is : options )
{
if( !is.isEmpty() )
{
replacement = is.copy();
break;
}
}
}
}
if( replacement.isEmpty() || AEConfig.instance().useAEVersion( mt ) )
{
// continue using the AE2 item.
for( final String name : names )
{
OreDictionary.registerOre( name, mt.stack( 1 ) );
}
}
else
{
if( mt.getItemInstance() == this )
{
this.dmgToMaterial.remove( mt.getDamageValue() );
}
mt.setItemInstance( replacement.getItem() );
mt.setDamageValue( replacement.getItemDamage() );
} }
} }
} }
@@ -341,8 +304,9 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
try try
{ {
eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.posX, eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class )
location.posY, location.posZ, itemstack ); .newInstance( w, location.posX,
location.posY, location.posZ, itemstack );
} }
catch( final Throwable t ) catch( final Throwable t )
{ {
@@ -27,13 +27,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.features.MaterialStackSrc; import appeng.core.features.MaterialStackSrc;
import appeng.entity.EntityChargedQuartz; import appeng.entity.EntityChargedQuartz;
import appeng.entity.EntityIds;
import appeng.entity.EntitySingularity; import appeng.entity.EntitySingularity;
@@ -148,11 +146,6 @@ public enum MaterialType
{ {
this( metaValue, modelName, features ); this( metaValue, modelName, features );
this.droppedEntity = c; this.droppedEntity = c;
EntityRegistry.registerModEntity( new ResourceLocation( "appliedenergistics2", this.droppedEntity.getName() ), this.droppedEntity,
this.droppedEntity.getSimpleName(),
EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4,
true );
} }
MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final String oreDictionary, final Class<? extends Entity> c ) MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final String oreDictionary, final Class<? extends Entity> c )
@@ -160,10 +153,6 @@ public enum MaterialType
this( metaValue, modelName, features ); this( metaValue, modelName, features );
this.oreName = oreDictionary; this.oreName = oreDictionary;
this.droppedEntity = c; this.droppedEntity = c;
EntityRegistry.registerModEntity( new ResourceLocation( "appliedenergistics2", this.droppedEntity.getName() ), this.droppedEntity,
this.droppedEntity.getSimpleName(),
EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4,
true );
} }
MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final String oreDictionary ) MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final String oreDictionary )
@@ -32,9 +32,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@@ -42,10 +40,8 @@ import appeng.api.AEApi;
import appeng.api.definitions.IMaterials; import appeng.api.definitions.IMaterials;
import appeng.api.implementations.items.IGrowableCrystal; import appeng.api.implementations.items.IGrowableCrystal;
import appeng.api.recipes.ResolverResult; import appeng.api.recipes.ResolverResult;
import appeng.core.AppEng;
import appeng.core.localization.ButtonToolTips; import appeng.core.localization.ButtonToolTips;
import appeng.entity.EntityGrowingCrystal; import appeng.entity.EntityGrowingCrystal;
import appeng.entity.EntityIds;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
import appeng.util.Platform; import appeng.util.Platform;
@@ -64,9 +60,6 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
public ItemCrystalSeed() public ItemCrystalSeed()
{ {
this.setHasSubtypes( true ); this.setHasSubtypes( true );
EntityRegistry.registerModEntity( new ResourceLocation( "appliedenergistics2", EntityGrowingCrystal.class.getName() ), EntityGrowingCrystal.class,
EntityGrowingCrystal.class.getSimpleName(), EntityIds.get( EntityGrowingCrystal.class ), AppEng.instance(), 16, 4, true );
} }
@Nullable @Nullable
@@ -34,6 +34,7 @@ import appeng.api.util.AEColor;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer; import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.client.render.StaticItemColor; import appeng.client.render.StaticItemColor;
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import appeng.parts.automation.PlaneConnections; import appeng.parts.automation.PlaneConnections;
@@ -128,6 +129,9 @@ public class ItemPartRendering extends ItemRenderingCustomizer
} }
// base p2p model with frequency
rendering.builtInModel( "models/part/builtin/p2p_tunnel_frequency", new P2PTunnelFrequencyModel() );
List<ResourceLocation> partResourceLocs = modelNames.stream() List<ResourceLocation> partResourceLocs = modelNames.stream()
.map( name -> new ResourceLocation( AppEng.MOD_ID, name ) ) .map( name -> new ResourceLocation( AppEng.MOD_ID, name ) )
.collect( Collectors.toList() ); .collect( Collectors.toList() );
@@ -29,6 +29,7 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -37,6 +38,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages; import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.util.AEColor;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
@@ -45,6 +47,12 @@ import appeng.util.Platform;
public class ToolMemoryCard extends AEBaseItem implements IMemoryCard public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{ {
private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] {
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
};
public ToolMemoryCard() public ToolMemoryCard()
{ {
this.setMaxStackSize( 1 ); this.setMaxStackSize( 1 );
@@ -61,6 +69,14 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{ {
lines.add( I18n.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) ); lines.add( I18n.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
} }
if( data.hasKey( "freq" ) )
{
final short freq = data.getShort( "freq" );
final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString( freq );
lines.add( I18n.translateToLocalFormatted( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
}
} }
/** /**
@@ -114,7 +130,26 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{ {
o = new NBTTagCompound(); o = new NBTTagCompound();
} }
return (NBTTagCompound) o.copy(); return o.copy();
}
@Override
public AEColor[] getColorCode( ItemStack is )
{
final NBTTagCompound tag = this.getData( is );
if( tag.hasKey( "colorCode" ) )
{
final int[] frequency = tag.getIntArray( "colorCode" );
final AEColor[] colorArray = AEColor.values();
return new AEColor[] {
colorArray[frequency[0]], colorArray[frequency[1]], colorArray[frequency[2]], colorArray[frequency[3]],
colorArray[frequency[4]], colorArray[frequency[5]], colorArray[frequency[6]], colorArray[frequency[7]],
};
}
return DEFAULT_COLOR_CODE;
} }
@Override @Override
@@ -0,0 +1,28 @@
package appeng.items.tools;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.client.render.model.MemoryCardModel;
import appeng.core.AppEng;
public class ToolMemoryCardRendering extends ItemRenderingCustomizer
{
private static final ResourceLocation MODEL = new ResourceLocation( AppEng.MOD_ID, "builtin/memory_card" );
@Override
@SideOnly( Side.CLIENT )
public void customize( IItemRendering rendering )
{
rendering.builtInModel( "models/item/builtin/memory_card", new MemoryCardModel() );
rendering.model( new ModelResourceLocation( MODEL, "inventory" ) ).variants( MODEL );
}
}
@@ -54,11 +54,9 @@ import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IStorageCell; import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.ICellInventory; import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
@@ -77,7 +75,6 @@ import appeng.items.contents.CellUpgrades;
import appeng.items.misc.ItemPaintBall; import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.helpers.PlayerSource; import appeng.me.helpers.PlayerSource;
import appeng.me.storage.ItemCellInventoryHandler;
import appeng.tile.misc.TilePaint; import appeng.tile.misc.TilePaint;
import appeng.util.LookDirection; import appeng.util.LookDirection;
import appeng.util.Platform; import appeng.util.Platform;
@@ -97,12 +94,15 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
{ {
super.addCheckedInformation( stack, world, lines, advancedTooltips ); super.addCheckedInformation( stack, world, lines, advancedTooltips );
final IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); .registries()
.cell()
.getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cdi instanceof ItemCellInventoryHandler ) if( cdi != null )
{ {
final ICellInventory cd = ( (ICellInventoryHandler) cdi ).getCellInv(); final ICellInventory<IAEItemStack> cd = cdi.getCellInv();
if( cd != null ) if( cd != null )
{ {
lines.add( cd.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cd.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() ); lines.add( cd.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cd.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() );
@@ -124,17 +124,22 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
shots += cu.getInstalledUpgrades( Upgrades.SPEED ); shots += cu.getInstalledUpgrades( Upgrades.SPEED );
} }
final IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( p.getHeldItem( hand ), null, final ICellInventoryHandler<IAEItemStack> inv = AEApi.instance()
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); .registries()
.cell()
.getCellInventory( p.getHeldItem( hand ), null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( inv != null ) if( inv != null )
{ {
final IItemList itemList = inv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); final IItemList<IAEItemStack> itemList = inv
IAEStack aeAmmo = itemList.getFirstItem(); .getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
if( aeAmmo instanceof IAEItemStack ) IAEItemStack req = itemList.getFirstItem();
if( req instanceof IAEItemStack )
{ {
shots = Math.min( shots, (int) aeAmmo.getStackSize() ); shots = Math.min( shots, (int) req.getStackSize() );
for( int sh = 0; sh < shots; sh++ ) for( int sh = 0; sh < shots; sh++ )
{ {
IAEItemStack aeAmmo = req.copy();
this.extractAEPower( p.getHeldItem( hand ), 1600, Actionable.MODULATE ); this.extractAEPower( p.getHeldItem( hand ), 1600, Actionable.MODULATE );
if( Platform.isClient() ) if( Platform.isClient() )
@@ -206,7 +206,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
} }
te.setCoreBlock( false ); te.setCoreBlock( false );
te.markDirty(); te.saveChanges();
this.tiles.add( 0, te ); this.tiles.add( 0, te );
if( te.isStorage() ) if( te.isStorage() )
@@ -395,7 +395,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
private void markDirty() private void markDirty()
{ {
this.getCore().markDirty(); this.getCore().saveChanges();
} }
private void postCraftingStatusChange( final IAEItemStack diff ) private void postCraftingStatusChange( final IAEItemStack diff )
@@ -42,7 +42,7 @@ import appeng.util.Platform;
*/ */
public abstract class AbstractCellInventory<T extends IAEStack<T>> implements ICellInventory<T> public abstract class AbstractCellInventory<T extends IAEStack<T>> implements ICellInventory<T>
{ {
private static final int MAX_ITEM_TYPES = 63;
private static final String ITEM_TYPE_TAG = "it"; private static final String ITEM_TYPE_TAG = "it";
private static final String ITEM_COUNT_TAG = "ic"; private static final String ITEM_COUNT_TAG = "ic";
private static final String ITEM_SLOT = "#"; private static final String ITEM_SLOT = "#";
@@ -51,46 +51,37 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
protected static final String ITEM_PRE_FORMATTED_SLOT = "PF#"; protected static final String ITEM_PRE_FORMATTED_SLOT = "PF#";
protected static final String ITEM_PRE_FORMATTED_NAME = "PN"; protected static final String ITEM_PRE_FORMATTED_NAME = "PN";
protected static final String ITEM_PRE_FORMATTED_FUZZY = "FP"; protected static final String ITEM_PRE_FORMATTED_FUZZY = "FP";
private static String[] itemSlots; private static final String[] ITEM_SLOT_KEYS = new String[MAX_ITEM_TYPES];
private static String[] itemSlotCount; private static final String[] ITEM_SLOT_COUNT_KEYS = new String[MAX_ITEM_TYPES];
private final NBTTagCompound tagCompound; private final NBTTagCompound tagCompound;
protected final ISaveProvider container; protected final ISaveProvider container;
private int maxItemTypes = 63; private int maxItemTypes = MAX_ITEM_TYPES;
private short storedItems = 0; private short storedItems = 0;
private int storedItemCount = 0; private int storedItemCount = 0;
protected IItemList<T> cellItems; protected IItemList<T> cellItems;
protected ItemStack i; protected final ItemStack i;
protected IStorageCell<T> cellType; protected final IStorageCell<T> cellType;
protected final int itemsPerByte; protected final int itemsPerByte;
private boolean isPersisted = true;
protected AbstractCellInventory( final NBTTagCompound data, final ISaveProvider container, final int itemsPerByte ) static
{ {
this.tagCompound = data; for( int x = 0; x < MAX_ITEM_TYPES; x++ )
this.container = container; {
this.itemsPerByte = itemsPerByte; ITEM_SLOT_KEYS[x] = ITEM_SLOT + x;
ITEM_SLOT_COUNT_KEYS[x] = ITEM_SLOT_COUNT + x;
}
} }
protected AbstractCellInventory( final ItemStack o, final ISaveProvider container, final int itemsPerByte ) throws AppEngException protected AbstractCellInventory( final ItemStack o, final ISaveProvider container, final int itemsPerByte ) throws AppEngException
{ {
this.itemsPerByte = itemsPerByte; this.itemsPerByte = itemsPerByte;
if( itemSlots == null )
{
itemSlots = new String[this.maxItemTypes];
itemSlotCount = new String[this.maxItemTypes];
for( int x = 0; x < this.maxItemTypes; x++ )
{
itemSlots[x] = ITEM_SLOT + x;
itemSlotCount[x] = ITEM_SLOT_COUNT + x;
}
}
if( o == null ) if( o == null )
{ {
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
} }
this.cellType = null;
this.i = o; this.i = o;
final Item type = this.i.getItem(); final Item type = this.i.getItem();
@@ -99,8 +90,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
this.cellType = (IStorageCell<T>) this.i.getItem(); this.cellType = (IStorageCell<T>) this.i.getItem();
this.maxItemTypes = this.cellType.getTotalTypes( this.i ); this.maxItemTypes = this.cellType.getTotalTypes( this.i );
} }
else
if( this.cellType == null )
{ {
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
} }
@@ -110,9 +100,9 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
} }
if( this.maxItemTypes > 63 ) if( this.maxItemTypes > MAX_ITEM_TYPES )
{ {
this.maxItemTypes = 63; this.maxItemTypes = MAX_ITEM_TYPES;
} }
if( this.maxItemTypes < 1 ) if( this.maxItemTypes < 1 )
{ {
@@ -142,14 +132,14 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
return this.cellItems; return this.cellItems;
} }
protected void updateItemCount( final long delta ) @Override
public void persist()
{ {
this.storedItemCount += delta; if( this.isPersisted )
this.tagCompound.setInteger( ITEM_COUNT_TAG, this.storedItemCount ); {
} return;
}
protected void saveChanges()
{
int itemCount = 0; int itemCount = 0;
// add new pretty stuff... // add new pretty stuff...
@@ -160,9 +150,8 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
final NBTTagCompound g = new NBTTagCompound(); final NBTTagCompound g = new NBTTagCompound();
v.writeToNBT( g ); v.writeToNBT( g );
this.tagCompound.setTag( itemSlots[x], g ); this.tagCompound.setTag( ITEM_SLOT_KEYS[x], g );
this.tagCompound.setInteger( ITEM_SLOT_COUNT_KEYS[x], (int) v.getStackSize() );
this.tagCompound.setInteger( itemSlotCount[x], (int) v.getStackSize() );
x++; x++;
} }
@@ -192,14 +181,33 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
// clean any old crusty stuff... // clean any old crusty stuff...
for( ; x < oldStoredItems && x < this.maxItemTypes; x++ ) for( ; x < oldStoredItems && x < this.maxItemTypes; x++ )
{ {
this.tagCompound.removeTag( itemSlots[x] ); this.tagCompound.removeTag( ITEM_SLOT_KEYS[x] );
this.tagCompound.removeTag( itemSlotCount[x] ); this.tagCompound.removeTag( ITEM_SLOT_COUNT_KEYS[x] );
} }
this.isPersisted = true;
}
protected void saveChanges()
{
// recalculate values
this.storedItems = (short) this.cellItems.size();
this.storedItemCount = 0;
for( final T v : this.cellItems )
{
this.storedItemCount += v.getStackSize();
}
this.isPersisted = false;
if( this.container != null ) if( this.container != null )
{ {
this.container.saveChanges( this ); this.container.saveChanges( this );
} }
else
{
// if there is no ISaveProvider, store to NBT immediately
this.persist();
}
} }
private void loadCellItems() private void loadCellItems()
@@ -215,8 +223,8 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
for( int slot = 0; slot < types; slot++ ) for( int slot = 0; slot < types; slot++ )
{ {
NBTTagCompound compoundTag = this.tagCompound.getCompoundTag( itemSlots[slot] ); NBTTagCompound compoundTag = this.tagCompound.getCompoundTag( ITEM_SLOT_KEYS[slot] );
int stackSize = this.tagCompound.getInteger( itemSlotCount[slot] ); int stackSize = this.tagCompound.getInteger( ITEM_SLOT_COUNT_KEYS[slot] );
this.loadCellItem( compoundTag, stackSize ); this.loadCellItem( compoundTag, stackSize );
} }
} }
@@ -25,6 +25,7 @@ import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
@@ -53,7 +54,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
} }
} }
public static IMEInventoryHandler getCell( final ItemStack o ) public static ICellInventoryHandler getCell( final ItemStack o )
{ {
return new ItemCellInventoryHandler( new CreativeCellInventory( o ) ); return new ItemCellInventoryHandler( new CreativeCellInventory( o ) );
} }
@@ -45,6 +45,11 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
this.cord = cod; this.cord = cod;
} }
public int getStatus()
{
return this.handler.getStatusForCell( this.is, this.getInternal() );
}
@Override @Override
public T injectItems( final T input, final Actionable type, final IActionSource src ) public T injectItems( final T input, final Actionable type, final IActionSource src )
{ {
@@ -54,7 +59,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
if( type == Actionable.MODULATE && ( a == null || a.getStackSize() != size ) ) if( type == Actionable.MODULATE && ( a == null || a.getStackSize() != size ) )
{ {
final int newStatus = this.handler.getStatusForCell( this.is, this.getInternal() ); final int newStatus = this.getStatus();
if( newStatus != this.oldStatus ) if( newStatus != this.oldStatus )
{ {
@@ -73,7 +78,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
if( type == Actionable.MODULATE && a != null ) if( type == Actionable.MODULATE && a != null )
{ {
final int newStatus = this.handler.getStatusForCell( this.is, this.getInternal() ); final int newStatus = this.getStatus();
if( newStatus != this.oldStatus ) if( newStatus != this.oldStatus )
{ {
@@ -28,8 +28,8 @@ import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException; import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IStorageCell; import appeng.api.implementations.items.IStorageCell;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
@@ -40,17 +40,12 @@ import appeng.core.AELog;
public class ItemCellInventory extends AbstractCellInventory<IAEItemStack> public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
{ {
protected ItemCellInventory( final NBTTagCompound data, final ISaveProvider container )
{
super( data, container, 8 );
}
private ItemCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException private ItemCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
{ {
super( o, container, 8 ); super( o, container, 8 );
} }
public static IMEInventoryHandler getCell( final ItemStack o, final ISaveProvider container2 ) public static ICellInventoryHandler<IAEItemStack> getCell( final ItemStack o, final ISaveProvider container2 )
{ {
try try
{ {
@@ -95,7 +90,7 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
final Item type = i.getItem(); final Item type = i.getItem();
if( type instanceof IStorageCell ) if( type instanceof IStorageCell )
{ {
if ( ( (IStorageCell) type ).getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) if( ( (IStorageCell) type ).getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{ {
return ( (IStorageCell) type ).isStorageCell( i ); return ( (IStorageCell) type ).isStorageCell( i );
} }
@@ -136,7 +131,7 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
if( l != null ) if( l != null )
{ {
final long remainingItemCount = this.getRemainingItemCount(); final long remainingItemCount = this.getRemainingItemCount();
if( remainingItemCount < 0 ) if( remainingItemCount <= 0 )
{ {
return input; return input;
} }
@@ -148,7 +143,6 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
l.setStackSize( l.getStackSize() + remainingItemCount ); l.setStackSize( l.getStackSize() + remainingItemCount );
this.updateItemCount( remainingItemCount );
this.saveChanges(); this.saveChanges();
} }
return r; return r;
@@ -158,7 +152,6 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
l.setStackSize( l.getStackSize() + input.getStackSize() ); l.setStackSize( l.getStackSize() + input.getStackSize() );
this.updateItemCount( input.getStackSize() );
this.saveChanges(); this.saveChanges();
} }
return null; return null;
@@ -180,8 +173,6 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
toWrite.setStackSize( remainingItemCount ); toWrite.setStackSize( remainingItemCount );
this.cellItems.add( toWrite ); this.cellItems.add( toWrite );
this.updateItemCount( toWrite.getStackSize() );
this.saveChanges(); this.saveChanges();
} }
return toReturn; return toReturn;
@@ -189,7 +180,6 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
this.updateItemCount( input.getStackSize() );
this.cellItems.add( input ); this.cellItems.add( input );
this.saveChanges(); this.saveChanges();
} }
@@ -223,7 +213,6 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
Results.setStackSize( l.getStackSize() ); Results.setStackSize( l.getStackSize() );
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
this.updateItemCount( -l.getStackSize() );
l.setStackSize( 0 ); l.setStackSize( 0 );
this.saveChanges(); this.saveChanges();
} }
@@ -234,7 +223,6 @@ public class ItemCellInventory extends AbstractCellInventory<IAEItemStack>
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
l.setStackSize( l.getStackSize() - size ); l.setStackSize( l.getStackSize() - size );
this.updateItemCount( -size );
this.saveChanges(); this.saveChanges();
} }
} }
@@ -818,11 +818,35 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
final SelectedPart p = this.selectPart( pos ); final SelectedPart p = this.selectPart( pos );
if( p != null && p.part != null ) if( p != null && p.part != null )
{ {
// forge sends activate even when sneaking in some cases (eg emtpy hand)
// if sneaking try shift activate first.
if( player.isSneaking() && p.part.onShiftActivate( player, hand, pos ) )
{
return true;
}
return p.part.onActivate( player, hand, pos ); return p.part.onActivate( player, hand, pos );
} }
return false; return false;
} }
@Override
public boolean clicked( EntityPlayer player, EnumHand hand, Vec3d hitVec )
{
final SelectedPart p = this.selectPart( hitVec );
if( p != null && p.part != null )
{
if( player.isSneaking() )
{
return p.part.onShiftClicked( player, hand, hitVec );
}
else
{
return p.part.onClicked( player, hand, hitVec );
}
}
return false;
}
@Override @Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor ) public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{ {
@@ -1223,6 +1247,8 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
continue; continue;
} }
renderState.getPartFlags().put( facing, part.getRenderFlag() );
// This will add the part's bounding boxes to the render state, which is required for facades // This will add the part's bounding boxes to the render state, which is required for facades
final AEPartLocation loc = AEPartLocation.fromFacing( facing ); final AEPartLocation loc = AEPartLocation.fromFacing( facing );
final IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true ); final IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true );
@@ -52,6 +52,8 @@ public interface ICableBusContainer
boolean activate( EntityPlayer player, EnumHand hand, Vec3d vecFromPool ); boolean activate( EntityPlayer player, EnumHand hand, Vec3d vecFromPool );
boolean clicked( EntityPlayer player, EnumHand hand, Vec3d hitVec );
void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor ); void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor );
boolean isSolidOnSide( EnumFacing side ); boolean isSolidOnSide( EnumFacing side );
@@ -124,4 +124,10 @@ public class NullCableBusContainer implements ICableBusContainer
return new CableBusRenderState(); return new CableBusRenderState();
} }
@Override
public boolean clicked( EntityPlayer player, EnumHand hand, Vec3d hitVec )
{
return false;
}
} }
@@ -196,7 +196,7 @@ public class PartPlacement
} }
} }
// if ( held == null ) if( held.isEmpty() )
{ {
final Block block = world.getBlockState( pos ).getBlock(); final Block block = world.getBlockState( pos ).getBlock();
if( host != null && player.isSneaking() && block != null ) if( host != null && player.isSneaking() && block != null )
@@ -261,8 +261,9 @@ public class PartPlacement
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent(); final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent();
final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_pos ); final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_pos );
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player, if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get()
world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) ) .placeBlockAt( maybeMultiPartStack.get(), player,
world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) )
{ {
if( !world.isRemote ) if( !world.isRemote )
{ {
@@ -15,6 +15,7 @@ import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper; import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost; import appeng.api.parts.IPartHost;
import appeng.api.storage.ICellContainer; import appeng.api.storage.ICellContainer;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
@@ -257,7 +258,7 @@ public abstract class PartAbstractFormationPlane<T extends IAEStack<T>> extends
} }
@Override @Override
public void saveChanges( final IMEInventory cell ) public void saveChanges( final ICellInventory<?> cell )
{ {
// nope! // nope!
} }
@@ -130,8 +130,10 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
try try
{ {
final InventoryAdaptor destination = this.getHandler(); final InventoryAdaptor destination = this.getHandler();
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory( final IMEMonitor<IAEItemStack> inv = this.getProxy()
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); .getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IEnergyGrid energy = this.getProxy().getEnergy(); final IEnergyGrid energy = this.getProxy().getEnergy();
final ICraftingGrid cg = this.getProxy().getCrafting(); final ICraftingGrid cg = this.getProxy().getCrafting();
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
@@ -215,18 +217,11 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -61,6 +61,7 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.parts.IPartItem; import appeng.api.parts.IPartItem;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
@@ -196,18 +197,11 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -93,8 +93,10 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
try try
{ {
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory( final IMEMonitor<IAEItemStack> inv = this.getProxy()
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); .getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IAEItemStack out = inv.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), final IAEItemStack out = inv.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ),
Actionable.SIMULATE, Actionable.SIMULATE,
@@ -128,18 +130,11 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -173,8 +168,10 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
{ {
this.itemsToSend = this.calculateItemsToSend(); this.itemsToSend = this.calculateItemsToSend();
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory( final IMEMonitor<IAEItemStack> inv = this.getProxy()
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); .getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IEnergyGrid energy = this.getProxy().getEnergy(); final IEnergyGrid energy = this.getProxy().getEnergy();
boolean Configured = false; boolean Configured = false;
@@ -465,18 +465,11 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_LEVEL_EMITTER ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_LEVEL_EMITTER );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -174,16 +174,10 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
@Override @Override
public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos )
{ {
if( p.isSneaking() )
{
return false;
}
if( Platform.isServer() ) if( Platform.isServer() )
{ {
Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_INTERFACE ); Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_INTERFACE );
} }
return true; return true;
} }
@@ -311,7 +305,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
{ {
return this.duality.getCapability( capabilityClass, this.getSide().getFacing() ); return this.duality.getCapability( capabilityClass, this.getSide().getFacing() );
} }
@Override @Override
public ItemStack getItemStackRepresentation() public ItemStack getItemStackRepresentation()
{ {
@@ -39,7 +39,7 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.parts.IPartCollisionHelper; import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.api.storage.ICellContainer; import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory; import appeng.api.storage.ICellInventory;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
@@ -126,7 +126,7 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
} }
@Override @Override
public void saveChanges( IMEInventory<?> cellInventory ) public void saveChanges( ICellInventory<?> cellInventory )
{ {
} }
@@ -58,6 +58,7 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost; import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.api.storage.ICellContainer; import appeng.api.storage.ICellContainer;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitorHandlerReceiver; import appeng.api.storage.IMEMonitorHandlerReceiver;
@@ -256,8 +257,10 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{ {
if( this.getProxy().isActive() ) if( this.getProxy().isActive() )
{ {
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, this.getProxy()
this.mySrc ); .getStorage()
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change,
this.mySrc );
} }
} }
catch( final GridAccessException e ) catch( final GridAccessException e )
@@ -298,18 +301,11 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS );
return true;
} }
return true;
return false;
} }
@Override @Override
@@ -604,7 +600,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
* } * }
*/ */
@Override @Override
public void saveChanges( final IMEInventory cellInventory ) public void saveChanges( final ICellInventory<?> cellInventory )
{ {
// nope! // nope!
} }
@@ -625,7 +621,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
return MODELS_OFF; return MODELS_OFF;
} }
} }
@Override @Override
public ItemStack getItemStackRepresentation() public ItemStack getItemStackRepresentation()
{ {
@@ -38,6 +38,7 @@ class P2PModels
public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_off" ); public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_off" );
public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_on" ); public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_on" );
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_has_channel" ); public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_has_channel" );
public static final ResourceLocation MODEL_FREQUENCY = new ResourceLocation( AppEng.MOD_ID, "part/builtin/p2p_tunnel_frequency" );
private final IPartModel modelsOff; private final IPartModel modelsOff;
private final IPartModel modelsOn; private final IPartModel modelsOn;
@@ -46,9 +47,10 @@ class P2PModels
public P2PModels( String frontModelPath ) public P2PModels( String frontModelPath )
{ {
ResourceLocation frontModel = new ResourceLocation( AppEng.MOD_ID, frontModelPath ); ResourceLocation frontModel = new ResourceLocation( AppEng.MOD_ID, frontModelPath );
this.modelsOff = new PartModel( MODEL_STATUS_OFF, frontModel );
this.modelsOn = new PartModel( MODEL_STATUS_ON, frontModel ); this.modelsOff = new PartModel( MODEL_STATUS_OFF, MODEL_FREQUENCY, frontModel );
this.modelsHasChannel = new PartModel( MODEL_STATUS_HAS_CHANNEL, frontModel ); this.modelsOn = new PartModel( MODEL_STATUS_ON, MODEL_FREQUENCY, frontModel );
this.modelsHasChannel = new PartModel( MODEL_STATUS_HAS_CHANNEL, MODEL_FREQUENCY, frontModel );
} }
public IPartModel getModel( boolean hasPower, boolean hasChannel ) public IPartModel getModel( boolean hasPower, boolean hasChannel )
@@ -19,10 +19,13 @@
package appeng.parts.p2p; package appeng.parts.p2p;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -42,6 +45,7 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartItem; import appeng.api.parts.IPartItem;
import appeng.api.parts.PartItemStack; import appeng.api.parts.PartItemStack;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
@@ -134,7 +138,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
{ {
super.readFromNBT( data ); super.readFromNBT( data );
this.setOutput( data.getBoolean( "output" ) ); this.setOutput( data.getBoolean( "output" ) );
this.setFrequency( data.getShort( "freq" ) ); this.freq = data.getShort( "freq" );
} }
@Override @Override
@@ -145,6 +149,22 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
data.setShort( "freq", this.getFrequency() ); data.setShort( "freq", this.getFrequency() );
} }
@Override
public boolean readFromStream( ByteBuf data ) throws IOException
{
final boolean c = super.readFromStream( data );
final short oldf = this.freq;
this.freq = data.readShort();
return c || oldf != this.freq;
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
data.writeShort( getFrequency() );
}
@Override @Override
public float getCableConnectionLength( AECableType cable ) public float getCableConnectionLength( AECableType cable )
{ {
@@ -160,6 +180,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
@Override @Override
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{ {
if( Platform.isClient() )
{
return true;
}
if( hand == EnumHand.OFF_HAND ) if( hand == EnumHand.OFF_HAND )
{ {
return false; return false;
@@ -305,6 +330,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final ItemStack is = player.inventory.getCurrentItem(); final ItemStack is = player.inventory.getCurrentItem();
if( !is.isEmpty() && is.getItem() instanceof IMemoryCard ) if( !is.isEmpty() && is.getItem() instanceof IMemoryCard )
{ {
if( Platform.isClient() )
{
return true;
}
final IMemoryCard mc = (IMemoryCard) is.getItem(); final IMemoryCard mc = (IMemoryCard) is.getItem();
final NBTTagCompound data = new NBTTagCompound(); final NBTTagCompound data = new NBTTagCompound();
@@ -334,6 +364,14 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
p2pItem.writeToNBT( data ); p2pItem.writeToNBT( data );
data.setShort( "freq", this.getFrequency() ); data.setShort( "freq", this.getFrequency() );
final AEColor[] colors = Platform.p2p().toColors( this.getFrequency() );
final int[] colorCode = new int[] {
colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), colors[1].ordinal(),
colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(),
};
data.setIntArray( "colorCode", colorCode );
mc.setMemoryCardContents( is, type + ".name", data ); mc.setMemoryCardContents( is, type + ".name", data );
mc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); mc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
return true; return true;
@@ -371,7 +409,12 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
public void setFrequency( final short freq ) public void setFrequency( final short freq )
{ {
final short oldf = this.freq;
this.freq = freq; this.freq = freq;
if( oldf != this.freq )
{
this.getHost().markForUpdate();
}
} }
public boolean isOutput() public boolean isOutput()
@@ -383,4 +426,17 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
{ {
this.output = output; this.output = output;
} }
@Override
public Long getRenderFlag()
{
long ret = Short.toUnsignedLong( this.getFrequency() );
if( this.isActive() && this.isPowered() )
{
ret |= 0x10000L;
}
return ret;
}
} }
@@ -27,7 +27,6 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@@ -163,24 +162,46 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
return false; return false;
} }
final TileEntity te = this.getTile(); if( !this.isLocked )
final ItemStack eq = player.getHeldItem( hand );
if( Platform.isWrench( player, eq, te.getPos() ) )
{
this.isLocked = !this.isLocked;
player.sendMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForUpdate();
}
else if( !this.isLocked )
{ {
final ItemStack eq = player.getHeldItem( hand );
this.configuredItem = AEItemStack.fromItemStack( eq ); this.configuredItem = AEItemStack.fromItemStack( eq );
this.configureWatchers(); this.configureWatchers();
this.getHost().markForSave();
this.getHost().markForUpdate(); this.getHost().markForUpdate();
} }
else else
{ {
this.extractItem( player ); return super.onPartActivate( player, hand, pos );
}
return true;
}
@Override
public boolean onPartShiftActivate( EntityPlayer player, EnumHand hand, Vec3d pos )
{
if( Platform.isClient() )
{
return true;
}
if( !this.getProxy().isActive() )
{
return false;
}
if( !Platform.hasPermissions( this.getLocation(), player ) )
{
return false;
}
if( player.getHeldItem( hand ).isEmpty() )
{
this.isLocked = !this.isLocked;
player.sendMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForSave();
this.getHost().markForUpdate();
} }
return true; return true;
@@ -213,11 +234,6 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
} }
} }
protected void extractItem( final EntityPlayer player )
{
}
private void updateReportingValue( final IMEMonitor<IAEItemStack> itemInventory ) private void updateReportingValue( final IMEMonitor<IAEItemStack> itemInventory )
{ {
if( this.configuredItem != null ) if( this.configuredItem != null )
@@ -271,7 +287,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
} }
@Override @Override
public IAEStack<?> getDisplayed() public IAEItemStack getDisplayed()
{ {
return this.configuredItem; return this.configuredItem;
} }
@@ -199,7 +199,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
{ {
final TileEntity te = this.getTile(); final TileEntity te = this.getTile();
if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) ) if( Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) )
{ {
if( Platform.isServer() ) if( Platform.isServer() )
{ {
@@ -115,19 +115,12 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement
{ {
if( !super.onPartActivate( player, hand, pos ) ) if( !super.onPartActivate( player, hand, pos ) )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) );
return true;
} }
} }
return false; return true;
} }
public GuiBridge getGui( final EntityPlayer player ) public GuiBridge getGui( final EntityPlayer player )
@@ -28,6 +28,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource; import appeng.api.networking.energy.IEnergySource;
@@ -72,7 +74,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
} }
@Override @Override
public boolean onPartShiftActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) public boolean onPartActivate( EntityPlayer player, EnumHand hand, Vec3d pos )
{ {
if( Platform.isClient() ) if( Platform.isClient() )
{ {
@@ -89,62 +91,133 @@ public class PartConversionMonitor extends AbstractPartMonitor
return false; return false;
} }
boolean ModeB = false; final ItemStack eq = player.getHeldItem( hand );
if( this.isLocked() )
ItemStack item = player.getHeldItem( hand );
if( item.isEmpty() && this.getDisplayed() != null )
{ {
ModeB = true; if( eq.isEmpty() )
item = ( (IAEItemStack) this.getDisplayed() ).createItemStack();
}
if( !item.isEmpty() )
{
try
{ {
if( !this.getProxy().isActive() ) this.insertItem( player, hand, true );
{
return false;
}
final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IAEItemStack input = AEItemStack.fromItemStack( item );
if( ModeB )
{
for( int x = 0; x < player.inventory.getSizeInventory(); x++ )
{
final ItemStack targetStack = player.inventory.getStackInSlot( x );
if( input.equals( targetStack ) )
{
final IAEItemStack insertItem = input.copy();
insertItem.setStackSize( targetStack.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
player.inventory.setInventorySlotContents( x, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
}
}
}
else
{
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
player.inventory.setInventorySlotContents( player.inventory.currentItem,
failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
}
} }
catch( final GridAccessException e ) else if( Platform.isWrench( player, eq, this.getLocation().getPos() ) && ( this.getDisplayed() == null || !this.getDisplayed().equals( eq ) ) )
{ {
// :P // wrench it
return super.onPartActivate( player, hand, pos );
}
else
{
this.insertItem( player, hand, false );
} }
} }
else if( this.getDisplayed() != null && this.getDisplayed().equals( eq ) )
{
this.insertItem( player, hand, false );
}
else
{
return super.onPartActivate( player, hand, pos );
}
return true; return true;
} }
@Override @Override
protected void extractItem( final EntityPlayer player ) public boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
{ {
final IAEItemStack input = (IAEItemStack) this.getDisplayed(); if( Platform.isClient() )
{
return true;
}
if( !this.getProxy().isActive() )
{
return false;
}
if( !Platform.hasPermissions( this.getLocation(), player ) )
{
return false;
}
if( this.getDisplayed() != null )
{
this.extractItem( player, this.getDisplayed().getDefinition().getMaxStackSize() );
}
return true;
}
@Override
public boolean onShiftClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
{
if( Platform.isClient() )
{
return true;
}
if( !this.getProxy().isActive() )
{
return false;
}
if( !Platform.hasPermissions( this.getLocation(), player ) )
{
return false;
}
if( this.getDisplayed() != null )
{
this.extractItem( player, 1 );
}
return true;
}
private void insertItem( final EntityPlayer player, final EnumHand hand, final boolean allItems )
{
try
{
final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy()
.getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( allItems )
{
final IAEItemStack input = this.getDisplayed().copy();
IItemHandler inv = new PlayerMainInvWrapper( player.inventory );
for( int x = 0; x < inv.getSlots(); x++ )
{
final ItemStack targetStack = inv.getStackInSlot( x );
if( input.equals( targetStack ) )
{
final ItemStack canExtract = inv.extractItem( x, targetStack.getCount(), true );
if( !canExtract.isEmpty() )
{
input.setStackSize( canExtract.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
inv.extractItem( x, failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(),
false );
}
}
}
}
else
{
final IAEItemStack input = AEItemStack.fromItemStack( player.getHeldItem( hand ) );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
player.setHeldItem( hand, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
}
}
catch( final GridAccessException e )
{
// :P
}
}
private void extractItem( final EntityPlayer player, int count )
{
final IAEItemStack input = this.getDisplayed();
if( input != null ) if( input != null )
{ {
try try
@@ -155,11 +228,12 @@ public class PartConversionMonitor extends AbstractPartMonitor
} }
final IEnergySource energy = this.getProxy().getEnergy(); final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getInventory( final IMEMonitor<IAEItemStack> cell = this.getProxy()
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); .getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final ItemStack is = input.createItemStack(); input.setStackSize( count );
input.setStackSize( is.getMaxStackSize() );
final IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) ); final IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
if( retrieved != null ) if( retrieved != null )
@@ -55,20 +55,12 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
{ {
if( !super.onPartActivate( player, hand, pos ) ) if( !super.onPartActivate( player, hand, pos ) )
{ {
if( !player.isSneaking() ) if( Platform.isServer() )
{ {
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_INTERFACE_TERMINAL ); Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_INTERFACE_TERMINAL );
return true;
} }
} }
return true;
return false;
} }
@Override @Override
+18 -1
View File
@@ -52,6 +52,7 @@ import appeng.core.AELog;
import appeng.core.features.IStackSrc; import appeng.core.features.IStackSrc;
import appeng.helpers.ICustomNameObject; import appeng.helpers.ICustomNameObject;
import appeng.helpers.IPriorityHost; import appeng.helpers.IPriorityHost;
import appeng.hooks.TickHandler;
import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.SettingsFrom; import appeng.util.SettingsFrom;
@@ -68,6 +69,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
private EnumFacing forward = null; private EnumFacing forward = null;
private EnumFacing up = null; private EnumFacing up = null;
private IBlockState state; private IBlockState state;
private boolean markDirtyQueued = false;
@Override @Override
public boolean shouldRefresh( final World world, final BlockPos pos, final IBlockState oldState, final IBlockState newSate ) public boolean shouldRefresh( final World world, final BlockPos pos, final IBlockState oldState, final IBlockState newSate )
@@ -488,7 +490,22 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
public void saveChanges() public void saveChanges()
{ {
markDirty(); if( this.world != null )
{
this.world.markChunkDirty( this.pos, this );
if( !this.markDirtyQueued )
{
TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
this.markDirtyQueued = true;
}
}
}
private Object markDirtyAtEndOfTick( final World w )
{
this.markDirty();
this.markDirtyQueued = false;
return null;
} }
public boolean requiresTESR() public boolean requiresTESR()
@@ -159,7 +159,7 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
} }
this.paintedColor = newPaintedColor; this.paintedColor = newPaintedColor;
this.markDirty(); this.saveChanges();
this.markForUpdate(); this.markForUpdate();
return true; return true;
} }
@@ -133,7 +133,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
} }
this.updateSleepiness(); this.updateSleepiness();
this.markDirty(); this.saveChanges();
return true; return true;
} }
} }
@@ -398,7 +398,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
// did it eject? // did it eject?
if( this.gridInv.getStackInSlot( 9 ).isEmpty() ) if( this.gridInv.getStackInSlot( 9 ).isEmpty() )
{ {
this.markDirty(); this.saveChanges();
} }
this.ejectHeldItems(); this.ejectHeldItems();
@@ -487,7 +487,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
// ;P // ;P
} }
this.markDirty(); this.saveChanges();
this.updateSleepiness(); this.updateSleepiness();
return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP; return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP;
} }
@@ -509,7 +509,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
{ {
this.gridInv.setStackInSlot( 9, is ); this.gridInv.setStackInSlot( 9, is );
this.gridInv.setStackInSlot( x, ItemStack.EMPTY ); this.gridInv.setStackInSlot( x, ItemStack.EMPTY );
this.markDirty(); this.saveChanges();
return; return;
} }
} }
@@ -580,7 +580,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
if( size != newSize ) if( size != newSize )
{ {
this.markDirty(); this.saveChanges();
} }
return output; return output;
@@ -0,0 +1,119 @@
package appeng.tile.inventory;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellInventoryHandler;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.IInternalItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
public class AppEngCellInventory implements IInternalItemHandler
{
private final AppEngInternalInventory inv;
private final ICellInventoryHandler handlerForSlot[];
public AppEngCellInventory( final IAEAppEngInventory host, final int slots )
{
this.inv = new AppEngInternalInventory( host, slots, 1 );
this.handlerForSlot = new ICellInventoryHandler[slots];
}
public void setHandler( final int slot, final ICellInventoryHandler handler )
{
this.handlerForSlot[slot] = handler;
}
public void setFilter( IAEItemFilter filter )
{
this.inv.setFilter( filter );
}
@Override
public void setStackInSlot( int slot, ItemStack stack )
{
this.persist( slot );
this.inv.setStackInSlot( slot, stack );
this.cleanup( slot );
}
@Override
public int getSlots()
{
return this.inv.getSlots();
}
@Override
public ItemStack getStackInSlot( int slot )
{
this.persist( slot );
return this.inv.getStackInSlot( slot );
}
@Override
public ItemStack insertItem( int slot, ItemStack stack, boolean simulate )
{
this.persist( slot );
final ItemStack ret = inv.insertItem( slot, stack, simulate );
this.cleanup( slot );
return ret;
}
@Override
public ItemStack extractItem( int slot, int amount, boolean simulate )
{
this.persist( slot );
final ItemStack ret = inv.extractItem( slot, amount, simulate );
this.cleanup( slot );
return ret;
}
@Override
public int getSlotLimit( int slot )
{
return inv.getSlotLimit( slot );
}
@Override
public boolean isItemValidForSlot( int slot, ItemStack stack )
{
return inv.isItemValidForSlot( slot, stack );
}
@Override
public void markDirty( int slot )
{
this.persist( slot );
this.inv.markDirty( slot );
this.cleanup( slot );
}
public void persist()
{
for( int i = 0; i < this.getSlots(); ++i )
{
this.persist( i );
}
}
private void persist( int slot )
{
if( this.handlerForSlot[slot] != null )
{
this.handlerForSlot[slot].getCellInv().persist();
}
}
private void cleanup( int slot )
{
if( this.handlerForSlot[slot] != null )
{
if( this.handlerForSlot[slot].getCellInv().getItemStack() != this.inv.getStackInSlot( slot ) )
{
this.handlerForSlot[slot] = null;
}
}
}
}
@@ -185,7 +185,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
this.config.setStackInSlot( x, ItemStack.EMPTY ); this.config.setStackInSlot( x, ItemStack.EMPTY );
} }
this.markDirty(); this.saveChanges();
} }
this.locked = false; this.locked = false;
@@ -98,6 +98,8 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
private final IItemHandler bottomItemHandlerExtern; private final IItemHandler bottomItemHandlerExtern;
private final IItemHandler sideItemHandlerExtern; private final IItemHandler sideItemHandlerExtern;
private IInscriberRecipe cachedTask = null;
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler ); private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler );
public TileInscriber() public TileInscriber()
@@ -172,6 +174,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
this.inv.setStackInSlot( num, ItemStack.EMPTY ); this.inv.setStackInSlot( num, ItemStack.EMPTY );
} }
} }
this.cachedTask = null;
return c; return c;
} }
@@ -251,6 +254,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
this.markForUpdate(); this.markForUpdate();
} }
this.cachedTask = null;
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
} }
catch( final GridAccessException e ) catch( final GridAccessException e )
@@ -281,7 +285,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@Nullable @Nullable
public IInscriberRecipe getTask() public IInscriberRecipe getTask()
{ {
return this.getTask( this.sideItemHandler.getStackInSlot( 0 ), this.topItemHandler.getStackInSlot( 0 ), this.bottomItemHandler.getStackInSlot( 0 ) ); if( this.cachedTask == null )
{
this.cachedTask = this.getTask( this.sideItemHandler.getStackInSlot( 0 ), this.topItemHandler.getStackInSlot( 0 ),
this.bottomItemHandler.getStackInSlot( 0 ) );
}
return this.cachedTask;
} }
@Nullable @Nullable
@@ -318,15 +327,19 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() ) for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{ {
final boolean matchA = ( plateA.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, final boolean matchA = ( plateA.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons()
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and... .isSameItem( plateA,
( ( plateB.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) ); ( ( plateB.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons()
.isSameItem( plateB,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
final boolean matchB = ( plateB.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, final boolean matchB = ( plateB.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons()
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and... .isSameItem( plateB,
( ( plateA.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) ); ( ( plateA.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons()
.isSameItem( plateA,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
if( matchA || matchB ) if( matchA || matchB )
{ {
@@ -367,8 +380,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
this.sideItemHandler.setStackInSlot( 0, ItemStack.EMPTY ); this.sideItemHandler.setStackInSlot( 0, ItemStack.EMPTY );
} }
} }
this.saveChanges();
this.markDirty();
} }
else if( this.finalStep == 16 ) else if( this.finalStep == 16 )
{ {
@@ -130,7 +130,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
this.configureNodeSides(); this.configureNodeSides();
this.markForUpdate(); this.markForUpdate();
this.markDirty(); this.saveChanges();
} }
private void configureNodeSides() private void configureNodeSides()
@@ -145,12 +145,6 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
} }
} }
@Override
public void markDirty()
{
this.duality.markDirty();
}
@Override @Override
public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops ) public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
{ {
@@ -191,7 +191,7 @@ public class TilePaint extends AEBaseTile
} }
this.markForUpdate(); this.markForUpdate();
this.markDirty(); this.saveChanges();
} }
private void updateData() private void updateData()
@@ -265,7 +265,7 @@ public class TilePaint extends AEBaseTile
this.maxLit(); this.maxLit();
this.markForUpdate(); this.markForUpdate();
this.markDirty(); this.saveChanges();
} }
} }
@@ -363,7 +363,7 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
} }
this.paintedColor = newPaintedColor; this.paintedColor = newPaintedColor;
this.markDirty(); this.saveChanges();
this.markForUpdate(); this.markForUpdate();
return true; return true;
} }
@@ -261,7 +261,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
this.inv.setStackInSlot( 0, is ); this.inv.setStackInSlot( 0, is );
} }
this.markDirty(); this.saveChanges();
} }
} }
@@ -312,7 +312,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override @Override
public void markForSave() public void markForSave()
{ {
super.markDirty(); this.saveChanges();
} }
@Override @Override
@@ -163,9 +163,10 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
} }
@Override @Override
public void markDirty() public void saveChanges()
{ {
this.updatePower(); this.updatePower();
super.saveChanges();
} }
@Override @Override
@@ -69,6 +69,8 @@ import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.storage.IBaseMonitor; import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid; import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitor;
@@ -121,7 +123,6 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
private boolean wasActive = false; private boolean wasActive = false;
private AEColor paintedColor = AEColor.TRANSPARENT; private AEColor paintedColor = AEColor.TRANSPARENT;
private boolean isCached = false; private boolean isCached = false;
private ICellHandler cellHandler;
private MEMonitorHandler<IAEItemStack> itemCell; private MEMonitorHandler<IAEItemStack> itemCell;
private MEMonitorHandler<IAEFluidStack> fluidCell; private MEMonitorHandler<IAEFluidStack> fluidCell;
private Accessor accessor; private Accessor accessor;
@@ -226,23 +227,23 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
if( !is.isEmpty() ) if( !is.isEmpty() )
{ {
this.isCached = true; this.isCached = true;
this.cellHandler = AEApi.instance().registries().cell().getHandler( is ); ICellHandler cellHandler = AEApi.instance().registries().cell().getHandler( is );
if( this.cellHandler != null ) if( cellHandler != null )
{ {
double power = 1.0; double power = 1.0;
final IMEInventoryHandler<IAEItemStack> itemCell = this.cellHandler.getCellInventory( is, this, final ICellInventoryHandler<IAEItemStack> itemCell = cellHandler.getCellInventory( is, this,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventoryHandler<IAEFluidStack> fluidCell = this.cellHandler.getCellInventory( is, this, final ICellInventoryHandler<IAEFluidStack> fluidCell = cellHandler.getCellInventory( is, this,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( itemCell != null ) if( itemCell != null )
{ {
power += this.cellHandler.cellIdleDrain( is, itemCell ); power += cellHandler.cellIdleDrain( is, itemCell );
} }
else if( fluidCell != null ) else if( fluidCell != null )
{ {
power += this.cellHandler.cellIdleDrain( is, fluidCell ); power += cellHandler.cellIdleDrain( is, fluidCell );
} }
this.getProxy().setIdlePowerUsage( power ); this.getProxy().setIdlePowerUsage( power );
@@ -766,15 +767,16 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
} }
this.paintedColor = newPaintedColor; this.paintedColor = newPaintedColor;
this.markDirty(); this.saveChanges();
this.markForUpdate(); this.markForUpdate();
return true; return true;
} }
@Override @Override
public void saveChanges( final IMEInventory cellInventory ) public void saveChanges( final ICellInventory<?> cellInventory )
{ {
this.markDirty(); cellInventory.persist();
this.world.markChunkDirty( this.pos, this );
} }
private static class ChestNoHandler extends Exception private static class ChestNoHandler extends Exception
@@ -43,7 +43,8 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid; import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventory; import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
@@ -56,9 +57,8 @@ import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource; import appeng.me.helpers.MachineSource;
import appeng.me.storage.DriveWatcher; import appeng.me.storage.DriveWatcher;
import appeng.me.storage.MEInventoryHandler;
import appeng.tile.grid.AENetworkInvTile; import appeng.tile.grid.AENetworkInvTile;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngCellInventory;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.IAEItemFilter; import appeng.util.inv.filter.IAEItemFilter;
@@ -71,7 +71,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
private static final int BIT_BLINK_MASK = 0x24924924; private static final int BIT_BLINK_MASK = 0x24924924;
private static final int BIT_STATE_MASK = 0xDB6DB6DB; private static final int BIT_STATE_MASK = 0xDB6DB6DB;
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 10, 1 ); private final AppEngCellInventory inv = new AppEngCellInventory( this, 10 );
private final ICellHandler[] handlersBySlot = new ICellHandler[10]; private final ICellHandler[] handlersBySlot = new ICellHandler[10];
private final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10]; private final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
private final IActionSource mySrc; private final IActionSource mySrc;
@@ -145,21 +145,13 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
return ( this.state >> ( slot * 3 ) ) & 3; return ( this.state >> ( slot * 3 ) ) & 3;
} }
final ItemStack cell = this.inv.getStackInSlot( 2 ); final DriveWatcher handler = this.invBySlot[slot];
final ICellHandler ch = this.handlersBySlot[slot];
final MEInventoryHandler handler = this.invBySlot[slot];
if( handler == null ) if( handler == null )
{ {
return 0; return 0;
} }
if( ch != null ) return handler.getStatus();
{
return ch.getStatusForCell( cell, handler.getInternal() );
}
return 0;
} }
@Override @Override
@@ -307,10 +299,11 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
for( IStorageChannel<? extends IAEStack<?>> channel : storageChannels ) for( IStorageChannel<? extends IAEStack<?>> channel : storageChannels )
{ {
IMEInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, channel ); ICellInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, channel );
if( cell != null ) if( cell != null )
{ {
this.inv.setHandler( x, cell );
power += this.handlersBySlot[x].cellIdleDrain( is, cell ); power += this.handlersBySlot[x].cellIdleDrain( is, cell );
final DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, this.handlersBySlot[x], this ); final DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, this.handlersBySlot[x], this );
@@ -360,7 +353,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
public void setPriority( final int newValue ) public void setPriority( final int newValue )
{ {
this.priority = newValue; this.priority = newValue;
this.markDirty(); this.saveChanges();
this.isCached = false; // recalculate the storage cell. this.isCached = false; // recalculate the storage cell.
this.updateState(); this.updateState();
@@ -384,7 +377,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
} }
@Override @Override
public void saveChanges( final IMEInventory cellInventory ) public void saveChanges( final ICellInventory<?> cellInventory )
{ {
this.world.markChunkDirty( this.pos, this ); this.world.markChunkDirty( this.pos, this );
} }
+3 -3
View File
@@ -87,7 +87,7 @@ public class ItemSorters
return CONFIG_BASED_SORT_BY_NAME.compare( o1, o2 ); return CONFIG_BASED_SORT_BY_NAME.compare( o1, o2 );
} }
final int cmp = api.compareItems( o1.asItemStackRepresentation(), o2.asItemStackRepresentation() ); final int cmp = api.compareItems( o1.createItemStack(), o2.createItemStack() );
return applyDirection( cmp ); return applyDirection( cmp );
} }
}; };
@@ -120,8 +120,8 @@ public class ItemSorters
} }
private static int applyDirection( int cmp ) private static int applyDirection( int cmp )
{ {
if ( getDirection() == SortDir.ASCENDING ) if( getDirection() == SortDir.ASCENDING )
{ {
return cmp; return cmp;
} }

Some files were not shown because too many files have changed in this diff Show More