Make some devices properly tell their container they changed.
Item devices for computer/robot, so not strictly necessary, but for clarity.
This commit is contained in:
@@ -2,17 +2,20 @@
|
||||
|
||||
package li.cil.oc2.common.bus.device.item;
|
||||
|
||||
import li.cil.oc2.api.bus.device.DeviceContainer;
|
||||
import li.cil.oc2.api.bus.device.ItemDevice;
|
||||
import li.cil.oc2.api.bus.device.object.ObjectDevice;
|
||||
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
|
||||
import li.cil.oc2.api.bus.device.rpc.RPCMethodGroup;
|
||||
import li.cil.oc2.common.bus.device.util.IdentityProxy;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractItemRPCDevice extends IdentityProxy<ItemStack> implements RPCDevice, ItemDevice {
|
||||
private final ObjectDevice device;
|
||||
private DeviceContainer container;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -23,6 +26,11 @@ public abstract class AbstractItemRPCDevice extends IdentityProxy<ItemStack> imp
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setDeviceContainer(@Nullable final DeviceContainer container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTypeNames() {
|
||||
return device.getTypeNames();
|
||||
@@ -33,18 +41,11 @@ public abstract class AbstractItemRPCDevice extends IdentityProxy<ItemStack> imp
|
||||
return device.getMethodGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mount() {
|
||||
device.mount();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void unmount() {
|
||||
device.unmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
device.dispose();
|
||||
protected void setChanged() {
|
||||
if (container != null) {
|
||||
container.setChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ public final class BlockOperationsModuleDevice extends AbstractItemRPCDevice {
|
||||
|
||||
private void beginCooldown() {
|
||||
lastOperation = entity.level.getGameTime();
|
||||
setChanged();
|
||||
}
|
||||
|
||||
private boolean isOnCooldown() {
|
||||
|
||||
@@ -120,6 +120,7 @@ public final class RedstoneInterfaceCardItemDevice extends AbstractItemRPCDevice
|
||||
}
|
||||
|
||||
output[index] = clampedValue;
|
||||
setChanged();
|
||||
|
||||
final Direction direction = HorizontalBlockUtils.toGlobal(blockEntity.getBlockState(), side);
|
||||
if (direction != null) {
|
||||
|
||||
@@ -53,7 +53,9 @@ public final class SoundCardItemDevice extends AbstractItemRPCDevice {
|
||||
if (gameTime < gameTimeCooldownExpiresAt) {
|
||||
return;
|
||||
}
|
||||
|
||||
gameTimeCooldownExpiresAt = gameTime + COOLDOWN_IN_TICKS;
|
||||
setChanged();
|
||||
|
||||
final SoundEvent soundEvent = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(name));
|
||||
if (soundEvent == null) throw new IllegalArgumentException("Sound not found.");
|
||||
|
||||
Reference in New Issue
Block a user