Compare commits

...

14 Commits

Author SHA1 Message Date
yueh a14cf2204d Fixes anchor rendering (#2698)
* Fixes #2680: Use a shorter cable anchor model when blocked by a facade.
* Fixes #2664: Prevent anchors from creating intersection.

Replaced the simple List<ResourceLocation> for the static models with a
new container also indicating a solid part, which can be used to prevent
the creation of an intersection.
2016-12-14 22:37:10 +01:00
yueh 8bed7f223e TheOneProbe integration (#2696)
Displayed information is equal to current the WAILA integration.

Added a preInit stage to IIntegrationModule.
Added a factory method to IntegrationType to avoid touching
IntegrationNode for every new integration.

Fixes #2650
2016-12-14 22:36:40 +01:00
yueh db85419702 Restructured registry packages (#2703)
Moved larger registries together with their related classes instead of putting unrelated classes into the same package.
2016-12-14 22:35:52 +01:00
yueh fb79fd284d Replaced Watcher using Collection with a more fitting interface (#2693)
Replaced the watchers for energy, storage and crafting with a more fitting interface compared to a common collection.

Fixes #229
2016-12-14 18:30:49 +01:00
yueh e3305c1963 Update Forge to latest RB
Updated JEI
2016-12-14 17:46:16 +01:00
yueh a3c85b4a59 Fixes #2699: Do not trust the stackSize in case of internal changes.
An external inventory might change the stacksize of the slot we currently
are extracting from. Thus we have to cache the initial stackSize for a later
calculation of the extracted amount per slot.
As other inventories might NOT change the stacksize after a modification,
we can not use the stack reaching 0 as conditions to break.
2016-12-14 11:25:49 +01:00
yueh a2b20f1d67 Fixes #2689: Do not pass our own blockstate to the adjacent block. 2016-12-08 21:29:46 +01:00
yueh 86908b1ae6 Fixes #2647: Prevent crafting status from crashing due to missing network. 2016-12-08 13:07:25 +01:00
dshadowwolf 6bf52b0b0f Fixes constant reequip animation on portable cells/terminals (#2690)
Fix for portable cell and wireless terminal going into re-equip animations when GUI is open.
2016-12-08 12:34:41 +01:00
yueh eb1e86cacb Refactored GrinderRegistry. (#2644)
* Refactored GrinderRegistry.

Changed IGrinderRegistry#getRecipes to return an unmodifiable collection.
Added a way to remove recipes explicitly instead the internal list.
Added a cache to lookup recipes instead of iterating a list.

Renamed IGrinderEntry to IGrinderRecipe
Made IGrindRecipe immutable for easy caching.

Improved GrinderLogging and Exception Handling
JEI Workaround as it expects a List instead Collection.

* Added blacklist of explicit oredict names for the grindstone.

This can be used should the automatic recipe generation create unintended
loopholes.
2016-12-02 23:47:50 +01:00
yueh c405e725b2 Fixes #2667: Use new IC2 item names for P2P attunement. 2016-12-02 22:16:29 +01:00
yueh d377af9a69 Fixes #2675: Set fullBlock correctly afterwards.
Reduces the visibility of some methods as these should be access through the public methods of Block or the overridden ones.
Removes now useless getCheckedSubBlocks.
2016-12-02 22:15:56 +01:00
yueh 12dbd17320 Fixes #2666: Restore inventory after powerloss and still avoid dupes. 2016-12-01 16:17:46 +01:00
yueh 5028c8025b Fixes #2669: Missing particle texture for pylons. 2016-12-01 10:56:01 +01:00
140 changed files with 2746 additions and 1505 deletions
+3 -2
View File
@@ -9,7 +9,7 @@ aebasename=appliedenergistics2
#########################################################
minecraft_version=1.10.2
mcp_mappings=snapshot_20161111
forge_version=12.18.2.2139
forge_version=12.18.3.2185
#########################################################
# Installable #
@@ -19,6 +19,7 @@ waila_version=1.7.0-B3_1.9.4
#########################################################
# Provided APIs #
#########################################################
jei_version=3.13.3.373
jei_version=3.13.6.391
tesla_version=1.10.2-1.2.1.50
ic2_version=2.6.99-ex110
top_version=1.10-1.3.3-41
+7
View File
@@ -38,6 +38,11 @@ repositories {
name = "IC2 repo"
url = "http://maven.ic2.player.to"
}
maven { // TheOneProbe
name 'tterrag maven'
url "http://maven.tterrag.com/"
}
}
configurations {
@@ -48,12 +53,14 @@ dependencies {
// installable runtime dependencies
mods "mcp.mobius.waila:Waila:${waila_version}"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
mods "mcjty.theoneprobe:TheOneProbe:${top_version}"
// compile against provided APIs
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
compileOnly "mcp.mobius.waila:Waila:${waila_version}"
compileOnly "net.darkhax.tesla:Tesla:${tesla_version}"
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
compileOnly "mcjty.theoneprobe:TheOneProbe:${top_version}:api"
// at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
+13 -1
View File
@@ -31,7 +31,7 @@ task deinstallWaila(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*Waila*.jar")
}
// IC²
// IC2
task installIC2(type: Copy, dependsOn: "deinstallIC2") {
from { configurations.mods }
include "**/*industrialcraft-2*.jar"
@@ -41,3 +41,15 @@ task installIC2(type: Copy, dependsOn: "deinstallIC2") {
task deinstallIC2(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*industrialcraft-2*.jar")
}
// TOP
task installTop(type: Copy, dependsOn: "deinstallTop") {
from { configurations.mods }
include "**/*TheOneProbe*.jar"
into file(minecraft.runDir + "/mods")
}
task deinstallTop(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*TheOneProbe*.jar")
}
@@ -24,13 +24,17 @@
package appeng.api.features;
import java.util.Optional;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
/**
* Registration Records for {@link IGrinderRegistry}
*/
public interface IGrinderEntry
public interface IGrinderRecipe
{
/**
@@ -38,66 +42,40 @@ public interface IGrinderEntry
*
* @return input that the grinder will accept.
*/
@Nonnull
ItemStack getInput();
/**
* lets you change the grinder recipe by changing its input.
*
* @param input input item
*/
void setInput( ItemStack input );
/**
* gets the current output
*
* @return output that the grinder will produce
*/
@Nonnull
ItemStack getOutput();
/**
* allows you to change the output.
* gets the current output
*
* @param output output item
* @return output that the grinder will produce
*/
void setOutput( ItemStack output );
@Nonnull
Optional<ItemStack> getOptionalOutput();
/**
* gets the current output
*
* @return output that the grinder will produce
*/
ItemStack getOptionalOutput();
/**
* gets the current output
*
* @return output that the grinder will produce
*/
ItemStack getSecondOptionalOutput();
/**
* stack, and 0.0-1.0 chance that it will be generated.
*
* @param output output item
* @param chance generation chance
*/
void setOptionalOutput( ItemStack output, float chance );
Optional<ItemStack> getSecondOptionalOutput();
/**
* 0.0 - 1.0 the chance that the optional output will be generated.
*
* @return chance of optional output
*/
@Nonnull
float getOptionalChance();
/**
* stack, and 0.0-1.0 chance that it will be generated.
*
* @param output second optional output item
* @param chance second optional output chance
*/
void setSecondOptionalOutput( ItemStack output, float chance );
/**
* 0.0 - 1.0 the chance that the optional output will be generated.
*
@@ -106,16 +84,10 @@ public interface IGrinderEntry
float getSecondOptionalChance();
/**
* Energy cost, in turns.
* Amount of turns required to process the item.
*
* @return number of turns it takes to produce the output from the input.
*/
int getEnergyCost();
int getRequiredTurns();
/**
* Allows you to adjust the number of turns
*
* @param c number of turns to produce output.
*/
void setEnergyCost( int c );
}
@@ -24,7 +24,10 @@
package appeng.api.features;
import java.util.List;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
@@ -36,51 +39,90 @@ public interface IGrinderRegistry
{
/**
* Current list of registered recipes, you can modify this if you want too.
* An immutable list of the currently registered recipes.
*
* @return currentlyRegisteredRecipes
*/
List<IGrinderEntry> getRecipes();
@Nonnull
Collection<IGrinderRecipe> getRecipes();
/**
* add a new recipe the easy way, in &#8594; out, how many turns., duplicates will not be added.
* Add a new recipe with a single input and output and how many turns it requires.
*
* Will ignore duplicate recipes with the same input item.
*
* @param in input
* @param out output
* @param turns amount of turns to turn the input into the output
* @param in The {@link ItemStack} to grind.
* @param out The {@link ItemStack} to output.
* @param turns Amount of turns to turn the input into the output, with turns > 0.
*/
void addRecipe( ItemStack in, ItemStack out, int turns );
void addRecipe( @Nonnull ItemStack in, @Nonnull ItemStack out, int turns );
/**
* Add a new recipe with an input, output and a single optional output.
*
* Will ignore duplicate recipes with the same input item.
*
* @param in The {@link ItemStack} to grind.
* @param out The {@link ItemStack} to output.
* @param optional The optional {@link ItemStack} to output of a certain chance.
* @param chance Chance to get the optional output within 0.0 - 1.0
* @param turns Amount of turns to turn the input into the output, with turns > 0.
*/
void addRecipe( @Nonnull ItemStack in, @Nonnull ItemStack out, @Nonnull ItemStack optional, float chance, int turns );
/**
* add a new recipe with optional outputs, duplicates will not be added.
*
* Will ignore duplicate recipes with the same input item.
*
* @param in input
* @param out output
* @param optional optional output
* @param chance chance to get the optional output within 0.0 - 1.0
* @param turns amount of turns to turn the input into the outputs
*/
void addRecipe( ItemStack in, ItemStack out, ItemStack optional, float chance, int turns );
/**
* add a new recipe with optional outputs, duplicates will not be added.
*
* @param in input
* @param out output
* @param optional optional output
* @param chance chance to get the optional output within 0.0 - 1.0
* @param optional2 second optional output
* @param in The {@link ItemStack} to grind.
* @param out The {@link ItemStack} to output.
* @param optional The first optional {@link ItemStack} to output of a certain chance.
* @param chance Chance to get the first optional output within 0.0 - 1.0
* @param optional2 The second optional {@link ItemStack} to output of a certain chance.
* @param chance2 chance to get the second optional output within 0.0 - 1.0
* @param turns amount of turns to turn the input into the outputs
* @param turns Amount of turns to turn the input into the output, with turns > 0.
*
*/
void addRecipe( ItemStack in, ItemStack out, ItemStack optional, float chance, ItemStack optional2, float chance2, int turns );
void addRecipe( @Nonnull ItemStack in, @Nonnull ItemStack out, @Nonnull ItemStack optional, float chance, @Nonnull ItemStack optional2, float chance2, int turns );
/**
* Remove the specific from the recipe list.
*
* @param recipe The recipe to be removed.
* @return true, if it was removed
*/
boolean removeRecipe( @Nonnull IGrinderRecipe recipe );
/**
* Searches for a recipe for a given input, and returns it.
*
* @param input input
* @param input The {@link ItemStack} to be grinded.
*
* @return identified recipe or null
*/
IGrinderEntry getRecipeForInput( ItemStack input );
@Nullable
IGrinderRecipe getRecipeForInput( @Nonnull ItemStack input );
/**
* Allows do add a custom ratio from an ore to dust when being grinded.
*
* The default ratio is 1 ore to 2 dusts.
*
* These have to be added before any recipe is registered. Otherwise it will use the default value.
*
* @param oredictName The name of the ore;
* @param ratio The amount, must be > 0;
*/
void addDustRatio( @Nonnull String oredictName, int ratio );
/**
* Remove a custom ratio for a specific ore name.
*
* Will use the default of 2 value afterwards.
*
* @param oredictName The name of the ore;
*/
boolean removeDustRatio( @Nonnull String oredictName );
}
@@ -24,12 +24,36 @@
package appeng.api.networking.crafting;
import java.util.Collection;
import appeng.api.storage.data.IAEStack;
public interface ICraftingWatcher extends Collection<IAEStack>
/**
* DO NOT IMPLEMENT.
*
* Will be injected when adding an {@link ICraftingWatcherHost} to a grid.
*/
public interface ICraftingWatcher
{
/**
* Add a specific {@link IAEStack} to watch.
*
* Supports multiple values, duplicate ones will not be added.
*
* @param stack
* @return true, if successfully added.
*/
boolean add( IAEStack<?> stack );
/**
* Remove a specific {@link IAEStack} from the watcher.
*
* @param stack
* @return true, if successfully removed.
*/
boolean remove( IAEStack<?> stack );
/**
* Removes all watched stacks and resets the watcher to a clean state.
*/
void reset();
}
@@ -24,10 +24,34 @@
package appeng.api.networking.energy;
import java.util.Collection;
public interface IEnergyWatcher extends Collection<Double>
/**
* DO NOT IMPLEMENT.
*
* Will be injected when adding an {@link IEnergyWatcherHost} to a grid.
*/
public interface IEnergyWatcher
{
/**
* Add a specific threshold to watch.
*
* Supports multiple values, duplicate ones will not be added.
*
* @param amount
* @return true, if successfully added.
*/
boolean add( double amount );
/**
* Remove a specific threshold from the watcher.
*
* @param amount
* @return true, if successfully removed.
*/
boolean remove( double amount );
/**
* Removes all thresholds and resets the watcher to a clean state.
*/
void reset();
}
@@ -24,12 +24,36 @@
package appeng.api.networking.storage;
import java.util.Collection;
import appeng.api.storage.data.IAEStack;
public interface IStackWatcher extends Collection<IAEStack>
/**
* DO NOT IMPLEMENT.
*
* Will be injected when adding an {@link IStackWatcherHost} to a grid.
*/
public interface IStackWatcher
{
/**
* Add a specific {@link IAEStack} to watch.
*
* Supports multiple values, duplicate ones will not be added.
*
* @param stack
* @return true, if successfully added.
*/
boolean add( IAEStack<?> stack );
/**
* Remove a specific {@link IAEStack} from the watcher.
*
* @param stack
* @return true, if successfully removed.
*/
boolean remove( IAEStack<?> stack );
/**
* Removes all watched stacks and resets the watcher to a clean state.
*/
void reset();
}
+19 -10
View File
@@ -25,10 +25,11 @@ package appeng.api.parts;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import javax.annotation.Nonnull;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
@@ -39,7 +40,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@@ -71,7 +71,8 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
ItemStack getItemStack( PartItemStack type );
/**
* Render dynamic portions of this part, as part of the cable bus TESR. This part has to return true for {@link #requireDynamicRender()} in order for
* Render dynamic portions of this part, as part of the cable bus TESR. This part has to return true for
* {@link #requireDynamicRender()} in order for
* this method to be called.
*/
@SideOnly( Side.CLIENT )
@@ -267,8 +268,10 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
boolean canBePlacedOn( BusSupport what );
/**
* This method is used when a chunk is rebuilt to determine how this part should be rendered. The returned models should represent the
* part oriented north. They will be automatically rotated to match the part's actual orientation. Tint indices 1-4 can be used in the
* This method is used when a chunk is rebuilt to determine how this part should be rendered. The returned models
* should represent the
* part oriented north. They will be automatically rotated to match the part's actual orientation. Tint indices 1-4
* can be used in the
* models to access the parts color.
*
* <dl>
@@ -279,18 +282,23 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
* <dt>Tint Index 3</dt>
* <dd>The {@link AEColor#whiteVariant bright variant color} of the cable that this part is attached to.</dd>
* <dt>Tint Index 4</dt>
* <dd>A color variant that is between the cable's {@link AEColor#mediumVariant color} and its {@link AEColor#whiteVariant bright variant}.</dd>
* <dd>A color variant that is between the cable's {@link AEColor#mediumVariant color} and its
* {@link AEColor#whiteVariant bright variant}.</dd>
* </dl>
*
* <b>Important:</b> All models must have been registered via the {@link IPartModels} API before use.
*/
default List<ResourceLocation> getStaticModels()
@Nonnull
default IPartModel getStaticModels()
{
return Collections.emptyList();
return new IPartModel()
{
};
}
/**
* Implement this method if your part exposes capabilitys. Any requests for capabilities on the cable bus will be forwarded to parts on the appropriate
* Implement this method if your part exposes capabilitys. Any requests for capabilities on the cable bus will be
* forwarded to parts on the appropriate
* side.
*
* @see TileEntity#hasCapability(Capability, EnumFacing)
@@ -303,7 +311,8 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
}
/**
* Implement this method if your part exposes capabilitys. Any requests for capabilities on the cable bus will be forwarded to parts on the appropriate
* Implement this method if your part exposes capabilitys. Any requests for capabilities on the cable bus will be
* forwarded to parts on the appropriate
* side.
*
* @see TileEntity#getCapability(Capability, EnumFacing)
@@ -0,0 +1,65 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 - 2015 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.parts;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.util.ResourceLocation;
/**
* A container to store a collection of {@link ResourceLocation} as models for a part as well as other properties.
*/
public interface IPartModel
{
/**
* A solid {@link IPartModel} indicates that the rendering requires a cable connection, which will also result in
* creating an intersection for the cable.
*
* This should be true for pretty much all parts.
*
* @return true for a solid part.
*/
default boolean requireCableConnection()
{
return true;
}
/**
* A collection of {@link ResourceLocation} used as models for a part.
*
* @return a collection of models, never null.
*/
@Nonnull
default List<ResourceLocation> getModels()
{
return Collections.emptyList();
}
}
+89 -100
View File
@@ -31,10 +31,8 @@ import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -65,12 +63,6 @@ public abstract class AEBaseBlock extends Block
protected AxisAlignedBB boundingBox = FULL_BLOCK_AABB;
@Override
public boolean isVisuallyOpaque()
{
return this.isOpaque() && this.isFullSize();
}
protected AEBaseBlock( final Material mat )
{
super( mat );
@@ -96,13 +88,15 @@ public abstract class AEBaseBlock extends Block
this.setLightLevel( 0 );
this.setHardness( 2.2F );
this.setHarvestLevel( "pickaxe", 0 );
// Workaround as vanilla sets it way too early.
this.fullBlock = this.isFullSize();
}
@Override
public String toString()
public final boolean isVisuallyOpaque()
{
String regName = getRegistryName() != null ? getRegistryName().getResourcePath() : "unregistered";
return getClass().getSimpleName() + "[" + regName + "]";
return this.isOpaque() && this.isFullSize();
}
@Override
@@ -111,31 +105,12 @@ public abstract class AEBaseBlock extends Block
return new BlockStateContainer( this, this.getAEStates() );
}
protected IProperty[] getAEStates()
{
return new IProperty[0];
}
public boolean isOpaque()
{
return this.isOpaque;
}
@Override
public boolean isNormalCube( IBlockState state )
public final boolean isNormalCube( IBlockState state )
{
return this.isFullSize() && this.isOpaque();
}
protected ICustomCollision getCustomCollision( final World w, final BlockPos pos )
{
if( this instanceof ICustomCollision )
{
return (ICustomCollision) this;
}
return null;
}
@Override
public AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess source, BlockPos pos )
{
@@ -210,7 +185,8 @@ public abstract class AEBaseBlock extends Block
if( br != null )
{
br = new AxisAlignedBB( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos.getY(), br.maxZ + pos.getZ() );
br = new AxisAlignedBB( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos
.getY(), br.maxZ + pos.getZ() );
return br;
}
}
@@ -241,7 +217,8 @@ public abstract class AEBaseBlock extends Block
}
else
{
b = new AxisAlignedBB( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos.getZ() );
b = new AxisAlignedBB( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos
.getZ() );
}
return b;
@@ -303,19 +280,6 @@ public abstract class AEBaseBlock extends Block
return super.collisionRayTrace( state, w, pos, a, b );
}
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 )
{
return false;
}
@Override
@SideOnly( Side.CLIENT )
@SuppressWarnings( "unchecked" )
public final void getSubBlocks( final Item item, final CreativeTabs tabs, final List itemStacks )
{
this.getCheckedSubBlocks( item, tabs, itemStacks );
}
@Override
public boolean hasComparatorInputOverride( IBlockState state )
{
@@ -329,21 +293,11 @@ public abstract class AEBaseBlock extends Block
}
@Override
public boolean isNormalCube( IBlockState state, final IBlockAccess world, final BlockPos pos )
public final boolean isNormalCube( IBlockState state, final IBlockAccess world, final BlockPos pos )
{
return this.isFullSize();
}
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable( w, pos );
}
return null;
}
@Override
public boolean rotateBlock( final World w, final BlockPos pos, final EnumFacing axis )
{
@@ -378,50 +332,24 @@ public abstract class AEBaseBlock extends Block
return super.rotateBlock( w, pos, axis );
}
protected boolean hasCustomRotation()
{
return false;
}
protected void customRotateBlock( final IOrientable rotatable, final EnumFacing axis )
{
}
public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up )
{
return true;
}
@Override
public EnumFacing[] getValidRotations( final World w, final BlockPos pos )
{
return new EnumFacing[0];
}
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
super.getSubBlocks( item, tabs, itemStacks );
}
public String getUnlocalizedName( final ItemStack is )
{
return this.getUnlocalizedName();
}
@Override
public void addInformation( final ItemStack is, final EntityPlayer player, final List<String> lines, final boolean advancedItemTooltips )
{
}
public boolean hasSubtypes()
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 )
{
return this.hasSubtypes;
return false;
}
public EnumFacing mapRotation( final IOrientable ori, final EnumFacing dir )
public final EnumFacing mapRotation( final IOrientable ori, final EnumFacing dir )
{
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
@@ -486,36 +414,97 @@ public abstract class AEBaseBlock extends Block
return null;
}
public boolean isFullSize()
@Override
public String toString()
{
return this.isFullSize;
String regName = getRegistryName() != null ? getRegistryName().getResourcePath() : "unregistered";
return getClass().getSimpleName() + "[" + regName + "]";
}
public boolean setFullSize( final boolean isFullSize )
protected String getUnlocalizedName( final ItemStack is )
{
this.isFullSize = isFullSize;
return isFullSize;
return this.getUnlocalizedName();
}
public boolean setOpaque( final boolean isOpaque )
protected boolean hasCustomRotation()
{
return false;
}
protected void customRotateBlock( final IOrientable rotatable, final EnumFacing axis )
{
}
protected IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable( w, pos );
}
return null;
}
protected boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up )
{
return true;
}
protected ICustomCollision getCustomCollision( final World w, final BlockPos pos )
{
if( this instanceof ICustomCollision )
{
return (ICustomCollision) this;
}
return null;
}
protected IProperty[] getAEStates()
{
return new IProperty[0];
}
protected boolean isOpaque()
{
return this.isOpaque;
}
protected boolean setOpaque( final boolean isOpaque )
{
this.isOpaque = isOpaque;
return isOpaque;
}
public boolean isInventory()
protected boolean hasSubtypes()
{
return this.isInventory;
return this.hasSubtypes;
}
public void setInventory( final boolean isInventory )
{
this.isInventory = isInventory;
}
public void setHasSubtypes( final boolean hasSubtypes )
protected void setHasSubtypes( final boolean hasSubtypes )
{
this.hasSubtypes = hasSubtypes;
}
protected boolean isFullSize()
{
return this.isFullSize;
}
protected boolean setFullSize( final boolean isFullSize )
{
this.isFullSize = isFullSize;
return isFullSize;
}
protected boolean isInventory()
{
return this.isInventory;
}
protected void setInventory( final boolean isInventory )
{
this.isInventory = isInventory;
}
}
@@ -85,7 +85,7 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
itemStacks.add( new ItemStack( this, 1, 0 ) );
}
@@ -22,6 +22,7 @@ package appeng.block.misc;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -22,6 +22,7 @@ package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
@@ -376,7 +377,7 @@ public class BlockCableBus extends AEBaseTileBlock
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
// do nothing
}
@@ -63,9 +63,9 @@ public class BlockEnergyCell extends AEBaseTileBlock
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
super.getCheckedSubBlocks( item, tabs, itemStacks );
super.getSubBlocks( item, tabs, itemStacks );
final ItemStack charged = new ItemStack( this, 1 );
final NBTTagCompound tag = Platform.openNbtData( charged );
@@ -21,6 +21,7 @@ package appeng.block.networking;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.block.properties.IProperty;
@@ -94,7 +94,7 @@ public class BlockPaint extends AEBaseTileBlock
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
// do nothing
}
@@ -4,6 +4,7 @@ package appeng.block.paint;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Function;
@@ -4,6 +4,7 @@ package appeng.block.qnb;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
import com.google.common.base.Function;
@@ -53,7 +53,7 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
// do nothing
}
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
@@ -54,7 +54,6 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar;
@@ -22,6 +22,7 @@ package appeng.client.me;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
@@ -21,6 +21,7 @@ package appeng.client.render;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState;
@@ -22,6 +22,7 @@ package appeng.client.render;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState;
@@ -25,6 +25,8 @@ import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState;
@@ -41,6 +43,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.block.networking.BlockCableBus;
@@ -81,8 +84,9 @@ public class CableBusBakedModel implements IBakedModel
List<BakedQuad> quads = new ArrayList<>();
// The core parts of the cable will only be rendered in the CUTOUT layer. TRANSLUCENT is used only for translucent facades further down below.
if ( layer == BlockRenderLayer.CUTOUT )
// The core parts of the cable will only be rendered in the CUTOUT layer. TRANSLUCENT is used only for
// translucent facades further down below.
if( layer == BlockRenderLayer.CUTOUT )
{
// First, handle the cable at the center of the cable bus
addCableQuads( renderState, quads );
@@ -90,13 +94,13 @@ public class CableBusBakedModel implements IBakedModel
// Then handle attachments
for( EnumFacing facing : EnumFacing.values() )
{
List<ResourceLocation> models = renderState.getAttachments().get( facing );
if( models == null )
final IPartModel partModel = renderState.getAttachments().get( facing );
if( partModel == null )
{
continue;
}
for( ResourceLocation model : models )
for( ResourceLocation model : partModel.getModels() )
{
IBakedModel bakedModel = partModels.get( model );
@@ -122,8 +126,7 @@ public class CableBusBakedModel implements IBakedModel
renderState.getBoundingBoxes(),
renderState.getAttachments().keySet(),
rand,
quads
);
quads );
return quads;
}
@@ -131,25 +134,30 @@ public class CableBusBakedModel implements IBakedModel
// Determines whether a cable is connected to exactly two sides that are opposite each other
private static boolean isStraightLine( AECableType cableType, EnumMap<EnumFacing, AECableType> sides )
{
Iterator<EnumFacing> it = sides.keySet().iterator();
final Iterator<Entry<EnumFacing, AECableType>> it = sides.entrySet().iterator();
if( !it.hasNext() )
{
return false; // No connections
}
EnumFacing firstSide = it.next();
AECableType firstType = sides.get( firstSide );
final Entry<EnumFacing, AECableType> nextConnection = it.next();
final EnumFacing firstSide = nextConnection.getKey();
final AECableType firstType = nextConnection.getValue();
if( !it.hasNext() )
{
return false; // Only a single connection
}
if( firstSide.getOpposite() != it.next() )
if( firstSide.getOpposite() != it.next().getKey() )
{
return false; // Connected to two sides that are not opposite each other
}
if (it.hasNext()) {
if( it.hasNext() )
{
return false; // Must not have any other connection points
}
AECableType secondType = sides.get( firstSide.getOpposite() );
final AECableType secondType = sides.get( firstSide.getOpposite() );
// Certain cable types have restrictions on when they're rendered as a straight connection
switch( cableType )
@@ -176,8 +184,8 @@ public class CableBusBakedModel implements IBakedModel
// If the connection is straight, no busses are attached, and no covered core has been forced (in case of glass
// cables), then render the cable as a simplified straight line.
boolean noAttachments = renderState.getAttachments().isEmpty();
if( isStraightLine( cableType, connectionTypes ) && noAttachments )
boolean noAttachments = !renderState.getAttachments().values().stream().anyMatch( IPartModel::requireCableConnection );
if( noAttachments && isStraightLine( cableType, connectionTypes ) )
{
EnumFacing facing = connectionTypes.keySet().iterator().next();
@@ -227,11 +235,12 @@ public class CableBusBakedModel implements IBakedModel
}
// Render all outgoing connections using the appropriate type
for( EnumFacing facing : connectionTypes.keySet() )
for( final Entry<EnumFacing, AECableType> connection : connectionTypes.entrySet() )
{
AECableType connectionType = connectionTypes.get( facing );
boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains( facing );
int channels = renderState.getChannelsOnSide().get( facing );
final EnumFacing facing = connection.getKey();
final AECableType connectionType = connection.getValue();
final boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains( facing );
final int channels = renderState.getChannelsOnSide().get( facing );
switch( cableType )
{
@@ -269,9 +278,9 @@ public class CableBusBakedModel implements IBakedModel
// If no core is present, just use the first part that comes into play
for( EnumFacing side : renderState.getAttachments().keySet() )
{
List<ResourceLocation> models = renderState.getAttachments().get( side );
IPartModel partModel = renderState.getAttachments().get( side );
for( ResourceLocation model : models )
for( ResourceLocation model : partModel.getModels() )
{
IBakedModel bakedModel = partModels.get( model );
@@ -282,9 +291,11 @@ public class CableBusBakedModel implements IBakedModel
TextureAtlasSprite particleTexture = bakedModel.getParticleTexture();
// If a part sub-model has no particle texture (indicated by it being the missing texture), don't add it,
// If a part sub-model has no particle texture (indicated by it being the missing texture), don't
// add
// it,
// so we don't get ugly missing texture break particles.
if ( textureMap.getMissingSprite() != particleTexture )
if( textureMap.getMissingSprite() != particleTexture )
{
result.add( particleTexture );
}
@@ -25,9 +25,9 @@ import java.util.EnumSet;
import java.util.List;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
@@ -60,7 +60,7 @@ public class CableBusRenderState
// connections contains a corresponding entry.
private EnumMap<EnumFacing, Integer> channelsOnSide = new EnumMap<>( EnumFacing.class );
private EnumMap<EnumFacing, List<ResourceLocation>> attachments = new EnumMap<>( EnumFacing.class );
private EnumMap<EnumFacing, IPartModel> attachments = new EnumMap<>( EnumFacing.class );
// For each attachment, this contains the distance from the edge until which a cable connection should be drawn
private EnumMap<EnumFacing, Integer> attachmentConnections = new EnumMap<>( EnumFacing.class );
@@ -68,7 +68,8 @@ public class CableBusRenderState
// Contains the facade to use for each side that has a facade attached
private EnumMap<EnumFacing, FacadeRenderState> facades = new EnumMap<>( EnumFacing.class );
// Contains the bounding boxes of all parts on the cable bus to allow facades to cut out holes for the parts. This list is only populated if there are
// Contains the bounding boxes of all parts on the cable bus to allow facades to cut out holes for the parts. This
// list is only populated if there are
// facades on this cable bus
private List<AxisAlignedBB> boundingBoxes = new ArrayList<>();
@@ -132,7 +133,7 @@ public class CableBusRenderState
this.cableBusAdjacent = cableBusAdjacent;
}
public EnumMap<EnumFacing, List<ResourceLocation>> getAttachments()
public EnumMap<EnumFacing, IPartModel> getAttachments()
{
return attachments;
}
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.List;
import javax.vecmath.Vector4f;
import com.google.common.base.Preconditions;
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.vecmath.Vector3f;
@@ -2,6 +2,7 @@ package appeng.client.render.crafting;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
@@ -21,6 +21,7 @@ package appeng.client.render.model;
import java.util.ArrayList;
import java.util.List;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
@@ -4,6 +4,7 @@ package appeng.client.render.model;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
@@ -32,6 +32,7 @@ import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import com.google.common.base.Charsets;
@@ -233,7 +233,7 @@ class SpatialPylonBakedModel implements IBakedModel
@Override
public TextureAtlasSprite getParticleTexture()
{
return null;
return this.textures.get( SpatialPylonTextureType.DIM );
}
@Override
@@ -31,6 +31,7 @@ import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.util.Platform;
public class ContainerCraftingStatus extends ContainerCraftingCPU
@@ -52,50 +53,53 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
@Override
public void detectAndSendChanges()
{
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
if( Platform.isServer() && this.getNetwork() != null )
{
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
{
if( ccr.getCpu() == c )
{
found = true;
}
}
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
final boolean matched = this.cpuMatches( c );
if( matched )
{
matches++;
}
if( found == !matched )
{
changed = true;
}
}
if( changed || this.cpus.size() != matches )
{
this.cpus.clear();
int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
{
if( this.cpuMatches( c ) )
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
if( ccr.getCpu() == c )
{
found = true;
}
}
final boolean matched = this.cpuMatches( c );
if( matched )
{
matches++;
}
if( found == !matched )
{
changed = true;
}
}
this.sendCPUs();
}
if( changed || this.cpus.size() != matches )
{
this.cpus.clear();
for( final ICraftingCPU c : cpuSet )
{
if( this.cpuMatches( c ) )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
}
this.noCPU = this.cpus.isEmpty();
this.sendCPUs();
}
this.noCPU = this.cpus.isEmpty();
}
super.detectAndSendChanges();
}
+19 -2
View File
@@ -24,8 +24,11 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import com.google.common.collect.Sets;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
@@ -99,6 +102,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
// Grindstone
private String[] grinderOres = Stream.of( ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC ).flatMap( Stream::of ).toArray( String[]::new );
private Set<String> grinderBlackList;
private double oreDoublePercentage = 90.0;
// Batteries
@@ -153,8 +157,16 @@ public final class AEConfig extends Configuration implements IConfigurableObject
this.removeCrashingItemsOnLoad = this.get( "general", "removeCrashingItemsOnLoad", false,
"Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!" ).getBoolean();
this.grinderOres = this.get( "GrindStone", "grinderOres", this.grinderOres ).getStringList();
this.oreDoublePercentage = this.get( "GrindStone", "oreDoublePercentage", this.oreDoublePercentage ).getDouble( this.oreDoublePercentage );
this.setCategoryComment( "GrindStone",
"Creates recipe of the following pattern automatically: '1 oreTYPE => 2 dustTYPE' and '(1 ingotTYPE or 1 crystalTYPE or 1 gemTYPE) => 1 dustTYPE'" );
this.grinderOres = this.get( "GrindStone", "grinderOres", this.grinderOres, "The list of types to handle. Specify without a prefix like ore or dust." )
.getStringList();
this.grinderBlackList = Sets.newHashSet(
this.get( "GrindStone", "blacklist", new String[] {}, "Blacklists the exact oredict name from being handled by any recipe." )
.getStringList() );
this.oreDoublePercentage = this
.get( "GrindStone", "oreDoublePercentage", this.oreDoublePercentage, "Chance to actually get an output with stacksize > 1." )
.getDouble( this.oreDoublePercentage );
this.settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
this.settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL );
@@ -632,6 +644,11 @@ public final class AEConfig extends Configuration implements IConfigurableObject
return grinderOres;
}
public Set<String> getGrinderBlackList()
{
return this.grinderBlackList;
}
public double getOreDoublePercentage()
{
return oreDoublePercentage;
+2 -2
View File
@@ -290,11 +290,11 @@ public final class AELog
*
* @param message String to be logged
*/
public static void grinder( @Nonnull final String message )
public static void grinder( @Nonnull final String message, final Object... params )
{
if( AEConfig.instance().isFeatureEnabled( AEFeature.GRINDER_LOGGING ) )
{
log( Level.DEBUG, "grinder: " + message );
log( Level.DEBUG, "grinder: " + message, params );
}
}
+1
View File
@@ -22,6 +22,7 @@ package appeng.core;
import java.io.File;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import com.google.common.base.Stopwatch;
+3 -2
View File
@@ -22,6 +22,7 @@ package appeng.core;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
@@ -57,8 +58,8 @@ import appeng.api.parts.IPartHelper;
import appeng.capabilities.Capabilities;
import appeng.core.features.AEFeature;
import appeng.core.features.registries.P2PTunnelRegistry;
import appeng.core.features.registries.entries.BasicCellHandler;
import appeng.core.features.registries.entries.CreativeCellHandler;
import appeng.core.features.registries.cell.BasicCellHandler;
import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.core.stats.PlayerStatsRegistration;
@@ -1,299 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IGrinderRegistry;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.registries.entries.AppEngGrinderRecipe;
import appeng.recipes.ores.IOreListener;
import appeng.recipes.ores.OreDictionaryHandler;
import appeng.util.Platform;
public final class GrinderRecipeManager implements IGrinderRegistry, IOreListener
{
private final List<IGrinderEntry> recipes;
private final Map<ItemStack, String> ores;
private final Map<ItemStack, String> ingots;
private final Map<String, ItemStack> dusts;
public GrinderRecipeManager()
{
this.recipes = new ArrayList<IGrinderEntry>();
this.ores = new HashMap<ItemStack, String>();
this.ingots = new HashMap<ItemStack, String>();
this.dusts = new HashMap<String, ItemStack>();
this.addOre( "Coal", new ItemStack( Items.COAL ) );
this.addOre( "Charcoal", new ItemStack( Items.COAL, 1, 1 ) );
this.addOre( "NetherQuartz", new ItemStack( Blocks.QUARTZ_ORE ) );
this.addIngot( "NetherQuartz", new ItemStack( Items.QUARTZ ) );
this.addOre( "Gold", new ItemStack( Blocks.GOLD_ORE ) );
this.addIngot( "Gold", new ItemStack( Items.GOLD_INGOT ) );
this.addOre( "Iron", new ItemStack( Blocks.IRON_ORE ) );
this.addIngot( "Iron", new ItemStack( Items.IRON_INGOT ) );
this.addOre( "Obsidian", new ItemStack( Blocks.OBSIDIAN ) );
this.addIngot( "Ender", new ItemStack( Items.ENDER_PEARL ) );
this.addIngot( "EnderPearl", new ItemStack( Items.ENDER_PEARL ) );
this.addIngot( "Wheat", new ItemStack( Items.WHEAT ) );
OreDictionaryHandler.INSTANCE.observe( this );
}
@Override
public List<IGrinderEntry> getRecipes()
{
this.log( "API - getRecipes" );
return this.recipes;
}
@Override
public void addRecipe( final ItemStack in, final ItemStack out, final int cost )
{
if( in == null || out == null )
{
this.log( "Invalid Grinder Recipe Specified." );
return;
}
this.log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " for " + cost );
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), cost ) );
}
@Override
public void addRecipe( final ItemStack in, final ItemStack out, final ItemStack optional, final float chance, final int cost )
{
if( in == null || ( optional == null && out == null ) )
{
this.log( "Invalid Grinder Recipe Specified." );
return;
}
this.log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional " + Platform.getItemDisplayName( optional ) + " for " + cost );
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), this.copy( optional ), chance, cost ) );
}
@Override
public void addRecipe( final ItemStack in, final ItemStack out, final ItemStack optional, final float chance, final ItemStack optional2, final float chance2, final int cost )
{
if( in == null || ( optional == null && out == null && optional2 == null ) )
{
this.log( "Invalid Grinder Recipe Specified." );
return;
}
this.log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional " + Platform.getItemDisplayName( optional ) + " for " + cost );
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), this.copy( optional ), this.copy( optional2 ), chance, chance2, cost ) );
}
private void injectRecipe( final AppEngGrinderRecipe appEngGrinderRecipe )
{
for( final IGrinderEntry gr : this.recipes )
{
if( Platform.itemComparisons().isSameItem( gr.getInput(), appEngGrinderRecipe.getInput() ) )
{
return;
}
}
this.recipes.add( appEngGrinderRecipe );
}
private ItemStack copy( final ItemStack is )
{
if( is != null )
{
return is.copy();
}
return null;
}
@Override
public IGrinderEntry getRecipeForInput( final ItemStack input )
{
this.log( "Looking up recipe for " + Platform.getItemDisplayName( input ) );
if( input != null )
{
for( final IGrinderEntry r : this.recipes )
{
if( Platform.itemComparisons().isEqualItem( input, r.getInput() ) )
{
this.log( "Recipe for " + input.getUnlocalizedName() + " found " + Platform.getItemDisplayName( r.getOutput() ) );
return r;
}
}
this.log( "Could not find recipe for " + Platform.getItemDisplayName( input ) );
}
return null;
}
private void log( final String o )
{
AELog.grinder( o );
}
private int getDustToOreRatio( final String name )
{
if( name.equals( "Obsidian" ) )
{
return 1;
}
if( name.equals( "Charcoal" ) )
{
return 1;
}
if( name.equals( "Coal" ) )
{
return 1;
}
return 2;
}
private void addOre( final String name, final ItemStack item )
{
if( item == null )
{
return;
}
this.log( "Adding Ore - " + name + " : " + Platform.getItemDisplayName( item ) );
this.ores.put( item, name );
if( this.dusts.containsKey( name ) )
{
final ItemStack is = this.dusts.get( name ).copy();
final int ratio = this.getDustToOreRatio( name );
if( ratio > 1 )
{
final ItemStack extra = is.copy();
extra.stackSize = ratio - 1;
this.addRecipe( item, is, extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ), 8 );
}
else
{
this.addRecipe( item, is, 8 );
}
}
}
private void addIngot( final String name, final ItemStack item )
{
if( item == null )
{
return;
}
this.log( "Adding Ingot - " + name + " : " + Platform.getItemDisplayName( item ) );
this.ingots.put( item, name );
if( this.dusts.containsKey( name ) )
{
this.addRecipe( item, this.dusts.get( name ), 4 );
}
}
private void addDust( final String name, final ItemStack item )
{
if( item == null )
{
return;
}
if( this.dusts.containsKey( name ) )
{
this.log( "Rejecting Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
return;
}
this.log( "Adding Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
this.dusts.put( name, item );
for( final Entry<ItemStack, String> d : this.ores.entrySet() )
{
if( name.equals( d.getValue() ) )
{
final ItemStack is = item.copy();
is.stackSize = 1;
final int ratio = this.getDustToOreRatio( name );
if( ratio > 1 )
{
final ItemStack extra = is.copy();
extra.stackSize = ratio - 1;
this.addRecipe( d.getKey(), is, extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ), 8 );
}
else
{
this.addRecipe( d.getKey(), is, 8 );
}
}
}
for( final Entry<ItemStack, String> d : this.ingots.entrySet() )
{
if( name.equals( d.getValue() ) )
{
this.addRecipe( d.getKey(), item, 4 );
}
}
}
@Override
public void oreRegistered( final String name, final ItemStack item )
{
if( name.startsWith( "ore" ) || name.startsWith( "crystal" ) || name.startsWith( "gem" ) || name.startsWith( "ingot" ) || name.startsWith( "dust" ) )
{
for( final String ore : AEConfig.instance().getGrinderOres() )
{
if( name.equals( "ore" + ore ) )
{
this.addOre( ore, item );
}
else if( name.equals( "crystal" + ore ) || name.equals( "ingot" + ore ) || name.equals( "gem" + ore ) )
{
this.addIngot( ore, item );
}
else if( name.equals( "dust" + ore ) )
{
this.addDust( ore, item );
}
}
}
}
}
@@ -34,6 +34,9 @@ import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels;
import appeng.api.storage.ICellRegistry;
import appeng.core.features.registries.cell.CellRegistry;
import appeng.core.features.registries.grinder.GrinderRecipeManager;
import appeng.core.features.registries.inscriber.InscriberRegistry;
/**
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.entries;
package appeng.core.features.registries.cell;
import net.minecraft.entity.player.EntityPlayer;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
package appeng.core.features.registries.cell;
import java.util.ArrayList;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.entries;
package appeng.core.features.registries.cell;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,146 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.entries;
import net.minecraft.item.ItemStack;
import appeng.api.features.IGrinderEntry;
public class AppEngGrinderRecipe implements IGrinderEntry
{
private ItemStack in;
private ItemStack out;
private float optionalChance;
private ItemStack optionalOutput;
private float optionalChance2;
private ItemStack optionalOutput2;
private int energy;
public AppEngGrinderRecipe( final ItemStack a, final ItemStack b, final int cost )
{
this.in = a;
this.out = b;
this.energy = cost;
}
public AppEngGrinderRecipe( final ItemStack a, final ItemStack b, final ItemStack c, final float chance, final int cost )
{
this.in = a;
this.out = b;
this.optionalOutput = c;
this.optionalChance = chance;
this.energy = cost;
}
public AppEngGrinderRecipe( final ItemStack a, final ItemStack b, final ItemStack c, final ItemStack d, final float chance, final float chance2, final int cost )
{
this.in = a;
this.out = b;
this.optionalOutput = c;
this.optionalChance = chance;
this.optionalOutput2 = d;
this.optionalChance2 = chance2;
this.energy = cost;
}
@Override
public ItemStack getInput()
{
return this.in;
}
@Override
public void setInput( final ItemStack i )
{
this.in = i.copy();
}
@Override
public ItemStack getOutput()
{
return this.out;
}
@Override
public void setOutput( final ItemStack o )
{
this.out = o.copy();
}
@Override
public ItemStack getOptionalOutput()
{
return this.optionalOutput;
}
@Override
public ItemStack getSecondOptionalOutput()
{
return this.optionalOutput2;
}
@Override
public void setOptionalOutput( final ItemStack output, final float chance )
{
this.optionalOutput = output.copy();
this.optionalChance = chance;
}
@Override
public float getOptionalChance()
{
return this.optionalChance;
}
@Override
public void setSecondOptionalOutput( final ItemStack output, final float chance )
{
this.optionalChance2 = chance;
this.optionalOutput2 = output.copy();
}
@Override
public float getSecondOptionalChance()
{
return this.optionalChance2;
}
@Override
public int getEnergyCost()
{
return this.energy;
}
@Override
public void setEnergyCost( final int c )
{
this.energy = c;
}
}
@@ -0,0 +1,108 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.grinder;
import java.util.Optional;
import net.minecraft.item.ItemStack;
import appeng.api.features.IGrinderRecipe;
public class AppEngGrinderRecipe implements IGrinderRecipe
{
private final ItemStack in;
private final ItemStack out;
private final float optionalChance;
private final Optional<ItemStack> optionalOutput;
private final float optionalChance2;
private final Optional<ItemStack> optionalOutput2;
private final int turns;
AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final int cost )
{
this( input, output, null, null, 0, 0, cost );
}
AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final ItemStack optional, final float chance, final int cost )
{
this( input, output, optional, null, chance, 0, cost );
}
AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final ItemStack optional1, final ItemStack optional2, final float chance1, final float chance2, final int cost )
{
this.in = input;
this.out = output;
this.optionalOutput = Optional.ofNullable( optional1 );
this.optionalChance = chance1;
this.optionalOutput2 = Optional.ofNullable( optional2 );
this.optionalChance2 = chance2;
this.turns = cost;
}
@Override
public ItemStack getInput()
{
return this.in;
}
@Override
public ItemStack getOutput()
{
return this.out;
}
@Override
public Optional<ItemStack> getOptionalOutput()
{
return this.optionalOutput;
}
@Override
public Optional<ItemStack> getSecondOptionalOutput()
{
return this.optionalOutput2;
}
@Override
public float getOptionalChance()
{
return this.optionalChance;
}
@Override
public float getSecondOptionalChance()
{
return this.optionalChance2;
}
@Override
public int getRequiredTurns()
{
return this.turns;
}
}
@@ -0,0 +1,396 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.grinder;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.features.IGrinderRecipe;
import appeng.api.features.IGrinderRegistry;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.recipes.ores.IOreListener;
import appeng.recipes.ores.OreDictionaryHandler;
import appeng.util.Platform;
public final class GrinderRecipeManager implements IGrinderRegistry, IOreListener
{
private final Map<CacheKey, IGrinderRecipe> recipes;
private final Map<ItemStack, String> ores;
private final Map<ItemStack, String> ingots;
private final Map<String, ItemStack> dusts;
private final Map<String, Integer> dustToOreRatio;
public GrinderRecipeManager()
{
this.recipes = Maps.newHashMap();
this.ores = Maps.newHashMap();
this.ingots = Maps.newHashMap();
this.dusts = Maps.newHashMap();
this.dustToOreRatio = Maps.newHashMap();
this.addDustRatio( "Obsidian", 1 );
this.addDustRatio( "Charcoal", 1 );
this.addDustRatio( "Coal", 1 );
this.addOre( "Coal", new ItemStack( Items.COAL ) );
this.addOre( "Charcoal", new ItemStack( Items.COAL, 1, 1 ) );
this.addOre( "NetherQuartz", new ItemStack( Blocks.QUARTZ_ORE ) );
this.addIngot( "NetherQuartz", new ItemStack( Items.QUARTZ ) );
this.addOre( "Gold", new ItemStack( Blocks.GOLD_ORE ) );
this.addIngot( "Gold", new ItemStack( Items.GOLD_INGOT ) );
this.addOre( "Iron", new ItemStack( Blocks.IRON_ORE ) );
this.addIngot( "Iron", new ItemStack( Items.IRON_INGOT ) );
this.addOre( "Obsidian", new ItemStack( Blocks.OBSIDIAN ) );
this.addIngot( "Ender", new ItemStack( Items.ENDER_PEARL ) );
this.addIngot( "EnderPearl", new ItemStack( Items.ENDER_PEARL ) );
this.addIngot( "Wheat", new ItemStack( Items.WHEAT ) );
OreDictionaryHandler.INSTANCE.observe( this );
}
@Override
public Collection<IGrinderRecipe> getRecipes()
{
return Collections.unmodifiableCollection( this.recipes.values() );
}
@Override
public void addRecipe( final ItemStack in, final ItemStack out, final int cost )
{
Preconditions.checkNotNull( in, "Null is not accepted as input itemstack." );
Preconditions.checkNotNull( out, "Null is not accepted as output itemstack." );
Preconditions.checkArgument( cost > 0, "Turns must be > 0" );
this.log( "Allow Grinding of '%1$s' to '%2$s' for %3$d turn", Platform.getItemDisplayName( in ), Platform.getItemDisplayName( out ), cost );
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), cost ) );
}
@Override
public void addRecipe( final ItemStack in, final ItemStack out, final ItemStack optional, final float chance, final int cost )
{
Preconditions.checkNotNull( in, "Null is not accepted as input itemstack." );
Preconditions.checkNotNull( out, "Null is not accepted as output itemstack." );
Preconditions.checkNotNull( optional, "Null is not accepted as optional itemstack." );
Preconditions.checkArgument( chance >= 0.0 && chance <= 1.0, "chance must be within 0.0 - 1.0." );
Preconditions.checkArgument( cost > 0, "Turns must be > 0" );
this.log( "Allow Grinding of '%1$s' to '%2$s' with optional '%3$s' @ %4$.2f for %5$d", Platform.getItemDisplayName( in ),
Platform.getItemDisplayName( out ), Platform.getItemDisplayName( optional ), chance, cost );
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), this.copy( optional ), chance, cost ) );
}
@Override
public void addRecipe( final ItemStack in, final ItemStack out, final ItemStack optional1, final float chance1, final ItemStack optional2, final float chance2, final int cost )
{
Preconditions.checkNotNull( in, "Null is not accepted as input itemstack." );
Preconditions.checkNotNull( out, "Null is not accepted as output itemstack." );
Preconditions.checkNotNull( optional1, "Null is not accepted as optional itemstack." );
Preconditions.checkArgument( chance1 >= 0.0 && chance1 <= 1.0, "chance must be within 0.0 - 1.0." );
Preconditions.checkNotNull( optional2, "Null is not accepted as optional2 itemstack." );
Preconditions.checkArgument( chance2 >= 0.0 && chance2 <= 1.0, "chance2 must be within 0.0 - 1.0." );
Preconditions.checkArgument( cost > 0, "Turns must be > 0" );
this.log( "Allow Grinding of '%1$s' to '%2$s' with optional '%3$s' @ %4$.2f and optional2 '%5$s' @ %6$.2f for %7$d", Platform.getItemDisplayName( in ),
Platform.getItemDisplayName( out ), Platform.getItemDisplayName( optional1 ), chance1, Platform.getItemDisplayName( optional2 ), chance2,
cost );
this.injectRecipe(
new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), this.copy( optional1 ), this.copy( optional2 ), chance1, chance2, cost ) );
}
@Override
public boolean removeRecipe( IGrinderRecipe recipe )
{
Preconditions.checkNotNull( recipe, "Cannot remove null as recipe." );
final CacheKey key = new CacheKey( recipe.getInput() );
final IGrinderRecipe removedRecipe = this.recipes.remove( key );
this.log( "Removed Grinding of '%1%s'", Platform.getItemDisplayName( recipe.getInput() ) );
return removedRecipe != null;
}
@Override
public IGrinderRecipe getRecipeForInput( final ItemStack input )
{
this.log( "Looking up recipe for '%1$s'", Platform.getItemDisplayName( input ) );
if( input == null )
{
return null;
}
final IGrinderRecipe recipe = this.recipes.get( new CacheKey( input ) );
if( recipe == null )
{
return null;
}
this.log( "Recipe for '%1$s' found '%2$s'", input.getUnlocalizedName(), Platform.getItemDisplayName( recipe.getOutput() ) );
return recipe;
}
@Override
public void addDustRatio( String oredictName, int ratio )
{
Preconditions.checkNotNull( oredictName );
Preconditions.checkArgument( ratio > 0 );
this.log( "Added ratio for '%1$s' of %2$d", oredictName, ratio );
this.dustToOreRatio.put( oredictName, ratio );
}
@Override
public boolean removeDustRatio( String oredictName )
{
Preconditions.checkNotNull( oredictName );
this.log( "Removed ratio for '%1$s'", oredictName );
return this.dustToOreRatio.remove( oredictName ) != null;
}
@Override
public void oreRegistered( final String name, final ItemStack item )
{
if( !AEConfig.instance().getGrinderBlackList().contains( name ) && ( name.startsWith( "ore" ) || name.startsWith( "crystal" ) || name
.startsWith( "gem" ) || name.startsWith( "ingot" ) || name.startsWith( "dust" ) ) )
{
for( final String ore : AEConfig.instance().getGrinderOres() )
{
if( name.equals( "ore" + ore ) )
{
this.addOre( ore, item );
}
else if( name.equals( "crystal" + ore ) || name.equals( "ingot" + ore ) || name.equals( "gem" + ore ) )
{
this.addIngot( ore, item );
}
else if( name.equals( "dust" + ore ) )
{
this.addDust( ore, item );
}
}
}
}
private void injectRecipe( final AppEngGrinderRecipe appEngGrinderRecipe )
{
final CacheKey cacheKey = new CacheKey( appEngGrinderRecipe.getInput() );
if( this.recipes.containsKey( cacheKey ) )
{
this.log( "Tried to add duplicate recipe for '%1$s'", Platform.getItemDisplayName( appEngGrinderRecipe.getInput() ) );
return;
}
this.recipes.put( cacheKey, appEngGrinderRecipe );
}
private ItemStack copy( final ItemStack is )
{
if( is != null )
{
return is.copy();
}
return null;
}
private int getDustToOreRatio( final String name )
{
return this.dustToOreRatio.getOrDefault( name, 2 );
}
private void addOre( final String name, final ItemStack item )
{
if( item == null )
{
return;
}
this.log( "Adding Ore: '%1$s'", Platform.getItemDisplayName( item ) );
this.ores.put( item, name );
if( this.dusts.containsKey( name ) )
{
final ItemStack is = this.dusts.get( name ).copy();
final int ratio = this.getDustToOreRatio( name );
if( ratio > 1 )
{
final ItemStack extra = is.copy();
extra.stackSize = ratio - 1;
this.addRecipe( item, is, extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ), 8 );
}
else
{
this.addRecipe( item, is, 8 );
}
}
}
private void addIngot( final String name, final ItemStack item )
{
if( item == null )
{
return;
}
this.log( "Adding Ingot: '%1$s'", Platform.getItemDisplayName( item ) );
this.ingots.put( item, name );
if( this.dusts.containsKey( name ) )
{
this.addRecipe( item, this.dusts.get( name ), 4 );
}
}
private void addDust( final String name, final ItemStack item )
{
if( item == null )
{
return;
}
if( this.dusts.containsKey( name ) )
{
this.log( "Rejecting Dust: '%1$s'", Platform.getItemDisplayName( item ) );
return;
}
this.log( "Adding Dust: '%1$s'", Platform.getItemDisplayName( item ) );
this.dusts.put( name, item );
for( final Entry<ItemStack, String> d : this.ores.entrySet() )
{
if( name.equals( d.getValue() ) )
{
final ItemStack is = item.copy();
is.stackSize = 1;
final int ratio = this.getDustToOreRatio( name );
if( ratio > 1 )
{
final ItemStack extra = is.copy();
extra.stackSize = ratio - 1;
this.addRecipe( d.getKey(), is, extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ), 8 );
}
else
{
this.addRecipe( d.getKey(), is, 8 );
}
}
}
for( final Entry<ItemStack, String> d : this.ingots.entrySet() )
{
if( name.equals( d.getValue() ) )
{
this.addRecipe( d.getKey(), item, 4 );
}
}
}
private void log( final String o, Object... params )
{
AELog.grinder( o, params );
}
private static class CacheKey
{
private final Item item;
private final int damage;
CacheKey( ItemStack input )
{
Preconditions.checkNotNull( input );
Preconditions.checkNotNull( input.getItem() );
this.item = input.getItem();
this.damage = input.getItemDamage();
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + damage;
result = prime * result + ( ( item == null ) ? 0 : item.hashCode() );
return result;
}
@Override
public boolean equals( Object obj )
{
if( this == obj )
{
return true;
}
if( obj == null || getClass() != obj.getClass() )
{
return false;
}
CacheKey other = (CacheKey) obj;
if( damage != other.damage )
{
return false;
}
if( item == null )
{
if( other.item != null )
{
return false;
}
}
else if( item != other.item )
{
return false;
}
return true;
}
}
}
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.entries;
package appeng.core.features.registries.inscriber;
import java.util.Collection;
@@ -38,7 +38,7 @@ import appeng.api.features.InscriberProcessType;
*/
public class InscriberInscribeRecipe extends InscriberRecipe
{
public InscriberInscribeRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot )
InscriberInscribeRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot )
{
super( inputs, output, top, bot, InscriberProcessType.INSCRIBE );
}
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.entries;
package appeng.core.features.registries.inscriber;
import java.util.ArrayList;
@@ -57,7 +57,7 @@ public class InscriberRecipe implements IInscriberRecipe
@Nonnull
private final InscriberProcessType type;
public InscriberRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot, @Nonnull final InscriberProcessType type )
InscriberRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot, @Nonnull final InscriberProcessType type )
{
this.inputs = new ArrayList<ItemStack>( inputs.size() );
this.inputs.addAll( inputs );
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
package appeng.core.features.registries.inscriber;
import java.util.ArrayList;
@@ -35,7 +35,6 @@ import appeng.api.features.IInscriberRecipe;
import appeng.api.features.IInscriberRecipeBuilder;
import appeng.api.features.IInscriberRegistry;
import appeng.api.features.InscriberProcessType;
import appeng.core.features.registries.entries.InscriberRecipe;
/**
@@ -34,11 +34,11 @@ import appeng.core.sync.packets.PacketCompressedNBT;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketCraftRequest;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketJEIRecipe;
import appeng.core.sync.packets.PacketLightning;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.core.sync.packets.PacketMatterCannon;
import appeng.core.sync.packets.PacketMockExplosion;
import appeng.core.sync.packets.PacketJEIRecipe;
import appeng.core.sync.packets.PacketNewStorageDimension;
import appeng.core.sync.packets.PacketPaintedEntity;
import appeng.core.sync.packets.PacketPartPlacement;
@@ -19,11 +19,9 @@
package appeng.crafting;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import javax.annotation.Nonnull;
import java.util.Set;
import appeng.api.networking.crafting.ICraftingWatcher;
import appeng.api.networking.crafting.ICraftingWatcherHost;
@@ -39,7 +37,7 @@ public class CraftingWatcher implements ICraftingWatcher
private final CraftingGridCache gsc;
private final ICraftingWatcherHost host;
private final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
private final Set<IAEStack> myInterests = new HashSet<IAEStack>();
public CraftingWatcher( final CraftingGridCache cache, final ICraftingWatcherHost host )
{
@@ -52,45 +50,6 @@ public class CraftingWatcher implements ICraftingWatcher
return this.host;
}
@Override
public int size()
{
return this.myInterests.size();
}
@Override
public boolean isEmpty()
{
return this.myInterests.isEmpty();
}
@Override
public boolean contains( final Object o )
{
return this.myInterests.contains( o );
}
@Nonnull
@Override
public Iterator<IAEStack> iterator()
{
return new ItemWatcherIterator( this, this.myInterests.iterator() );
}
@Nonnull
@Override
public Object[] toArray()
{
return this.myInterests.toArray();
}
@Nonnull
@Override
public <T> T[] toArray( @Nonnull final T[] a )
{
return this.myInterests.toArray( a );
}
@Override
public boolean add( final IAEStack e )
{
@@ -103,100 +62,20 @@ public class CraftingWatcher implements ICraftingWatcher
}
@Override
public boolean remove( final Object o )
public boolean remove( final IAEStack o )
{
return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( (IAEStack) o, this );
}
@Override
public boolean containsAll( @Nonnull final Collection<?> c )
{
return this.myInterests.containsAll( c );
}
@Override
public boolean addAll( @Nonnull final Collection<? extends IAEStack> c )
{
boolean didChange = false;
for( final IAEStack o : c )
{
didChange = this.add( o ) || didChange;
}
return didChange;
}
@Override
public boolean removeAll( @Nonnull final Collection<?> c )
{
boolean didSomething = false;
for( final Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@Override
public boolean retainAll( @Nonnull final Collection<?> c )
{
boolean changed = false;
final Iterator<IAEStack> i = this.iterator();
while( i.hasNext() )
{
if( !c.contains( i.next() ) )
{
i.remove();
changed = true;
}
}
return changed;
}
@Override
public void clear()
public void reset()
{
final Iterator<IAEStack> i = this.myInterests.iterator();
while( i.hasNext() )
{
this.gsc.getInterestManager().remove( i.next(), this );
i.remove();
}
}
private class ItemWatcherIterator implements Iterator<IAEStack>
{
private final CraftingWatcher watcher;
private final Iterator<IAEStack> interestIterator;
private IAEStack myLast;
public ItemWatcherIterator( final CraftingWatcher parent, final Iterator<IAEStack> i )
{
this.watcher = parent;
this.interestIterator = i;
}
@Override
public boolean hasNext()
{
return this.interestIterator.hasNext();
}
@Override
public IAEStack next()
{
return this.myLast = this.interestIterator.next();
}
@Override
public void remove()
{
CraftingWatcher.this.gsc.getInterestManager().remove( this.myLast, this.watcher );
this.interestIterator.remove();
}
}
}
@@ -2,6 +2,7 @@ package appeng.decorative.slab;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
@@ -95,15 +95,17 @@ public class BlockQuartzGlass extends AEBaseBlock
{
BlockPos adjacentPos = pos.offset( side );
final Material mat = w.getBlockState( adjacentPos ).getBlock().getMaterial( state );
final Material mat = w.getBlockState( adjacentPos ).getMaterial();
if( mat == Material.GLASS || mat == AEGlassMaterial.INSTANCE )
{
if( w.getBlockState( adjacentPos ).getBlock().getRenderType( state ) == this.getRenderType( state ) )
if( w.getBlockState( adjacentPos ).getRenderType() == this.getRenderType( state ) )
{
return false;
}
}
return super.shouldSideBeRendered( state, w, pos, side );
return w.getBlockState( pos ).shouldSideBeRendered( w, adjacentPos, side );
}
@Override
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
@@ -27,6 +27,10 @@ public interface IIntegrationModule
return true;
}
default void preInit() throws Throwable
{
}
default void init() throws Throwable
{
}
@@ -94,24 +94,14 @@ final class IntegrationNode
if( enabled )
{
switch( type )
{
case IC2:
this.mod = Integrations.setIc2( new IC2Module() );
break;
case JEI:
this.mod = Integrations.setJei( new JEIModule() );
break;
case Waila:
this.mod = new WailaModule();
break;
}
this.mod = type.createInstance();
}
else
{
throw new ModNotInstalled( this.modID );
}
this.mod.preInit();
this.setState( IntegrationStage.INIT );
break;
@@ -19,9 +19,22 @@
package appeng.integration;
import appeng.integration.modules.ic2.IC2Module;
import appeng.integration.modules.jei.JEIModule;
import appeng.integration.modules.theoneprobe.TheOneProbeModule;
import appeng.integration.modules.waila.WailaModule;
public enum IntegrationType
{
IC2( IntegrationSide.BOTH, "Industrial Craft 2", "IC2" ),
IC2( IntegrationSide.BOTH, "Industrial Craft 2", "IC2" )
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setIc2( new IC2Module() );
}
},
RC( IntegrationSide.BOTH, "Railcraft", "Railcraft" ),
@@ -31,15 +44,38 @@ public enum IntegrationType
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded" ),
Waila( IntegrationSide.BOTH, "Waila", "Waila" ),
Waila( IntegrationSide.BOTH, "Waila", "Waila" )
{
@Override
public IIntegrationModule createInstance()
{
return new WailaModule();
}
},
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" ),
JEI( IntegrationSide.CLIENT, "Just Enough Items", "JEI" ),
JEI( IntegrationSide.CLIENT, "Just Enough Items", "JEI" )
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setJei( new JEIModule() );
}
},
Mekanism( IntegrationSide.BOTH, "Mekanism", "Mekanism" ),
OpenComputers( IntegrationSide.BOTH, "OpenComputers", "OpenComputers" );
OpenComputers( IntegrationSide.BOTH, "OpenComputers", "OpenComputers" ),
THE_ONE_PROBE( IntegrationSide.BOTH, "TheOneProbe", "theoneprobe" )
{
@Override
public IIntegrationModule createInstance()
{
return new TheOneProbeModule();
}
};
public final IntegrationSide side;
public final String dspName;
@@ -52,4 +88,9 @@ public enum IntegrationType
this.modID = modid;
}
public IIntegrationModule createInstance()
{
throw new UnsupportedOperationException();
}
}
@@ -36,9 +36,13 @@ import appeng.tile.powersink.IExternalPowerSink;
public class IC2Module implements IIC2
{
private static final String[] IC2_CABLE_TYPES = { "copper", "glass", "gold", "iron", "tin", "detector", "splitter" };
public IC2Module()
{
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyTile.class );
IntegrationHelper.testClassExistence( this, ic2.api.item.IC2Items.class );
IntegrationHelper.testClassExistence( this, ic2.api.recipe.Recipes.class );
IntegrationHelper.testClassExistence( this, ic2.api.recipe.RecipeInputItemStack.class );
}
@@ -46,22 +50,21 @@ public class IC2Module implements IIC2
public void postInit()
{
final IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
reg.addNewAttunement( this.getItem( "copperCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedCopperCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "goldCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedGoldCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "ironCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedIronCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedTinCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "glassFiberCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "tinCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "detectorCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "splitterCableItem" ), TunnelType.IC2_POWER );
for( String string : IC2_CABLE_TYPES )
{
reg.addNewAttunement( this.getCable( string ), TunnelType.IC2_POWER );
}
}
private ItemStack getItem( final String name )
private ItemStack getItem( final String name, String variant )
{
return ic2.api.item.IC2Items.getItem( name );
return ic2.api.item.IC2Items.getItem( name, variant );
}
private ItemStack getCable( final String type )
{
return this.getItem( "cable", "type:" + type );
}
/**
@@ -21,6 +21,7 @@ package appeng.integration.modules.jei;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Splitter;
@@ -22,16 +22,16 @@ package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IGrinderRecipe;
class GrinderRecipeHandler implements IRecipeHandler<IGrinderEntry>
class GrinderRecipeHandler implements IRecipeHandler<IGrinderRecipe>
{
@Override
public Class<IGrinderEntry> getRecipeClass()
public Class<IGrinderRecipe> getRecipeClass()
{
return IGrinderEntry.class;
return IGrinderRecipe.class;
}
@Override
@@ -41,19 +41,19 @@ class GrinderRecipeHandler implements IRecipeHandler<IGrinderEntry>
}
@Override
public String getRecipeCategoryUid( IGrinderEntry recipe )
public String getRecipeCategoryUid( IGrinderRecipe recipe )
{
return GrinderRecipeCategory.UID;
}
@Override
public IRecipeWrapper getRecipeWrapper( IGrinderEntry recipe )
public IRecipeWrapper getRecipeWrapper( IGrinderRecipe recipe )
{
return new GrinderRecipeWrapper( recipe );
}
@Override
public boolean isRecipeValid( IGrinderEntry recipe )
public boolean isRecipeValid( IGrinderRecipe recipe )
{
return true;
}
@@ -31,15 +31,15 @@ import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IGrinderRecipe;
class GrinderRecipeWrapper extends BlankRecipeWrapper
{
private final IGrinderEntry recipe;
private final IGrinderRecipe recipe;
GrinderRecipeWrapper( IGrinderEntry recipe )
GrinderRecipeWrapper( IGrinderRecipe recipe )
{
this.recipe = recipe;
}
@@ -50,14 +50,8 @@ class GrinderRecipeWrapper extends BlankRecipeWrapper
ingredients.setInput( ItemStack.class, recipe.getInput() );
List<ItemStack> outputs = new ArrayList<>( 3 );
outputs.add( recipe.getOutput() );
if( recipe.getOptionalOutput() != null )
{
outputs.add( recipe.getOptionalOutput() );
}
if( recipe.getSecondOptionalOutput() != null )
{
outputs.add( recipe.getSecondOptionalOutput() );
}
recipe.getOptionalOutput().ifPresent( outputs::add );
recipe.getSecondOptionalOutput().ifPresent( outputs::add );
ingredients.setOutputs( ItemStack.class, outputs );
}
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -70,8 +71,10 @@ public class JEIPlugin extends BlankModPlugin
registerDescriptions( definitions, registry );
// Allow recipe transfer from JEI to crafting and pattern terminal
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ), VanillaRecipeCategoryUid.CRAFTING );
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), VanillaRecipeCategoryUid.CRAFTING );
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ),
VanillaRecipeCategoryUid.CRAFTING );
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ),
VanillaRecipeCategoryUid.CRAFTING );
}
private void registerDescriptions( IDefinitions definitions, IModRegistry registry )
@@ -130,7 +133,7 @@ public class JEIPlugin extends BlankModPlugin
return;
}
registry.addRecipes( AEApi.instance().registries().grinder().getRecipes() );
registry.addRecipes( Lists.newArrayList( AEApi.instance().registries().grinder().getRecipes() ) );
registry.addRecipeHandlers( new GrinderRecipeHandler() );
registry.addRecipeCategories( new GrinderRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
registry.addRecipeCategoryCraftingItem( grindstone, GrinderRecipeCategory.UID );
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
@@ -0,0 +1,86 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe;
import java.util.List;
import java.util.Optional;
import com.google.common.collect.Lists;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.parts.IPart;
import appeng.core.AppEng;
import appeng.integration.modules.theoneprobe.part.ChannelInfoProvider;
import appeng.integration.modules.theoneprobe.part.IPartProbInfoProvider;
import appeng.integration.modules.theoneprobe.part.P2PStateInfoProvider;
import appeng.integration.modules.theoneprobe.part.PartAccessor;
import appeng.integration.modules.theoneprobe.part.PowerStateInfoProvider;
import appeng.integration.modules.theoneprobe.part.StorageMonitorInfoProvider;
public final class PartInfoProvider implements IProbeInfoProvider
{
private final List<IPartProbInfoProvider> providers;
private final PartAccessor accessor = new PartAccessor();
public PartInfoProvider()
{
final IPartProbInfoProvider channel = new ChannelInfoProvider();
final IPartProbInfoProvider power = new PowerStateInfoProvider();
final IPartProbInfoProvider storageMonitor = new StorageMonitorInfoProvider();
final IPartProbInfoProvider p2p = new P2PStateInfoProvider();
this.providers = Lists.newArrayList( channel, power, p2p, storageMonitor );
}
@Override
public String getID()
{
return AppEng.MOD_ID + ":PartInfoProvider";
}
@Override
public void addProbeInfo( ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
final TileEntity te = world.getTileEntity( data.getPos() );
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, data );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( final IPartProbInfoProvider provider : this.providers )
{
provider.addProbeInfo( part, mode, probeInfo, player, world, blockState, data );
}
}
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe;
import com.google.common.base.Function;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import mcjty.theoneprobe.api.ITheOneProbe;
import appeng.integration.IIntegrationModule;
import appeng.integration.modules.theoneprobe.config.AEConfigProvider;
public class TheOneProbeModule implements IIntegrationModule, Function<ITheOneProbe, Void>
{
@Override
public void preInit() throws Throwable
{
FMLInterModComms.sendFunctionMessage( "theoneprobe", "getTheOneProbe", this.getClass().getName() );
}
@Override
public Void apply( ITheOneProbe input )
{
input.registerProbeConfigProvider( new AEConfigProvider() );
input.registerProvider( new TileInfoProvider() );
input.registerProvider( new PartInfoProvider() );
return null;
}
}
@@ -0,0 +1,66 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe;
import java.util.Locale;
import net.minecraft.util.text.translation.I18n;
public enum TheOneProbeText
{
CRAFTING,
DEVICE_ONLINE,
DEVICE_OFFLINE,
DEVICE_MISSING_CHANNEL,
P2P_UNLINKED,
P2P_INPUT_ONE_OUTPUT,
P2P_INPUT_MANY_OUTPUTS,
P2P_OUTPUT,
LOCKED,
UNLOCKED,
SHOWING,
CONTAINS,
CHANNELS,
STORED_ENERGY;
private final String root;
TheOneProbeText()
{
this.root = "theoneprobe.appliedenergistics2";
}
public String getLocal()
{
return I18n.translateToLocal( this.getUnlocalized() );
}
public String getUnlocalized()
{
return this.root + '.' + this.name().toLowerCase( Locale.ENGLISH );
}
}
@@ -0,0 +1,80 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.core.AppEng;
import appeng.integration.modules.theoneprobe.tile.ChargerInfoProvider;
import appeng.integration.modules.theoneprobe.tile.CraftingMonitorInfoProvider;
import appeng.integration.modules.theoneprobe.tile.ITileProbInfoProvider;
import appeng.integration.modules.theoneprobe.tile.PowerStateInfoProvider;
import appeng.integration.modules.theoneprobe.tile.PowerStorageInfoProvider;
import appeng.tile.AEBaseTile;
public final class TileInfoProvider implements IProbeInfoProvider
{
private final List<ITileProbInfoProvider> providers;
public TileInfoProvider()
{
final ITileProbInfoProvider charger = new ChargerInfoProvider();
final ITileProbInfoProvider energyCell = new CraftingMonitorInfoProvider();
final ITileProbInfoProvider craftingBlock = new PowerStateInfoProvider();
final ITileProbInfoProvider craftingMonitor = new PowerStorageInfoProvider();
this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor );
}
@Override
public String getID()
{
return AppEng.MOD_ID + ":TileInfoProvider";
}
@Override
public void addProbeInfo( ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
final TileEntity tile = world.getTileEntity( data.getPos() );
if( tile instanceof AEBaseTile )
{
final AEBaseTile aeBaseTile = (AEBaseTile) tile;
for( final ITileProbInfoProvider provider : this.providers )
{
provider.addProbeInfo( aeBaseTile, mode, probeInfo, player, world, blockState, data );
}
}
}
}
@@ -0,0 +1,53 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.config;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeConfig;
import mcjty.theoneprobe.api.IProbeConfigProvider;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeHitEntityData;
import appeng.tile.AEBaseTile;
public class AEConfigProvider implements IProbeConfigProvider
{
@Override
public void getProbeConfig( IProbeConfig config, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data )
{
// Still no AE entities.
}
@Override
public void getProbeConfig( IProbeConfig config, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( world.getTileEntity( data.getPos() ) instanceof AEBaseTile )
{
config.setRFMode( 0 );
}
}
}
@@ -0,0 +1,66 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.parts.IPart;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
public class ChannelInfoProvider implements IPartProbInfoProvider
{
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( part instanceof PartDenseCable || part instanceof PartCableSmart )
{
final int usedChannels;
final int maxChannels = ( part instanceof PartDenseCable ) ? 32 : 8;
if( part.getGridNode().isActive() )
{
final NBTTagCompound tmp = new NBTTagCompound();
part.writeToNBT( tmp );
usedChannels = tmp.getByte( "usedChannels" );
}
else
{
usedChannels = 0;
}
final String formattedChannelString = String.format( TheOneProbeText.CHANNELS.getLocal(), usedChannels, maxChannels );
probeInfo.text( formattedChannelString );
}
}
}
@@ -0,0 +1,45 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.parts.IPart;
/**
* Similar to {@link IProbeInfoProvider}, but already providing the {@link IPart} being looked at.
*
*/
public interface IPartProbInfoProvider
{
/**
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
*/
void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
}
@@ -0,0 +1,115 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.part;
import com.google.common.collect.Iterators;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.parts.IPart;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.me.GridAccessException;
import appeng.parts.p2p.PartP2PTunnel;
public class P2PStateInfoProvider implements IPartProbInfoProvider
{
private static final int STATE_UNLINKED = 0;
private static final int STATE_OUTPUT = 1;
private static final int STATE_INPUT = 2;
public static final String TAG_P2P_STATE = "p2p_state";
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( part instanceof PartP2PTunnel )
{
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
// The default state
int state = STATE_UNLINKED;
int outputCount = 0;
if( !tunnel.isOutput() )
{
outputCount = getOutputCount( tunnel );
if( outputCount > 0 )
{
// Only set it to INPUT if we know there are any outputs
state = STATE_INPUT;
}
}
else
{
final PartP2PTunnel input = tunnel.getInput();
if( input != null )
{
state = STATE_OUTPUT;
}
}
switch( state )
{
case STATE_UNLINKED:
probeInfo.text( TheOneProbeText.P2P_UNLINKED.getLocal() );
break;
case STATE_OUTPUT:
probeInfo.text( TheOneProbeText.P2P_OUTPUT.getLocal() );
break;
case STATE_INPUT:
probeInfo.text( getOutputText( outputCount ) );
break;
}
}
}
private static int getOutputCount( PartP2PTunnel tunnel )
{
try
{
return Iterators.size( tunnel.getOutputs().iterator() );
}
catch( GridAccessException e )
{
// Well... unknown size it is!
return 0;
}
}
private static String getOutputText( int outputs )
{
if( outputs <= 1 )
{
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getLocal();
}
else
{
return String.format( TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
}
}
}
@@ -0,0 +1,55 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.part;
import java.util.Optional;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import mcjty.theoneprobe.api.IProbeHitData;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
public final class PartAccessor
{
public Optional<IPart> getMaybePart( final TileEntity te, final IProbeHitData data )
{
if( te instanceof IPartHost )
{
BlockPos pos = data.getPos();
final Vec3d position = data.getHitVec().addVector( -pos.getX(), -pos.getY(), -pos.getZ() );
final IPartHost host = (IPartHost) te;
final SelectedPart sp = host.selectPart( position );
if( sp.part != null )
{
return Optional.of( sp.part );
}
}
return Optional.empty();
}
}
@@ -0,0 +1,71 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.parts.IPart;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
public class PowerStateInfoProvider implements IPartProbInfoProvider
{
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( part instanceof IPowerChannelState )
{
final IPowerChannelState state = (IPowerChannelState) part;
final String tooltip = this.getToolTip( state.isActive(), state.isPowered() );
probeInfo.text( tooltip );
}
}
private String getToolTip( final boolean isActive, final boolean isPowered )
{
final String result;
if( isActive && isPowered )
{
result = TheOneProbeText.DEVICE_ONLINE.getLocal();
}
else if( isPowered )
{
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal();
}
else
{
result = TheOneProbeText.DEVICE_OFFLINE.getLocal();
}
return result;
}
}
@@ -0,0 +1,66 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
public class StorageMonitorInfoProvider implements IPartProbInfoProvider
{
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( part instanceof IPartStorageMonitor )
{
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
final IAEStack<?> displayed = monitor.getDisplayed();
final boolean isLocked = monitor.isLocked();
if( displayed instanceof IAEItemStack )
{
final IAEItemStack ais = (IAEItemStack) displayed;
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getItemStack().getDisplayName() );
}
else if( displayed instanceof IAEFluidStack )
{
final IAEFluidStack ais = (IAEFluidStack) displayed;
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
}
probeInfo.text( isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal() );
}
}
}
@@ -0,0 +1,61 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.ElementAlignment;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileCharger;
public class ChargerInfoProvider implements ITileProbInfoProvider
{
@Override
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( tile instanceof TileCharger )
{
final TileCharger charger = (TileCharger) tile;
final IInventory chargerInventory = charger.getInternalInventory();
final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 );
if( chargingItem != null )
{
final String currentInventory = chargingItem.getDisplayName();
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
.horizontal( probeInfo.defaultLayoutStyle().alignment( ElementAlignment.ALIGN_CENTER ) );
centerAlignedHorizontalLayout.item( chargingItem );
centerAlignedHorizontalLayout.text( currentInventory );
}
}
}
}
@@ -0,0 +1,64 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.ElementAlignment;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.storage.data.IAEItemStack;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.tile.AEBaseTile;
import appeng.tile.crafting.TileCraftingMonitorTile;
public class CraftingMonitorInfoProvider implements ITileProbInfoProvider
{
@Override
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( tile instanceof TileCraftingMonitorTile )
{
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) tile;
final IAEItemStack displayStack = monitor.getJobProgress();
if( displayStack != null )
{
final ItemStack itemStack = displayStack.getItemStack();
final String itemName = itemStack.getDisplayName();
final String formattedCrafting = String.format( TheOneProbeText.CRAFTING.getLocal(), itemName );
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
.horizontal( probeInfo.defaultLayoutStyle().alignment( ElementAlignment.ALIGN_CENTER ) );
centerAlignedHorizontalLayout.item( itemStack );
centerAlignedHorizontalLayout.text( formattedCrafting );
}
}
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.tile.AEBaseTile;
/**
* Similar to {@link IProbeInfoProvider}, but already providing the {@link AEBaseTile} being looked at.
*
*/
public interface ITileProbInfoProvider
{
/**
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
*/
void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
}
@@ -0,0 +1,64 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.implementations.IPowerChannelState;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.tile.AEBaseTile;
public class PowerStateInfoProvider implements ITileProbInfoProvider
{
@Override
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( tile instanceof IPowerChannelState )
{
final IPowerChannelState state = (IPowerChannelState) tile;
final boolean isActive = state.isActive();
final boolean isPowered = state.isPowered();
if( isActive && isPowered )
{
probeInfo.text( TheOneProbeText.DEVICE_ONLINE.getLocal() );
}
else if( isPowered )
{
probeInfo.text( TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal() );
}
else
{
probeInfo.text( TheOneProbeText.DEVICE_OFFLINE.getLocal() );
}
}
}
}
@@ -0,0 +1,66 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.networking.energy.IAEPowerStorage;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class PowerStorageInfoProvider implements ITileProbInfoProvider
{
@Override
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( tile instanceof IAEPowerStorage )
{
final IAEPowerStorage storage = (IAEPowerStorage) tile;
final double maxPower = storage.getAEMaxPower();
if( maxPower > 0 )
{
final long internalCurrentPower = (long) ( storage.getAECurrentPower() * 100 );
if( internalCurrentPower >= 0 )
{
final long internalMaxPower = (long) ( 100 * maxPower );
final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false );
final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false );
final String formattedString = String.format( TheOneProbeText.STORED_ENERGY.getLocal(), formatCurrentPower, formatMaxPower );
probeInfo.text( formattedString );
}
}
}
}
}
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -1,3 +1,4 @@
package appeng.items.parts;
@@ -11,6 +12,7 @@ import java.util.List;
import net.minecraft.util.ResourceLocation;
import appeng.api.parts.IPartModel;
import appeng.core.AELog;
@@ -22,7 +24,7 @@ class PartModelsHelper
static List<ResourceLocation> createModels( Class<?> clazz )
{
List<ResourceLocation> locations = new ArrayList<>( );
List<ResourceLocation> locations = new ArrayList<>();
// Check all static fields for used models
Field[] fields = clazz.getDeclaredFields();
@@ -33,7 +35,6 @@ class PartModelsHelper
continue;
}
if( !Modifier.isStatic( field.getModifiers() ) )
{
AELog.error( "The @PartModels annotation can only be used on static fields or methods. Was seen on: " + field );
@@ -80,8 +81,8 @@ class PartModelsHelper
Class<?> returnType = method.getReturnType();
if( !ResourceLocation.class.isAssignableFrom( returnType ) && !Collection.class.isAssignableFrom( returnType ) )
{
AELog.error( "The @PartModels annotation can only be used on static methods that return a ResourceLocation or Collection of "
+ "ResourceLocations. Was seen on: " + method );
AELog.error(
"The @PartModels annotation can only be used on static methods that return a ResourceLocation or Collection of " + "ResourceLocations. Was seen on: " + method );
continue;
}
@@ -119,18 +120,23 @@ class PartModelsHelper
{
locations.add( (ResourceLocation) value );
}
else if( value instanceof IPartModel )
{
locations.addAll( ( (IPartModel) value ).getModels() );
}
else if( value instanceof Collection )
{
// Check that each object is a ResourceLocation
// Check that each object is an IPartModel
Collection values = (Collection) value;
for( Object candidate : values )
{
if ( !( candidate instanceof ResourceLocation )) {
if( !( candidate instanceof IPartModel ) )
{
AELog.error( "List of locations obtained from {} contains a non resource location: {}", source, candidate );
continue;
}
locations.add( (ResourceLocation) candidate );
locations.addAll( ( (IPartModel) candidate ).getModels() );
}
}
}
@@ -62,8 +62,8 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
import appeng.block.paint.BlockPaint;
import appeng.block.networking.BlockCableBus;
import appeng.block.paint.BlockPaint;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.IMouseWheelItem;
@@ -186,4 +186,10 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
{
return new PortableCellViewer( is, pos.getX() );
}
@Override
public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged )
{
return slotChanged;
}
}
@@ -150,4 +150,10 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
tag.setString( "encryptionKey", encKey );
tag.setString( "name", name );
}
@Override
public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged )
{
return slotChanged;
}
}
+1 -1
View File
@@ -172,7 +172,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
final ICraftingWatcher craftingWatcher = this.craftingWatchers.get( machine );
if( craftingWatcher != null )
{
craftingWatcher.clear();
craftingWatcher.reset();
this.craftingWatchers.remove( machine );
}
}
+23 -15
View File
@@ -23,11 +23,12 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
@@ -58,8 +59,8 @@ import appeng.me.energy.EnergyWatcher;
public class EnergyGridCache implements IEnergyGrid
{
private final TreeSet<EnergyThreshold> interests = new TreeSet<EnergyThreshold>();
private final double AvgLength = 40.0;
private final NavigableSet<EnergyThreshold> interests = Sets.newTreeSet();
private final double averageLength = 40.0;
private final Set<IAEPowerStorage> providers = new LinkedHashSet<IAEPowerStorage>();
private final Set<IAEPowerStorage> requesters = new LinkedHashSet<IAEPowerStorage>();
private final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
@@ -150,24 +151,25 @@ public class EnergyGridCache implements IEnergyGrid
@Override
public void onUpdateTick()
{
if( !this.getInterests().isEmpty() )
if( !this.interests.isEmpty() )
{
final double oldPower = this.lastStoredPower;
this.lastStoredPower = this.getStoredPower();
final EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), null );
final EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), null );
for( final EnergyThreshold th : this.getInterests().subSet( low, true, high, true ) )
final EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), Integer.MIN_VALUE );
final EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), Integer.MAX_VALUE );
for( final EnergyThreshold th : this.interests.subSet( low, true, high, true ) )
{
( (EnergyWatcher) th.getWatcher() ).post( this );
( (EnergyWatcher) th.getEnergyWatcher() ).post( this );
}
}
this.avgDrainPerTick *= ( this.AvgLength - 1 ) / this.AvgLength;
this.avgInjectionPerTick *= ( this.AvgLength - 1 ) / this.AvgLength;
this.avgDrainPerTick *= ( this.averageLength - 1 ) / this.averageLength;
this.avgInjectionPerTick *= ( this.averageLength - 1 ) / this.averageLength;
this.avgDrainPerTick += this.tickDrainPerTick / this.AvgLength;
this.avgInjectionPerTick += this.tickInjectionPerTick / this.AvgLength;
this.avgDrainPerTick += this.tickDrainPerTick / this.averageLength;
this.avgInjectionPerTick += this.tickInjectionPerTick / this.averageLength;
this.tickDrainPerTick = 0;
this.tickInjectionPerTick = 0;
@@ -554,7 +556,7 @@ public class EnergyGridCache implements IEnergyGrid
final IEnergyWatcher myWatcher = this.watchers.get( machine );
if( myWatcher != null )
{
myWatcher.clear();
myWatcher.reset();
this.watchers.remove( machine );
}
}
@@ -631,8 +633,14 @@ public class EnergyGridCache implements IEnergyGrid
storage.dataObject().setDouble( "extraEnergy", this.extra );
}
public TreeSet<EnergyThreshold> getInterests()
public boolean registerEnergyInterest( final EnergyThreshold threshold )
{
return this.interests;
return this.interests.add( threshold );
}
public boolean unregisterEnergyInterest( final EnergyThreshold threshold )
{
return this.interests.remove( threshold );
}
}
+3 -2
View File
@@ -89,8 +89,8 @@ public class GridStorageCache implements IStorageGrid
final ICellContainer cc = (ICellContainer) machine;
final CellChangeTracker tracker = new CellChangeTracker();
this.inactiveCellProviders.remove( cc );
this.removeCellProvider( cc, tracker );
this.inactiveCellProviders.remove( cc );
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
tracker.applyChanges();
@@ -102,7 +102,7 @@ public class GridStorageCache implements IStorageGrid
if( myWatcher != null )
{
myWatcher.clear();
myWatcher.reset();
this.watchers.remove( machine );
}
}
@@ -186,6 +186,7 @@ public class GridStorageCache implements IStorageGrid
if( this.activeCellProviders.contains( cc ) )
{
this.activeCellProviders.remove( cc );
this.inactiveCellProviders.add( cc );
BaseActionSource actionSrc = new BaseActionSource();
@@ -20,50 +20,98 @@ package appeng.me.energy;
import appeng.api.networking.energy.IEnergyWatcher;
import appeng.util.ItemSorters;
public class EnergyThreshold implements Comparable<EnergyThreshold>
{
private final double Limit;
private final double threshold;
private final IEnergyWatcher watcher;
private final int hash;
private final int watcherHash;
public EnergyThreshold( final double lim, final IEnergyWatcher wat )
public EnergyThreshold( final double lim, final IEnergyWatcher watcher )
{
this.Limit = lim;
this.watcher = wat;
this.threshold = lim;
this.watcher = watcher;
this.watcherHash = watcher.hashCode();
}
if( this.getWatcher() != null )
/**
* Special constructor to allow querying a for a subset of thresholds.
*
* @param lim
* @param bound
*/
public EnergyThreshold( final double lim, final int bound )
{
this.threshold = lim;
this.watcher = null;
this.watcherHash = bound;
}
public IEnergyWatcher getEnergyWatcher()
{
return watcher;
}
@Override
public int compareTo( EnergyThreshold o )
{
int a = Double.compare( this.threshold, o.threshold );
if( a == 0 )
{
this.hash = this.getWatcher().hashCode() ^ ( (Double) lim ).hashCode();
}
else
{
this.hash = ( (Double) lim ).hashCode();
return Integer.compare( this.watcherHash, o.watcherHash );
}
return a;
}
@Override
public int hashCode()
{
return this.hash;
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits( threshold );
result = prime * result + (int) ( temp ^ ( temp >>> 32 ) );
result = prime * result + ( ( watcher == null ) ? 0 : watcher.hashCode() );
return result;
}
@Override
public int compareTo( final EnergyThreshold o )
public boolean equals( Object obj )
{
return ItemSorters.compareDouble( this.getLimit(), o.getLimit() );
}
if( this == obj )
{
return true;
}
if( obj == null )
{
return false;
}
if( getClass() != obj.getClass() )
{
return false;
}
double getLimit()
{
return this.Limit;
}
EnergyThreshold other = (EnergyThreshold) obj;
if( Double.doubleToLongBits( threshold ) != Double.doubleToLongBits( other.threshold ) )
{
return false;
}
public IEnergyWatcher getWatcher()
{
return this.watcher;
if( watcher == null )
{
if( other.watcher != null )
{
return false;
}
}
else if( !watcher.equals( other.watcher ) )
{
return false;
}
return true;
}
}
+19 -132
View File
@@ -19,9 +19,9 @@
package appeng.me.energy;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import appeng.api.networking.energy.IEnergyWatcher;
import appeng.api.networking.energy.IEnergyWatcherHost;
@@ -35,170 +35,57 @@ public class EnergyWatcher implements IEnergyWatcher
{
private final EnergyGridCache gsc;
private final IEnergyWatcherHost myObject;
private final HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
private final IEnergyWatcherHost watcherHost;
private final Set<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
public EnergyWatcher( final EnergyGridCache cache, final IEnergyWatcherHost host )
{
this.gsc = cache;
this.myObject = host;
this.watcherHost = host;
}
public void post( final EnergyGridCache energyGridCache )
{
this.myObject.onThresholdPass( energyGridCache );
this.watcherHost.onThresholdPass( energyGridCache );
}
public IEnergyWatcherHost getHost()
{
return this.myObject;
return this.watcherHost;
}
@Override
public int size()
public boolean add( final double amount )
{
return this.myInterests.size();
}
final EnergyThreshold eh = new EnergyThreshold( amount, this );
@Override
public boolean isEmpty()
{
return this.myInterests.isEmpty();
}
if( this.myInterests.contains( eh ) )
@Override
public boolean contains( final Object o )
{
return this.myInterests.contains( o );
}
@Override
public Iterator<Double> iterator()
{
return new EnergyWatcherIterator( this, this.myInterests.iterator() );
}
@Override
public Object[] toArray()
{
return this.myInterests.toArray();
}
@Override
public <T> T[] toArray( final T[] a )
{
return this.myInterests.toArray( a );
}
@Override
public boolean add( final Double e )
{
if( this.myInterests.contains( e ) )
{
return false;
}
final EnergyThreshold eh = new EnergyThreshold( e, this );
return this.gsc.getInterests().add( eh ) && this.myInterests.add( eh );
return this.gsc.registerEnergyInterest( eh ) && this.myInterests.add( eh );
}
@Override
public boolean remove( final Object o )
public boolean remove( final double amount )
{
final EnergyThreshold eh = new EnergyThreshold( (Double) o, this );
return this.myInterests.remove( eh ) && this.gsc.getInterests().remove( eh );
final EnergyThreshold eh = new EnergyThreshold( amount, this );
return this.myInterests.remove( eh ) && this.gsc.unregisterEnergyInterest( eh );
}
@Override
public boolean containsAll( final Collection<?> c )
public void reset()
{
return this.myInterests.containsAll( c );
}
@Override
public boolean addAll( final Collection<? extends Double> c )
{
boolean didChange = false;
for( final Double o : c )
for( Iterator<EnergyThreshold> iterator = myInterests.iterator(); iterator.hasNext(); )
{
didChange = this.add( o ) || didChange;
}
final EnergyThreshold threshold = iterator.next();
return didChange;
}
@Override
public boolean removeAll( final Collection<?> c )
{
boolean didSomething = false;
for( final Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@Override
public boolean retainAll( final Collection<?> c )
{
boolean changed = false;
final Iterator<Double> i = this.iterator();
while( i.hasNext() )
{
if( !c.contains( i.next() ) )
{
i.remove();
changed = true;
}
}
return changed;
}
@Override
public void clear()
{
final Iterator<EnergyThreshold> i = this.myInterests.iterator();
while( i.hasNext() )
{
this.gsc.getInterests().remove( i.next() );
i.remove();
this.gsc.unregisterEnergyInterest( threshold );
iterator.remove();
}
}
private class EnergyWatcherIterator implements Iterator<Double>
{
private final EnergyWatcher watcher;
private final Iterator<EnergyThreshold> interestIterator;
private EnergyThreshold myLast;
public EnergyWatcherIterator( final EnergyWatcher parent, final Iterator<EnergyThreshold> i )
{
this.watcher = parent;
this.interestIterator = i;
}
@Override
public boolean hasNext()
{
return this.interestIterator.hasNext();
}
@Override
public Double next()
{
this.myLast = this.interestIterator.next();
return this.myLast.getLimit();
}
@Override
public void remove()
{
EnergyWatcher.this.gsc.getInterests().remove( this.myLast );
this.interestIterator.remove();
}
}
}
@@ -19,9 +19,9 @@
package appeng.me.storage;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
@@ -37,7 +37,7 @@ public class ItemWatcher implements IStackWatcher
private final GridStorageCache gsc;
private final IStackWatcherHost myObject;
private final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
private final Set<IAEStack> myInterests = new HashSet<IAEStack>();
public ItemWatcher( final GridStorageCache cache, final IStackWatcherHost host )
{
@@ -50,42 +50,6 @@ public class ItemWatcher implements IStackWatcher
return this.myObject;
}
@Override
public int size()
{
return this.myInterests.size();
}
@Override
public boolean isEmpty()
{
return this.myInterests.isEmpty();
}
@Override
public boolean contains( final Object o )
{
return this.myInterests.contains( o );
}
@Override
public Iterator<IAEStack> iterator()
{
return new ItemWatcherIterator( this, this.myInterests.iterator() );
}
@Override
public Object[] toArray()
{
return this.myInterests.toArray();
}
@Override
public <T> T[] toArray( final T[] a )
{
return this.myInterests.toArray( a );
}
@Override
public boolean add( final IAEStack e )
{
@@ -98,100 +62,20 @@ public class ItemWatcher implements IStackWatcher
}
@Override
public boolean remove( final Object o )
public boolean remove( final IAEStack o )
{
return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( (IAEStack) o, this );
}
@Override
public boolean containsAll( final Collection<?> c )
{
return this.myInterests.containsAll( c );
}
@Override
public boolean addAll( final Collection<? extends IAEStack> c )
{
boolean didChange = false;
for( final IAEStack o : c )
{
didChange = this.add( o ) || didChange;
}
return didChange;
}
@Override
public boolean removeAll( final Collection<?> c )
{
boolean didSomething = false;
for( final Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@Override
public boolean retainAll( final Collection<?> c )
{
boolean changed = false;
final Iterator<IAEStack> i = this.iterator();
while( i.hasNext() )
{
if( !c.contains( i.next() ) )
{
i.remove();
changed = true;
}
}
return changed;
}
@Override
public void clear()
public void reset()
{
final Iterator<IAEStack> i = this.myInterests.iterator();
while( i.hasNext() )
{
this.gsc.getInterestManager().remove( i.next(), this );
i.remove();
}
}
private class ItemWatcherIterator implements Iterator<IAEStack>
{
private final ItemWatcher watcher;
private final Iterator<IAEStack> interestIterator;
private IAEStack myLast;
public ItemWatcherIterator( final ItemWatcher parent, final Iterator<IAEStack> i )
{
this.watcher = parent;
this.interestIterator = i;
}
@Override
public boolean hasNext()
{
return this.interestIterator.hasNext();
}
@Override
public IAEStack next()
{
return this.myLast = this.interestIterator.next();
}
@Override
public void remove()
{
ItemWatcher.this.gsc.getInterestManager().remove( this.myLast, this.watcher );
this.interestIterator.remove();
}
}
}
@@ -25,6 +25,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
+80
View File
@@ -0,0 +1,80 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.util.ResourceLocation;
import appeng.api.parts.IPartModel;
public class PartModel implements IPartModel
{
private final boolean isSolid;
private final List<ResourceLocation> resources;
public PartModel( ResourceLocation resource )
{
this( true, resource );
}
public PartModel( ResourceLocation... resources )
{
this( true, resources );
}
public PartModel( boolean isSolid, ResourceLocation resource )
{
this( isSolid, ImmutableList.of( resource ) );
}
public PartModel( boolean isSolid, ResourceLocation... resources )
{
this( isSolid, ImmutableList.copyOf( resources ) );
}
public PartModel( List<ResourceLocation> resources )
{
this( true, resources );
}
public PartModel( boolean isSolid, List<ResourceLocation> resources )
{
this.isSolid = isSolid;
this.resources = resources;
}
@Override
public boolean requireCableConnection()
{
return this.isSolid;
}
@Override
public List<ResourceLocation> getModels()
{
return this.resources;
}
}
@@ -31,7 +31,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -53,6 +52,7 @@ import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
@@ -74,7 +74,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
private static final PlaneModels MODELS = new PlaneModels( "part/annihilation_plane_", "part/annihilation_plane_on_" );
@PartModels
public static List<ResourceLocation> getModels()
public static List<IPartModel> getModels()
{
return MODELS.getModels();
}
@@ -233,8 +233,9 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
boolean capture = false;
final BlockPos pos = this.getTile().getPos();
// This is the middle point of the entities BB, which is better suited for comparisons that don't rely on it "touching" the plane
double posYMiddle = (entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY) / 2.0D;
// This is the middle point of the entities BB, which is better suited for comparisons that don't rely on it
// "touching" the plane
double posYMiddle = ( entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY ) / 2.0D;
switch( this.getSide() )
{
@@ -244,7 +245,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
if( entity.posZ > pos.getZ() && entity.posZ < pos.getZ() + 1 )
{
if( ( entity.posY > pos.getY() + 0.9 && this.getSide() == AEPartLocation.UP ) || ( entity.posY < pos.getY() + 0.1 && this.getSide() == AEPartLocation.DOWN ) )
if( ( entity.posY > pos.getY() + 0.9 && this.getSide() == AEPartLocation.UP ) || ( entity.posY < pos.getY() + 0.1 && this
.getSide() == AEPartLocation.DOWN ) )
{
capture = true;
}
@@ -257,7 +259,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
if( posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1 )
{
if( ( entity.posZ > pos.getZ() + 0.9 && this.getSide() == AEPartLocation.SOUTH ) || ( entity.posZ < pos.getZ() + 0.1 && this.getSide() == AEPartLocation.NORTH ) )
if( ( entity.posZ > pos.getZ() + 0.9 && this.getSide() == AEPartLocation.SOUTH ) || ( entity.posZ < pos.getZ() + 0.1 && this
.getSide() == AEPartLocation.NORTH ) )
{
capture = true;
}
@@ -270,7 +273,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
if( posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1 )
{
if( ( entity.posX > pos.getX() + 0.9 && this.getSide() == AEPartLocation.EAST ) || ( entity.posX < pos.getX() + 0.1 && this.getSide() == AEPartLocation.WEST ) )
if( ( entity.posX > pos.getX() + 0.9 && this.getSide() == AEPartLocation.EAST ) || ( entity.posX < pos.getX() + 0.1 && this
.getSide() == AEPartLocation.WEST ) )
{
capture = true;
}
@@ -288,7 +292,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
if( changed )
{
ServerHelper.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(), new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.getSide(), false ) );
ServerHelper.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(),
new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.getSide(), false ) );
}
}
}
@@ -452,7 +457,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
energy.extractAEPower( requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.breakBlockAndStoreItems( w, pos, items );
ServerHelper.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w, new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
ServerHelper.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w,
new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
}
else
{
@@ -500,9 +506,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
final Material material = state.getMaterial();
final float hardness = state.getBlockHardness( w, pos );
final boolean ignoreMaterials = material == Material.AIR || material == Material.LAVA || material == Material.WATER || material.isLiquid();
final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL || state.getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK;
final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL || state
.getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK;
return !ignoreMaterials && !ignoreBlocks && !w.isAirBlock( pos ) && w.isBlockLoaded( pos ) && w.canMineBlockBody( Platform.getPlayer( w ), pos ) && hardness >= 0f;
return !ignoreMaterials && !ignoreBlocks && hardness >= 0f && !w.isAirBlock( pos ) && w.isBlockLoaded( pos ) && w.canMineBlockBody(
Platform.getPlayer( w ),
pos );
}
protected List<ItemStack> obtainBlockDrops( final WorldServer w, final BlockPos pos )
@@ -568,7 +577,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
w.setBlockToAir( pos );
final AxisAlignedBB box = new AxisAlignedBB( pos.getX() - 0.2, pos.getY() - 0.2, pos.getZ() - 0.2, pos.getX() + 1.2, pos.getY() + 1.2, pos.getZ() + 1.2 );
final AxisAlignedBB box = new AxisAlignedBB( pos.getX() - 0.2, pos.getY() - 0.2, pos.getZ() - 0.2, pos.getX() + 1.2, pos.getY() + 1.2, pos
.getZ() + 1.2 );
for( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) )
{
if( ei instanceof EntityItem )
@@ -586,7 +596,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
return MODELS.getModel( getConnections(), isPowered(), isActive() );
}
@@ -19,8 +19,6 @@
package appeng.parts.automation;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -49,6 +47,7 @@ import appeng.api.networking.security.MachineSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
@@ -61,6 +60,7 @@ import appeng.helpers.MultiCraftingTracker;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.parts.PartModel;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
@@ -70,22 +70,16 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/export_bus_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/export_bus_off" )
);
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_off" ) );
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/export_bus_on" )
);
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_on" ) );
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/export_bus_has_channel" )
);
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_has_channel" ) );
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 );
private final BaseActionSource mySrc;
private long itemToSend = 1;
@@ -154,7 +148,8 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
{
if( this.isCraftingEnabled() )
{
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
}
continue;
}
@@ -179,7 +174,8 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
if( this.itemToSend == before && this.isCraftingEnabled() )
{
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
}
}
@@ -362,7 +358,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( isActive() && isPowered() )
{
@@ -37,7 +37,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@@ -62,6 +61,7 @@ import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartItem;
import appeng.api.parts.IPartModel;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
@@ -90,7 +90,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
private static final PlaneModels MODELS = new PlaneModels( "part/formation_plane_", "part/formation_plane_on_" );
@PartModels
public static List<ResourceLocation> getModels()
public static List<IPartModel> getModels()
{
return MODELS.getModels();
}
@@ -447,8 +447,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) )
{
if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i == Item.getItemFromBlock(
Blocks.REEDS ) ) )
if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i == Item
.getItemFromBlock(
Blocks.REEDS ) ) )
{
final EntityPlayer player = Platform.getPlayer( (WorldServer) w );
Platform.configurePlayer( player, side, this.getTile() );
@@ -614,7 +615,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
return MODELS.getModel( getConnections(), isPowered(), isActive() );
}
@@ -26,7 +26,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
@@ -34,6 +33,7 @@ import net.minecraftforge.common.util.FakePlayerFactory;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.util.AEPartLocation;
import appeng.items.parts.PartModels;
@@ -44,7 +44,7 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
private static final PlaneModels MODELS = new PlaneModels( "part/identity_annihilation_plane_", "part/identity_annihilation_plane_on_" );
@PartModels
public static List<ResourceLocation> getModels()
public static List<IPartModel> getModels()
{
return MODELS.getModels();
}
@@ -105,7 +105,7 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
return MODELS.getModel( getConnections(), isPowered(), isActive() );
}
@@ -19,10 +19,6 @@
package appeng.parts.automation;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
@@ -44,6 +40,7 @@ import appeng.api.networking.security.MachineSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
@@ -54,6 +51,7 @@ import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.parts.PartModel;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
@@ -65,21 +63,12 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/import_bus_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/import_bus_off" )
);
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_off" ) );
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/import_bus_on" )
);
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_on" ) );
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" )
);
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" ) );
private final BaseActionSource source;
private IMEInventory<IAEItemStack> destination = null;
private IAEItemStack lastItemChecked = null;
@@ -104,7 +93,8 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
return false;
}
final IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source );
final IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE,
this.source );
if( out == null )
{
return true;
@@ -173,7 +163,8 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
try
{
this.itemToSend = this.calculateItemsToSend();
this.itemToSend = Math.min( this.itemToSend, (int) ( 0.01 + this.getProxy().getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) );
this.itemToSend = Math.min( this.itemToSend,
(int) ( 0.01 + this.getProxy().getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) );
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getItemInventory();
final IEnergyGrid energy = this.getProxy().getEnergy();
@@ -235,7 +226,8 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( newItems != null )
{
newItems.stackSize = (int) ( Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 );
newItems.stackSize = (int) ( Math.min( newItems.stackSize,
energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 );
this.itemToSend -= newItems.stackSize;
if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
@@ -321,7 +313,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( isActive() && isPowered() )
{
@@ -20,11 +20,8 @@ package appeng.parts.automation;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
@@ -62,6 +59,7 @@ import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
@@ -76,6 +74,7 @@ import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.parts.PartModel;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
@@ -95,12 +94,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
@PartModels
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_has_channel" );
public static final List<ResourceLocation> MODEL_OFF_OFF = ImmutableList.of( MODEL_BASE_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODEL_OFF_ON = ImmutableList.of( MODEL_BASE_OFF, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODEL_OFF_HAS_CHANNEL = ImmutableList.of( MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL );
public static final List<ResourceLocation> MODEL_ON_OFF = ImmutableList.of( MODEL_BASE_ON, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODEL_ON_ON = ImmutableList.of( MODEL_BASE_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODEL_ON_HAS_CHANNEL = ImmutableList.of( MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL );
public static final PartModel MODEL_OFF_OFF = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_OFF );
public static final PartModel MODEL_OFF_ON = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_ON );
public static final PartModel MODEL_OFF_HAS_CHANNEL = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL );
public static final PartModel MODEL_ON_OFF = new PartModel( MODEL_BASE_ON, MODEL_STATUS_OFF );
public static final PartModel MODEL_ON_ON = new PartModel( MODEL_BASE_ON, MODEL_STATUS_ON );
public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel( MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL );
private static final int FLAG_ON = 4;
@@ -229,17 +228,17 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
if( this.myWatcher != null )
{
this.myWatcher.clear();
this.myWatcher.reset();
}
if( this.myEnergyWatcher != null )
{
this.myEnergyWatcher.clear();
this.myEnergyWatcher.reset();
}
if( this.myCraftingWatcher != null )
{
this.myCraftingWatcher.clear();
this.myCraftingWatcher.reset();
}
try
@@ -445,7 +444,8 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
final double d1 = d.yOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
final double d2 = d.zOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
world.spawnParticle( EnumParticleTypes.REDSTONE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D, new int[0] );
world.spawnParticle( EnumParticleTypes.REDSTONE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D,
new int[0] );
}
}
@@ -561,7 +561,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( isActive() && isPowered() )
{

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