Update changelog, small fixes
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
### 1.8.1
|
### 1.8.1
|
||||||
- Port to Minecraft 1.15.2 (raoulvdberge)
|
- Port to Minecraft 1.15.2 (raoulvdberge)
|
||||||
|
- The Storage Monitor supports fluids as well now (V1RTUOZ)
|
||||||
|
|
||||||
### 1.8
|
### 1.8
|
||||||
- Port to Minecraft 1.15 (raoulvdberge)
|
- Port to Minecraft 1.15 (raoulvdberge)
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ErrorCraftingPreviewElement;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ErrorCraftingPreviewElement;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridCraftingPreviewResponseMessage;
|
import com.raoulvdberge.refinedstorage.network.grid.GridCraftingPreviewResponseMessage;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridCraftingStartResponseMessage;
|
import com.raoulvdberge.refinedstorage.network.grid.GridCraftingStartResponseMessage;
|
||||||
|
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
@@ -41,25 +41,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack bucket = ItemStack.EMPTY;
|
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> {
|
||||||
|
|
||||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
|
||||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (API.instance().getComparer().isEqualNoQuantity(StackUtils.EMPTY_BUCKET, slot)) {
|
|
||||||
bucket = StackUtils.EMPTY_BUCKET.copy();
|
|
||||||
|
|
||||||
player.inventory.decrStackSize(i, 1);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bucket.isEmpty()) {
|
|
||||||
bucket = network.extractItem(StackUtils.EMPTY_BUCKET, 1, Action.PERFORM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bucket.isEmpty()) {
|
|
||||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||||
|
|
||||||
@@ -78,7 +60,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
|||||||
|
|
||||||
network.getNetworkItemManager().drainEnergy(player, RS.SERVER_CONFIG.getWirelessFluidGrid().getExtractUsage());
|
network.getNetworkItemManager().drainEnergy(player, RS.SERVER_CONFIG.getWirelessFluidGrid().getExtractUsage());
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.raoulvdberge.refinedstorage.tile.StorageMonitorTile;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||||
|
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
@@ -49,7 +50,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
private FluidInventory fluidFilter = new FluidInventory(1, 1000)
|
private FluidInventory fluidFilter = new FluidInventory(1, FluidAttributes.BUCKET_VOLUME)
|
||||||
.addListener((handler, slot, reading) -> {
|
.addListener((handler, slot, reading) -> {
|
||||||
if (!reading) {
|
if (!reading) {
|
||||||
WorldUtils.updateBlock(world, pos);
|
WorldUtils.updateBlock(world, pos);
|
||||||
@@ -85,6 +86,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
if (getType() != IType.ITEMS) {
|
if (getType() != IType.ITEMS) {
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
@@ -145,10 +147,13 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
|
|
||||||
private void depositFluids(PlayerEntity player, ItemStack toInsert) {
|
private void depositFluids(PlayerEntity player, ItemStack toInsert) {
|
||||||
FluidStack filter = fluidFilter.getFluid(0);
|
FluidStack filter = fluidFilter.getFluid(0);
|
||||||
|
|
||||||
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(toInsert, true);
|
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(toInsert, true);
|
||||||
|
|
||||||
if (filter.isEmpty() || !API.instance().getComparer().isEqual(filter, result.getRight(), compare)) {
|
if (filter.isEmpty() || !API.instance().getComparer().isEqual(filter, result.getRight(), compare)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.getValue().isEmpty() && network.insertFluid(result.getValue(), result.getValue().getAmount(), Action.SIMULATE).isEmpty()) {
|
if (!result.getValue().isEmpty() && network.insertFluid(result.getValue(), result.getValue().getAmount(), Action.SIMULATE).isEmpty()) {
|
||||||
network.getFluidStorageTracker().changed(player, result.getValue().copy());
|
network.getFluidStorageTracker().changed(player, result.getValue().copy());
|
||||||
|
|
||||||
@@ -198,7 +203,6 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void extractFluids(PlayerEntity player) {
|
private void extractFluids(PlayerEntity player) {
|
||||||
|
|
||||||
FluidStack filter = fluidFilter.getFluid(0);
|
FluidStack filter = fluidFilter.getFluid(0);
|
||||||
|
|
||||||
if (filter.isEmpty()) {
|
if (filter.isEmpty()) {
|
||||||
@@ -212,27 +216,8 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
|
|
||||||
boolean shift = player.isCrouching();
|
boolean shift = player.isCrouching();
|
||||||
if (shift) {
|
if (shift) {
|
||||||
ItemStack bucket = ItemStack.EMPTY;
|
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> {
|
||||||
|
|
||||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
|
||||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (API.instance().getComparer().isEqualNoQuantity(StackUtils.EMPTY_BUCKET, slot)) {
|
|
||||||
bucket = StackUtils.EMPTY_BUCKET.copy();
|
|
||||||
|
|
||||||
player.inventory.decrStackSize(i, 1);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bucket.isEmpty()) {
|
|
||||||
bucket = network.extractItem(StackUtils.EMPTY_BUCKET, 1, Action.PERFORM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bucket.isEmpty()) {
|
|
||||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||||
|
|
||||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||||
|
|
||||||
fluidHandler.fill(network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
fluidHandler.fill(network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||||
@@ -241,7 +226,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), fluidHandler.getContainer());
|
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), fluidHandler.getContainer());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,11 +304,13 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
|||||||
return stored != null ? stored.getCount() : 0;
|
return stored != null ? stored.getCount() : 0;
|
||||||
} else if (getType() == IType.FLUIDS) {
|
} else if (getType() == IType.FLUIDS) {
|
||||||
FluidStack toCheck = fluidFilter.getFluid(0);
|
FluidStack toCheck = fluidFilter.getFluid(0);
|
||||||
|
|
||||||
if (toCheck.isEmpty()) {
|
if (toCheck.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidStack stored = network.getFluidStorageCache().getList().get(toCheck, compare);
|
FluidStack stored = network.getFluidStorageCache().getList().get(toCheck, compare);
|
||||||
|
|
||||||
return stored != null ? stored.getAmount() : 0;
|
return stored != null ? stored.getAmount() : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class StorageMonitorContainer extends BaseContainer {
|
|||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
|
|
||||||
transferManager.addItemFilterTransfer(player.inventory, storageMonitor.getNode().getItemFilters());
|
transferManager.addFilterTransfer(player.inventory, storageMonitor.getNode().getItemFilters(), storageMonitor.getNode().getFluidFilters(), storageMonitor.getNode()::getType);
|
||||||
transferManager.addFluidFilterTransfer(player.inventory, storageMonitor.getNode().getFluidFilters());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,15 +27,12 @@ import net.minecraftforge.fluids.FluidAttributes;
|
|||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonitorTile> {
|
public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonitorTile> {
|
||||||
public static final int DEFAULT_LIGHTMAP = 15728880;
|
|
||||||
|
|
||||||
public StorageMonitorTileRenderer(TileEntityRendererDispatcher dispatcher) {
|
public StorageMonitorTileRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
super(dispatcher);
|
super(dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(StorageMonitorTile tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int i, int i1) {
|
public void render(StorageMonitorTile tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int i, int i1) {
|
||||||
Minecraft.getInstance().getProfiler().startSection("StorageMonitorTileRenderer");
|
|
||||||
Direction direction = Direction.NORTH;
|
Direction direction = Direction.NORTH;
|
||||||
|
|
||||||
BlockState state = tile.getWorld().getBlockState(tile.getPos());
|
BlockState state = tile.getWorld().getBlockState(tile.getPos());
|
||||||
@@ -43,8 +40,7 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
|||||||
direction = state.get(RSBlocks.STORAGE_MONITOR.getDirection().getProperty());
|
direction = state.get(RSBlocks.STORAGE_MONITOR.getDirection().getProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: we can replace const with 'WorldRenderer.getCombinedLight(tile.getWorld(), tile.getPos().add(direction.getDirectionVec()))' for better lightning later
|
final int light = 15728880;
|
||||||
final int light = DEFAULT_LIGHTMAP;
|
|
||||||
final float rotation = (float) (Math.PI * (360 - direction.getOpposite().getHorizontalIndex() * 90) / 180d);
|
final float rotation = (float) (Math.PI * (360 - direction.getOpposite().getHorizontalIndex() * 90) / 180d);
|
||||||
|
|
||||||
final int type = tile.getStackType();
|
final int type = tile.getStackType();
|
||||||
@@ -56,14 +52,15 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
|||||||
renderItem(matrixStack, renderTypeBuffer, direction, rotation, light, itemStack);
|
renderItem(matrixStack, renderTypeBuffer, direction, rotation, light, itemStack);
|
||||||
|
|
||||||
String amount = API.instance().getQuantityFormatter().formatWithUnits(tile.getAmount());
|
String amount = API.instance().getQuantityFormatter().formatWithUnits(tile.getAmount());
|
||||||
|
|
||||||
renderText(matrixStack, renderTypeBuffer, direction, rotation, light, amount);
|
renderText(matrixStack, renderTypeBuffer, direction, rotation, light, amount);
|
||||||
} else if (type == IType.FLUIDS && fluidStack != null && !fluidStack.isEmpty()) {
|
} else if (type == IType.FLUIDS && fluidStack != null && !fluidStack.isEmpty()) {
|
||||||
renderFluid(matrixStack, renderTypeBuffer, direction, rotation, light, fluidStack);
|
renderFluid(matrixStack, renderTypeBuffer, direction, rotation, light, fluidStack);
|
||||||
|
|
||||||
String amount = API.instance().getQuantityFormatter().formatInBucketFormWithOnlyTrailingDigitsIfZero(tile.getAmount());
|
String amount = API.instance().getQuantityFormatter().formatInBucketFormWithOnlyTrailingDigitsIfZero(tile.getAmount());
|
||||||
|
|
||||||
renderText(matrixStack, renderTypeBuffer, direction, rotation, light, amount);
|
renderText(matrixStack, renderTypeBuffer, direction, rotation, light, amount);
|
||||||
}
|
}
|
||||||
Minecraft.getInstance().getProfiler().endSection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderText(MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, Direction direction, float rotation, int light, String amount) {
|
private void renderText(MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, Direction direction, float rotation, int light, String amount) {
|
||||||
@@ -124,7 +121,7 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
|||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
|
|
||||||
matrixStack.translate(0.5D, 0.5D, 0.5D);
|
matrixStack.translate(0.5D, 0.5D, 0.5D);
|
||||||
matrixStack.translate((float) direction.getXOffset() * 0.5F + 0.0001F, 0.5F, (float) direction.getZOffset() * 0.5F + 0.0001F);
|
matrixStack.translate((float) direction.getXOffset() * 0.51F, 0.5F, (float) direction.getZOffset() * 0.51F);
|
||||||
matrixStack.rotate(TransformationHelper.quatFromXYZ(new Vector3f(0, rotation, 0), false));
|
matrixStack.rotate(TransformationHelper.quatFromXYZ(new Vector3f(0, rotation, 0), false));
|
||||||
|
|
||||||
matrixStack.scale(0.5F, 0.5F, 0.5F);
|
matrixStack.scale(0.5F, 0.5F, 0.5F);
|
||||||
@@ -141,6 +138,7 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
|||||||
final int colorGreen = fluidColor >> 8 & 0xFF;
|
final int colorGreen = fluidColor >> 8 & 0xFF;
|
||||||
final int colorBlue = fluidColor & 0xFF;
|
final int colorBlue = fluidColor & 0xFF;
|
||||||
final int colorAlpha = fluidColor >> 24 & 0xFF;
|
final int colorAlpha = fluidColor >> 24 & 0xFF;
|
||||||
|
|
||||||
buffer.pos(matrixStack.getLast().getPositionMatrix(), -0.5F, -0.5F, 0F)
|
buffer.pos(matrixStack.getLast().getPositionMatrix(), -0.5F, -0.5F, 0F)
|
||||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||||
.tex(sprite.getMinU(), sprite.getMinV())
|
.tex(sprite.getMinU(), sprite.getMinV())
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
@@ -13,6 +16,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class NetworkUtils {
|
public class NetworkUtils {
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -62,4 +66,23 @@ public class NetworkUtils {
|
|||||||
|
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void extractBucketFromPlayerInventoryOrNetwork(PlayerEntity player, INetwork network, Consumer<ItemStack> onBucketFound) {
|
||||||
|
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||||
|
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||||
|
|
||||||
|
if (API.instance().getComparer().isEqualNoQuantity(StackUtils.EMPTY_BUCKET, slot)) {
|
||||||
|
player.inventory.decrStackSize(i, 1);
|
||||||
|
|
||||||
|
onBucketFound.accept(StackUtils.EMPTY_BUCKET.copy());
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack fromNetwork = network.extractItem(StackUtils.EMPTY_BUCKET, 1, Action.PERFORM);
|
||||||
|
if (!fromNetwork.isEmpty()) {
|
||||||
|
onBucketFound.accept(fromNetwork);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user