This commit is contained in:
Florian Nücke
2021-01-08 19:21:06 +01:00
parent 99d86c9f6e
commit 81378fd5c7
5 changed files with 24 additions and 35 deletions

View File

@@ -105,6 +105,8 @@ public final class BusCableBlock extends Block {
shapes = makeShapes();
}
///////////////////////////////////////////////////////////////////
public boolean addPlug(final World world, final BlockPos pos, final BlockState state, final Direction side) {
final EnumProperty<BusCableBlock.ConnectionType> property = BusCableBlock.FACING_TO_CONNECTION_MAP.get(side);
if (state.get(property) == BusCableBlock.ConnectionType.NONE) {

View File

@@ -26,6 +26,8 @@ public final class RedstoneInterfaceBlock extends HorizontalBlock {
setDefaultState(getStateContainer().getBaseState().with(HORIZONTAL_FACING, Direction.NORTH));
}
///////////////////////////////////////////////////////////////////
@Override
public BlockState getStateForPlacement(final BlockItemUseContext context) {
return super.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());

View File

@@ -42,8 +42,8 @@ public abstract class AbstractHardDriveVMDevice<T extends BlockDevice> extends I
///////////////////////////////////////////////////////////////
protected AbstractHardDriveVMDevice(final ItemStack stack) {
super(stack);
protected AbstractHardDriveVMDevice(final ItemStack identity) {
super(identity);
}
///////////////////////////////////////////////////////////////////
@@ -97,7 +97,7 @@ public abstract class AbstractHardDriveVMDevice<T extends BlockDevice> extends I
@Override
public CompoundNBT serializeNBT() {
final CompoundNBT nbt = new CompoundNBT();
final CompoundNBT tag = new CompoundNBT();
if (data != null) {
final Optional<InputStream> optional = getSerializationStream(data);
@@ -114,36 +114,36 @@ public abstract class AbstractHardDriveVMDevice<T extends BlockDevice> extends I
deviceNbt = NBTSerialization.serialize(device);
}
if (deviceNbt != null) {
nbt.put(DEVICE_NBT_TAG_NAME, deviceNbt);
tag.put(DEVICE_NBT_TAG_NAME, deviceNbt);
}
if (address.isPresent()) {
nbt.putLong(ADDRESS_NBT_TAG_NAME, address.getAsLong());
tag.putLong(ADDRESS_NBT_TAG_NAME, address.getAsLong());
}
if (interrupt.isPresent()) {
nbt.putInt(INTERRUPT_NBT_TAG_NAME, interrupt.getAsInt());
tag.putInt(INTERRUPT_NBT_TAG_NAME, interrupt.getAsInt());
}
if (blobHandle != null) {
nbt.putUniqueId(BLOB_HANDLE_NBT_TAG_NAME, blobHandle);
tag.putUniqueId(BLOB_HANDLE_NBT_TAG_NAME, blobHandle);
}
return nbt;
return tag;
}
@Override
public void deserializeNBT(final CompoundNBT nbt) {
if (nbt.hasUniqueId(BLOB_HANDLE_NBT_TAG_NAME)) {
blobHandle = nbt.getUniqueId(BLOB_HANDLE_NBT_TAG_NAME);
public void deserializeNBT(final CompoundNBT tag) {
if (tag.hasUniqueId(BLOB_HANDLE_NBT_TAG_NAME)) {
blobHandle = tag.getUniqueId(BLOB_HANDLE_NBT_TAG_NAME);
}
if (nbt.contains(DEVICE_NBT_TAG_NAME, NBTTagIds.TAG_COMPOUND)) {
deviceNbt = nbt.getCompound(DEVICE_NBT_TAG_NAME);
if (tag.contains(DEVICE_NBT_TAG_NAME, NBTTagIds.TAG_COMPOUND)) {
deviceNbt = tag.getCompound(DEVICE_NBT_TAG_NAME);
}
if (nbt.contains(ADDRESS_NBT_TAG_NAME, NBTTagIds.TAG_LONG)) {
address.set(nbt.getLong(ADDRESS_NBT_TAG_NAME));
if (tag.contains(ADDRESS_NBT_TAG_NAME, NBTTagIds.TAG_LONG)) {
address.set(tag.getLong(ADDRESS_NBT_TAG_NAME));
}
if (nbt.contains(INTERRUPT_NBT_TAG_NAME, NBTTagIds.TAG_INT)) {
interrupt.set(nbt.getInt(INTERRUPT_NBT_TAG_NAME));
if (tag.contains(INTERRUPT_NBT_TAG_NAME, NBTTagIds.TAG_INT)) {
interrupt.set(tag.getInt(INTERRUPT_NBT_TAG_NAME));
}
}

View File

@@ -35,9 +35,9 @@ public final class MemoryDevice extends IdentityProxy<ItemStack> implements VMDe
///////////////////////////////////////////////////////////////
public MemoryDevice(final ItemStack value) {
super(value);
size = MathHelper.clamp(MemoryItem.getCapacity(value), 0, Config.maxMemorySize);
public MemoryDevice(final ItemStack identity) {
super(identity);
size = MathHelper.clamp(MemoryItem.getCapacity(identity), 0, Config.maxMemorySize);
}
///////////////////////////////////////////////////////////////////

View File

@@ -26,7 +26,6 @@ import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
public final class RedstoneInterfaceCardItemDevice extends IdentityProxy<ItemStack> implements RPCDevice, DocumentedDevice, ItemDevice, ICapabilityProvider {
private static final int FACE_COUNT = Direction.values().length;
@@ -161,20 +160,6 @@ public final class RedstoneInterfaceCardItemDevice extends IdentityProxy<ItemSta
.parameterDescription(VALUE, "the output level to set, will be clamped to [0, 15].");
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
final RedstoneInterfaceCardItemDevice that = (RedstoneInterfaceCardItemDevice) o;
return tileEntity.equals(that.tileEntity);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), tileEntity);
}
///////////////////////////////////////////////////////////////////
private void notifyNeighbor(final Direction direction) {