1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-03-13 15:08:12 +00:00

Remove IComputerBlockEntity

We only really made use of it in the has_computer_id loot condition, so
probably easier to remove it.
This commit is contained in:
Jonathan Coates 2024-07-25 09:28:00 +01:00
parent 63e40cf3cb
commit 99c60ac54b
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
4 changed files with 4 additions and 31 deletions

View File

@ -146,7 +146,7 @@ public abstract class AbstractComputerBlock<T extends AbstractComputerBlockEntit
super.setPlacedBy(world, pos, state, placer, stack); super.setPlacedBy(world, pos, state, placer, stack);
var tile = world.getBlockEntity(pos); var tile = world.getBlockEntity(pos);
if (!world.isClientSide && tile instanceof IComputerBlockEntity computer && stack.getItem() instanceof IComputerItem item) { if (!world.isClientSide && tile instanceof AbstractComputerBlockEntity computer && stack.getItem() instanceof IComputerItem item) {
var id = item.getComputerID(stack); var id = item.getComputerID(stack);
if (id != -1) computer.setComputerID(id); if (id != -1) computer.setComputerID(id);

View File

@ -38,7 +38,7 @@ import javax.annotation.Nullable;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
public abstract class AbstractComputerBlockEntity extends BlockEntity implements IComputerBlockEntity, Nameable, MenuProvider { public abstract class AbstractComputerBlockEntity extends BlockEntity implements Nameable, MenuProvider {
private static final String NBT_ID = "ComputerId"; private static final String NBT_ID = "ComputerId";
private static final String NBT_LABEL = "Label"; private static final String NBT_LABEL = "Label";
private static final String NBT_ON = "On"; private static final String NBT_ON = "On";
@ -300,17 +300,14 @@ public abstract class AbstractComputerBlockEntity extends BlockEntity implements
for (var dir : DirectionUtil.FACINGS) updateRedstoneTo(dir); for (var dir : DirectionUtil.FACINGS) updateRedstoneTo(dir);
} }
@Override
public final int getComputerID() { public final int getComputerID() {
return computerID; return computerID;
} }
@Override
public final @Nullable String getLabel() { public final @Nullable String getLabel() {
return label; return label;
} }
@Override
public final void setComputerID(int id) { public final void setComputerID(int id) {
if (getLevel().isClientSide || computerID == id) return; if (getLevel().isClientSide || computerID == id) return;
@ -318,7 +315,6 @@ public abstract class AbstractComputerBlockEntity extends BlockEntity implements
BlockEntityHelpers.updateBlock(this); BlockEntityHelpers.updateBlock(this);
} }
@Override
public final void setLabel(@Nullable String label) { public final void setLabel(@Nullable String label) {
if (getLevel().isClientSide || Objects.equals(this.label, label)) return; if (getLevel().isClientSide || Objects.equals(this.label, label)) return;
@ -328,7 +324,6 @@ public abstract class AbstractComputerBlockEntity extends BlockEntity implements
BlockEntityHelpers.updateBlock(this); BlockEntityHelpers.updateBlock(this);
} }
@Override
public ComputerFamily getFamily() { public ComputerFamily getFamily() {
return family; return family;
} }

View File

@ -1,22 +0,0 @@
// Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
//
// SPDX-License-Identifier: LicenseRef-CCPL
package dan200.computercraft.shared.computer.blocks;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import javax.annotation.Nullable;
public interface IComputerBlockEntity {
int getComputerID();
void setComputerID(int id);
@Nullable
String getLabel();
void setLabel(@Nullable String label);
ComputerFamily getFamily();
}

View File

@ -5,7 +5,7 @@
package dan200.computercraft.shared.data; package dan200.computercraft.shared.data;
import dan200.computercraft.shared.ModRegistry; import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.computer.blocks.IComputerBlockEntity; import dan200.computercraft.shared.computer.blocks.AbstractComputerBlockEntity;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParam; import net.minecraft.world.level.storage.loot.parameters.LootContextParam;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
@ -27,7 +27,7 @@ public final class HasComputerIdLootCondition implements LootItemCondition {
@Override @Override
public boolean test(LootContext lootContext) { public boolean test(LootContext lootContext) {
var tile = lootContext.getParamOrNull(LootContextParams.BLOCK_ENTITY); var tile = lootContext.getParamOrNull(LootContextParams.BLOCK_ENTITY);
return tile instanceof IComputerBlockEntity computer && computer.getComputerID() >= 0; return tile instanceof AbstractComputerBlockEntity computer && computer.getComputerID() >= 0;
} }
@Override @Override