mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-11-22 15:17:16 +00:00
Remove deprecated upgrade methods
I'm not aware of any addon mods targetting 26.3, and the whole ecosystem is pretty unstable. I think this is safe to do.
This commit is contained in:
28 files changed
+141
-425
No files matched your search
@@ -50,13 +50,13 @@ dependencies {
|
||||
// Vanilla (i.e. for multi-loader systems)
|
||||
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-common-api:$cctVersion")
|
||||
|
||||
// Forge Gradle
|
||||
// NeoForge
|
||||
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-forge-api:$cctVersion")
|
||||
runtimeOnly("cc.tweaked:cc-tweaked-$mcVersion-forge:$cctVersion")
|
||||
|
||||
// Fabric Loom
|
||||
modCompileOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric-api:$cctVersion")
|
||||
modRuntimeOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric:$cctVersion")
|
||||
// Fabric
|
||||
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric-api:$cctVersion")
|
||||
runtimeOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric:$cctVersion")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ dependencies {
|
||||
}
|
||||
|
||||
val javadocOverview = tasks.register<Copy>("javadocOverview") {
|
||||
from("src/overview.html")
|
||||
from("src/overview.md")
|
||||
into(layout.buildDirectory.dir(name))
|
||||
|
||||
expand(
|
||||
@@ -49,7 +49,7 @@ tasks.javadoc {
|
||||
(this as StandardJavadocDocletOptions)
|
||||
|
||||
inputs.files(javadocOverview)
|
||||
overview(javadocOverview.get().destinationDir.resolve("overview.html").absolutePath)
|
||||
overview(javadocOverview.get().destinationDir.resolve("overview.md").absolutePath)
|
||||
|
||||
groups = mapOf(
|
||||
"Common" to listOf(
|
||||
|
||||
+1
-3
@@ -19,7 +19,6 @@ import net.minecraft.client.renderer.item.TrackingItemStackRenderState;
|
||||
import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
||||
import net.minecraft.client.resources.model.ModelBaker;
|
||||
import net.minecraft.client.resources.model.cuboid.ItemTransform;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -30,8 +29,7 @@ import org.jspecify.annotations.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A {@link TurtleUpgradeModel} that renders the upgrade's {@linkplain ITurtleUpgrade#getUpgradeItem(DataComponentPatch)
|
||||
* upgrade item}.
|
||||
* A {@link TurtleUpgradeModel} that renders the upgrade's {@linkplain UpgradeData#getUpgradeItem()} item.
|
||||
* <p>
|
||||
* This uses appropriate transformations for "flat" items, namely those extending the {@literal minecraft:item/generated}
|
||||
* model type. It will not appear correct for 3D models with additional depth, such as blocks.
|
||||
|
||||
+2
-53
@@ -4,12 +4,8 @@
|
||||
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStackTemplate;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,23 +15,15 @@ import org.jspecify.annotations.Nullable;
|
||||
*/
|
||||
public abstract class AbstractPocketUpgrade implements IPocketUpgrade {
|
||||
private final Component adjective;
|
||||
private final @Nullable ItemStackTemplate stack;
|
||||
private final Ingredient ingredient;
|
||||
|
||||
protected AbstractPocketUpgrade(Component adjective, ItemStackTemplate stack) {
|
||||
this.adjective = adjective;
|
||||
this.stack = stack;
|
||||
this.ingredient = Ingredient.of(stack.item().value());
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade(Component adjective, Ingredient ingredient) {
|
||||
this.adjective = adjective;
|
||||
this.stack = null; // We need to lazily resolve the ingredient, so don't set the stack.
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade(String adjective, ItemStackTemplate stack) {
|
||||
this(Component.translatable(adjective), stack);
|
||||
protected AbstractPocketUpgrade(String adjective, Ingredient ingredient) {
|
||||
this(Component.translatable(adjective), ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,47 +31,8 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade {
|
||||
return adjective;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final ItemStackTemplate getCraftingItem() {
|
||||
if (stack != null) return stack;
|
||||
|
||||
var items = ingredient.items().findFirst().orElseThrow(() -> new IllegalStateException("No item preset"));
|
||||
return new ItemStackTemplate(items.value());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Ingredient getCraftingIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of {@link AbstractPocketUpgrade} which is aware of the stack the upgrade was equipped with.
|
||||
* <p>
|
||||
* Upgrades implementing this method should only interact with the upgrade via
|
||||
* {@link IPocketAccess#getUpgradeHandle()} (and not {@link IPocketAccess#getUpgradeData()} or
|
||||
* {@link IPocketAccess#setUpgradeData(DataComponentPatch)}).
|
||||
*
|
||||
* @since 1.121.0
|
||||
*/
|
||||
public abstract static class StackAware extends AbstractPocketUpgrade {
|
||||
protected StackAware(Component adjective, Ingredient ingredient) {
|
||||
super(adjective, ingredient);
|
||||
}
|
||||
|
||||
protected StackAware(String adjective, Ingredient ingredient) {
|
||||
this(Component.translatable(adjective), ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final DataComponentPatch getUpgradeData(ItemStackTemplate stack) {
|
||||
return super.getUpgradeData(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemSuitable(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,7 @@
|
||||
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeData;
|
||||
import dan200.computercraft.api.upgrades.UpgradeHandle;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.world.item.ItemStackTemplate;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@@ -35,66 +31,16 @@ public interface IPocketAccess extends PocketComputer {
|
||||
*/
|
||||
void setLight(int colour);
|
||||
|
||||
/**
|
||||
* Get the currently equipped upgrade.
|
||||
*
|
||||
* @return The currently equipped upgrade.
|
||||
* @see #setUpgrade(UpgradeData)
|
||||
* @see #getUpgradeHandle()
|
||||
*/
|
||||
@Nullable UpgradeData<IPocketUpgrade> getUpgrade();
|
||||
|
||||
/**
|
||||
* Get a handle to the equipped upgrade.
|
||||
* <p>
|
||||
* This function is not thread safe and must be called from the server thread.
|
||||
*
|
||||
* @return The currently equipped upgrade.
|
||||
* @see #setUpgrade(UpgradeData)
|
||||
* @since 1.121.0
|
||||
*/
|
||||
@Nullable UpgradeHandle<IPocketUpgrade> getUpgradeHandle();
|
||||
|
||||
/**
|
||||
* Set the upgrade for this pocket computer, also updating the item stack.
|
||||
* <p>
|
||||
* This method can only be called from the main server thread, when this computer is {@linkplain #isActive() is
|
||||
* active}.
|
||||
*
|
||||
* @param upgrade The new upgrade to set it to, may be {@code null}.
|
||||
* @see #getUpgrade()
|
||||
* @see #getUpgradeHandle()
|
||||
*/
|
||||
void setUpgrade(@Nullable UpgradeData<IPocketUpgrade> upgrade);
|
||||
|
||||
/**
|
||||
* Get the upgrade-specific NBT.
|
||||
* <p>
|
||||
* This is persisted between computer reboots and chunk loads.
|
||||
*
|
||||
* @return The upgrade's NBT.
|
||||
* @see #setUpgradeData(DataComponentPatch)
|
||||
* @see UpgradeBase#getUpgradeItem(DataComponentPatch)
|
||||
* @see UpgradeBase#getUpgradeData(ItemStackTemplate)
|
||||
* @see #getUpgrade()
|
||||
* @deprecated Use {@link #getUpgradeHandle()} and {@link UpgradeHandle#getData()}.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
DataComponentPatch getUpgradeData();
|
||||
|
||||
/**
|
||||
* Update the upgrade-specific data.
|
||||
* <p>
|
||||
* This method can only be called from the main server thread, when this computer is {@linkplain #isActive() is
|
||||
* active}.
|
||||
*
|
||||
* @param data The new upgrade data.
|
||||
* @see #getUpgradeData()
|
||||
* @deprecated Use {@link #getUpgradeHandle()} and {@link UpgradeHandle#setData(DataComponentPatch)}.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
void setUpgradeData(DataComponentPatch data);
|
||||
|
||||
/**
|
||||
* Remove the current peripheral and create a new one.
|
||||
* <p>
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jspecify.annotations.Nullable;
|
||||
* You then write a JSON file in your mod's {@literal data/} folder. This is then parsed when the world is loaded, and
|
||||
* the upgrade registered internally.
|
||||
*
|
||||
* @see AbstractPocketUpgrade.StackAware
|
||||
* @see AbstractPocketUpgrade
|
||||
*/
|
||||
public interface IPocketUpgrade extends UpgradeBase {
|
||||
ResourceKey<Registry<IPocketUpgrade>> REGISTRY = ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "pocket_upgrade"));
|
||||
|
||||
+2
-55
@@ -4,13 +4,8 @@
|
||||
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStackTemplate;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* A base class for {@link ITurtleUpgrade}s.
|
||||
@@ -20,25 +15,16 @@ import org.jspecify.annotations.Nullable;
|
||||
public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade {
|
||||
private final TurtleUpgradeType type;
|
||||
private final Component adjective;
|
||||
private final @Nullable ItemStackTemplate stack;
|
||||
private final Ingredient ingredient;
|
||||
|
||||
protected AbstractTurtleUpgrade(TurtleUpgradeType type, Component adjective, ItemStackTemplate stack) {
|
||||
this.type = type;
|
||||
this.adjective = adjective;
|
||||
this.stack = stack;
|
||||
this.ingredient = Ingredient.of(stack.item().value());
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade(TurtleUpgradeType type, Component adjective, Ingredient ingredient) {
|
||||
this.type = type;
|
||||
this.adjective = adjective;
|
||||
this.stack = null; // We need to lazily resolve the ingredient, so don't set the stack.
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade(TurtleUpgradeType type, String adjective, ItemStackTemplate stack) {
|
||||
this(type, Component.translatable(adjective), stack);
|
||||
protected AbstractTurtleUpgrade(TurtleUpgradeType type, String adjective, Ingredient item) {
|
||||
this(type, Component.translatable(adjective), item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,47 +37,8 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final ItemStackTemplate getCraftingItem() {
|
||||
if (stack != null) return stack;
|
||||
|
||||
var items = ingredient.items().findFirst().orElseThrow(() -> new IllegalStateException("No item preset"));
|
||||
return new ItemStackTemplate(items.value());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Ingredient getCraftingIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of {@link AbstractTurtleUpgrade} which is aware of the stack the upgrade was equipped with.
|
||||
* <p>
|
||||
* Upgrades implementing this method should only interact with the upgrade via
|
||||
* {@link ITurtleAccess#getUpgradeHandle(TurtleSide)} (and not {@link ITurtleAccess#getUpgradeData(TurtleSide)}
|
||||
* or {@link ITurtleAccess#setUpgradeData(TurtleSide, DataComponentPatch)}).
|
||||
*
|
||||
* @since 1.121.0
|
||||
*/
|
||||
public abstract static class StackAware extends AbstractTurtleUpgrade {
|
||||
protected StackAware(TurtleUpgradeType type, Component adjective, Ingredient ingredient) {
|
||||
super(type, adjective, ingredient);
|
||||
}
|
||||
|
||||
protected StackAware(TurtleUpgradeType type, String adjective, Ingredient ingredient) {
|
||||
this(type, Component.translatable(adjective), ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final DataComponentPatch getUpgradeData(ItemStackTemplate stack) {
|
||||
return super.getUpgradeData(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemSuitable(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import dan200.computercraft.api.upgrades.UpgradeData;
|
||||
import dan200.computercraft.api.upgrades.UpgradeHandle;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -271,28 +270,4 @@ public interface ITurtleAccess {
|
||||
* @return The peripheral created by the upgrade on the specified side of the turtle, {@code null} if none exists.
|
||||
*/
|
||||
@Nullable IPeripheral getPeripheral(TurtleSide side);
|
||||
|
||||
/**
|
||||
* Get an upgrade-specific NBT compound, which can be used to store arbitrary data.
|
||||
* <p>
|
||||
* This will be persisted across turtle restarts and chunk loads, as well as being synced to the client. You can
|
||||
* call {@link #setUpgrade(TurtleSide, UpgradeData)} to modify it.
|
||||
*
|
||||
* @param side The side to get the upgrade data for.
|
||||
* @return The upgrade-specific data.
|
||||
* @deprecated Use {@link #getUpgradeHandle(TurtleSide)} and {@link UpgradeHandle#getData()}.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
DataComponentPatch getUpgradeData(TurtleSide side);
|
||||
|
||||
/**
|
||||
* Update the upgrade-specific data.
|
||||
*
|
||||
* @param side The side to set the upgrade data for.
|
||||
* @param data The new upgrade data.
|
||||
* @see #getUpgradeData(TurtleSide)
|
||||
* @deprecated Use {@link #getUpgradeHandle(TurtleSide)} and {@link UpgradeHandle#setData(DataComponentPatch)}.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
void setUpgradeData(TurtleSide side, DataComponentPatch data);
|
||||
}
|
||||
+2
-15
@@ -35,7 +35,7 @@ import java.util.function.Function;
|
||||
* <h2>Example</h2>
|
||||
* <h3>Registering the upgrade type</h3>
|
||||
* First, let's create a new class that implements {@link ITurtleUpgrade}. It is recommended to subclass
|
||||
* {@link AbstractTurtleUpgrade.StackAware}, as that provides a default implementation of most methods.
|
||||
* {@link AbstractTurtleUpgrade}, as that provides a default implementation of most methods.
|
||||
*
|
||||
* {@snippet class=com.example.examplemod.ExampleTurtleUpgrade region=body}
|
||||
*
|
||||
@@ -87,7 +87,7 @@ import java.util.function.Function;
|
||||
* <h4>Forge</h4>
|
||||
* {@snippet class=com.example.examplemod.ForgeExampleModDataGenerator region=turtle_upgrades}
|
||||
*
|
||||
* @see AbstractTurtleUpgrade.StackAware
|
||||
* @see AbstractTurtleUpgrade
|
||||
*/
|
||||
public interface ITurtleUpgrade extends UpgradeBase {
|
||||
/**
|
||||
@@ -95,19 +95,6 @@ public interface ITurtleUpgrade extends UpgradeBase {
|
||||
*/
|
||||
ResourceKey<Registry<ITurtleUpgrade>> REGISTRY = ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "turtle_upgrade"));
|
||||
|
||||
/**
|
||||
* Create a {@link ResourceKey} for a turtle upgrade given a {@link Identifier}.
|
||||
* <p>
|
||||
* This should only be called from within data generation code. Do not hard code references to your upgrades!
|
||||
*
|
||||
* @param id The id of the turtle upgrade.
|
||||
* @return The upgrade registry key.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
static ResourceKey<ITurtleUpgrade> createKey(Identifier id) {
|
||||
return ResourceKey.create(REGISTRY, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The registry key for turtle upgrade types.
|
||||
*
|
||||
|
||||
+14
-57
@@ -4,11 +4,8 @@
|
||||
|
||||
package dan200.computercraft.api.upgrades;
|
||||
|
||||
import dan200.computercraft.api.pocket.IPocketAccess;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
@@ -40,86 +37,46 @@ public interface UpgradeBase {
|
||||
*/
|
||||
Component getAdjective();
|
||||
|
||||
/**
|
||||
* Return an item stack representing the type of item that a computer must be crafted
|
||||
* with to create a version which holds this upgrade. This item stack is also used
|
||||
* to determine the upgrade given by {@code turtle.equipLeft()} or {@code pocket.equipBack()}
|
||||
* <p>
|
||||
* This should be constant over a session (or at least a datapack reload). It is recommended
|
||||
* that you cache the stack too, in order to prevent constructing it every time the method
|
||||
* is called.
|
||||
*
|
||||
* @return The item stack to craft with.
|
||||
* @deprecated Prefer {@link #getCraftingIngredient()}.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
ItemStackTemplate getCraftingItem();
|
||||
|
||||
/**
|
||||
* Returns an ingredient representing the item(s) that a computer must be crafted with to create a version which
|
||||
* holds this upgrade.
|
||||
* <p>
|
||||
* This should be constant over a session (or at least a datapack reload).
|
||||
* This should be constant for a given upgrade.
|
||||
*
|
||||
* @return The ingredient for this upgrade.
|
||||
* @since 1.121.0
|
||||
*/
|
||||
default Ingredient getCraftingIngredient() {
|
||||
return Ingredient.of(getCraftingItem().item().value());
|
||||
}
|
||||
Ingredient getCraftingIngredient();
|
||||
|
||||
/**
|
||||
* Returns the item stack representing a currently equipped turtle upgrade.
|
||||
* <p>
|
||||
* Historically, upgrades did not store the item they were equipped with. Instead, {@link #getUpgradeData(ItemStackTemplate)}
|
||||
* could be used to extract data from the equipped item, then {@link #getUpgradeItem(DataComponentPatch)} could be used to
|
||||
* reconstruct it.
|
||||
* Historically, upgrades did not store the item they were equipped with. Instead, one could extract data from the
|
||||
* equipped item, then call {@link #getUpgradeItem(DataComponentPatch)} to reconstruct it.
|
||||
* <p>
|
||||
* As of CC: Tweaked 1.121.0, upgrades now store the item they were originally equipped with. This function is
|
||||
* used to reconstruct the item from older saves, or if the upgrade still uses the legacy
|
||||
* {@link ITurtleAccess#setUpgradeData(TurtleSide, DataComponentPatch)}/{@link IPocketAccess#setUpgradeData(DataComponentPatch)} API.
|
||||
* used to reconstruct the item from older saves.
|
||||
*
|
||||
* @param upgradeData The current upgrade data. This should <strong>NOT</strong> be mutated.
|
||||
* @return The item stack returned when unequipping.
|
||||
* @param upgradeData The current upgrade data.
|
||||
* @return The item provided by this upgrade.
|
||||
*/
|
||||
default ItemStackTemplate getUpgradeItem(DataComponentPatch upgradeData) {
|
||||
return getCraftingItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract upgrade data from an {@link ItemStack}.
|
||||
* <p>
|
||||
* This upgrade data will be available with {@link UpgradeHandle#getData()} or
|
||||
* {@link IPocketAccess#getUpgradeData()}.
|
||||
* <p>
|
||||
* This should be an inverse to {@link #getUpgradeItem(DataComponentPatch)}.
|
||||
*
|
||||
* @param stack The stack that was equipped by the turtle or pocket computer. This will have the same item as
|
||||
* {@link #getCraftingItem()}.
|
||||
* @return The upgrade data that should be set on the turtle or pocket computer.
|
||||
* @deprecated Upgrades now store their item by default, so this function does not need to be implemented.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
default DataComponentPatch getUpgradeData(ItemStackTemplate stack) {
|
||||
return DataComponentPatch.EMPTY;
|
||||
var items = getCraftingIngredient().items().findFirst().orElseThrow(() -> new IllegalStateException("No item preset"));
|
||||
return new ItemStackTemplate(items.value());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an item is suitable for being used for this upgrade.
|
||||
* <p>
|
||||
* When un-equipping an upgrade, we return {@link #getCraftingItem()} rather than
|
||||
* the original stack. In order to prevent people losing items with enchantments (or
|
||||
* repairing items with non-0 damage), we impose additional checks on the item.
|
||||
* <p>
|
||||
* The default check requires that any NBT is exactly the same as the crafting item,
|
||||
* but this may be relaxed for your upgrade.
|
||||
* This is used <em>in addition to</em> {@link #getCraftingIngredient()} to determine whether an item is suitable
|
||||
* as an upgrade. This may be used to check additional properties of an item (e.g. the presence/absence of a
|
||||
* component) that is not possible with vanilla's {@link Ingredient}s.
|
||||
*
|
||||
* @param stack The stack to check. This is guaranteed to be non-empty and have the same item as
|
||||
* {@link #getCraftingItem()}.
|
||||
* @param stack The stack to check. This is guaranteed to be non-empty and match {@link #getCraftingIngredient()}.
|
||||
* @return If this stack may be used to equip this upgrade.
|
||||
*/
|
||||
default boolean isItemSuitable(ItemStack stack) {
|
||||
return stack.is(getCraftingItem().item()) && stack.getComponentsPatch().equals(getCraftingItem().components());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-18
@@ -46,18 +46,6 @@ public final class UpgradeData<T extends UpgradeBase> implements DataComponentGe
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link UpgradeData} with an item and upgrade data.
|
||||
*
|
||||
* @param upgrade The current upgrade.
|
||||
* @param data The upgrade's data.
|
||||
* @deprecated Use {@link UpgradeData#of(Holder.Reference, ItemStackTemplate, DataComponentPatch)}.
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
public UpgradeData(Holder.Reference<T> upgrade, DataComponentPatch data) {
|
||||
this(upgrade, data, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to construct a new {@link UpgradeData} instance.
|
||||
*
|
||||
@@ -68,10 +56,8 @@ public final class UpgradeData<T extends UpgradeBase> implements DataComponentGe
|
||||
* @deprecated Use {@link #of(Holder.Reference, ItemStackTemplate, DataComponentPatch)}
|
||||
*/
|
||||
@Deprecated(since = "1.121.0")
|
||||
public static <T extends UpgradeBase> UpgradeData<T> of(
|
||||
Holder.Reference<T> upgrade, DataComponentPatch data
|
||||
) {
|
||||
return new UpgradeData<>(upgrade, data);
|
||||
public static <T extends UpgradeBase> UpgradeData<T> of(Holder.Reference<T> upgrade, DataComponentPatch data) {
|
||||
return new UpgradeData<>(upgrade, data, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,8 +82,7 @@ public final class UpgradeData<T extends UpgradeBase> implements DataComponentGe
|
||||
* @return The default upgrade data.
|
||||
*/
|
||||
public static <T extends UpgradeBase> UpgradeData<T> ofDefault(Holder.Reference<T> holder) {
|
||||
var upgrade = holder.value();
|
||||
return of(holder, upgrade.getCraftingItem(), upgrade.getUpgradeData(upgrade.getCraftingItem()));
|
||||
return of(holder, holder.value().getUpgradeItem(DataComponentPatch.EMPTY), DataComponentPatch.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-3
@@ -88,9 +88,7 @@ public interface UpgradeHandle<U extends UpgradeBase> {
|
||||
/**
|
||||
* Remove this upgrade, unequipping it and destroying the item.
|
||||
* <p>
|
||||
* This is typically used when the item is consumed (e.g. a tool using all durability). This is equivalent to
|
||||
* calling {@link ITurtleAccess#setUpgrade(TurtleSide, UpgradeData)} or {@link IPocketAccess#setUpgrade(UpgradeData)}
|
||||
* with {@code null}.
|
||||
* This is typically used when the item is consumed (e.g. a tool using all durability).
|
||||
*/
|
||||
void remove();
|
||||
}
|
||||
+1
-19
@@ -7,9 +7,6 @@ package dan200.computercraft.api.upgrades;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStackTemplate;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.storage.loot.functions.LootItemFunction;
|
||||
@@ -63,7 +60,7 @@ public sealed interface UpgradeType<T extends UpgradeBase> permits UpgradeTypeIm
|
||||
/**
|
||||
* Create an upgrade type for an upgrade that takes no arguments.
|
||||
* <p>
|
||||
* If you might want to vary the item, it's suggested you use {@link #simpleWithCustomItem(Function)} instead.
|
||||
* If you might want to vary the item, it's suggested you use {@link #simpleWithCustomIngredient(Function)} instead.
|
||||
*
|
||||
* @param instance Generate a new upgrade with a specific ID.
|
||||
* @param <T> The type of the generated upgrade.
|
||||
@@ -73,21 +70,6 @@ public sealed interface UpgradeType<T extends UpgradeBase> permits UpgradeTypeIm
|
||||
return create(MapCodec.unit(instance));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an upgrade type for a simple upgrade whose crafting item can be specified.
|
||||
*
|
||||
* @param factory Generate a new upgrade with a specific ID and crafting item. The returned upgrade's
|
||||
* {@link UpgradeBase#getCraftingItem()} <strong>MUST</strong> equal the provided item.
|
||||
* @param <T> The type of the generated upgrade.
|
||||
* @return A new upgrade type.
|
||||
* @see #simple(UpgradeBase) For upgrades whose crafting stack should not vary.
|
||||
*/
|
||||
static <T extends UpgradeBase> UpgradeType<T> simpleWithCustomItem(Function<ItemStackTemplate, T> factory) {
|
||||
return create(Item.CODEC
|
||||
.xmap(x -> factory.apply(new ItemStackTemplate(x, 1, DataComponentPatch.EMPTY)), x -> x.getCraftingItem().item())
|
||||
.fieldOf("item"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an upgrade type for a simple upgrade whose crafting item can be specified.
|
||||
*
|
||||
|
||||
@@ -66,64 +66,35 @@ dependencies {
|
||||
let me know!
|
||||
|
||||
|
||||
<h1>Updating from Minecraft 1.20.1 to 1.21.1</h1>
|
||||
|
||||
<h2>Peripherals</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
On NeoForge, the peripheral capability has migrated to NeoForge's new capability system.
|
||||
<code>dan200.computercraft.api.peripheral.PeripheralCapability</code> can be used to register a peripheral.
|
||||
<code>IPeripheralProvider</code> has also been removed, as capabilities can now be used for arbitrary
|
||||
blocks.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
{@linkplain dan200.computercraft.api.peripheral Read more on registering peripherals}.
|
||||
<h1>Updating from Minecraft 1.21.1 to 26.3</h1>
|
||||
|
||||
<h2>Turtle and pocket upgrades</h2>
|
||||
Turtle and pocket upgrades have been migrated to use Minecraft's dynamic registries. While upgrades themselves have not
|
||||
changed much, the interface for registering them is dramatically different.
|
||||
<p>
|
||||
In CC: Tweaked 1.121.0, upgrades were changed to store the item they were originally equipped with (alongside their
|
||||
upgrade data), along with changing how upgrade data is read/written. This was done in a backwards-compatible manner
|
||||
on older Minecraft versions. The Minecraft 26.3 version finishes this migration, deprecating the legacy methods used
|
||||
to interact with upgrade data (e.g. <code>ITurtleAccess.setUpgradeData</code>).It is recommended you upgrade to
|
||||
CC: Tweaked 1.121.0 and fix any deprecations before updating Minecraft.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
<code>TurtleUpgradeSerialiser</code> and <code>PocketUpgradeSerialiser</code> have been unified into a
|
||||
single {@link dan200.computercraft.api.upgrades.UpgradeType} class
|
||||
{@code UpgradeBase.getCraftingItem} has been removed in favour of
|
||||
{@link dan200.computercraft.api.upgrades.UpgradeBase#getCraftingIngredient()}.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Replace <code>TurtleUpgradeSerialiser.registryId()</code> with
|
||||
{@link dan200.computercraft.api.turtle.ITurtleUpgrade#typeRegistry()} and <code>PocketUpgradeSerialiser.registryId()</code>
|
||||
with {@link dan200.computercraft.api.pocket.IPocketUpgrade#typeRegistry()}.
|
||||
Replace usages of {@code AbstractTurtleUpgrade.StackAware} with <code>AbstractTurtleUpgrade</code> and
|
||||
similarly <code>AbstractPocketUpgrade.StackAware</code> with <code>AbstractPocketUpgrade.StackAware</code>.
|
||||
<li>
|
||||
Replace all other usages of <code>TurtleUpgradeSerialiser</code> and <code>PocketUpgradeSerialiser</code>
|
||||
with {@link dan200.computercraft.api.upgrades.UpgradeType}.
|
||||
Change your upgrade constructor to accept an {@link net.minecraft.world.item.crafting.Ingredient} instead
|
||||
of an item or item stack.
|
||||
<li>
|
||||
Replace usages of {@code UpgradeType.simpleWithCustomIngredient} with
|
||||
{@link dan200.computercraft.api.upgrades.UpgradeType#simpleWithCustomIngredient}.
|
||||
</ul>
|
||||
|
||||
<li>
|
||||
Upgrades are now (de)serialised using codecs, rather than manually reading from JSON and encoding/decoding
|
||||
network packets. Instead of subclassing {@link dan200.computercraft.api.upgrades.UpgradeType}, it is recommended
|
||||
you use {@link dan200.computercraft.api.upgrades.UpgradeType#create} to create a new type from a
|
||||
<code>MapCodec</code>.
|
||||
|
||||
<li>
|
||||
Upgrades are no longer aware of their ID, and so cannot compute their adjective. The adjective must now either
|
||||
be hard-coded, or read as part of the codec.
|
||||
|
||||
<li>
|
||||
The upgrade data providers have been removed, in favour of mod-loaders built-in support for dynamic registries.
|
||||
I'm afraid it's probably easier if you delete your existing upgrade datagen code and start from scratch. See
|
||||
<a href="./dan200/computercraft/api/turtle/ITurtleUpgrade.html#datagen">the <code>ITurtleUpgrade</code>
|
||||
documentation for an example</a>.
|
||||
|
||||
<li>
|
||||
Upgrades now store their additional data ({@link dan200.computercraft.api.turtle.ITurtleAccess#getUpgradeData},
|
||||
{@link dan200.computercraft.api.pocket.IPocketAccess#getUpgradeData()}) as an immutable component map, rather
|
||||
than a compound tag.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
{@linkplain dan200.computercraft.api.turtle.ITurtleUpgrade Read more on registering turtle upgrades}.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,80 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2025 The CC: Tweaked Developers
|
||||
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
-->
|
||||
|
||||
This is the documentation for CC: Tweaked $modVersion for Minecraft $mcVersion. Documentation for other versions of
|
||||
Minecraft are available on the CC: Tweaked website:
|
||||
|
||||
- [Minecraft 1.20.1](/mc-1.20.x/javadoc/)
|
||||
- [Minecraft 1.21.1](/mc-1.21.x/javadoc/)
|
||||
- [Minecraft 26.3](/mc-26.3/javadoc/)
|
||||
|
||||
# Quick links
|
||||
|
||||
You probably want to start in the following places:
|
||||
|
||||
- [Registering new peripherals][dan200.computercraft.api.peripheral]
|
||||
- [dan200.computercraft.api.lua.LuaFunction] and [dan200.computercraft.api.lua.IArguments] for adding methods to your
|
||||
peripheral or Lua objects.
|
||||
- [Turtle upgrades][dan200.computercraft.api.turtle.ITurtleUpgrade]
|
||||
- [Pocket upgrades][dan200.computercraft.api.pocket.IPocketUpgrade]
|
||||
|
||||
# Using
|
||||
CC: Tweaked is hosted on my maven repo, and so is relatively simple to depend on. You may wish to add a soft (or hard)
|
||||
dependency in your `mods.toml` file, with the appropriate version bounds, to ensure that API functionality you depend on
|
||||
is present.
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
maven {
|
||||
url "https://maven.squiddev.cc"
|
||||
content { includeGroup("cc.tweaked") }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Vanilla (i.e. for multi-loader systems)
|
||||
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-common-api:$modVersion")
|
||||
|
||||
// NeoForge
|
||||
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-forge-api:$modVersion")
|
||||
runtimeOnly("cc.tweaked:cc-tweaked-$mcVersion-forge:$modVersion")
|
||||
|
||||
// Fabric
|
||||
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric-api:$modVersion")
|
||||
runtimeOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric:$modVersion")
|
||||
}
|
||||
```
|
||||
|
||||
You should also be careful to only use classes within the `dan200.computercraft.api` package. Non-API classes are
|
||||
subject to change at any point. If you depend on functionality outside the API (or need to mixin to CC:T), please
|
||||
[start a discussion](https://github.com/cc-tweaked/CC-Tweaked/discussions/new/choose) to let me know!
|
||||
|
||||
# Updating from Minecraft 1.21.1 to 26.3
|
||||
|
||||
## Turtle and pocket upgrades
|
||||
In CC: Tweaked 1.121.0, upgrades were changed to store the item they were originally equipped with (alongside their
|
||||
upgrade data), along with changing how upgrade data is read/written. This was done in a backwards-compatible manner on
|
||||
older Minecraft versions. The Minecraft 26.3 version finishes this migration, removing the deprecated methods for
|
||||
interacting with upgrade data (e.g. `ITurtleAccess.setUpgradeData`). It is recommended you upgrade to CC: Tweaked 1.121.0
|
||||
and fix any deprecations before updating Minecraft.
|
||||
|
||||
- `UpgradeBase.getCraftingItem` has been removed in favour of [dan200.computercraft.api.upgrades.UpgradeBase#getCraftingIngredient()],
|
||||
|
||||
- Remove implementations of `getUpgradeItem` from your upgrade. For compatibility with older saves, you may want to
|
||||
keep your implementation of [dan200.computercraft.api.upgrades.UpgradeBase#getUpgradeItem(DataComponentPatch)].
|
||||
- Replace usages of `AbstractTurtleUpgrade.StackAware` with `AbstractTurtleUpgrade` and similarly
|
||||
`AbstractPocketUpgrade.StackAware` with `AbstractPocketUpgrade.StackAware`.
|
||||
- Change your upgrade's constructor to accept an [ingredient][net.minecraft.world.item.crafting.Ingredient] instead of
|
||||
an item or item stack.
|
||||
- Replace usages of `UpgradeType.simpleWithCustomItem` with [dan200.computercraft.api.upgrades.UpgradeType#simpleWithCustomIngredient].
|
||||
|
||||
- `ITurtleAccess.getUpgradeData`/`IPocketAccess.getUpgradeData` and `ITurtleAccess.setUpgradeData`/`IPocketAccess.setUpgradeData`
|
||||
have been removed. Replace these with a call to [dan200.computercraft.api.turtle.ITurtleAccess#getUpgradeHandle(TurtleSide)]/
|
||||
[dan200.computercraft.api.pocket.IPocketAccess#getUpgradeHandle()], then [dan200.computercraft.api.upgrades.UpgradeHandle#getData()]
|
||||
and [dan200.computercraft.api.upgrades.UpgradeHandle#setData(DataComponentPatch)].
|
||||
|
||||
Note these new methods can only be called on the main/server thread. You should **NOT** interact with them from off-thread
|
||||
peripheral calls.
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.item.crafting.Ingredient;
|
||||
* An example turtle upgrade.
|
||||
*/
|
||||
// @start region=body
|
||||
public class ExampleTurtleUpgrade extends AbstractTurtleUpgrade.StackAware {
|
||||
public class ExampleTurtleUpgrade extends AbstractTurtleUpgrade {
|
||||
public ExampleTurtleUpgrade(Ingredient stack) {
|
||||
super(TurtleUpgradeType.PERIPHERAL, "upgrade.examplemod.example_turtle_upgrade.adjective", stack);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.pocket.IPocketAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeData;
|
||||
import dan200.computercraft.api.upgrades.UpgradeHandle;
|
||||
@@ -88,14 +87,6 @@ public abstract class AbstractUpgradeHolder<U extends UpgradeBase> {
|
||||
this.upgradeData = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recompute the item from the upgrade's data. This should be called from methods like
|
||||
* {@link ITurtleAccess#setUpgradeData(TurtleSide, DataComponentPatch)} to support upgrades that do not preserve their item.
|
||||
*/
|
||||
public final void recomputeItem() {
|
||||
setItem(upgrade.value().getUpgradeItem(data));
|
||||
}
|
||||
|
||||
public final UpgradeHandle<U> getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -138,10 +138,7 @@ public final class UpgradeManager<T extends UpgradeBase> {
|
||||
return upgrade.getCraftingIngredient().test(stack) && upgrade.isItemSuitable(stack);
|
||||
})
|
||||
.findAny()
|
||||
.map(x -> {
|
||||
var item = ItemStackTemplate.fromNonEmptyStack(stack);
|
||||
return UpgradeData.of(x, item, x.value().getUpgradeData(item));
|
||||
})
|
||||
.map(upgrade -> UpgradeData.of(upgrade, ItemStackTemplate.fromNonEmptyStack(stack), DataComponentPatch.EMPTY))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
+2
-25
@@ -16,7 +16,6 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.network.client.PocketComputerDataMessage;
|
||||
import dan200.computercraft.shared.network.server.ServerNetworking;
|
||||
import dan200.computercraft.shared.util.DataComponentUtil;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -255,8 +254,7 @@ public final class PocketBrain implements PocketComputerInternal {
|
||||
if (!holder.isValid(computer)) throw new IllegalStateException("Pocket computer is not active");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UpgradeData<IPocketUpgrade> getUpgrade() {
|
||||
private @Nullable UpgradeData<IPocketUpgrade> getUpgrade() {
|
||||
return upgrade == null ? null : upgrade.getUpgradeData();
|
||||
}
|
||||
|
||||
@@ -266,26 +264,6 @@ public final class PocketBrain implements PocketComputerInternal {
|
||||
return upgrade == null ? null : upgrade.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public DataComponentPatch getUpgradeData() {
|
||||
var upgrade = this.upgrade;
|
||||
return upgrade == null ? DataComponentPatch.EMPTY : upgrade.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUpgradeData(DataComponentPatch data) {
|
||||
var stack = requireStack();
|
||||
|
||||
var upgrade = this.upgrade;
|
||||
if (upgrade == null || upgrade.getData().equals(data)) return;
|
||||
|
||||
upgrade.setData(data);
|
||||
upgrade.recomputeItem();
|
||||
stack.set(component, upgrade.getUpgradeData());
|
||||
holder.setChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidatePeripheral() {
|
||||
var upgrade = this.upgrade;
|
||||
@@ -300,8 +278,7 @@ public final class PocketBrain implements PocketComputerInternal {
|
||||
*
|
||||
* @param upgrade The new upgrade to set it to, may be {@code null}.
|
||||
*/
|
||||
@Override
|
||||
public void setUpgrade(@Nullable UpgradeData<IPocketUpgrade> upgrade) {
|
||||
private void setUpgrade(@Nullable UpgradeData<IPocketUpgrade> upgrade) {
|
||||
var stack = requireStack();
|
||||
|
||||
if (!setUpgradeDirect(upgrade)) return;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeriph
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class PocketModem extends AbstractPocketUpgrade.StackAware {
|
||||
public class PocketModem extends AbstractPocketUpgrade {
|
||||
public static final MapCodec<PocketModem> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
|
||||
Ingredient.CODEC.fieldOf("item").forGetter(AbstractPocketUpgrade::getCraftingIngredient),
|
||||
Codec.BOOL.fieldOf("advanced").forGetter(x -> x.advanced)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class PocketSpeaker extends AbstractPocketUpgrade.StackAware {
|
||||
public class PocketSpeaker extends AbstractPocketUpgrade {
|
||||
public PocketSpeaker(Ingredient item) {
|
||||
super(UpgradeSpeakerPeripheral.ADJECTIVE, item);
|
||||
}
|
||||
|
||||
-20
@@ -27,7 +27,6 @@ import dan200.computercraft.shared.util.BlockEntityHelpers;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
@@ -513,25 +512,6 @@ public class TurtleBrain implements TurtleAccessInternal {
|
||||
return upgrade == null ? null : upgrade.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public DataComponentPatch getUpgradeData(TurtleSide side) {
|
||||
var upgrade = upgrades.get(side);
|
||||
return upgrade == null ? DataComponentPatch.EMPTY : upgrade.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setUpgradeData(TurtleSide side, DataComponentPatch data) {
|
||||
var upgrade = upgrades.get(side);
|
||||
if (upgrade == null || Objects.equals(upgrade.getData(), data)) return;
|
||||
|
||||
upgrade.setData(data);
|
||||
upgrade.recomputeItem();
|
||||
|
||||
BlockEntityHelpers.updateBlock(owner);
|
||||
}
|
||||
|
||||
public Vec3 getRenderOffset(float f) {
|
||||
return switch (animation) {
|
||||
case MOVE_FORWARD, MOVE_BACK, MOVE_UP, MOVE_DOWN -> {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
||||
|
||||
public class TurtleCraftingTable extends AbstractTurtleUpgrade.StackAware {
|
||||
public class TurtleCraftingTable extends AbstractTurtleUpgrade {
|
||||
public TurtleCraftingTable(Ingredient stack) {
|
||||
super(TurtleUpgradeType.PERIPHERAL, "upgrade.minecraft.crafting_table.adjective", stack);
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class TurtleModem extends AbstractTurtleUpgrade.StackAware {
|
||||
public class TurtleModem extends AbstractTurtleUpgrade {
|
||||
public static final MapCodec<TurtleModem> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
|
||||
Ingredient.CODEC.fieldOf("item").forGetter(AbstractTurtleUpgrade::getCraftingIngredient),
|
||||
Codec.BOOL.fieldOf("advanced").forGetter(TurtleModem::advanced)
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class TurtleSpeaker extends AbstractTurtleUpgrade.StackAware {
|
||||
public class TurtleSpeaker extends AbstractTurtleUpgrade {
|
||||
private static final class Peripheral extends UpgradeSpeakerPeripheral {
|
||||
final ITurtleAccess turtle;
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* Turtle storage upgrade.
|
||||
*/
|
||||
public final class TurtleStorage extends AbstractTurtleUpgrade.StackAware {
|
||||
public final class TurtleStorage extends AbstractTurtleUpgrade {
|
||||
public static final String ADJECTIVE = "upgrade.computercraft.storage.adjective";
|
||||
|
||||
public static final String DATA_PACK_NAME = "turtle_storage";
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class TurtleTool extends AbstractTurtleUpgrade.StackAware {
|
||||
public class TurtleTool extends AbstractTurtleUpgrade {
|
||||
public static final MapCodec<TurtleTool> CODEC = TurtleToolSpec.CODEC.xmap(TurtleTool::new, x -> x.spec);
|
||||
|
||||
private static final TurtleCommandResult UNBREAKABLE = TurtleCommandResult.failure("Cannot break unbreakable block");
|
||||
|
||||
@@ -403,10 +403,6 @@ class Turtle_Test {
|
||||
if (!expected.matches(upgrade.upgradeItem)) {
|
||||
fail("Invalid upgrade item\n Expected => ${expected.componentsPatch}\n Actual => ${upgrade.upgradeItem.components}")
|
||||
}
|
||||
|
||||
if (!ItemStack(expected.item).matches(upgrade.upgrade().craftingItem)) {
|
||||
fail("Original upgrade item has changed (is now ${upgrade.upgrade().craftingItem})")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user