Skip to content

Commit

Permalink
fixup! Add option to clean up stuff (via unmount) when devices go mis…
Browse files Browse the repository at this point in the history
…sing. For block devices, this can happen when the block is broken while the computer is unloaded, for example. For items this is more esoteric, but it theoretically means items disappear while the container managing the item as a device is unloaded.
  • Loading branch information
fnuecke committed Jan 25, 2022
1 parent dbab733 commit 929f13d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public interface BlockDeviceProvider extends IForgeRegistryEntry<BlockDeviceProv
* Implementing this is only necessary, if the device holds some out-of-NBT serialized
* data, or does something similar.
*
* @param query the query that resulted in the device when it still existed, if available.
* @param query the query that resulted in a missing device being detected.
* @param tag data last serialized by the device that went missing.
*/
default void unmount(final BlockDeviceQuery query, final CompoundTag tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraftforge.registries.IForgeRegistryEntry;

import javax.annotation.Nullable;
import java.util.Optional;

/**
Expand Down Expand Up @@ -74,8 +75,9 @@ default int getEnergyConsumption(final ItemDeviceQuery query) {
* Implementing this is only necessary, if the device holds some out-of-NBT serialized
* data, or does something similar.
*
* @param tag the data last serialized by the device went missing.
* @param query the query that resulted in a missing device being detected, if available.
* @param tag the data last serialized by the device went missing.
*/
default void unmount(final CompoundTag tag) {
default void unmount(@Nullable final ItemDeviceQuery query, final CompoundTag tag) {
}
}

0 comments on commit 929f13d

Please sign in to comment.