mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-30 13:05:25 -05:00
Make ResourceView implement Closeable
This commit is contained in:
@@ -133,17 +133,24 @@ public class FluidTransferImpl {
|
||||
@NotNull
|
||||
@Override
|
||||
public net.minecraftforge.fluids.FluidStack getFluidInTank(int index) {
|
||||
return FluidStackHooksForge.toForge(handler.getContent(index).getResource());
|
||||
try (var resource = handler.getContent(index)) {
|
||||
return FluidStackHooksForge.toForge(resource.getResource());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int index) {
|
||||
return (int) handler.getContent(index).getCapacity();
|
||||
try (var resource = handler.getContent(index)) {
|
||||
return (int) resource.getCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int index, @NotNull net.minecraftforge.fluids.FluidStack stack) {
|
||||
FluidStack content = handler.getContent(index).getResource();
|
||||
FluidStack content;
|
||||
try (var resource = handler.getContent(index)) {
|
||||
content = resource.getResource();
|
||||
}
|
||||
return content.getFluid() == stack.getFluid() && Objects.equals(content.getTag(), stack.getTag());
|
||||
}
|
||||
|
||||
@@ -305,6 +312,10 @@ public class FluidTransferImpl {
|
||||
public void loadState(Object state) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,16 @@ public class ItemTransferImpl {
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index) {
|
||||
return handler.getContent(index).getResource();
|
||||
try (var resource = handler.getContent(index)) {
|
||||
return resource.getResource();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index) {
|
||||
return (int) handler.getContent(index).getCapacity();
|
||||
try (var resource = handler.getContent(index)) {
|
||||
return (int) resource.getCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -128,7 +132,11 @@ public class ItemTransferImpl {
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int index, @NotNull ItemStack stack) {
|
||||
ItemStack content = handler.getContent(index).getResource();
|
||||
ItemStack content;
|
||||
|
||||
try (var resource = handler.getContent(index)) {
|
||||
content = resource.getResource();
|
||||
}
|
||||
return content.getItem() == stack.getItem() && Objects.equals(content.getTag(), stack.getTag());
|
||||
}
|
||||
}
|
||||
@@ -247,6 +255,10 @@ public class ItemTransferImpl {
|
||||
public void loadState(Object state) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user