Fix some class attributes being hidden.
This commit is contained in:
@@ -44,19 +44,19 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
|||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
for (int i = 0; i < itemFilters.getSlots(); ++i) {
|
for (int i = 0; i < itemFilters.getSlots(); ++i) {
|
||||||
ItemStack filterSlot = itemFilters.getStackInSlot(i);
|
ItemStack filteredItem = itemFilters.getStackInSlot(i);
|
||||||
|
|
||||||
if (filterSlot.getCount() > 1) {
|
if (filteredItem.getCount() > 1) {
|
||||||
filterSlot.setCount(1);
|
filteredItem.setCount(1);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fluidFilters.getSlots(); ++i) {
|
for (int i = 0; i < fluidFilters.getSlots(); ++i) {
|
||||||
FluidStack filterSlot = fluidFilters.getFluid(i);
|
FluidStack filteredFluid = fluidFilters.getFluid(i);
|
||||||
|
|
||||||
if (!filterSlot.isEmpty() && filterSlot.getAmount() != FluidAttributes.BUCKET_VOLUME) {
|
if (!filteredFluid.isEmpty() && filteredFluid.getAmount() != FluidAttributes.BUCKET_VOLUME) {
|
||||||
filterSlot.setAmount(FluidAttributes.BUCKET_VOLUME);
|
filteredFluid.setAmount(FluidAttributes.BUCKET_VOLUME);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -113,7 +113,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
private boolean reading;
|
private boolean readingInventory;
|
||||||
|
|
||||||
private final Set<ICraftingGridListener> craftingListeners = new HashSet<>();
|
private final Set<ICraftingGridListener> craftingListeners = new HashSet<>();
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
|||||||
|
|
||||||
craftingListeners.forEach(ICraftingGridListener::onCraftingMatrixChanged);
|
craftingListeners.forEach(ICraftingGridListener::onCraftingMatrixChanged);
|
||||||
|
|
||||||
if (!reading) {
|
if (!readingInventory) {
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,7 +662,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
|||||||
allowedTagList.readFromNbt(tag.getCompound(NBT_ALLOWED_TAGS));
|
allowedTagList.readFromNbt(tag.getCompound(NBT_ALLOWED_TAGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
reading = true;
|
readingInventory = true;
|
||||||
|
|
||||||
StackUtils.readItems(matrix, 0, tag);
|
StackUtils.readItems(matrix, 0, tag);
|
||||||
StackUtils.readItems(patterns, 1, tag);
|
StackUtils.readItems(patterns, 1, tag);
|
||||||
@@ -681,7 +681,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
|||||||
tabPage = tag.getInt(NBT_TAB_PAGE);
|
tabPage = tag.getInt(NBT_TAB_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
reading = false;
|
readingInventory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -24,7 +24,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class FluidStorageCache implements IStorageCache<FluidStack> {
|
public class FluidStorageCache implements IStorageCache<FluidStack> {
|
||||||
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE_ACTION = cause -> network -> network.getFluidStorageCache().invalidate(cause);
|
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE_ACTION = cause -> invalidatedNetwork -> invalidatedNetwork.getFluidStorageCache().invalidate(cause);
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(FluidStorageCache.class);
|
private static final Logger LOGGER = LogManager.getLogger(FluidStorageCache.class);
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class ItemStorageCache implements IStorageCache<ItemStack> {
|
public class ItemStorageCache implements IStorageCache<ItemStack> {
|
||||||
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE_ACTION = cause -> network -> network.getItemStorageCache().invalidate(cause);
|
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE_ACTION = cause -> invalidatedNetwork -> invalidatedNetwork.getItemStorageCache().invalidate(cause);
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(ItemStorageCache.class);
|
private static final Logger LOGGER = LogManager.getLogger(ItemStorageCache.class);
|
||||||
|
|
||||||
|
@@ -115,19 +115,19 @@ public class StorageDiskManager extends WorldSavedData implements IStorageDiskMa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT write(CompoundNBT tag) {
|
public CompoundNBT write(CompoundNBT tag) {
|
||||||
ListNBT disks = new ListNBT();
|
ListNBT disksTag = new ListNBT();
|
||||||
|
|
||||||
for (Map.Entry<UUID, IStorageDisk> entry : this.disks.entrySet()) {
|
for (Map.Entry<UUID, IStorageDisk> entry : disks.entrySet()) {
|
||||||
CompoundNBT diskTag = new CompoundNBT();
|
CompoundNBT diskTag = new CompoundNBT();
|
||||||
|
|
||||||
diskTag.putUniqueId(NBT_DISK_ID, entry.getKey());
|
diskTag.putUniqueId(NBT_DISK_ID, entry.getKey());
|
||||||
diskTag.put(NBT_DISK_DATA, entry.getValue().writeToNbt());
|
diskTag.put(NBT_DISK_DATA, entry.getValue().writeToNbt());
|
||||||
diskTag.putString(NBT_DISK_TYPE, entry.getValue().getFactoryId().toString());
|
diskTag.putString(NBT_DISK_TYPE, entry.getValue().getFactoryId().toString());
|
||||||
|
|
||||||
disks.add(diskTag);
|
disksTag.add(diskTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.put(NBT_DISKS, disks);
|
tag.put(NBT_DISKS, disksTag);
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class GridContainer extends BaseContainer implements ICraftingGridListener {
|
public class GridContainer extends BaseContainer implements ICraftingGridListener {
|
||||||
private final IGrid grid;
|
private final IGrid grid;
|
||||||
private IStorageCache cache;
|
private IStorageCache storageCache;
|
||||||
private IStorageCacheListener listener;
|
private IStorageCacheListener storageCacheListener;
|
||||||
private IScreenInfoProvider screenInfoProvider;
|
private IScreenInfoProvider screenInfoProvider;
|
||||||
|
|
||||||
private ResultCraftingGridSlot craftingResultSlot;
|
private ResultCraftingGridSlot craftingResultSlot;
|
||||||
@@ -247,18 +247,18 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
|||||||
// The grid is offline.
|
// The grid is offline.
|
||||||
if (grid.getStorageCache() == null) {
|
if (grid.getStorageCache() == null) {
|
||||||
// The grid just went offline, there is still a listener.
|
// The grid just went offline, there is still a listener.
|
||||||
if (listener != null) {
|
if (storageCacheListener != null) {
|
||||||
// Remove it from the previous cache and clean up.
|
// Remove it from the previous cache and clean up.
|
||||||
cache.removeListener(listener);
|
storageCache.removeListener(storageCacheListener);
|
||||||
|
|
||||||
listener = null;
|
storageCacheListener = null;
|
||||||
cache = null;
|
storageCache = null;
|
||||||
}
|
}
|
||||||
} else if (listener == null) { // The grid came online.
|
} else if (storageCacheListener == null) { // The grid came online.
|
||||||
listener = grid.createListener((ServerPlayerEntity) getPlayer());
|
storageCacheListener = grid.createListener((ServerPlayerEntity) getPlayer());
|
||||||
cache = grid.getStorageCache();
|
storageCache = grid.getStorageCache();
|
||||||
|
|
||||||
cache.addListener(listener);
|
storageCache.addListener(storageCacheListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,8 +272,8 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
|||||||
if (!player.getEntityWorld().isRemote) {
|
if (!player.getEntityWorld().isRemote) {
|
||||||
grid.onClosed(player);
|
grid.onClosed(player);
|
||||||
|
|
||||||
if (cache != null && listener != null) {
|
if (storageCache != null && storageCacheListener != null) {
|
||||||
cache.removeListener(listener);
|
storageCache.removeListener(storageCacheListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,17 +59,14 @@ public class FilterItem extends Item {
|
|||||||
return new TranslationTextComponent("gui.refinedstorage.filter");
|
return new TranslationTextComponent("gui.refinedstorage.filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public Container createMenu(int windowId, PlayerInventory inventory, PlayerEntity player) {
|
public Container createMenu(int windowId, PlayerInventory inventory, PlayerEntity player) {
|
||||||
return new FilterContainer(player, inventory.getCurrentItem(), windowId);
|
return new FilterContainer(player, inventory.getCurrentItem(), windowId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new ActionResult<>(ActionResultType.SUCCESS, stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActionResult<>(ActionResultType.PASS, stack);
|
return new ActionResult<>(ActionResultType.CONSUME, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -76,7 +76,7 @@ public class FilterScreen extends BaseScreen<FilterContainer> {
|
|||||||
nameField.setCanLoseFocus(true);
|
nameField.setCanLoseFocus(true);
|
||||||
nameField.setFocused2(false);
|
nameField.setFocused2(false);
|
||||||
nameField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
|
nameField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
|
||||||
nameField.setResponder(name -> sendUpdate());
|
nameField.setResponder(content -> sendUpdate());
|
||||||
|
|
||||||
addButton(nameField);
|
addButton(nameField);
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
ItemListLine line = new ItemListLine();
|
ItemListLine line = new ItemListLine();
|
||||||
|
|
||||||
for (Item item : ItemTags.getCollection().get(owningTag).getAllElements()) {
|
for (Item itemInTag : ItemTags.getCollection().get(owningTag).getAllElements()) {
|
||||||
if (itemCount > 0 && itemCount % 8 == 0) {
|
if (itemCount > 0 && itemCount % 8 == 0) {
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
line = new ItemListLine();
|
line = new ItemListLine();
|
||||||
@@ -93,7 +93,7 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
itemCount++;
|
itemCount++;
|
||||||
|
|
||||||
line.addItem(new ItemStack(item));
|
line.addItem(new ItemStack(itemInTag));
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
@@ -108,7 +108,7 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
FluidListLine line = new FluidListLine();
|
FluidListLine line = new FluidListLine();
|
||||||
|
|
||||||
for (Fluid fluid : FluidTags.getCollection().get(owningTag).getAllElements()) {
|
for (Fluid fluidInTag : FluidTags.getCollection().get(owningTag).getAllElements()) {
|
||||||
if (fluidCount > 0 && fluidCount % 8 == 0) {
|
if (fluidCount > 0 && fluidCount % 8 == 0) {
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
line = new FluidListLine();
|
line = new FluidListLine();
|
||||||
@@ -116,7 +116,7 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
fluidCount++;
|
fluidCount++;
|
||||||
|
|
||||||
line.addFluid(new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME));
|
line.addFluid(new FluidStack(fluidInTag, FluidAttributes.BUCKET_VOLUME));
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
@@ -332,8 +332,8 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStack, int x, int y) {
|
public void render(MatrixStack matrixStack, int x, int y) {
|
||||||
for (ItemStack item : items) {
|
for (ItemStack itemInList : items) {
|
||||||
renderItem(matrixStack, x + 3, y, item);
|
renderItem(matrixStack, x + 3, y, itemInList);
|
||||||
|
|
||||||
x += 17;
|
x += 17;
|
||||||
}
|
}
|
||||||
@@ -341,9 +341,9 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTooltip(MatrixStack matrixStack, int x, int y, int mx, int my) {
|
public void renderTooltip(MatrixStack matrixStack, int x, int y, int mx, int my) {
|
||||||
for (ItemStack item : items) {
|
for (ItemStack itemInList : items) {
|
||||||
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
||||||
AlternativesScreen.this.renderTooltip(matrixStack, item, mx, my, RenderUtils.getTooltipFromItem(item));
|
AlternativesScreen.this.renderTooltip(matrixStack, itemInList, mx, my, RenderUtils.getTooltipFromItem(itemInList));
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 17;
|
x += 17;
|
||||||
@@ -360,8 +360,8 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStack, int x, int y) {
|
public void render(MatrixStack matrixStack, int x, int y) {
|
||||||
for (FluidStack fluid : fluids) {
|
for (FluidStack fluidInList : fluids) {
|
||||||
FluidRenderer.INSTANCE.render(matrixStack, x + 3, y, fluid);
|
FluidRenderer.INSTANCE.render(matrixStack, x + 3, y, fluidInList);
|
||||||
|
|
||||||
x += 17;
|
x += 17;
|
||||||
}
|
}
|
||||||
@@ -369,9 +369,9 @@ public class AlternativesScreen extends BaseScreen<AlternativesContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTooltip(MatrixStack matrixStack, int x, int y, int mx, int my) {
|
public void renderTooltip(MatrixStack matrixStack, int x, int y, int mx, int my) {
|
||||||
for (FluidStack fluid : fluids) {
|
for (FluidStack fluidInList : fluids) {
|
||||||
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
||||||
AlternativesScreen.this.renderTooltip(matrixStack, mx, my, fluid.getDisplayName().getString());
|
AlternativesScreen.this.renderTooltip(matrixStack, mx, my, fluidInList.getDisplayName().getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 17;
|
x += 17;
|
||||||
|
@@ -15,10 +15,10 @@ public class TooltipGridFilter implements Predicate<IGridStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(IGridStack stack) {
|
public boolean test(IGridStack stack) {
|
||||||
List<ITextComponent> tooltip = stack.getTooltip(false);
|
List<ITextComponent> stackTooltip = stack.getTooltip(false);
|
||||||
|
|
||||||
for (int i = 1; i < tooltip.size(); ++i) {
|
for (int i = 1; i < stackTooltip.size(); ++i) {
|
||||||
if (tooltip.get(i).getString().toLowerCase().contains(this.tooltip.toLowerCase())) {
|
if (stackTooltip.get(i).getString().toLowerCase().contains(tooltip.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,10 +49,10 @@ public abstract class BaseGridView implements IGridView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IGridStack> stacks = new ArrayList<>();
|
List<IGridStack> newStacks = new ArrayList<>();
|
||||||
|
|
||||||
if (screen.getGrid().isGridActive()) {
|
if (screen.getGrid().isGridActive()) {
|
||||||
stacks.addAll(map.values());
|
newStacks.addAll(map.values());
|
||||||
|
|
||||||
IGrid grid = screen.getGrid();
|
IGrid grid = screen.getGrid();
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public abstract class BaseGridView implements IGridView {
|
|||||||
(grid.getTabSelected() >= 0 && grid.getTabSelected() < grid.getTabs().size()) ? grid.getTabs().get(grid.getTabSelected()).getFilters() : grid.getFilters()
|
(grid.getTabSelected() >= 0 && grid.getTabSelected() < grid.getTabs().size()) ? grid.getTabs().get(grid.getTabSelected()).getFilters() : grid.getFilters()
|
||||||
);
|
);
|
||||||
|
|
||||||
stacks.removeIf(stack -> {
|
newStacks.removeIf(stack -> {
|
||||||
// If this is a crafting stack,
|
// If this is a crafting stack,
|
||||||
// and there is a regular matching stack in the view too,
|
// and there is a regular matching stack in the view too,
|
||||||
// and we aren't in "view only craftables" mode,
|
// and we aren't in "view only craftables" mode,
|
||||||
@@ -85,16 +85,16 @@ public abstract class BaseGridView implements IGridView {
|
|||||||
|
|
||||||
SortingDirection sortingDirection = grid.getSortingDirection() == IGrid.SORTING_DIRECTION_DESCENDING ? SortingDirection.DESCENDING : SortingDirection.ASCENDING;
|
SortingDirection sortingDirection = grid.getSortingDirection() == IGrid.SORTING_DIRECTION_DESCENDING ? SortingDirection.DESCENDING : SortingDirection.ASCENDING;
|
||||||
|
|
||||||
stacks.sort((left, right) -> defaultSorter.compare(left, right, sortingDirection));
|
newStacks.sort((left, right) -> defaultSorter.compare(left, right, sortingDirection));
|
||||||
|
|
||||||
for (IGridSorter sorter : sorters) {
|
for (IGridSorter sorter : sorters) {
|
||||||
if (sorter.isApplicable(grid)) {
|
if (sorter.isApplicable(grid)) {
|
||||||
stacks.sort((left, right) -> sorter.compare(left, right, sortingDirection));
|
newStacks.sort((left, right) -> sorter.compare(left, right, sortingDirection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stacks = stacks;
|
this.stacks = newStacks;
|
||||||
|
|
||||||
this.screen.updateScrollbar();
|
this.screen.updateScrollbar();
|
||||||
}
|
}
|
||||||
|
@@ -107,16 +107,16 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
storage = null;
|
storage = null;
|
||||||
cache = null;
|
cache = null;
|
||||||
} else {
|
} else {
|
||||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) player.world).getByStack(getDiskInventory().getStackInSlot(0));
|
IStorageDisk diskInSlot = API.instance().getStorageDiskManager((ServerWorld) player.world).getByStack(getDiskInventory().getStackInSlot(0));
|
||||||
|
|
||||||
if (disk != null) {
|
if (diskInSlot != null) {
|
||||||
StorageType type = ((IStorageDiskProvider) getDiskInventory().getStackInSlot(0).getItem()).getType();
|
StorageType type = ((IStorageDiskProvider) getDiskInventory().getStackInSlot(0).getItem()).getType();
|
||||||
|
|
||||||
if (type == StorageType.ITEM) {
|
if (type == StorageType.ITEM) {
|
||||||
storage = new PortableItemStorageDisk(disk, PortableGrid.this);
|
storage = new PortableItemStorageDisk(diskInSlot, PortableGrid.this);
|
||||||
cache = new PortableItemStorageCache(PortableGrid.this);
|
cache = new PortableItemStorageCache(PortableGrid.this);
|
||||||
} else if (type == StorageType.FLUID) {
|
} else if (type == StorageType.FLUID) {
|
||||||
storage = new PortableFluidStorageDisk(disk, PortableGrid.this);
|
storage = new PortableFluidStorageDisk(diskInSlot, PortableGrid.this);
|
||||||
cache = new PortableFluidStorageCache(PortableGrid.this);
|
cache = new PortableFluidStorageCache(PortableGrid.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,20 +186,17 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
@Override
|
@Override
|
||||||
public void drainEnergy(int energy) {
|
public void drainEnergy(int energy) {
|
||||||
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() && ((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE) {
|
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() && ((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE) {
|
||||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
stack.getCapability(CapabilityEnergy.ENERGY, null)
|
||||||
|
.ifPresent(energyStorage -> energyStorage.extractEnergy(energy, false));
|
||||||
if (storage != null) {
|
|
||||||
storage.extractEnergy(energy, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergy() {
|
public int getEnergy() {
|
||||||
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() && ((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE) {
|
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() && ((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE) {
|
||||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
return stack.getCapability(CapabilityEnergy.ENERGY, null)
|
||||||
|
.map(IEnergyStorage::getEnergyStored)
|
||||||
return storage == null ? RS.SERVER_CONFIG.getPortableGrid().getCapacity() : storage.getEnergyStored();
|
.orElse(RS.SERVER_CONFIG.getPortableGrid().getCapacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
return RS.SERVER_CONFIG.getPortableGrid().getCapacity();
|
return RS.SERVER_CONFIG.getPortableGrid().getCapacity();
|
||||||
|
@@ -194,16 +194,16 @@ public class PortableGridTile extends BaseTile implements ITickableTileEntity, I
|
|||||||
this.storage = null;
|
this.storage = null;
|
||||||
this.cache = null;
|
this.cache = null;
|
||||||
} else {
|
} else {
|
||||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).getByStack(getDiskInventory().getStackInSlot(0));
|
IStorageDisk diskInSlot = API.instance().getStorageDiskManager((ServerWorld) world).getByStack(getDiskInventory().getStackInSlot(0));
|
||||||
|
|
||||||
if (disk != null) {
|
if (diskInSlot != null) {
|
||||||
StorageType type = ((IStorageDiskProvider) getDiskInventory().getStackInSlot(0).getItem()).getType();
|
StorageType diskType = ((IStorageDiskProvider) getDiskInventory().getStackInSlot(0).getItem()).getType();
|
||||||
|
|
||||||
if (type == StorageType.ITEM) {
|
if (diskType == StorageType.ITEM) {
|
||||||
this.storage = new PortableItemStorageDisk(disk, this);
|
this.storage = new PortableItemStorageDisk(diskInSlot, this);
|
||||||
this.cache = new PortableItemStorageCache(this);
|
this.cache = new PortableItemStorageCache(this);
|
||||||
} else if (type == StorageType.FLUID) {
|
} else if (diskType == StorageType.FLUID) {
|
||||||
this.storage = new PortableFluidStorageDisk(disk, this);
|
this.storage = new PortableFluidStorageDisk(diskInSlot, this);
|
||||||
this.cache = new PortableFluidStorageCache(this);
|
this.cache = new PortableFluidStorageCache(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,9 +236,7 @@ public class PortableGridTile extends BaseTile implements ITickableTileEntity, I
|
|||||||
this.tabPage = WirelessGridItem.getTabPage(stack);
|
this.tabPage = WirelessGridItem.getTabPage(stack);
|
||||||
this.size = WirelessGridItem.getSize(stack);
|
this.size = WirelessGridItem.getSize(stack);
|
||||||
|
|
||||||
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY).orElse(null);
|
this.energyStorage = createEnergyStorage(stack.getCapability(CapabilityEnergy.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0));
|
||||||
|
|
||||||
this.energyStorage = createEnergyStorage(energyStorage != null ? energyStorage.getEnergyStored() : 0);
|
|
||||||
|
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
Reference in New Issue
Block a user