pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
@@ -41,165 +40,136 @@ import appeng.me.storage.ITickingMonitor;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
|
||||
class CondenserItemInventory implements IMEMonitor<IAEItemStack>, ITickingMonitor {
|
||||
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
||||
private final TileCondenser target;
|
||||
private boolean hasChanged = true;
|
||||
private final ItemList cachedList = new ItemList();
|
||||
private IActionSource actionSource = new BaseActionSource();
|
||||
private ItemList changeSet = new ItemList();
|
||||
|
||||
class CondenserItemInventory implements IMEMonitor<IAEItemStack>, ITickingMonitor
|
||||
{
|
||||
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
||||
private final TileCondenser target;
|
||||
private boolean hasChanged = true;
|
||||
private final ItemList cachedList = new ItemList();
|
||||
private IActionSource actionSource = new BaseActionSource();
|
||||
private ItemList changeSet = new ItemList();
|
||||
CondenserItemInventory(final TileCondenser te) {
|
||||
this.target = te;
|
||||
}
|
||||
|
||||
CondenserItemInventory( final TileCondenser te )
|
||||
{
|
||||
this.target = te;
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode, final IActionSource src) {
|
||||
if (mode == Actionable.MODULATE && input != null) {
|
||||
this.target.addPower(input.getStackSize());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.MODULATE && input != null )
|
||||
{
|
||||
this.target.addPower( input.getStackSize() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) {
|
||||
AEItemStack ret = null;
|
||||
ItemStack slotItem = this.target.getOutputSlot().getStackInSlot(0);
|
||||
if (!slotItem.isEmpty() && request.isSameType(slotItem)) {
|
||||
int count = (int) Math.min(request.getStackSize(), Integer.MAX_VALUE);
|
||||
ret = AEItemStack
|
||||
.fromItemStack(this.target.getOutputSlot().extractItem(0, count, mode == Actionable.SIMULATE));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
AEItemStack ret = null;
|
||||
ItemStack slotItem = this.target.getOutputSlot().getStackInSlot( 0 );
|
||||
if( !slotItem.isEmpty() && request.isSameType( slotItem ) )
|
||||
{
|
||||
int count = (int) Math.min( request.getStackSize(), Integer.MAX_VALUE );
|
||||
ret = AEItemStack.fromItemStack( this.target.getOutputSlot().extractItem( 0, count, mode == Actionable.SIMULATE ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(final IItemList<IAEItemStack> out) {
|
||||
if (!this.target.getOutputSlot().getStackInSlot(0).isEmpty()) {
|
||||
out.add(AEItemStack.fromItemStack(this.target.getOutputSlot().getStackInSlot(0)));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems( final IItemList<IAEItemStack> out )
|
||||
{
|
||||
if( !this.target.getOutputSlot().getStackInSlot( 0 ).isEmpty() )
|
||||
{
|
||||
out.add( AEItemStack.fromItemStack( this.target.getOutputSlot().getStackInSlot( 0 ) ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList() {
|
||||
if (this.hasChanged) {
|
||||
this.hasChanged = false;
|
||||
this.cachedList.resetStatus();
|
||||
return this.getAvailableItems(this.cachedList);
|
||||
}
|
||||
return this.cachedList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList()
|
||||
{
|
||||
if( this.hasChanged )
|
||||
{
|
||||
this.hasChanged = false;
|
||||
this.cachedList.resetStatus();
|
||||
return this.getAvailableItems( this.cachedList );
|
||||
}
|
||||
return this.cachedList;
|
||||
}
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel() {
|
||||
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
@Override
|
||||
public AccessRestriction getAccess() {
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getAccess()
|
||||
{
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
@Override
|
||||
public boolean isPrioritized(final IAEItemStack input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized( final IAEItemStack input )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canAccept(final IAEItemStack input) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept( final IAEItemStack input )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlot() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean validForPass(final int i) {
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validForPass( final int i )
|
||||
{
|
||||
return i == 2;
|
||||
}
|
||||
@Override
|
||||
public void addListener(final IMEMonitorHandlerReceiver<IAEItemStack> l, final Object verificationToken) {
|
||||
this.listeners.put(l, verificationToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( final IMEMonitorHandlerReceiver<IAEItemStack> l, final Object verificationToken )
|
||||
{
|
||||
this.listeners.put( l, verificationToken );
|
||||
}
|
||||
@Override
|
||||
public void removeListener(final IMEMonitorHandlerReceiver<IAEItemStack> l) {
|
||||
this.listeners.remove(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( final IMEMonitorHandlerReceiver<IAEItemStack> l )
|
||||
{
|
||||
this.listeners.remove( l );
|
||||
}
|
||||
public void updateOutput(ItemStack added, ItemStack removed) {
|
||||
this.hasChanged = true;
|
||||
if (!added.isEmpty()) {
|
||||
this.changeSet.add(AEItemStack.fromItemStack(added));
|
||||
}
|
||||
if (!removed.isEmpty()) {
|
||||
this.changeSet.add(AEItemStack.fromItemStack(removed).setStackSize(-removed.getCount()));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateOutput( ItemStack added, ItemStack removed )
|
||||
{
|
||||
this.hasChanged = true;
|
||||
if( !added.isEmpty() )
|
||||
{
|
||||
this.changeSet.add( AEItemStack.fromItemStack( added ) );
|
||||
}
|
||||
if( !removed.isEmpty() )
|
||||
{
|
||||
this.changeSet.add( AEItemStack.fromItemStack( removed ).setStackSize( -removed.getCount() ) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public TickRateModulation onTick() {
|
||||
final ItemList currentChanges = this.changeSet;
|
||||
|
||||
@Override
|
||||
public TickRateModulation onTick()
|
||||
{
|
||||
final ItemList currentChanges = this.changeSet;
|
||||
if (currentChanges.isEmpty()) {
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
if( currentChanges.isEmpty() )
|
||||
{
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
this.changeSet = new ItemList();
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
final Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
|
||||
final IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
|
||||
if (key.isValid(l.getValue())) {
|
||||
key.postChange(this, currentChanges, this.actionSource);
|
||||
} else {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
this.changeSet = new ItemList();
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
final Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
|
||||
final IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
|
||||
if( key.isValid( l.getValue() ) )
|
||||
{
|
||||
key.postChange( this, currentChanges, this.actionSource );
|
||||
}
|
||||
else
|
||||
{
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActionSource( IActionSource actionSource )
|
||||
{
|
||||
this.actionSource = actionSource;
|
||||
}
|
||||
@Override
|
||||
public void setActionSource(IActionSource actionSource) {
|
||||
this.actionSource = actionSource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
@@ -28,103 +27,86 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
class CondenserVoidInventory<T extends IAEStack<T>> implements IMEMonitor<T> {
|
||||
|
||||
class CondenserVoidInventory<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
{
|
||||
private final TileCondenser target;
|
||||
private final IStorageChannel<T> channel;
|
||||
|
||||
private final TileCondenser target;
|
||||
private final IStorageChannel<T> channel;
|
||||
CondenserVoidInventory(final TileCondenser te, final IStorageChannel<T> channel) {
|
||||
this.target = te;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
CondenserVoidInventory( final TileCondenser te, final IStorageChannel<T> channel )
|
||||
{
|
||||
this.target = te;
|
||||
this.channel = channel;
|
||||
}
|
||||
@Override
|
||||
public T injectItems(final T input, final Actionable mode, final IActionSource src) {
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems( final T input, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (input != null) {
|
||||
this.target.addPower(input.getStackSize() / (double) this.channel.transferFactor());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if( input != null )
|
||||
{
|
||||
this.target.addPower( input.getStackSize() / (double) this.channel.transferFactor() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public T extractItems(final T request, final Actionable mode, final IActionSource src) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems( final T request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems(final IItemList<T> out) {
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems( final IItemList<T> out )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
@Override
|
||||
public IItemList<T> getStorageList() {
|
||||
return this.channel.createList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<T> getStorageList()
|
||||
{
|
||||
return this.channel.createList();
|
||||
}
|
||||
@Override
|
||||
public IStorageChannel<T> getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<T> getChannel()
|
||||
{
|
||||
return this.channel;
|
||||
}
|
||||
@Override
|
||||
public AccessRestriction getAccess() {
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getAccess()
|
||||
{
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
@Override
|
||||
public boolean isPrioritized(final T input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized( final T input )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canAccept(final T input) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept( final T input )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlot() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean validForPass(final int i) {
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validForPass( final int i )
|
||||
{
|
||||
return i == 2;
|
||||
}
|
||||
@Override
|
||||
public void addListener(IMEMonitorHandlerReceiver<T> l, Object verificationToken) {
|
||||
// Not implemented since the Condenser automatically voids everything, and there
|
||||
// are no updates
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( IMEMonitorHandlerReceiver<T> l, Object verificationToken )
|
||||
{
|
||||
// Not implemented since the Condenser automatically voids everything, and there are no updates
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( IMEMonitorHandlerReceiver<T> l )
|
||||
{
|
||||
// Not implemented since we don't remember registered listeners anyway
|
||||
}
|
||||
@Override
|
||||
public void removeListener(IMEMonitorHandlerReceiver<T> l) {
|
||||
// Not implemented since we don't remember registered listeners anyway
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@@ -14,12 +14,16 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
|
||||
/**
|
||||
* This class indexes all inscriber recipes to find valid inputs for the top and bottom
|
||||
* optional slots. This speeds up checks whether inputs for those two slots are valid.
|
||||
* This class indexes all inscriber recipes to find valid inputs for the top and
|
||||
* bottom optional slots. This speeds up checks whether inputs for those two
|
||||
* slots are valid.
|
||||
*/
|
||||
public final class InscriberRecipes {
|
||||
|
||||
@@ -32,12 +36,14 @@ public final class InscriberRecipes {
|
||||
* Returns an unmodifiable view of all registered inscriber recipes.
|
||||
*/
|
||||
public static Iterable<InscriberRecipe> getRecipes(World world) {
|
||||
Collection<IRecipe<IInventory>> unfilteredRecipes = world.getRecipeManager().getRecipes(InscriberRecipe.TYPE).values();
|
||||
Collection<IRecipe<IInventory>> unfilteredRecipes = world.getRecipeManager().getRecipes(InscriberRecipe.TYPE)
|
||||
.values();
|
||||
return Iterables.filter(unfilteredRecipes, InscriberRecipe.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static InscriberRecipe findRecipe(World world, ItemStack input, ItemStack plateA, ItemStack plateB, boolean supportNamePress) {
|
||||
public static InscriberRecipe findRecipe(World world, ItemStack input, ItemStack plateA, ItemStack plateB,
|
||||
boolean supportNamePress) {
|
||||
if (supportNamePress) {
|
||||
IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress();
|
||||
boolean isNameA = namePress.isSameAs(plateA);
|
||||
@@ -50,14 +56,12 @@ public final class InscriberRecipes {
|
||||
}
|
||||
}
|
||||
|
||||
for( final InscriberRecipe recipe : getRecipes(world) )
|
||||
{
|
||||
for (final InscriberRecipe recipe : getRecipes(world)) {
|
||||
// The recipe can be flipped at will
|
||||
final boolean matchA = recipe.getTopOptional().test(plateA) && recipe.getBottomOptional().test(plateB);
|
||||
final boolean matchB = recipe.getTopOptional().test(plateB) && recipe.getBottomOptional().test(plateA);
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
if (matchA || matchB) {
|
||||
if (recipe.getMiddleInput().test(input)) {
|
||||
return recipe;
|
||||
}
|
||||
@@ -67,57 +71,45 @@ public final class InscriberRecipes {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static InscriberRecipe makeNamePressRecipe( ItemStack input, ItemStack plateA, ItemStack plateB )
|
||||
{
|
||||
private static InscriberRecipe makeNamePressRecipe(ItemStack input, ItemStack plateA, ItemStack plateB) {
|
||||
String name = "";
|
||||
|
||||
if( !plateA.isEmpty() )
|
||||
{
|
||||
if (!plateA.isEmpty()) {
|
||||
final CompoundNBT tag = plateA.getOrCreateTag();
|
||||
name += tag.getString( "InscribeName" );
|
||||
name += tag.getString("InscribeName");
|
||||
}
|
||||
|
||||
if( !plateB.isEmpty() )
|
||||
{
|
||||
if (!plateB.isEmpty()) {
|
||||
final CompoundNBT tag = plateB.getOrCreateTag();
|
||||
name += " " + tag.getString( "InscribeName" );
|
||||
name += " " + tag.getString("InscribeName");
|
||||
}
|
||||
|
||||
final Ingredient startingItem = Ingredient.fromStacks(input.copy());
|
||||
final ItemStack renamedItem = input.copy();
|
||||
|
||||
final CompoundNBT display = renamedItem.getOrCreateChildTag( "display" );
|
||||
if( !name.isEmpty() )
|
||||
{
|
||||
final CompoundNBT display = renamedItem.getOrCreateChildTag("display");
|
||||
if (!name.isEmpty()) {
|
||||
display.putString("Name", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
display.remove( "Name" );
|
||||
} else {
|
||||
display.remove("Name");
|
||||
}
|
||||
|
||||
final InscriberProcessType type = InscriberProcessType.INSCRIBE;
|
||||
|
||||
return new InscriberRecipe(
|
||||
NAMEPLATE_RECIPE_ID,
|
||||
"",
|
||||
startingItem,
|
||||
renamedItem,
|
||||
return new InscriberRecipe(NAMEPLATE_RECIPE_ID, "", startingItem, renamedItem,
|
||||
plateA.isEmpty() ? Ingredient.EMPTY : Ingredient.fromStacks(plateA),
|
||||
plateB.isEmpty() ? Ingredient.EMPTY : Ingredient.fromStacks(plateB),
|
||||
type
|
||||
);
|
||||
plateB.isEmpty() ? Ingredient.EMPTY : Ingredient.fromStacks(plateB), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is an inscriber recipe that supports the given combination of top/bottom presses.
|
||||
* Both the given combination and the reverse will be searched.
|
||||
* Checks if there is an inscriber recipe that supports the given combination of
|
||||
* top/bottom presses. Both the given combination and the reverse will be
|
||||
* searched.
|
||||
*/
|
||||
public static boolean isValidOptionalIngredientCombination(World world, ItemStack pressA, ItemStack pressB) {
|
||||
for (InscriberRecipe recipe : getRecipes(world)) {
|
||||
if (recipe.getTopOptional().test(pressA) && recipe.getBottomOptional().test(pressB)
|
||||
|| recipe.getTopOptional().test(pressB) && recipe.getBottomOptional().test(pressA))
|
||||
{
|
||||
|| recipe.getTopOptional().test(pressB) && recipe.getBottomOptional().test(pressA)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -126,14 +118,13 @@ public final class InscriberRecipes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is an inscriber recipe that would use the given item stack as an optional ingredient.
|
||||
* Bottom and top can be used interchangeably here, because the inscriber will flip the recipe if needed.
|
||||
* Checks if there is an inscriber recipe that would use the given item stack as
|
||||
* an optional ingredient. Bottom and top can be used interchangeably here,
|
||||
* because the inscriber will flip the recipe if needed.
|
||||
*/
|
||||
public static boolean isValidOptionalIngredient(World world, ItemStack is) {
|
||||
for (InscriberRecipe recipe : getRecipes(world)) {
|
||||
if (recipe.getTopOptional().test(is)
|
||||
|| recipe.getBottomOptional().test(is))
|
||||
{
|
||||
if (recipe.getTopOptional().test(is) || recipe.getBottomOptional().test(is)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -43,215 +42,176 @@ import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost {
|
||||
|
||||
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost
|
||||
{
|
||||
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 63);
|
||||
private final ConfigManager manager = new ConfigManager(this);
|
||||
|
||||
private final AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 );
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
|
||||
private final ConfigManager manager = new ConfigManager( this );
|
||||
private IItemHandler cacheUpgrades = null;
|
||||
private IItemHandler cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
|
||||
private IItemHandler cacheUpgrades = null;
|
||||
private IItemHandler cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
public TileCellWorkbench(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.manager.registerSetting(Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE);
|
||||
this.cell.setEnableClientEvents(true);
|
||||
}
|
||||
|
||||
public TileCellWorkbench(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.manager.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.setEnableClientEvents( true );
|
||||
}
|
||||
public IItemHandler getCellUpgradeInventory() {
|
||||
if (this.cacheUpgrades == null) {
|
||||
final ICellWorkbenchItem cell = this.getCell();
|
||||
if (cell == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IItemHandler getCellUpgradeInventory()
|
||||
{
|
||||
if( this.cacheUpgrades == null )
|
||||
{
|
||||
final ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final ItemStack is = this.cell.getStackInSlot(0);
|
||||
if (is.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final IItemHandler inv = cell.getUpgradesInventory(is);
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final IItemHandler inv = cell.getUpgradesInventory( is );
|
||||
if( inv == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.cacheUpgrades = inv;
|
||||
}
|
||||
return this.cacheUpgrades;
|
||||
}
|
||||
|
||||
return this.cacheUpgrades = inv;
|
||||
}
|
||||
return this.cacheUpgrades;
|
||||
}
|
||||
public ICellWorkbenchItem getCell() {
|
||||
if (this.cell.getStackInSlot(0).isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if( this.cell.getStackInSlot( 0 ).isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (this.cell.getStackInSlot(0).getItem() instanceof ICellWorkbenchItem) {
|
||||
return ((ICellWorkbenchItem) this.cell.getStackInSlot(0).getItem());
|
||||
}
|
||||
|
||||
if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
{
|
||||
return( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
this.cell.writeToNBT(data, "cell");
|
||||
this.config.writeToNBT(data, "config");
|
||||
this.manager.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.manager.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.cell.readFromNBT(data, "cell");
|
||||
this.config.readFromNBT(data, "config");
|
||||
this.manager.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.manager.readFromNBT( data );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
if (name.equals("cell")) {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
if( name.equals( "cell" ) )
|
||||
{
|
||||
return this.cell;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int getInstalledUpgrades(final Upgrades u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( final Upgrades u )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == this.cell && !this.locked) {
|
||||
this.locked = true;
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if( inv == this.cell && !this.locked )
|
||||
{
|
||||
this.locked = true;
|
||||
this.cacheUpgrades = null;
|
||||
this.cacheConfig = null;
|
||||
|
||||
this.cacheUpgrades = null;
|
||||
this.cacheConfig = null;
|
||||
final IItemHandler configInventory = this.getCellConfigInventory();
|
||||
if (configInventory != null) {
|
||||
boolean cellHasConfig = false;
|
||||
for (int x = 0; x < configInventory.getSlots(); x++) {
|
||||
if (!configInventory.getStackInSlot(x).isEmpty()) {
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final IItemHandler configInventory = this.getCellConfigInventory();
|
||||
if( configInventory != null )
|
||||
{
|
||||
boolean cellHasConfig = false;
|
||||
for( int x = 0; x < configInventory.getSlots(); x++ )
|
||||
{
|
||||
if( !configInventory.getStackInSlot( x ).isEmpty() )
|
||||
{
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cellHasConfig) {
|
||||
for (int x = 0; x < this.config.getSlots(); x++) {
|
||||
this.config.setStackInSlot(x, configInventory.getStackInSlot(x));
|
||||
}
|
||||
} else {
|
||||
ItemHandlerUtil.copy(this.config, configInventory, false);
|
||||
}
|
||||
} else if (this.manager.getSetting(Settings.COPY_MODE) == CopyMode.CLEAR_ON_REMOVE) {
|
||||
for (int x = 0; x < this.config.getSlots(); x++) {
|
||||
this.config.setStackInSlot(x, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
if( cellHasConfig )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSlots(); x++ )
|
||||
{
|
||||
this.config.setStackInSlot( x, configInventory.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.copy( this.config, configInventory, false );
|
||||
}
|
||||
}
|
||||
else if( this.manager.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSlots(); x++ )
|
||||
{
|
||||
this.config.setStackInSlot( x, ItemStack.EMPTY );
|
||||
}
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
this.saveChanges();
|
||||
}
|
||||
this.locked = false;
|
||||
} else if (inv == this.config && !this.locked) {
|
||||
this.locked = true;
|
||||
final IItemHandler c = this.getCellConfigInventory();
|
||||
if (c != null) {
|
||||
ItemHandlerUtil.copy(this.config, c, false);
|
||||
// copy items back. The ConfigInventory may changed the items on insert
|
||||
ItemHandlerUtil.copy(c, this.config, false);
|
||||
}
|
||||
this.locked = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.locked = false;
|
||||
}
|
||||
else if( inv == this.config && !this.locked )
|
||||
{
|
||||
this.locked = true;
|
||||
final IItemHandler c = this.getCellConfigInventory();
|
||||
if( c != null )
|
||||
{
|
||||
ItemHandlerUtil.copy( this.config, c, false );
|
||||
// copy items back. The ConfigInventory may changed the items on insert
|
||||
ItemHandlerUtil.copy( c, this.config, false );
|
||||
}
|
||||
this.locked = false;
|
||||
}
|
||||
}
|
||||
private IItemHandler getCellConfigInventory() {
|
||||
if (this.cacheConfig == null) {
|
||||
final ICellWorkbenchItem cell = this.getCell();
|
||||
if (cell == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private IItemHandler getCellConfigInventory()
|
||||
{
|
||||
if( this.cacheConfig == null )
|
||||
{
|
||||
final ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final ItemStack is = this.cell.getStackInSlot(0);
|
||||
if (is.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final IItemHandler inv = cell.getConfigInventory(is);
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final IItemHandler inv = cell.getConfigInventory( is );
|
||||
if( inv == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
}
|
||||
|
||||
this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
}
|
||||
@Override
|
||||
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
|
||||
super.getDrops(w, pos, drops);
|
||||
|
||||
@Override
|
||||
public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
|
||||
{
|
||||
super.getDrops( w, pos, drops );
|
||||
if (this.cell.getStackInSlot(0) != null) {
|
||||
drops.add(this.cell.getStackInSlot(0));
|
||||
}
|
||||
}
|
||||
|
||||
if( this.cell.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
drops.add( this.cell.getStackInSlot( 0 ) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
|
||||
{
|
||||
// nothing here..
|
||||
}
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
// nothing here..
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -56,262 +55,222 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class TileCharger extends AENetworkPowerTile implements ICrankable, IGridTickable {
|
||||
private static final int POWER_MAXIMUM_AMOUNT = 1600;
|
||||
private static final int POWER_THRESHOLD = POWER_MAXIMUM_AMOUNT - 1;
|
||||
private static final int POWER_PER_CRANK_TURN = 160;
|
||||
|
||||
public class TileCharger extends AENetworkPowerTile implements ICrankable, IGridTickable
|
||||
{
|
||||
private static final int POWER_MAXIMUM_AMOUNT = 1600;
|
||||
private static final int POWER_THRESHOLD = POWER_MAXIMUM_AMOUNT - 1;
|
||||
private static final int POWER_PER_CRANK_TURN = 160;
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1, 1, new ChargerInvFilter());
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1, 1, new ChargerInvFilter() );
|
||||
public TileCharger(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
|
||||
this.getProxy().setFlags();
|
||||
this.setInternalMaxPower(POWER_MAXIMUM_AMOUNT);
|
||||
this.getProxy().setIdlePowerUsage(0);
|
||||
}
|
||||
|
||||
public TileCharger(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.getProxy().setFlags();
|
||||
this.setInternalMaxPower( POWER_MAXIMUM_AMOUNT );
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
try {
|
||||
final IAEItemStack item = AEItemStack.fromPacket(data);
|
||||
final ItemStack is = item.createItemStack();
|
||||
this.inv.setStackInSlot(0, is);
|
||||
} catch (final Throwable t) {
|
||||
this.inv.setStackInSlot(0, ItemStack.EMPTY);
|
||||
}
|
||||
return c; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
try
|
||||
{
|
||||
final IAEItemStack item = AEItemStack.fromPacket( data );
|
||||
final ItemStack is = item.createItemStack();
|
||||
this.inv.setStackInSlot( 0, is );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
this.inv.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
}
|
||||
return c; // TESR doesn't need updates!
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
final AEItemStack is = AEItemStack.fromItemStack(this.inv.getStackInSlot(0));
|
||||
if (is != null) {
|
||||
is.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
final AEItemStack is = AEItemStack.fromItemStack( this.inv.getStackInSlot( 0 ) );
|
||||
if( is != null )
|
||||
{
|
||||
is.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setOrientation(final Direction inForward, final Direction inUp) {
|
||||
super.setOrientation(inForward, inUp);
|
||||
this.getProxy().setValidSides(EnumSet.of(this.getUp(), this.getUp().getOpposite()));
|
||||
this.setPowerSides(EnumSet.of(this.getUp(), this.getUp().getOpposite()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation( final Direction inForward, final Direction inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.getProxy().setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
this.setPowerSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
}
|
||||
@Override
|
||||
public boolean canTurn() {
|
||||
return this.getInternalCurrentPower() < this.getInternalMaxPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTurn()
|
||||
{
|
||||
return this.getInternalCurrentPower() < this.getInternalMaxPower();
|
||||
}
|
||||
@Override
|
||||
public void applyTurn() {
|
||||
this.injectExternalPower(PowerUnits.AE, POWER_PER_CRANK_TURN, Actionable.MODULATE);
|
||||
|
||||
@Override
|
||||
public void applyTurn()
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.AE, POWER_PER_CRANK_TURN, Actionable.MODULATE );
|
||||
final ItemStack myItem = this.inv.getStackInSlot(0);
|
||||
if (this.getInternalCurrentPower() > POWER_THRESHOLD) {
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
final ItemStack myItem = this.inv.getStackInSlot( 0 );
|
||||
if( this.getInternalCurrentPower() > POWER_THRESHOLD )
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
if (materials.certusQuartzCrystal().isSameAs(myItem)) {
|
||||
this.extractAEPower(this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
|
||||
if( materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
materials.certusQuartzCrystalCharged().maybeStack(myItem.getCount())
|
||||
.ifPresent(charged -> this.inv.setStackInSlot(0, charged));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.getCount() ).ifPresent( charged -> this.inv.setStackInSlot( 0, charged ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canCrankAttach(final Direction directionToCrank) {
|
||||
return this.getUp() == directionToCrank || this.getUp().getOpposite() == directionToCrank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCrankAttach( final Direction directionToCrank )
|
||||
{
|
||||
return this.getUp() == directionToCrank || this.getUp().getOpposite() == directionToCrank;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
try {
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
}
|
||||
public void activate(final PlayerEntity player) {
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(this), player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void activate( final PlayerEntity player )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( this ), player ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ItemStack myItem = this.inv.getStackInSlot(0);
|
||||
if (myItem.isEmpty()) {
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
|
||||
final ItemStack myItem = this.inv.getStackInSlot( 0 );
|
||||
if( myItem.isEmpty() )
|
||||
{
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
if (AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs(held)
|
||||
|| Platform.isChargeable(held)) {
|
||||
held = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
this.inv.setStackInSlot(0, held);
|
||||
}
|
||||
} else {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add(myItem);
|
||||
this.inv.setStackInSlot(0, ItemStack.EMPTY);
|
||||
Platform.spawnDrops(this.world, this.pos.offset(this.getForward()), drops);
|
||||
}
|
||||
}
|
||||
|
||||
if( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) )
|
||||
{
|
||||
held = player.inventory.decrStackSize( player.inventory.currentItem, 1 );
|
||||
this.inv.setStackInSlot( 0, held );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add( myItem );
|
||||
this.inv.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
Platform.spawnDrops( this.world, this.pos.offset( this.getForward() ), drops );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(TickRates.Charger.getMin(), TickRates.Charger.getMin(), false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.Charger.getMin(), TickRates.Charger.getMin(), false, true );
|
||||
}
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLEEP;
|
||||
}
|
||||
private boolean doWork() {
|
||||
final ItemStack myItem = this.inv.getStackInSlot(0);
|
||||
boolean changed = false;
|
||||
|
||||
private boolean doWork()
|
||||
{
|
||||
final ItemStack myItem = this.inv.getStackInSlot( 0 );
|
||||
boolean changed = false;
|
||||
if (!myItem.isEmpty()) {
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if( !myItem.isEmpty() )
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
if (Platform.isChargeable(myItem)) {
|
||||
final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
|
||||
if( Platform.isChargeable( myItem ) )
|
||||
{
|
||||
final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if (ps.getAEMaxPower(myItem) > ps.getAECurrentPower(myItem)) {
|
||||
final double chargeRate = AEApi.instance().registries().charger().getChargeRate(myItem.getItem());
|
||||
|
||||
if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
final double chargeRate = AEApi.instance().registries().charger().getChargeRate( myItem.getItem() );
|
||||
double extractedAmount = this.extractAEPower(chargeRate, Actionable.MODULATE,
|
||||
PowerMultiplier.CONFIG);
|
||||
|
||||
double extractedAmount = this.extractAEPower( chargeRate, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
final double missingChargeRate = chargeRate - extractedAmount;
|
||||
final double missingAEPower = ps.getAEMaxPower(myItem) - ps.getAECurrentPower(myItem);
|
||||
final double toExtract = Math.min(missingChargeRate, missingAEPower);
|
||||
|
||||
final double missingChargeRate = chargeRate - extractedAmount;
|
||||
final double missingAEPower = ps.getAEMaxPower( myItem ) - ps.getAECurrentPower( myItem );
|
||||
final double toExtract = Math.min( missingChargeRate, missingAEPower );
|
||||
try {
|
||||
extractedAmount += this.getProxy().getEnergy().extractAEPower(toExtract, Actionable.MODULATE,
|
||||
PowerMultiplier.ONE);
|
||||
} catch (GridAccessException e1) {
|
||||
// Ignore.
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
extractedAmount += this.getProxy().getEnergy().extractAEPower( toExtract, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
}
|
||||
catch( GridAccessException e1 )
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
if (extractedAmount > 0) {
|
||||
final double adjustment = ps.injectAEPower(myItem, extractedAmount, Actionable.MODULATE);
|
||||
|
||||
if( extractedAmount > 0 )
|
||||
{
|
||||
final double adjustment = ps.injectAEPower( myItem, extractedAmount, Actionable.MODULATE );
|
||||
this.setInternalCurrentPower(this.getInternalCurrentPower() + adjustment);
|
||||
|
||||
this.setInternalCurrentPower( this.getInternalCurrentPower() + adjustment );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (this.getInternalCurrentPower() > POWER_THRESHOLD
|
||||
&& materials.certusQuartzCrystal().isSameAs(myItem)) {
|
||||
if (Platform.getRandomFloat() > 0.8f) // simulate wait
|
||||
{
|
||||
this.extractAEPower(this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( this.getInternalCurrentPower() > POWER_THRESHOLD && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
if( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
materials.certusQuartzCrystalCharged().maybeStack(myItem.getCount())
|
||||
.ifPresent(charged -> this.inv.setStackInSlot(0, charged));
|
||||
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.getCount() ).ifPresent( charged -> this.inv.setStackInSlot( 0, charged ) );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// charge from the network!
|
||||
if (this.getInternalCurrentPower() < POWER_THRESHOLD) {
|
||||
try {
|
||||
final double toExtract = Math.min(800.0, this.getInternalMaxPower() - this.getInternalCurrentPower());
|
||||
final double extracted = this.getProxy().getEnergy().extractAEPower(toExtract, Actionable.MODULATE,
|
||||
PowerMultiplier.ONE);
|
||||
|
||||
// charge from the network!
|
||||
if( this.getInternalCurrentPower() < POWER_THRESHOLD )
|
||||
{
|
||||
try
|
||||
{
|
||||
final double toExtract = Math.min( 800.0, this.getInternalMaxPower() - this.getInternalCurrentPower() );
|
||||
final double extracted = this.getProxy().getEnergy().extractAEPower( toExtract, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
this.injectExternalPower(PowerUnits.AE, extracted, Actionable.MODULATE);
|
||||
} catch (final GridAccessException e) {
|
||||
// continue!
|
||||
}
|
||||
|
||||
this.injectExternalPower( PowerUnits.AE, extracted, Actionable.MODULATE );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// continue!
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
if( changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private class ChargerInvFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, final int i, final ItemStack itemstack) {
|
||||
final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal();
|
||||
|
||||
private class ChargerInvFilter implements IAEItemFilter
|
||||
{
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, final int i, final ItemStack itemstack )
|
||||
{
|
||||
final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal();
|
||||
return Platform.isChargeable(itemstack) || cert.isSameAs(itemstack);
|
||||
}
|
||||
|
||||
return Platform.isChargeable( itemstack ) || cert.isSameAs( itemstack );
|
||||
}
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, final int slotIndex, int amount) {
|
||||
ItemStack extractedItem = inv.getStackInSlot(slotIndex);
|
||||
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, final int slotIndex, int amount )
|
||||
{
|
||||
ItemStack extractedItem = inv.getStackInSlot( slotIndex );
|
||||
if (Platform.isChargeable(extractedItem)) {
|
||||
final IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem();
|
||||
if (ips.getAECurrentPower(extractedItem) >= ips.getAEMaxPower(extractedItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( Platform.isChargeable( extractedItem ) )
|
||||
{
|
||||
final IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem();
|
||||
if( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem );
|
||||
}
|
||||
}
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs(extractedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -62,340 +61,295 @@ import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
|
||||
public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, IConfigurableObject {
|
||||
|
||||
public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, IConfigurableObject
|
||||
{
|
||||
public static final int BYTE_MULTIPLIER = 8;
|
||||
|
||||
public static final int BYTE_MULTIPLIER = 8;
|
||||
private final ConfigManager cm = new ConfigManager(this);
|
||||
|
||||
private final ConfigManager cm = new ConfigManager( this );
|
||||
private final AppEngInternalInventory outputSlot = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory storageSlot = new AppEngInternalInventory(this, 1);
|
||||
private final IItemHandler inputSlot = new CondenseItemHandler();
|
||||
private final IFluidHandler fluidHandler = new FluidHandler();
|
||||
private final MEHandler meHandler = new MEHandler();
|
||||
|
||||
private final AppEngInternalInventory outputSlot = new AppEngInternalInventory( this, 1 );
|
||||
private final AppEngInternalInventory storageSlot = new AppEngInternalInventory( this, 1 );
|
||||
private final IItemHandler inputSlot = new CondenseItemHandler();
|
||||
private final IFluidHandler fluidHandler = new FluidHandler();
|
||||
private final MEHandler meHandler = new MEHandler();
|
||||
private final IItemHandler externalInv = new WrapperChainedItemHandler(this.inputSlot,
|
||||
new WrapperFilteredItemHandler(this.outputSlot, AEItemFilters.EXTRACT_ONLY));
|
||||
private final IItemHandler combinedInv = new WrapperChainedItemHandler(this.inputSlot, this.outputSlot,
|
||||
this.storageSlot);
|
||||
|
||||
private final IItemHandler externalInv = new WrapperChainedItemHandler( this.inputSlot, new WrapperFilteredItemHandler( this.outputSlot, AEItemFilters.EXTRACT_ONLY ) );
|
||||
private final IItemHandler combinedInv = new WrapperChainedItemHandler( this.inputSlot, this.outputSlot, this.storageSlot );
|
||||
private double storedPower = 0;
|
||||
|
||||
private double storedPower = 0;
|
||||
public TileCondenser(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.cm.registerSetting(Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH);
|
||||
}
|
||||
|
||||
public TileCondenser(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
this.cm.writeToNBT(data);
|
||||
data.putDouble("storedPower", this.getStoredPower());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.putDouble("storedPower", this.getStoredPower());
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.cm.readFromNBT(data);
|
||||
this.setStoredPower(data.getDouble("storedPower"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.cm.readFromNBT( data );
|
||||
this.setStoredPower( data.getDouble( "storedPower" ) );
|
||||
}
|
||||
public double getStorage() {
|
||||
final ItemStack is = this.storageSlot.getStackInSlot(0);
|
||||
if (!is.isEmpty()) {
|
||||
if (is.getItem() instanceof IStorageComponent) {
|
||||
final IStorageComponent sc = (IStorageComponent) is.getItem();
|
||||
if (sc.isStorageComponent(is)) {
|
||||
return sc.getBytes(is) * BYTE_MULTIPLIER;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getStorage()
|
||||
{
|
||||
final ItemStack is = this.storageSlot.getStackInSlot( 0 );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
if( is.getItem() instanceof IStorageComponent )
|
||||
{
|
||||
final IStorageComponent sc = (IStorageComponent) is.getItem();
|
||||
if( sc.isStorageComponent( is ) )
|
||||
{
|
||||
return sc.getBytes( is ) * BYTE_MULTIPLIER;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public void addPower(final double rawPower) {
|
||||
this.setStoredPower(this.getStoredPower() + rawPower);
|
||||
this.setStoredPower(Math.max(0.0, Math.min(this.getStorage(), this.getStoredPower())));
|
||||
|
||||
public void addPower( final double rawPower )
|
||||
{
|
||||
this.setStoredPower( this.getStoredPower() + rawPower );
|
||||
this.setStoredPower( Math.max( 0.0, Math.min( this.getStorage(), this.getStoredPower() ) ) );
|
||||
final double requiredPower = this.getRequiredPower();
|
||||
final ItemStack output = this.getOutput();
|
||||
while (requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0) {
|
||||
if (this.canAddOutput(output)) {
|
||||
this.setStoredPower(this.getStoredPower() - requiredPower);
|
||||
this.addOutput(output);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final double requiredPower = this.getRequiredPower();
|
||||
final ItemStack output = this.getOutput();
|
||||
while( requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0 )
|
||||
{
|
||||
if( this.canAddOutput( output ) )
|
||||
{
|
||||
this.setStoredPower( this.getStoredPower() - requiredPower );
|
||||
this.addOutput( output );
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private boolean canAddOutput(final ItemStack output) {
|
||||
return this.outputSlot.insertItem(0, output, true).isEmpty();
|
||||
}
|
||||
|
||||
private boolean canAddOutput( final ItemStack output )
|
||||
{
|
||||
return this.outputSlot.insertItem( 0, output, true ).isEmpty();
|
||||
}
|
||||
/**
|
||||
* make sure you validate with canAddOutput prior to this.
|
||||
*
|
||||
* @param output to be added output
|
||||
*/
|
||||
private void addOutput(final ItemStack output) {
|
||||
this.outputSlot.insertItem(0, output, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* make sure you validate with canAddOutput prior to this.
|
||||
*
|
||||
* @param output to be added output
|
||||
*/
|
||||
private void addOutput( final ItemStack output )
|
||||
{
|
||||
this.outputSlot.insertItem( 0, output, false );
|
||||
}
|
||||
IItemHandler getOutputSlot() {
|
||||
return this.outputSlot;
|
||||
}
|
||||
|
||||
IItemHandler getOutputSlot()
|
||||
{
|
||||
return this.outputSlot;
|
||||
}
|
||||
private ItemStack getOutput() {
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
private ItemStack getOutput()
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
switch ((CondenserOutput) this.cm.getSetting(Settings.CONDENSER_OUTPUT)) {
|
||||
case MATTER_BALLS:
|
||||
return materials.matterBall().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
|
||||
switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
return materials.matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
case SINGULARITY:
|
||||
return materials.singularity().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
|
||||
case SINGULARITY:
|
||||
return materials.singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
case TRASH:
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
case TRASH:
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
public double getRequiredPower() {
|
||||
return ((CondenserOutput) this.cm.getSetting(Settings.CONDENSER_OUTPUT)).requiredPower;
|
||||
}
|
||||
|
||||
public double getRequiredPower()
|
||||
{
|
||||
return ( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) ).requiredPower;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.combinedInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.combinedInv;
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (inv == this.outputSlot) {
|
||||
this.meHandler.outputChanged(added, removed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
if( inv == this.outputSlot )
|
||||
{
|
||||
this.meHandler.outputChanged( added, removed );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
this.addPower(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
|
||||
{
|
||||
this.addPower( 0 );
|
||||
}
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.cm;
|
||||
}
|
||||
public double getStoredPower() {
|
||||
return this.storedPower;
|
||||
}
|
||||
|
||||
public double getStoredPower()
|
||||
{
|
||||
return this.storedPower;
|
||||
}
|
||||
private void setStoredPower(final double storedPower) {
|
||||
this.storedPower = storedPower;
|
||||
}
|
||||
|
||||
private void setStoredPower( final double storedPower )
|
||||
{
|
||||
this.storedPower = storedPower;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.externalInv);
|
||||
} else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.fluidHandler);
|
||||
} else if (capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.meHandler);
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
if( capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.externalInv);
|
||||
}
|
||||
else if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.fluidHandler);
|
||||
}
|
||||
else if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR )
|
||||
{
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.meHandler);
|
||||
}
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
private class CondenseItemHandler implements IItemHandler {
|
||||
|
||||
private class CondenseItemHandler implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public int getSlots() {
|
||||
// We only expose the void slot
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
// We only expose the void slot
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return slot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return slot == 0;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
// The void slot never has any content
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( int slot )
|
||||
{
|
||||
// The void slot never has any content
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
if (slot != 0) {
|
||||
return stack;
|
||||
}
|
||||
if (!simulate && !stack.isEmpty()) {
|
||||
TileCondenser.this.addPower(stack.getCount());
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem( int slot, ItemStack stack, boolean simulate )
|
||||
{
|
||||
if( slot != 0 )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
if( !simulate && !stack.isEmpty() )
|
||||
{
|
||||
TileCondenser.this.addPower( stack.getCount() );
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem( int slot, int amount, boolean simulate )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit( int slot )
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A fluid handler that exposes a 1 bucket tank that can only be filled, and -
|
||||
* when filled - will add power to this condenser.
|
||||
*/
|
||||
private class FluidHandler implements IFluidTank, IFluidHandler {
|
||||
|
||||
/**
|
||||
* A fluid handler that exposes a 1 bucket tank that can only be filled, and - when filled - will add power
|
||||
* to this condenser.
|
||||
*/
|
||||
private class FluidHandler implements IFluidTank, IFluidHandler
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
}
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return stack != FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return stack != FluidStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
if (action == FluidAction.EXECUTE) {
|
||||
final IStorageChannel<IAEFluidStack> chan = AEApi.instance().storage()
|
||||
.getStorageChannel(IFluidStorageChannel.class);
|
||||
TileCondenser.this
|
||||
.addPower((resource == null ? 0.0 : (double) resource.getAmount()) / chan.transferFactor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
if( action == FluidAction.EXECUTE )
|
||||
{
|
||||
final IStorageChannel<IAEFluidStack> chan = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
TileCondenser.this.addPower( ( resource == null ? 0.0 : (double) resource.getAmount() ) / chan.transferFactor() );
|
||||
}
|
||||
return resource == null ? 0 : resource.getAmount();
|
||||
}
|
||||
|
||||
return resource == null ? 0 : resource.getAmount();
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return tank == 0 ? getCapacity() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return tank == 0 ? getCapacity() : 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return tank == 0 && isFluidValid(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return tank == 0 && isFluidValid(stack);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is used to expose a fake ME subnetwork that is only composed of this
|
||||
* condenser tile. The purpose of this is to enable the condenser to override
|
||||
* the {@link appeng.api.storage.IMEInventoryHandler#validForPass(int)} method
|
||||
* to make sure a condenser is only ever used if an item can't go anywhere else.
|
||||
*/
|
||||
private class MEHandler implements IStorageMonitorableAccessor, IStorageMonitorable {
|
||||
private final CondenserItemInventory itemInventory = new CondenserItemInventory(TileCondenser.this);
|
||||
|
||||
/**
|
||||
* This is used to expose a fake ME subnetwork that is only composed of this condenser tile. The purpose of this is
|
||||
* to enable the condenser to
|
||||
* override the {@link appeng.api.storage.IMEInventoryHandler#validForPass(int)} method to make sure a condenser is
|
||||
* only ever used if an item
|
||||
* can't go anywhere else.
|
||||
*/
|
||||
private class MEHandler implements IStorageMonitorableAccessor, IStorageMonitorable
|
||||
{
|
||||
private final CondenserItemInventory itemInventory = new CondenserItemInventory( TileCondenser.this );
|
||||
void outputChanged(ItemStack added, ItemStack removed) {
|
||||
this.itemInventory.updateOutput(added, removed);
|
||||
}
|
||||
|
||||
void outputChanged( ItemStack added, ItemStack removed )
|
||||
{
|
||||
this.itemInventory.updateOutput( added, removed );
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public IStorageMonitorable getInventory(IActionSource src) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IStorageMonitorable getInventory( IActionSource src )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return (IMEMonitor<T>) this.itemInventory;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CondenserVoidInventory<>( TileCondenser.this, channel );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
|
||||
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
|
||||
return (IMEMonitor<T>) this.itemInventory;
|
||||
} else {
|
||||
return new CondenserVoidInventory<>(TileCondenser.this, channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -26,9 +25,6 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -42,6 +38,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
@@ -59,6 +56,7 @@ import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.DefinitionUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -69,447 +67,370 @@ import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost
|
||||
{
|
||||
private final int maxProcessingTime = 100;
|
||||
public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost {
|
||||
private final int maxProcessingTime = 100;
|
||||
|
||||
private final IConfigManager settings;
|
||||
private final UpgradeInventory upgrades;
|
||||
private int processingTime = 0;
|
||||
// cycles from 0 - 16, at 8 it preforms the action, at 16 it re-enables the normal routine.
|
||||
private boolean smash;
|
||||
private int finalStep;
|
||||
private long clientStart;
|
||||
private final AppEngInternalInventory topItemHandler = new AppEngInternalInventory( this, 1, 1 );
|
||||
private final AppEngInternalInventory bottomItemHandler = new AppEngInternalInventory( this, 1, 1 );
|
||||
private final AppEngInternalInventory sideItemHandler = new AppEngInternalInventory( this, 2, 1 );
|
||||
private final IConfigManager settings;
|
||||
private final UpgradeInventory upgrades;
|
||||
private int processingTime = 0;
|
||||
// cycles from 0 - 16, at 8 it preforms the action, at 16 it re-enables the
|
||||
// normal routine.
|
||||
private boolean smash;
|
||||
private int finalStep;
|
||||
private long clientStart;
|
||||
private final AppEngInternalInventory topItemHandler = new AppEngInternalInventory(this, 1, 1);
|
||||
private final AppEngInternalInventory bottomItemHandler = new AppEngInternalInventory(this, 1, 1);
|
||||
private final AppEngInternalInventory sideItemHandler = new AppEngInternalInventory(this, 2, 1);
|
||||
|
||||
private final IItemHandler topItemHandlerExtern;
|
||||
private final IItemHandler bottomItemHandlerExtern;
|
||||
private final IItemHandler sideItemHandlerExtern;
|
||||
private final IItemHandler topItemHandlerExtern;
|
||||
private final IItemHandler bottomItemHandlerExtern;
|
||||
private final IItemHandler sideItemHandlerExtern;
|
||||
|
||||
private InscriberRecipe cachedTask = null;
|
||||
private InscriberRecipe cachedTask = null;
|
||||
|
||||
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler );
|
||||
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler(this.topItemHandler,
|
||||
this.bottomItemHandler, this.sideItemHandler);
|
||||
|
||||
public TileInscriber(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
public TileInscriber(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.setInternalMaxPower( 1600 );
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
this.settings = new ConfigManager( this );
|
||||
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
|
||||
this.setInternalMaxPower(1600);
|
||||
this.getProxy().setIdlePowerUsage(0);
|
||||
this.settings = new ConfigManager(this);
|
||||
|
||||
final ITileDefinition inscriberDefinition = AEApi.instance().definitions().blocks().inscriber();
|
||||
this.upgrades = new DefinitionUpgradeInventory( inscriberDefinition, this, this.getUpgradeSlots() );
|
||||
final ITileDefinition inscriberDefinition = AEApi.instance().definitions().blocks().inscriber();
|
||||
this.upgrades = new DefinitionUpgradeInventory(inscriberDefinition, this, this.getUpgradeSlots());
|
||||
|
||||
this.sideItemHandler.setMaxStackSize( 1, 64 );
|
||||
this.sideItemHandler.setMaxStackSize(1, 64);
|
||||
|
||||
final IAEItemFilter filter = new ItemHandlerFilter();
|
||||
this.topItemHandlerExtern = new WrapperFilteredItemHandler( this.topItemHandler, filter );
|
||||
this.bottomItemHandlerExtern = new WrapperFilteredItemHandler( this.bottomItemHandler, filter );
|
||||
this.sideItemHandlerExtern = new WrapperFilteredItemHandler( this.sideItemHandler, filter );
|
||||
}
|
||||
final IAEItemFilter filter = new ItemHandlerFilter();
|
||||
this.topItemHandlerExtern = new WrapperFilteredItemHandler(this.topItemHandler, filter);
|
||||
this.bottomItemHandlerExtern = new WrapperFilteredItemHandler(this.bottomItemHandler, filter);
|
||||
this.sideItemHandlerExtern = new WrapperFilteredItemHandler(this.sideItemHandler, filter);
|
||||
}
|
||||
|
||||
private int getUpgradeSlots()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
private int getUpgradeSlots() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
this.settings.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
this.upgrades.writeToNBT(data, "upgrades");
|
||||
this.settings.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
this.settings.readFromNBT( data );
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.upgrades.readFromNBT(data, "upgrades");
|
||||
this.settings.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int slot = data.readByte();
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final int slot = data.readByte();
|
||||
|
||||
final boolean oldSmash = this.isSmash();
|
||||
final boolean newSmash = ( slot & 64 ) == 64;
|
||||
final boolean oldSmash = this.isSmash();
|
||||
final boolean newSmash = (slot & 64) == 64;
|
||||
|
||||
if( oldSmash != newSmash && newSmash )
|
||||
{
|
||||
this.setSmash( true );
|
||||
this.setClientStart( System.currentTimeMillis() );
|
||||
}
|
||||
if (oldSmash != newSmash && newSmash) {
|
||||
this.setSmash(true);
|
||||
this.setClientStart(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
for( int num = 0; num < this.inv.getSlots(); num++ )
|
||||
{
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
{
|
||||
this.inv.setStackInSlot( num, AEItemStack.fromPacket( data ).createItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setStackInSlot( num, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
this.cachedTask = null;
|
||||
for (int num = 0; num < this.inv.getSlots(); num++) {
|
||||
if ((slot & (1 << num)) > 0) {
|
||||
this.inv.setStackInSlot(num, AEItemStack.fromPacket(data).createItemStack());
|
||||
} else {
|
||||
this.inv.setStackInSlot(num, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
this.cachedTask = null;
|
||||
|
||||
return c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int slot = this.isSmash() ? 64 : 0;
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
int slot = this.isSmash() ? 64 : 0;
|
||||
|
||||
for( int num = 0; num < this.inv.getSlots(); num++ )
|
||||
{
|
||||
if( !this.inv.getStackInSlot( num ).isEmpty() )
|
||||
{
|
||||
slot |= ( 1 << num );
|
||||
}
|
||||
}
|
||||
for (int num = 0; num < this.inv.getSlots(); num++) {
|
||||
if (!this.inv.getStackInSlot(num).isEmpty()) {
|
||||
slot |= (1 << num);
|
||||
}
|
||||
}
|
||||
|
||||
data.writeByte( slot );
|
||||
for( int num = 0; num < this.inv.getSlots(); num++ )
|
||||
{
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
{
|
||||
final AEItemStack st = AEItemStack.fromItemStack( this.inv.getStackInSlot( num ) );
|
||||
st.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
}
|
||||
data.writeByte(slot);
|
||||
for (int num = 0; num < this.inv.getSlots(); num++) {
|
||||
if ((slot & (1 << num)) > 0) {
|
||||
final AEItemStack st = AEItemStack.fromItemStack(this.inv.getStackInSlot(num));
|
||||
st.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation( final Direction inForward, final Direction inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.getProxy().setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) );
|
||||
this.setPowerSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) );
|
||||
}
|
||||
@Override
|
||||
public void setOrientation(final Direction inForward, final Direction inUp) {
|
||||
super.setOrientation(inForward, inUp);
|
||||
this.getProxy().setValidSides(EnumSet.complementOf(EnumSet.of(this.getForward())));
|
||||
this.setPowerSides(EnumSet.complementOf(EnumSet.of(this.getForward())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
|
||||
{
|
||||
super.getDrops( w, pos, drops );
|
||||
@Override
|
||||
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
|
||||
super.getDrops(w, pos, drops);
|
||||
|
||||
for( int h = 0; h < this.upgrades.getSlots(); h++ )
|
||||
{
|
||||
final ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int h = 0; h < this.upgrades.getSlots(); h++) {
|
||||
final ItemStack is = this.upgrades.getStackInSlot(h);
|
||||
if (!is.isEmpty()) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
this.setProcessingTime( 0 );
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
try {
|
||||
if (slot == 0) {
|
||||
this.setProcessingTime(0);
|
||||
}
|
||||
|
||||
if( !this.isSmash() )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
if (!this.isSmash()) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
this.cachedTask = null;
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
this.cachedTask = null;
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @Override
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.Inscriber.getMin(), TickRates.Inscriber.getMax(), !this.hasWork(), false );
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(final IGridNode node) {
|
||||
return new TickingRequest(TickRates.Inscriber.getMin(), TickRates.Inscriber.getMax(), !this.hasWork(), false);
|
||||
}
|
||||
|
||||
private boolean hasWork()
|
||||
{
|
||||
if( this.getTask() != null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
private boolean hasWork() {
|
||||
if (this.getTask() != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.setProcessingTime( 0 );
|
||||
return this.isSmash();
|
||||
}
|
||||
this.setProcessingTime(0);
|
||||
return this.isSmash();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InscriberRecipe getTask()
|
||||
{
|
||||
if ( this.cachedTask == null && world != null )
|
||||
{
|
||||
ItemStack input = this.sideItemHandler.getStackInSlot(0);
|
||||
ItemStack plateA = this.topItemHandler.getStackInSlot(0);
|
||||
ItemStack plateB = this.bottomItemHandler.getStackInSlot(0);
|
||||
// If the player somehow managed to insert more than one item, we bail here
|
||||
if( input.getCount() > 1 || plateA.getCount() > 1 || plateB.getCount() > 1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
public InscriberRecipe getTask() {
|
||||
if (this.cachedTask == null && world != null) {
|
||||
ItemStack input = this.sideItemHandler.getStackInSlot(0);
|
||||
ItemStack plateA = this.topItemHandler.getStackInSlot(0);
|
||||
ItemStack plateB = this.bottomItemHandler.getStackInSlot(0);
|
||||
// If the player somehow managed to insert more than one item, we bail here
|
||||
if (input.getCount() > 1 || plateA.getCount() > 1 || plateB.getCount() > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.cachedTask = InscriberRecipes.findRecipe( world, input, plateA, plateB, true);
|
||||
}
|
||||
return this.cachedTask;
|
||||
}
|
||||
this.cachedTask = InscriberRecipes.findRecipe(world, input, plateA, plateB, true);
|
||||
}
|
||||
return this.cachedTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
|
||||
{
|
||||
if( this.isSmash() )
|
||||
{
|
||||
this.finalStep++;
|
||||
if( this.finalStep == 8 )
|
||||
{
|
||||
final InscriberRecipe out = this.getTask();
|
||||
if( out != null )
|
||||
{
|
||||
final ItemStack outputCopy = out.getOutput().copy();
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) {
|
||||
if (this.isSmash()) {
|
||||
this.finalStep++;
|
||||
if (this.finalStep == 8) {
|
||||
final InscriberRecipe out = this.getTask();
|
||||
if (out != null) {
|
||||
final ItemStack outputCopy = out.getOutput().copy();
|
||||
|
||||
if( this.sideItemHandler.insertItem( 1, outputCopy, false ).isEmpty() )
|
||||
{
|
||||
this.setProcessingTime( 0 );
|
||||
if( out.getProcessType() == InscriberProcessType.PRESS )
|
||||
{
|
||||
this.topItemHandler.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
this.bottomItemHandler.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
}
|
||||
this.sideItemHandler.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
this.saveChanges();
|
||||
}
|
||||
else if( this.finalStep == 16 )
|
||||
{
|
||||
this.finalStep = 0;
|
||||
this.setSmash( false );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.getProxy().getEnergy();
|
||||
IEnergySource src = this;
|
||||
if (this.sideItemHandler.insertItem(1, outputCopy, false).isEmpty()) {
|
||||
this.setProcessingTime(0);
|
||||
if (out.getProcessType() == InscriberProcessType.PRESS) {
|
||||
this.topItemHandler.setStackInSlot(0, ItemStack.EMPTY);
|
||||
this.bottomItemHandler.setStackInSlot(0, ItemStack.EMPTY);
|
||||
}
|
||||
this.sideItemHandler.setStackInSlot(0, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
this.saveChanges();
|
||||
} else if (this.finalStep == 16) {
|
||||
this.finalStep = 0;
|
||||
this.setSmash(false);
|
||||
this.markForUpdate();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
final IEnergyGrid eg = this.getProxy().getEnergy();
|
||||
IEnergySource src = this;
|
||||
|
||||
// Base 1, increase by 1 for each card
|
||||
final int speedFactor = 1 + this.upgrades.getInstalledUpgrades( Upgrades.SPEED );
|
||||
final int powerConsumption = 10 * speedFactor;
|
||||
final double powerThreshold = powerConsumption - 0.01;
|
||||
double powerReq = this.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
// Base 1, increase by 1 for each card
|
||||
final int speedFactor = 1 + this.upgrades.getInstalledUpgrades(Upgrades.SPEED);
|
||||
final int powerConsumption = 10 * speedFactor;
|
||||
final double powerThreshold = powerConsumption - 0.01;
|
||||
double powerReq = this.extractAEPower(powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG);
|
||||
|
||||
if( powerReq <= powerThreshold )
|
||||
{
|
||||
src = eg;
|
||||
powerReq = eg.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
}
|
||||
if (powerReq <= powerThreshold) {
|
||||
src = eg;
|
||||
powerReq = eg.extractAEPower(powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG);
|
||||
}
|
||||
|
||||
if( powerReq > powerThreshold )
|
||||
{
|
||||
src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
if (powerReq > powerThreshold) {
|
||||
src.extractAEPower(powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
|
||||
if( this.getProcessingTime() == 0 )
|
||||
{
|
||||
this.setProcessingTime( this.getProcessingTime() + speedFactor );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setProcessingTime( this.getProcessingTime() + ticksSinceLastCall * speedFactor );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
if (this.getProcessingTime() == 0) {
|
||||
this.setProcessingTime(this.getProcessingTime() + speedFactor);
|
||||
} else {
|
||||
this.setProcessingTime(this.getProcessingTime() + ticksSinceLastCall * speedFactor);
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
|
||||
if( this.getProcessingTime() > this.getMaxProcessingTime() )
|
||||
{
|
||||
this.setProcessingTime( this.getMaxProcessingTime() );
|
||||
final InscriberRecipe out = this.getTask();
|
||||
if( out != null )
|
||||
{
|
||||
final ItemStack outputCopy = out.getOutput().copy();
|
||||
if( this.sideItemHandler.insertItem( 1, outputCopy, true ).isEmpty() )
|
||||
{
|
||||
this.setSmash( true );
|
||||
this.finalStep = 0;
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.getProcessingTime() > this.getMaxProcessingTime()) {
|
||||
this.setProcessingTime(this.getMaxProcessingTime());
|
||||
final InscriberRecipe out = this.getTask();
|
||||
if (out != null) {
|
||||
final ItemStack outputCopy = out.getOutput().copy();
|
||||
if (this.sideItemHandler.insertItem(1, outputCopy, true).isEmpty()) {
|
||||
this.setSmash(true);
|
||||
this.finalStep = 0;
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP;
|
||||
}
|
||||
return this.hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.settings;
|
||||
}
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "inv" ) )
|
||||
{
|
||||
return this.getInternalInventory();
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("inv")) {
|
||||
return this.getInternalInventory();
|
||||
}
|
||||
|
||||
if( name.equals( "upgrades" ) )
|
||||
{
|
||||
return this.upgrades;
|
||||
}
|
||||
if (name.equals("upgrades")) {
|
||||
return this.upgrades;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide( @Nonnull Direction facing )
|
||||
{
|
||||
if( facing == this.getUp() )
|
||||
{
|
||||
return this.topItemHandlerExtern;
|
||||
}
|
||||
else if( facing == this.getUp().getOpposite() )
|
||||
{
|
||||
return this.bottomItemHandlerExtern;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.sideItemHandlerExtern;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide(@Nonnull Direction facing) {
|
||||
if (facing == this.getUp()) {
|
||||
return this.topItemHandlerExtern;
|
||||
} else if (facing == this.getUp().getOpposite()) {
|
||||
return this.bottomItemHandlerExtern;
|
||||
} else {
|
||||
return this.sideItemHandlerExtern;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( final Upgrades u )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
@Override
|
||||
public int getInstalledUpgrades(final Upgrades u) {
|
||||
return this.upgrades.getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
}
|
||||
|
||||
public long getClientStart()
|
||||
{
|
||||
return this.clientStart;
|
||||
}
|
||||
public long getClientStart() {
|
||||
return this.clientStart;
|
||||
}
|
||||
|
||||
private void setClientStart( final long clientStart )
|
||||
{
|
||||
this.clientStart = clientStart;
|
||||
}
|
||||
private void setClientStart(final long clientStart) {
|
||||
this.clientStart = clientStart;
|
||||
}
|
||||
|
||||
public boolean isSmash()
|
||||
{
|
||||
return this.smash;
|
||||
}
|
||||
public boolean isSmash() {
|
||||
return this.smash;
|
||||
}
|
||||
|
||||
public void setSmash( final boolean smash )
|
||||
{
|
||||
this.smash = smash;
|
||||
}
|
||||
public void setSmash(final boolean smash) {
|
||||
this.smash = smash;
|
||||
}
|
||||
|
||||
public int getMaxProcessingTime()
|
||||
{
|
||||
return this.maxProcessingTime;
|
||||
}
|
||||
public int getMaxProcessingTime() {
|
||||
return this.maxProcessingTime;
|
||||
}
|
||||
|
||||
public int getProcessingTime()
|
||||
{
|
||||
return this.processingTime;
|
||||
}
|
||||
public int getProcessingTime() {
|
||||
return this.processingTime;
|
||||
}
|
||||
|
||||
private void setProcessingTime( final int processingTime )
|
||||
{
|
||||
this.processingTime = processingTime;
|
||||
}
|
||||
private void setProcessingTime(final int processingTime) {
|
||||
this.processingTime = processingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an item handler that exposes the inscribers inventory while providing simulation capabilities that do not
|
||||
* reset the progress if there's already an item in a slot. Previously, the progress of the inscriber was reset when
|
||||
* another mod attempted insertion of items when there were already items in the slot.
|
||||
*/
|
||||
private class ItemHandlerFilter implements IAEItemFilter
|
||||
{
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
if( TileInscriber.this.isSmash() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* This is an item handler that exposes the inscribers inventory while providing
|
||||
* simulation capabilities that do not reset the progress if there's already an
|
||||
* item in a slot. Previously, the progress of the inscriber was reset when
|
||||
* another mod attempted insertion of items when there were already items in the
|
||||
* slot.
|
||||
*/
|
||||
private class ItemHandlerFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
if (TileInscriber.this.isSmash()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler || slot == 1;
|
||||
}
|
||||
return inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler || slot == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
// output slot
|
||||
if( slot == 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
// output slot
|
||||
if (slot == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( TileInscriber.this.isSmash() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (TileInscriber.this.isSmash()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler )
|
||||
{
|
||||
if( AEApi.instance().definitions().materials().namePress().isSameAs( stack ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return InscriberRecipes.isValidOptionalIngredient(getWorld(), stack);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler) {
|
||||
if (AEApi.instance().definitions().materials().namePress().isSameAs(stack)) {
|
||||
return true;
|
||||
}
|
||||
return InscriberRecipes.isValidOptionalIngredient(getWorld(), stack);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,12 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
@@ -60,7 +58,7 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -69,302 +67,250 @@ import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class TileInterface extends AENetworkInvTile
|
||||
implements IGridTickable, IInventoryDestination, IInterfaceHost, IPriorityHost {
|
||||
|
||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, IInventoryDestination, IInterfaceHost, IPriorityHost
|
||||
{
|
||||
private final DualityInterface duality = new DualityInterface(this.getProxy(), this);
|
||||
|
||||
private final DualityInterface duality = new DualityInterface( this.getProxy(), this );
|
||||
// Indicates that this interface has no specific direction set
|
||||
private boolean omniDirectional = true;
|
||||
|
||||
// Indicates that this interface has no specific direction set
|
||||
private boolean omniDirectional = true;
|
||||
public TileInterface(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public TileInterface(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkChannelsChanged c) {
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkPowerStatusChange c) {
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
public void setSide(final Direction facing) {
|
||||
if (isRemote()) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void setSide( final Direction facing )
|
||||
{
|
||||
if( isRemote() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
Direction newForward = facing;
|
||||
|
||||
Direction newForward = facing;
|
||||
if (!this.omniDirectional && this.getForward() == facing.getOpposite()) {
|
||||
newForward = facing;
|
||||
} else if (!this.omniDirectional
|
||||
&& (this.getForward() == facing || this.getForward() == facing.getOpposite())) {
|
||||
this.omniDirectional = true;
|
||||
} else if (this.omniDirectional) {
|
||||
newForward = facing.getOpposite();
|
||||
this.omniDirectional = false;
|
||||
} else {
|
||||
newForward = Platform.rotateAround(this.getForward(), facing);
|
||||
}
|
||||
|
||||
if( !this.omniDirectional && this.getForward() == facing.getOpposite() )
|
||||
{
|
||||
newForward = facing;
|
||||
}
|
||||
else if( !this.omniDirectional && ( this.getForward() == facing || this.getForward() == facing.getOpposite() ) )
|
||||
{
|
||||
this.omniDirectional = true;
|
||||
}
|
||||
else if( this.omniDirectional )
|
||||
{
|
||||
newForward = facing.getOpposite();
|
||||
this.omniDirectional = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
newForward = Platform.rotateAround( this.getForward(), facing );
|
||||
}
|
||||
if (this.omniDirectional) {
|
||||
this.setOrientation(Direction.NORTH, Direction.UP);
|
||||
} else {
|
||||
Direction newUp = Direction.UP;
|
||||
if (newForward == Direction.UP || newForward == Direction.DOWN) {
|
||||
newUp = Direction.NORTH;
|
||||
}
|
||||
this.setOrientation(newForward, newUp);
|
||||
}
|
||||
|
||||
if( this.omniDirectional )
|
||||
{
|
||||
this.setOrientation( Direction.NORTH, Direction.UP );
|
||||
}
|
||||
else
|
||||
{
|
||||
Direction newUp = Direction.UP;
|
||||
if( newForward == Direction.UP || newForward == Direction.DOWN )
|
||||
{
|
||||
newUp = Direction.NORTH;
|
||||
}
|
||||
this.setOrientation( newForward, newUp );
|
||||
}
|
||||
this.configureNodeSides();
|
||||
this.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
this.configureNodeSides();
|
||||
this.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
private void configureNodeSides() {
|
||||
if (this.omniDirectional) {
|
||||
this.getProxy().setValidSides(EnumSet.allOf(Direction.class));
|
||||
} else {
|
||||
this.getProxy().setValidSides(EnumSet.complementOf(EnumSet.of(this.getForward())));
|
||||
}
|
||||
}
|
||||
|
||||
private void configureNodeSides()
|
||||
{
|
||||
if( this.omniDirectional )
|
||||
{
|
||||
this.getProxy().setValidSides( EnumSet.allOf( Direction.class ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getProxy().setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
|
||||
this.duality.addDrops(drops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
|
||||
{
|
||||
this.duality.addDrops( drops );
|
||||
}
|
||||
@Override
|
||||
public void gridChanged() {
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
@Override
|
||||
public void onReady() {
|
||||
this.configureNodeSides();
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
this.configureNodeSides();
|
||||
super.onReady();
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
super.onReady();
|
||||
this.duality.initialize();
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
data.putBoolean("omniDirectional", this.omniDirectional);
|
||||
this.duality.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
data.putBoolean("omniDirectional", this.omniDirectional);
|
||||
this.duality.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.omniDirectional = data.getBoolean("omniDirectional");
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.omniDirectional = data.getBoolean( "omniDirectional" );
|
||||
this.duality.readFromNBT(data);
|
||||
}
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
boolean oldOmniDirectional = this.omniDirectional;
|
||||
this.omniDirectional = data.readBoolean();
|
||||
return oldOmniDirectional != this.omniDirectional || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
boolean oldOmniDirectional = this.omniDirectional;
|
||||
this.omniDirectional = data.readBoolean();
|
||||
return oldOmniDirectional != this.omniDirectional || c;
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.omniDirectional);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.omniDirectional );
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return this.duality.getCableConnectionType(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return this.duality.getCableConnectionType( dir );
|
||||
}
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return this.duality.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return this.duality.getLocation();
|
||||
}
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack stack) {
|
||||
return this.duality.canInsert(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert( final ItemStack stack )
|
||||
{
|
||||
return this.duality.canInsert( stack );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
return this.duality.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(final IGridNode node) {
|
||||
return this.duality.getTickingRequest(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
return this.duality.getTickingRequest( node );
|
||||
}
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) {
|
||||
return this.duality.tickingRequest(node, ticksSinceLastCall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
|
||||
{
|
||||
return this.duality.tickingRequest( node, ticksSinceLastCall );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.duality.getInternalInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.duality.getInternalInventory();
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
this.duality.onChangeInventory(inv, slot, mc, removed, added);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
this.duality.onChangeInventory( inv, slot, mc, removed, added );
|
||||
}
|
||||
@Override
|
||||
public DualityInterface getInterfaceDuality() {
|
||||
return this.duality;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualityInterface getInterfaceDuality()
|
||||
{
|
||||
return this.duality;
|
||||
}
|
||||
@Override
|
||||
public EnumSet<Direction> getTargets() {
|
||||
if (this.omniDirectional) {
|
||||
return EnumSet.allOf(Direction.class);
|
||||
}
|
||||
return EnumSet.of(this.getForward());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<Direction> getTargets()
|
||||
{
|
||||
if( this.omniDirectional )
|
||||
{
|
||||
return EnumSet.allOf( Direction.class );
|
||||
}
|
||||
return EnumSet.of( this.getForward() );
|
||||
}
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
@Override
|
||||
public boolean pushPattern(final ICraftingPatternDetails patternDetails, final CraftingInventory table) {
|
||||
return this.duality.pushPattern(patternDetails, table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table )
|
||||
{
|
||||
return this.duality.pushPattern( patternDetails, table );
|
||||
}
|
||||
@Override
|
||||
public boolean isBusy() {
|
||||
return this.duality.isBusy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy()
|
||||
{
|
||||
return this.duality.isBusy();
|
||||
}
|
||||
@Override
|
||||
public void provideCrafting(final ICraftingProviderHelper craftingTracker) {
|
||||
this.duality.provideCrafting(craftingTracker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCrafting( final ICraftingProviderHelper craftingTracker )
|
||||
{
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
@Override
|
||||
public int getInstalledUpgrades(final Upgrades u) {
|
||||
return this.duality.getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( final Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs() {
|
||||
return this.duality.getRequestedJobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||
{
|
||||
return this.duality.getRequestedJobs();
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack items, final Actionable mode) {
|
||||
return this.duality.injectCraftedItems(link, items, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems( final ICraftingLink link, final IAEItemStack items, final Actionable mode )
|
||||
{
|
||||
return this.duality.injectCraftedItems( link, items, mode );
|
||||
}
|
||||
@Override
|
||||
public void jobStateChange(final ICraftingLink link) {
|
||||
this.duality.jobStateChange(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange( final ICraftingLink link )
|
||||
{
|
||||
this.duality.jobStateChange( link );
|
||||
}
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.duality.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return this.duality.getPriority();
|
||||
}
|
||||
@Override
|
||||
public void setPriority(final int newValue) {
|
||||
this.duality.setPriority(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( final int newValue )
|
||||
{
|
||||
this.duality.setPriority( newValue );
|
||||
}
|
||||
/**
|
||||
* @return True if this interface is omni-directional.
|
||||
*/
|
||||
public boolean isOmniDirectional() {
|
||||
return this.omniDirectional;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if this interface is omni-directional.
|
||||
*/
|
||||
public boolean isOmniDirectional()
|
||||
{
|
||||
return this.omniDirectional;
|
||||
}
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
LazyOptional<T> result = this.duality.getCapability(capability, facing);
|
||||
if (result.isPresent()) {
|
||||
return result;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
LazyOptional<T> result = this.duality.getCapability( capability, facing );
|
||||
if( result.isPresent() )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation() {
|
||||
return AEApi.instance().definitions().blocks().iface().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().blocks().iface().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType()
|
||||
{
|
||||
return ContainerInterface.TYPE;
|
||||
}
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
return ContainerInterface.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,54 +18,45 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class TileLightDetector extends AEBaseTile implements ITickableTileEntity
|
||||
{
|
||||
public class TileLightDetector extends AEBaseTile implements ITickableTileEntity {
|
||||
|
||||
private int lastCheck = 30;
|
||||
private int lastLight = 0;
|
||||
private int lastCheck = 30;
|
||||
private int lastLight = 0;
|
||||
|
||||
public TileLightDetector(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
public TileLightDetector(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public boolean isReady()
|
||||
{
|
||||
return this.lastLight > 0;
|
||||
}
|
||||
public boolean isReady() {
|
||||
return this.lastLight > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
this.lastCheck++;
|
||||
if( this.lastCheck > 30 )
|
||||
{
|
||||
this.lastCheck = 0;
|
||||
this.updateLight();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
this.lastCheck++;
|
||||
if (this.lastCheck > 30) {
|
||||
this.lastCheck = 0;
|
||||
this.updateLight();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLight()
|
||||
{
|
||||
final int val = this.world.getLight( this.pos );
|
||||
public void updateLight() {
|
||||
final int val = this.world.getLight(this.pos);
|
||||
|
||||
if( this.lastLight != val )
|
||||
{
|
||||
this.lastLight = val;
|
||||
Platform.notifyBlocksOfNeighbors( this.world, this.pos );
|
||||
}
|
||||
}
|
||||
if (this.lastLight != val) {
|
||||
this.lastLight = val;
|
||||
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -26,7 +25,8 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.block.paint.PaintSplotches;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -38,266 +38,220 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.helpers.Splotch;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.paint.PaintSplotches;
|
||||
import appeng.helpers.Splotch;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class TilePaint extends AEBaseTile {
|
||||
|
||||
public class TilePaint extends AEBaseTile
|
||||
{
|
||||
public static final ModelProperty<PaintSplotches> SPLOTCHES = new ModelProperty<>();
|
||||
|
||||
public static final ModelProperty<PaintSplotches> SPLOTCHES = new ModelProperty<>();
|
||||
private static final int LIGHT_PER_DOT = 12;
|
||||
|
||||
private static final int LIGHT_PER_DOT = 12;
|
||||
private int isLit = 0;
|
||||
private List<Splotch> dots = null;
|
||||
|
||||
private int isLit = 0;
|
||||
private List<Splotch> dots = null;
|
||||
public TilePaint(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public TilePaint(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
final PacketBuffer myDat = new PacketBuffer(Unpooled.buffer());
|
||||
this.writeBuffer(myDat);
|
||||
if (myDat.hasArray()) {
|
||||
data.putByteArray("dots", myDat.array());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write( final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
final PacketBuffer myDat = new PacketBuffer( Unpooled.buffer() );
|
||||
this.writeBuffer( myDat );
|
||||
if( myDat.hasArray() )
|
||||
{
|
||||
data.putByteArray( "dots", myDat.array() );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
private void writeBuffer(final PacketBuffer out) {
|
||||
if (this.dots == null) {
|
||||
out.writeByte(0);
|
||||
return;
|
||||
}
|
||||
|
||||
private void writeBuffer( final PacketBuffer out )
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
out.writeByte( 0 );
|
||||
return;
|
||||
}
|
||||
out.writeByte(this.dots.size());
|
||||
|
||||
out.writeByte( this.dots.size() );
|
||||
for (final Splotch s : this.dots) {
|
||||
s.writeToStream(out);
|
||||
}
|
||||
}
|
||||
|
||||
for( final Splotch s : this.dots )
|
||||
{
|
||||
s.writeToStream( out );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
if (data.contains("dots")) {
|
||||
this.readBuffer(new PacketBuffer(Unpooled.copiedBuffer(data.getByteArray("dots"))));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read( final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
if( data.contains( "dots" ) )
|
||||
{
|
||||
this.readBuffer( new PacketBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) ) );
|
||||
}
|
||||
}
|
||||
private void readBuffer(final PacketBuffer in) {
|
||||
final byte howMany = in.readByte();
|
||||
|
||||
private void readBuffer( final PacketBuffer in )
|
||||
{
|
||||
final byte howMany = in.readByte();
|
||||
if (howMany == 0) {
|
||||
this.isLit = 0;
|
||||
this.dots = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if( howMany == 0 )
|
||||
{
|
||||
this.isLit = 0;
|
||||
this.dots = null;
|
||||
return;
|
||||
}
|
||||
this.dots = new ArrayList(howMany);
|
||||
for (int x = 0; x < howMany; x++) {
|
||||
this.dots.add(new Splotch(in));
|
||||
}
|
||||
|
||||
this.dots = new ArrayList( howMany );
|
||||
for( int x = 0; x < howMany; x++ )
|
||||
{
|
||||
this.dots.add( new Splotch( in ) );
|
||||
}
|
||||
this.isLit = 0;
|
||||
for (final Splotch s : this.dots) {
|
||||
if (s.isLumen()) {
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
|
||||
this.isLit = 0;
|
||||
for( final Splotch s : this.dots )
|
||||
{
|
||||
if( s.isLumen() )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
this.maxLit();
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
}
|
||||
private void maxLit() {
|
||||
if (this.isLit > 14) {
|
||||
this.isLit = 14;
|
||||
}
|
||||
|
||||
private void maxLit()
|
||||
{
|
||||
if( this.isLit > 14 )
|
||||
{
|
||||
this.isLit = 14;
|
||||
}
|
||||
if (this.world != null) {
|
||||
this.world.getLightFor(LightType.BLOCK, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.world != null )
|
||||
{
|
||||
this.world.getLightFor( LightType.BLOCK, this.pos );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
this.writeBuffer(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.writeBuffer( data );
|
||||
}
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
super.readFromStream(data);
|
||||
this.readBuffer(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
this.readBuffer( data );
|
||||
return true;
|
||||
}
|
||||
public void neighborChanged() {
|
||||
if (this.dots == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void neighborChanged()
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (final Direction side : Direction.values()) {
|
||||
if (!this.isSideValid(side)) {
|
||||
this.removeSide(side);
|
||||
}
|
||||
}
|
||||
|
||||
for( final Direction side : Direction.values() )
|
||||
{
|
||||
if( !this.isSideValid( side ) )
|
||||
{
|
||||
this.removeSide( side );
|
||||
}
|
||||
}
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
public boolean isSideValid(final Direction side) {
|
||||
final BlockPos p = this.pos.offset(side);
|
||||
final BlockState blk = this.world.getBlockState(p);
|
||||
return blk.isSolidSide(world, p, side.getOpposite());
|
||||
}
|
||||
|
||||
public boolean isSideValid( final Direction side )
|
||||
{
|
||||
final BlockPos p = this.pos.offset( side );
|
||||
final BlockState blk = this.world.getBlockState( p );
|
||||
return blk.isSolidSide( world, p, side.getOpposite() );
|
||||
}
|
||||
private void removeSide(final Direction side) {
|
||||
final Iterator<Splotch> i = this.dots.iterator();
|
||||
while (i.hasNext()) {
|
||||
final Splotch s = i.next();
|
||||
if (s.getSide() == side) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSide( final Direction side )
|
||||
{
|
||||
final Iterator<Splotch> i = this.dots.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
final Splotch s = i.next();
|
||||
if( s.getSide() == side )
|
||||
{
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
this.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
private void updateData() {
|
||||
this.isLit = 0;
|
||||
for (final Splotch s : this.dots) {
|
||||
if (s.isLumen()) {
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateData()
|
||||
{
|
||||
this.isLit = 0;
|
||||
for( final Splotch s : this.dots )
|
||||
{
|
||||
if( s.isLumen() )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
this.maxLit();
|
||||
|
||||
this.maxLit();
|
||||
if (this.dots.isEmpty()) {
|
||||
this.dots = null;
|
||||
}
|
||||
|
||||
if( this.dots.isEmpty() )
|
||||
{
|
||||
this.dots = null;
|
||||
}
|
||||
if (this.dots == null) {
|
||||
this.world.removeBlock(this.pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.dots == null )
|
||||
{
|
||||
this.world.removeBlock( this.pos, false );
|
||||
}
|
||||
}
|
||||
public void cleanSide(final Direction side) {
|
||||
if (this.dots == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void cleanSide( final Direction side )
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.removeSide(side);
|
||||
|
||||
this.removeSide( side );
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
public int getLightLevel() {
|
||||
return this.isLit;
|
||||
}
|
||||
|
||||
public int getLightLevel()
|
||||
{
|
||||
return this.isLit;
|
||||
}
|
||||
public void addBlot(final ItemStack type, final Direction side, final Vec3d hitVec) {
|
||||
final BlockPos p = this.pos.offset(side);
|
||||
|
||||
public void addBlot( final ItemStack type, final Direction side, final Vec3d hitVec )
|
||||
{
|
||||
final BlockPos p = this.pos.offset( side );
|
||||
final BlockState blk = this.world.getBlockState(p);
|
||||
if (blk.isSolidSide(this.world, p, side.getOpposite())) {
|
||||
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
final BlockState blk = this.world.getBlockState( p );
|
||||
if( blk.isSolidSide( this.world, p, side.getOpposite() ) )
|
||||
{
|
||||
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
final AEColor col = ipb.getColor();
|
||||
final boolean lit = ipb.isLumen();
|
||||
|
||||
final AEColor col = ipb.getColor();
|
||||
final boolean lit = ipb.isLumen();
|
||||
if (this.dots == null) {
|
||||
this.dots = new ArrayList<>();
|
||||
}
|
||||
|
||||
if( this.dots == null )
|
||||
{
|
||||
this.dots = new ArrayList<>();
|
||||
}
|
||||
if (this.dots.size() > 20) {
|
||||
this.dots.remove(0);
|
||||
}
|
||||
|
||||
if( this.dots.size() > 20 )
|
||||
{
|
||||
this.dots.remove( 0 );
|
||||
}
|
||||
this.dots.add(new Splotch(col, lit, side, hitVec));
|
||||
if (lit) {
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
|
||||
this.dots.add( new Splotch( col, lit, side, hitVec ) );
|
||||
if( lit )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
this.maxLit();
|
||||
this.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
this.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
public Collection<Splotch> getDots() {
|
||||
if (this.dots == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Collection<Splotch> getDots()
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.dots;
|
||||
}
|
||||
|
||||
return this.dots;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
// FIXME update trigger
|
||||
return new ModelDataMap.Builder()
|
||||
.withInitial(SPLOTCHES, new PaintSplotches(getDots()))
|
||||
.build();
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
// FIXME update trigger
|
||||
return new ModelDataMap.Builder().withInitial(SPLOTCHES, new PaintSplotches(getDots())).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
@@ -36,87 +35,71 @@ import appeng.me.GridAccessException;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class TileQuartzGrowthAccelerator extends AENetworkTile
|
||||
implements IPowerChannelState, ICrystalGrowthAccelerator {
|
||||
|
||||
public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPowerChannelState, ICrystalGrowthAccelerator
|
||||
{
|
||||
private boolean hasPower = false;
|
||||
|
||||
private boolean hasPower = false;
|
||||
public TileQuartzGrowthAccelerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
|
||||
this.getProxy().setFlags();
|
||||
this.getProxy().setIdlePowerUsage(8);
|
||||
}
|
||||
|
||||
public TileQuartzGrowthAccelerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.getProxy().setFlags();
|
||||
this.getProxy().setIdlePowerUsage( 8 );
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void onPower(final MENetworkPowerStatusChange ch) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPower( final MENetworkPowerStatusChange ch )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
@Override
|
||||
public boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final boolean hadPower = this.isPowered();
|
||||
this.setPowered(data.readBoolean());
|
||||
return this.isPowered() != hadPower || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean hadPower = this.isPowered();
|
||||
this.setPowered( data.readBoolean() );
|
||||
return this.isPowered() != hadPower || c;
|
||||
}
|
||||
@Override
|
||||
public void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
try {
|
||||
data.writeBoolean(this.getProxy().getEnergy().isNetworkPowered());
|
||||
} catch (final GridAccessException e) {
|
||||
data.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
try
|
||||
{
|
||||
data.writeBoolean( this.getProxy().getEnergy().isNetworkPowered() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setOrientation(final Direction inForward, final Direction inUp) {
|
||||
super.setOrientation(inForward, inUp);
|
||||
this.getProxy().setValidSides(EnumSet.of(this.getUp(), this.getUp().getOpposite()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation( final Direction inForward, final Direction inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.getProxy().setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
}
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
if (Platform.isServer()) {
|
||||
try {
|
||||
return this.getProxy().getEnergy().isNetworkPowered();
|
||||
} catch (final GridAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.getProxy().getEnergy().isNetworkPowered();
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
return this.hasPower;
|
||||
}
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return this.isPowered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
return this.isPowered();
|
||||
}
|
||||
|
||||
private void setPowered( final boolean hasPower )
|
||||
{
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
private void setPowered(final boolean hasPower) {
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -27,8 +26,8 @@ import java.util.Map;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -81,299 +80,256 @@ import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class TileSecurityStation extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable,
|
||||
IConfigManagerHost, ISecurityProvider, IColorableTile {
|
||||
|
||||
public class TileSecurityStation extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost, ISecurityProvider, IColorableTile
|
||||
{
|
||||
private static int difference = 0;
|
||||
private final AppEngInternalInventory configSlot = new AppEngInternalInventory(this, 1);
|
||||
private final IConfigManager cm = new ConfigManager(this);
|
||||
private final SecurityStationInventory inventory = new SecurityStationInventory(this);
|
||||
private final MEMonitorHandler<IAEItemStack> securityMonitor = new MEMonitorHandler<>(this.inventory);
|
||||
private long securityKey;
|
||||
private AEColor paintedColor = AEColor.TRANSPARENT;
|
||||
private boolean isActive = false;
|
||||
|
||||
private static int difference = 0;
|
||||
private final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
|
||||
private final IConfigManager cm = new ConfigManager( this );
|
||||
private final SecurityStationInventory inventory = new SecurityStationInventory( this );
|
||||
private final MEMonitorHandler<IAEItemStack> securityMonitor = new MEMonitorHandler<>( this.inventory );
|
||||
private long securityKey;
|
||||
private AEColor paintedColor = AEColor.TRANSPARENT;
|
||||
private boolean isActive = false;
|
||||
public TileSecurityStation(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
this.getProxy().setIdlePowerUsage(2.0);
|
||||
difference++;
|
||||
|
||||
public TileSecurityStation(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.getProxy().setIdlePowerUsage( 2.0 );
|
||||
difference++;
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if (difference > 10) {
|
||||
difference = 0;
|
||||
}
|
||||
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if( difference > 10 )
|
||||
{
|
||||
difference = 0;
|
||||
}
|
||||
this.cm.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
this.cm.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
this.cm.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
}
|
||||
|
||||
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
|
||||
if (!ItemHandlerUtil.isEmpty(this.getConfigSlot())) {
|
||||
drops.add(this.getConfigSlot().getStackInSlot(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
|
||||
{
|
||||
if( !ItemHandlerUtil.isEmpty( this.getConfigSlot() ) )
|
||||
{
|
||||
drops.add( this.getConfigSlot().getStackInSlot( 0 ) );
|
||||
}
|
||||
for (final IAEItemStack ais : this.inventory.getStoredItems()) {
|
||||
drops.add(ais.createItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
for( final IAEItemStack ais : this.inventory.getStoredItems() )
|
||||
{
|
||||
drops.add( ais.createItemStack() );
|
||||
}
|
||||
}
|
||||
IMEInventoryHandler<IAEItemStack> getSecurityInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
IMEInventoryHandler<IAEItemStack> getSecurityInventory()
|
||||
{
|
||||
return this.inventory;
|
||||
}
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final boolean wasActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean wasActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive || c;
|
||||
}
|
||||
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive || c;
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.getProxy().isActive());
|
||||
data.writeByte(this.paintedColor.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getProxy().isActive() );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
this.cm.writeToNBT(data);
|
||||
data.putByte("paintedColor", (byte) this.paintedColor.ordinal());
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
data.putLong("securityKey", this.securityKey);
|
||||
this.getConfigSlot().writeToNBT(data, "config");
|
||||
|
||||
data.putLong( "securityKey", this.securityKey );
|
||||
this.getConfigSlot().writeToNBT( data, "config" );
|
||||
final CompoundNBT storedItems = new CompoundNBT();
|
||||
|
||||
final CompoundNBT storedItems = new CompoundNBT();
|
||||
int offset = 0;
|
||||
for (final IAEItemStack ais : this.inventory.getStoredItems()) {
|
||||
final CompoundNBT it = new CompoundNBT();
|
||||
ais.createItemStack().write(it);
|
||||
storedItems.put(String.valueOf(offset), it);
|
||||
offset++;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
for( final IAEItemStack ais : this.inventory.getStoredItems() )
|
||||
{
|
||||
final CompoundNBT it = new CompoundNBT();
|
||||
ais.createItemStack().write(it);
|
||||
storedItems.put( String.valueOf( offset ), it );
|
||||
offset++;
|
||||
}
|
||||
data.put("storedItems", storedItems);
|
||||
return data;
|
||||
}
|
||||
|
||||
data.put( "storedItems", storedItems );
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.cm.readFromNBT(data);
|
||||
if (data.contains("paintedColor")) {
|
||||
this.paintedColor = AEColor.values()[data.getByte("paintedColor")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.cm.readFromNBT( data );
|
||||
if( data.contains("paintedColor") )
|
||||
{
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
this.securityKey = data.getLong("securityKey");
|
||||
this.getConfigSlot().readFromNBT(data, "config");
|
||||
|
||||
this.securityKey = data.getLong( "securityKey" );
|
||||
this.getConfigSlot().readFromNBT( data, "config" );
|
||||
final CompoundNBT storedItems = data.getCompound("storedItems");
|
||||
for (final Object key : storedItems.keySet()) {
|
||||
final INBT obj = storedItems.get((String) key);
|
||||
if (obj instanceof CompoundNBT) {
|
||||
this.inventory.getStoredItems().add(AEItemStack.fromItemStack(ItemStack.read((CompoundNBT) obj)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final CompoundNBT storedItems = data.getCompound( "storedItems" );
|
||||
for( final Object key : storedItems.keySet() )
|
||||
{
|
||||
final INBT obj = storedItems.get( (String) key );
|
||||
if( obj instanceof CompoundNBT )
|
||||
{
|
||||
this.inventory.getStoredItems().add( AEItemStack.fromItemStack( ItemStack.read((CompoundNBT) obj) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
public void inventoryChanged() {
|
||||
try {
|
||||
this.saveChanges();
|
||||
this.getProxy().getGrid().postEvent(new MENetworkSecurityChange());
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
public void inventoryChanged()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.saveChanges();
|
||||
this.getProxy().getGrid().postEvent( new MENetworkSecurityChange() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void bootUpdate(final MENetworkChannelsChanged changed) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootUpdate( final MENetworkChannelsChanged changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void powerUpdate(final MENetworkPowerStatusChange changed) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerUpdate( final MENetworkPowerStatusChange changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
@Override
|
||||
public void onChunkUnloaded() {
|
||||
super.onChunkUnloaded();
|
||||
MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER));
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnloaded();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
if (Platform.isServer()) {
|
||||
this.isActive = true;
|
||||
MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.REGISTER));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.isActive = true;
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.REGISTER ) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER));
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
super.remove();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return new DimensionalCoord(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
public boolean isActive() {
|
||||
if (world != null && !world.isRemote) {
|
||||
return isPowered();
|
||||
} else {
|
||||
return this.isActive;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
if (world != null && !world.isRemote) {
|
||||
return isPowered();
|
||||
} else {
|
||||
return this.isActive;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
|
||||
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
|
||||
return (IMEMonitor<T>) this.securityMonitor;
|
||||
}
|
||||
return null;
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return (IMEMonitor<T>) this.securityMonitor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public long getLocatableSerial() {
|
||||
return this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLocatableSerial()
|
||||
{
|
||||
return this.securityKey;
|
||||
}
|
||||
public boolean isPowered() {
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.cm;
|
||||
}
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public long getSecurityKey() {
|
||||
return this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSecurityKey()
|
||||
{
|
||||
return this.securityKey;
|
||||
}
|
||||
@Override
|
||||
public void readPermissions(final Map<Integer, EnumSet<SecurityPermissions>> playerPerms) {
|
||||
final IPlayerRegistry pr = AEApi.instance().registries().players();
|
||||
|
||||
@Override
|
||||
public void readPermissions( final Map<Integer, EnumSet<SecurityPermissions>> playerPerms )
|
||||
{
|
||||
final IPlayerRegistry pr = AEApi.instance().registries().players();
|
||||
// read permissions
|
||||
for (final IAEItemStack ais : this.inventory.getStoredItems()) {
|
||||
final ItemStack is = ais.createItemStack();
|
||||
final Item i = is.getItem();
|
||||
if (i instanceof IBiometricCard) {
|
||||
final IBiometricCard bc = (IBiometricCard) i;
|
||||
bc.registerPermissions(new PlayerSecurityWrapper(playerPerms), pr, is);
|
||||
}
|
||||
}
|
||||
|
||||
// read permissions
|
||||
for( final IAEItemStack ais : this.inventory.getStoredItems() )
|
||||
{
|
||||
final ItemStack is = ais.createItemStack();
|
||||
final Item i = is.getItem();
|
||||
if( i instanceof IBiometricCard )
|
||||
{
|
||||
final IBiometricCard bc = (IBiometricCard) i;
|
||||
bc.registerPermissions( new PlayerSecurityWrapper( playerPerms ), pr, is );
|
||||
}
|
||||
}
|
||||
// make sure thea admin is Boss.
|
||||
playerPerms.put(this.getProxy().getNode().getPlayerID(), EnumSet.allOf(SecurityPermissions.class));
|
||||
}
|
||||
|
||||
// make sure thea admin is Boss.
|
||||
playerPerms.put( this.getProxy().getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
|
||||
}
|
||||
@Override
|
||||
public boolean isSecurityEnabled() {
|
||||
return this.isActive && this.getProxy().isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled()
|
||||
{
|
||||
return this.isActive && this.getProxy().isActive();
|
||||
}
|
||||
@Override
|
||||
public int getOwner() {
|
||||
return this.getProxy().getNode().getPlayerID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
return this.getProxy().getNode().getPlayerID();
|
||||
}
|
||||
@Override
|
||||
public AEColor getColor() {
|
||||
return this.paintedColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.paintedColor;
|
||||
}
|
||||
@Override
|
||||
public boolean recolourBlock(final Direction side, final AEColor newPaintedColor, final PlayerEntity who) {
|
||||
if (this.paintedColor == newPaintedColor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock( final Direction side, final AEColor newPaintedColor, final PlayerEntity who )
|
||||
{
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.paintedColor = newPaintedColor;
|
||||
this.saveChanges();
|
||||
this.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
this.saveChanges();
|
||||
this.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public AppEngInternalInventory getConfigSlot()
|
||||
{
|
||||
return this.configSlot;
|
||||
}
|
||||
public AppEngInternalInventory getConfigSlot() {
|
||||
return this.configSlot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,14 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class TileSkyCompass extends AEBaseTile
|
||||
{
|
||||
public class TileSkyCompass extends AEBaseTile {
|
||||
|
||||
public TileSkyCompass(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
public TileSkyCompass(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -50,283 +49,233 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable {
|
||||
public static final double POWER_PER_TICK = 5;
|
||||
public static final int MIN_BURN_SPEED = 20;
|
||||
public static final int MAX_BURN_SPEED = 200;
|
||||
public static final double DILATION_SCALING = 25.0; // x4 ~ 40 AE/t at max
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1);
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new FuelSlotFilter());
|
||||
|
||||
public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable
|
||||
{
|
||||
public static final double POWER_PER_TICK = 5;
|
||||
public static final int MIN_BURN_SPEED = 20;
|
||||
public static final int MAX_BURN_SPEED = 200;
|
||||
public static final double DILATION_SCALING = 25.0; // x4 ~ 40 AE/t at max
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new FuelSlotFilter() );
|
||||
private int burnSpeed = 100;
|
||||
private double burnTime = 0;
|
||||
private double maxBurnTime = 0;
|
||||
|
||||
private int burnSpeed = 100;
|
||||
private double burnTime = 0;
|
||||
private double maxBurnTime = 0;
|
||||
// client side..
|
||||
public boolean isOn;
|
||||
|
||||
// client side..
|
||||
public boolean isOn;
|
||||
public TileVibrationChamber(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage(0);
|
||||
this.getProxy().setFlags();
|
||||
}
|
||||
|
||||
public TileVibrationChamber(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
this.getProxy().setFlags();
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final boolean wasOn = this.isOn;
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean wasOn = this.isOn;
|
||||
this.isOn = data.readBoolean();
|
||||
|
||||
this.isOn = data.readBoolean();
|
||||
return wasOn != this.isOn || c; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
return wasOn != this.isOn || c; // TESR doesn't need updates!
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.getBurnTime() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getBurnTime() > 0 );
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
data.putDouble("burnTime", this.getBurnTime());
|
||||
data.putDouble("maxBurnTime", this.getMaxBurnTime());
|
||||
data.putInt("burnSpeed", this.getBurnSpeed());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
data.putDouble("burnTime", this.getBurnTime());
|
||||
data.putDouble("maxBurnTime", this.getMaxBurnTime());
|
||||
data.putInt( "burnSpeed", this.getBurnSpeed() );
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.setBurnTime(data.getDouble("burnTime"));
|
||||
this.setMaxBurnTime(data.getDouble("maxBurnTime"));
|
||||
this.setBurnSpeed(data.getInt("burnSpeed"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.setBurnTime( data.getDouble( "burnTime" ) );
|
||||
this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) );
|
||||
this.setBurnSpeed( data.getInt( "burnSpeed" ) );
|
||||
}
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide(@Nonnull Direction facing) {
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide( @Nonnull Direction facing )
|
||||
{
|
||||
return this.invExt;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (this.getBurnTime() <= 0) {
|
||||
if (this.canEatFuel()) {
|
||||
try {
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
} catch (final GridAccessException e) {
|
||||
// wake up!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
if( this.getBurnTime() <= 0 )
|
||||
{
|
||||
if( this.canEatFuel() )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// wake up!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private boolean canEatFuel() {
|
||||
final ItemStack is = this.inv.getStackInSlot(0);
|
||||
if (!is.isEmpty()) {
|
||||
final int newBurnTime = ForgeHooks.getBurnTime(is);
|
||||
if (newBurnTime > 0 && is.getCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canEatFuel()
|
||||
{
|
||||
final ItemStack is = this.inv.getStackInSlot( 0 );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final int newBurnTime = ForgeHooks.getBurnTime( is );
|
||||
if( newBurnTime > 0 && is.getCount() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return new DimensionalCoord(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(final IGridNode node) {
|
||||
if (this.getBurnTime() <= 0) {
|
||||
this.eatFuel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
if( this.getBurnTime() <= 0 )
|
||||
{
|
||||
this.eatFuel();
|
||||
}
|
||||
return new TickingRequest(TickRates.VibrationChamber.getMin(), TickRates.VibrationChamber.getMax(),
|
||||
this.getBurnTime() <= 0, false);
|
||||
}
|
||||
|
||||
return new TickingRequest( TickRates.VibrationChamber.getMin(), TickRates.VibrationChamber.getMax(), this.getBurnTime() <= 0, false );
|
||||
}
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) {
|
||||
if (this.getBurnTime() <= 0) {
|
||||
this.eatFuel();
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
|
||||
{
|
||||
if( this.getBurnTime() <= 0 )
|
||||
{
|
||||
this.eatFuel();
|
||||
if (this.getBurnTime() > 0) {
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
if( this.getBurnTime() > 0 )
|
||||
{
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
this.setBurnSpeed(100);
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
this.setBurnSpeed( 100 );
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
this.setBurnSpeed(Math.max(MIN_BURN_SPEED, Math.min(this.getBurnSpeed(), MAX_BURN_SPEED)));
|
||||
final double dilation = this.getBurnSpeed() / DILATION_SCALING;
|
||||
|
||||
this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) );
|
||||
final double dilation = this.getBurnSpeed() / DILATION_SCALING;
|
||||
double timePassed = ticksSinceLastCall * dilation;
|
||||
this.setBurnTime(this.getBurnTime() - timePassed);
|
||||
if (this.getBurnTime() < 0) {
|
||||
timePassed += this.getBurnTime();
|
||||
this.setBurnTime(0);
|
||||
}
|
||||
|
||||
double timePassed = ticksSinceLastCall * dilation;
|
||||
this.setBurnTime( this.getBurnTime() - timePassed );
|
||||
if( this.getBurnTime() < 0 )
|
||||
{
|
||||
timePassed += this.getBurnTime();
|
||||
this.setBurnTime( 0 );
|
||||
}
|
||||
try {
|
||||
final IEnergyGrid grid = this.getProxy().getEnergy();
|
||||
final double newPower = timePassed * POWER_PER_TICK;
|
||||
final double overFlow = grid.injectPower(newPower, Actionable.SIMULATE);
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergyGrid grid = this.getProxy().getEnergy();
|
||||
final double newPower = timePassed * POWER_PER_TICK;
|
||||
final double overFlow = grid.injectPower( newPower, Actionable.SIMULATE );
|
||||
// burn the over flow.
|
||||
grid.injectPower(Math.max(0.0, newPower - overFlow), Actionable.MODULATE);
|
||||
|
||||
// burn the over flow.
|
||||
grid.injectPower( Math.max( 0.0, newPower - overFlow ), Actionable.MODULATE );
|
||||
if (overFlow > 0) {
|
||||
this.setBurnSpeed(this.getBurnSpeed() - ticksSinceLastCall);
|
||||
} else {
|
||||
this.setBurnSpeed(this.getBurnSpeed() + ticksSinceLastCall);
|
||||
}
|
||||
|
||||
if( overFlow > 0 )
|
||||
{
|
||||
this.setBurnSpeed( this.getBurnSpeed() - ticksSinceLastCall );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBurnSpeed( this.getBurnSpeed() + ticksSinceLastCall );
|
||||
}
|
||||
this.setBurnSpeed(Math.max(MIN_BURN_SPEED, Math.min(this.getBurnSpeed(), MAX_BURN_SPEED)));
|
||||
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
|
||||
} catch (final GridAccessException e) {
|
||||
this.setBurnSpeed(this.getBurnSpeed() - ticksSinceLastCall);
|
||||
this.setBurnSpeed(Math.max(MIN_BURN_SPEED, Math.min(this.getBurnSpeed(), MAX_BURN_SPEED)));
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
}
|
||||
|
||||
this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) );
|
||||
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
this.setBurnSpeed( this.getBurnSpeed() - ticksSinceLastCall );
|
||||
this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) );
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
}
|
||||
private void eatFuel() {
|
||||
final ItemStack is = this.inv.getStackInSlot(0);
|
||||
if (!is.isEmpty()) {
|
||||
final int newBurnTime = ForgeHooks.getBurnTime(is);
|
||||
if (newBurnTime > 0 && is.getCount() > 0) {
|
||||
this.setBurnTime(this.getBurnTime() + newBurnTime);
|
||||
this.setMaxBurnTime(this.getBurnTime());
|
||||
|
||||
private void eatFuel()
|
||||
{
|
||||
final ItemStack is = this.inv.getStackInSlot( 0 );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final int newBurnTime = ForgeHooks.getBurnTime( is );
|
||||
if( newBurnTime > 0 && is.getCount() > 0 )
|
||||
{
|
||||
this.setBurnTime( this.getBurnTime() + newBurnTime );
|
||||
this.setMaxBurnTime( this.getBurnTime() );
|
||||
final Item fuelItem = is.getItem();
|
||||
is.shrink(1);
|
||||
|
||||
final Item fuelItem = is.getItem();
|
||||
is.shrink( 1 );
|
||||
if (is.isEmpty()) {
|
||||
this.inv.setStackInSlot(0, fuelItem.getContainerItem(is));
|
||||
} else {
|
||||
this.inv.setStackInSlot(0, is);
|
||||
}
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
this.inv.setStackInSlot( 0, fuelItem.getContainerItem( is ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setStackInSlot( 0, is );
|
||||
}
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
if (this.getBurnTime() > 0) {
|
||||
try {
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
} catch (final GridAccessException e) {
|
||||
// gah!
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getBurnTime() > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// gah!
|
||||
}
|
||||
}
|
||||
// state change
|
||||
if ((!this.isOn && this.getBurnTime() > 0) || (this.isOn && this.getBurnTime() <= 0)) {
|
||||
this.isOn = this.getBurnTime() > 0;
|
||||
this.markForUpdate();
|
||||
|
||||
// state change
|
||||
if( ( !this.isOn && this.getBurnTime() > 0 ) || ( this.isOn && this.getBurnTime() <= 0 ) )
|
||||
{
|
||||
this.isOn = this.getBurnTime() > 0;
|
||||
this.markForUpdate();
|
||||
if (this.hasWorld()) {
|
||||
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.hasWorld() )
|
||||
{
|
||||
Platform.notifyBlocksOfNeighbors( this.world, this.pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
public int getBurnSpeed() {
|
||||
return this.burnSpeed;
|
||||
}
|
||||
|
||||
public int getBurnSpeed()
|
||||
{
|
||||
return this.burnSpeed;
|
||||
}
|
||||
private void setBurnSpeed(final int burnSpeed) {
|
||||
this.burnSpeed = burnSpeed;
|
||||
}
|
||||
|
||||
private void setBurnSpeed( final int burnSpeed )
|
||||
{
|
||||
this.burnSpeed = burnSpeed;
|
||||
}
|
||||
public double getMaxBurnTime() {
|
||||
return this.maxBurnTime;
|
||||
}
|
||||
|
||||
public double getMaxBurnTime()
|
||||
{
|
||||
return this.maxBurnTime;
|
||||
}
|
||||
private void setMaxBurnTime(final double maxBurnTime) {
|
||||
this.maxBurnTime = maxBurnTime;
|
||||
}
|
||||
|
||||
private void setMaxBurnTime( final double maxBurnTime )
|
||||
{
|
||||
this.maxBurnTime = maxBurnTime;
|
||||
}
|
||||
public double getBurnTime() {
|
||||
return this.burnTime;
|
||||
}
|
||||
|
||||
public double getBurnTime()
|
||||
{
|
||||
return this.burnTime;
|
||||
}
|
||||
private void setBurnTime(final double burnTime) {
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
private void setBurnTime( final double burnTime )
|
||||
{
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
private class FuelSlotFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
return ForgeHooks.getBurnTime(inv.getStackInSlot(slot)) == 0;
|
||||
}
|
||||
|
||||
private class FuelSlotFilter implements IAEItemFilter
|
||||
{
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return ForgeHooks.getBurnTime( inv.getStackInSlot( slot ) ) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
return ForgeHooks.getBurnTime( stack ) != 0;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
return ForgeHooks.getBurnTime(stack) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user