mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-10 01:10:30 +00:00
Update to Minecraft 1.21
API Changes: - Minecraft had updated ModelResourceLocation to no longer inherit from ResourceLocation. To allow referencing both already baked models (ModelResourceLocation) and loading new models (via ResourceLocation) in turtle model loadders, we add a new "ModelLocation" class, that acts as a union between the two. I'm not entirely convinced by the design here, so might end up changing again before a stable release.o - Merge IMedia.getAudioTitle and IMedia.getAudio into a single IMedia.getAudio method, which now returns a JukeboxSong rather than a SoundEvent. Other update notes: - Minecraft had rewritten how buffers are managed again. This is a fairly minor change for us (vertex -> addVertex, normal -> setNormal, etc...), with the exception that you can no longer use MultiBufferSource.immediate with the tesselator. I've replaced this with GuiGraphics.bufferSource, which appears to be fine, but worth keeping an eye on in case there's any odd render state issues. - Crafting now uses a CraftingInput (a list of items) rather than a CraftingContainer, which allows us to simplify turtle crafting code.
This commit is contained in:
parent
bb933d0100
commit
4b102f16b3
@ -31,9 +31,9 @@ fun JavaExec.setRunConfig(config: Run) {
|
|||||||
environment(config.environmentVariables.get())
|
environment(config.environmentVariables.get())
|
||||||
systemProperties(config.systemProperties.get())
|
systemProperties(config.systemProperties.get())
|
||||||
|
|
||||||
config.modSources.get().forEach { classpath(it.runtimeClasspath) }
|
config.modSources.all().get().values().forEach { classpath(it.runtimeClasspath) }
|
||||||
classpath(config.classpath)
|
classpath(config.classpath)
|
||||||
classpath(config.dependencies.get().configuration)
|
classpath(config.dependencies.get().runtimeConfiguration)
|
||||||
|
|
||||||
(config as RunImpl).taskDependencies.forEach { dependsOn(it) }
|
(config as RunImpl).taskDependencies.forEach { dependsOn(it) }
|
||||||
|
|
||||||
|
@ -8,9 +8,11 @@ org.gradle.parallel=true
|
|||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
kotlin.jvm.target.validation.mode=error
|
kotlin.jvm.target.validation.mode=error
|
||||||
|
|
||||||
|
neogradle.subsystems.conventions.runs.enabled=false
|
||||||
|
|
||||||
# Mod properties
|
# Mod properties
|
||||||
isUnstable=true
|
isUnstable=true
|
||||||
modVersion=1.111.0
|
modVersion=1.111.0
|
||||||
|
|
||||||
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
|
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
|
||||||
mcVersion=1.20.6
|
mcVersion=1.21
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
# Minecraft
|
# Minecraft
|
||||||
# MC version is specified in gradle.properties, as we need that in settings.gradle.
|
# MC version is specified in gradle.properties, as we need that in settings.gradle.
|
||||||
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
|
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
|
||||||
fabric-api = "0.98.0+1.20.6"
|
fabric-api = "0.100.3+1.21"
|
||||||
fabric-loader = "0.15.10"
|
fabric-loader = "0.15.11"
|
||||||
neoForge = "20.6.48-beta"
|
neoForge = "21.0.21-beta"
|
||||||
neoForgeSpi = "8.0.1"
|
neoForgeSpi = "8.0.1"
|
||||||
mixin = "0.8.5"
|
mixin = "0.8.5"
|
||||||
parchment = "2024.05.01"
|
parchment = "2024.06.16"
|
||||||
parchmentMc = "1.20.6"
|
parchmentMc = "1.20.6"
|
||||||
yarn = "1.20.6+build.1"
|
yarn = "1.21+build.1"
|
||||||
|
|
||||||
# Core dependencies (these versions are tied to the version Minecraft uses)
|
# Core dependencies (these versions are tied to the version Minecraft uses)
|
||||||
fastutil = "8.5.12"
|
fastutil = "8.5.12"
|
||||||
@ -36,14 +36,14 @@ kotlin-coroutines = "1.7.3"
|
|||||||
nightConfig = "3.6.7"
|
nightConfig = "3.6.7"
|
||||||
|
|
||||||
# Minecraft mods
|
# Minecraft mods
|
||||||
emi = "1.1.5+1.20.6"
|
emi = "1.1.7+1.21"
|
||||||
fabricPermissions = "0.3.1"
|
fabricPermissions = "0.3.1"
|
||||||
iris = "1.6.14+1.20.4"
|
iris = "1.6.14+1.20.4"
|
||||||
jei = "17.3.0.48"
|
jei = "19.0.0.1"
|
||||||
modmenu = "9.0.0"
|
modmenu = "11.0.0-rc.4"
|
||||||
moreRed = "4.0.0.4"
|
moreRed = "4.0.0.4"
|
||||||
oculus = "1.2.5"
|
oculus = "1.2.5"
|
||||||
rei = "15.0.728"
|
rei = "16.0.729"
|
||||||
rubidium = "0.6.1"
|
rubidium = "0.6.1"
|
||||||
sodium = "mc1.20-0.4.10"
|
sodium = "mc1.20-0.4.10"
|
||||||
mixinExtra = "0.3.5"
|
mixinExtra = "0.3.5"
|
||||||
@ -67,7 +67,7 @@ ideaExt = "1.1.7"
|
|||||||
illuaminate = "0.1.0-73-g43ee16c"
|
illuaminate = "0.1.0-73-g43ee16c"
|
||||||
lwjgl = "3.3.3"
|
lwjgl = "3.3.3"
|
||||||
minotaur = "2.8.7"
|
minotaur = "2.8.7"
|
||||||
neoGradle = "7.0.116"
|
neoGradle = "7.0.145"
|
||||||
nullAway = "0.10.25"
|
nullAway = "0.10.25"
|
||||||
spotless = "6.23.3"
|
spotless = "6.23.3"
|
||||||
taskTree = "2.1.1"
|
taskTree = "2.1.1"
|
||||||
@ -106,9 +106,9 @@ fabric-junit = { module = "net.fabricmc:fabric-loader-junit", version.ref = "fab
|
|||||||
fabricPermissions = { module = "me.lucko:fabric-permissions-api", version.ref = "fabricPermissions" }
|
fabricPermissions = { module = "me.lucko:fabric-permissions-api", version.ref = "fabricPermissions" }
|
||||||
emi = { module = "dev.emi:emi-xplat-mojmap", version.ref = "emi" }
|
emi = { module = "dev.emi:emi-xplat-mojmap", version.ref = "emi" }
|
||||||
iris = { module = "maven.modrinth:iris", version.ref = "iris" }
|
iris = { module = "maven.modrinth:iris", version.ref = "iris" }
|
||||||
jei-api = { module = "mezz.jei:jei-1.20.4-common-api", version.ref = "jei" }
|
jei-api = { module = "mezz.jei:jei-1.21-common-api", version.ref = "jei" }
|
||||||
jei-fabric = { module = "mezz.jei:jei-1.20.4-fabric", version.ref = "jei" }
|
jei-fabric = { module = "mezz.jei:jei-1.21-fabric", version.ref = "jei" }
|
||||||
jei-forge = { module = "mezz.jei:jei-1.20.4-forge", version.ref = "jei" }
|
jei-forge = { module = "mezz.jei:jei-1.21-neoforge", version.ref = "jei" }
|
||||||
mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
|
mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
|
||||||
mixinExtra = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixinExtra" }
|
mixinExtra = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixinExtra" }
|
||||||
modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
|
modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
|
||||||
@ -179,9 +179,9 @@ kotlin = ["kotlin-stdlib", "kotlin-coroutines"]
|
|||||||
# Minecraft
|
# Minecraft
|
||||||
externalMods-common = ["jei-api", "nightConfig-core", "nightConfig-toml"]
|
externalMods-common = ["jei-api", "nightConfig-core", "nightConfig-toml"]
|
||||||
externalMods-forge-compile = ["moreRed", "oculus", "jei-api"]
|
externalMods-forge-compile = ["moreRed", "oculus", "jei-api"]
|
||||||
externalMods-forge-runtime = []
|
externalMods-forge-runtime = ["jei-forge"]
|
||||||
externalMods-fabric-compile = ["fabricPermissions", "iris", "jei-api", "rei-api", "rei-builtin"]
|
externalMods-fabric-compile = ["fabricPermissions", "iris", "jei-api", "rei-api", "rei-builtin"]
|
||||||
externalMods-fabric-runtime = [] # ["jei-fabric", "modmenu"]
|
externalMods-fabric-runtime = ["jei-fabric", "modmenu"]
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
test = ["junit-jupiter-api", "junit-jupiter-params", "hamcrest", "jqwik-api"]
|
test = ["junit-jupiter-api", "junit-jupiter-params", "hamcrest", "jqwik-api"]
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
package dan200.computercraft.api.client;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
||||||
|
import dan200.computercraft.impl.client.ClientPlatformHelper;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
|
import net.minecraft.client.resources.model.ModelManager;
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of a model to load. This may either be:
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>A {@link ModelResourceLocation}, referencing an already baked model (such as {@code minecraft:dirt#inventory}).</li>
|
||||||
|
* <li>
|
||||||
|
* A {@link ResourceLocation}, referencing a path to a model resource (such as {@code minecraft:item/dirt}.
|
||||||
|
* These models will be baked and stored in the {@link ModelManager} in a loader-specific way.
|
||||||
|
* </li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public final class ModelLocation {
|
||||||
|
/**
|
||||||
|
* The location of the model.
|
||||||
|
* <p>
|
||||||
|
* When {@link #resourceLocation} is null, this is the location of the model to load. When {@link #resourceLocation}
|
||||||
|
* is non-null, this is the "standalone" variant of the model resource — this is used by NeoForge's implementation
|
||||||
|
* of {@link ClientPlatformHelper#getModel(ModelManager, ModelResourceLocation, ResourceLocation)} to fetch the
|
||||||
|
* model from the model manger. It is not used on Fabric.
|
||||||
|
*/
|
||||||
|
private final ModelResourceLocation modelLocation;
|
||||||
|
private final @Nullable ResourceLocation resourceLocation;
|
||||||
|
|
||||||
|
private ModelLocation(ModelResourceLocation modelLocation, @Nullable ResourceLocation resourceLocation) {
|
||||||
|
this.modelLocation = modelLocation;
|
||||||
|
this.resourceLocation = resourceLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link ModelLocation} from model in the model manager.
|
||||||
|
*
|
||||||
|
* @param location The name of the model to load.
|
||||||
|
* @return The new {@link ModelLocation} instance.
|
||||||
|
*/
|
||||||
|
public static ModelLocation ofModel(ModelResourceLocation location) {
|
||||||
|
return new ModelLocation(location, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link ModelLocation} from a resource.
|
||||||
|
*
|
||||||
|
* @param location The location of the model resource, such as {@code minecraft:item/dirt}.
|
||||||
|
* @return The new {@link ModelLocation} instance.
|
||||||
|
*/
|
||||||
|
public static ModelLocation ofResource(ResourceLocation location) {
|
||||||
|
return new ModelLocation(new ModelResourceLocation(location, "standalone"), location);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this model from the provided model manager.
|
||||||
|
*
|
||||||
|
* @param manager The model manger.
|
||||||
|
* @return This model, or the missing model if it could not be found.
|
||||||
|
*/
|
||||||
|
public BakedModel getModel(ModelManager manager) {
|
||||||
|
return ClientPlatformHelper.get().getModel(manager, modelLocation, resourceLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the models this model location depends on.
|
||||||
|
*
|
||||||
|
* @return A list of models that this model location depends on.
|
||||||
|
* @see TurtleUpgradeModeller#getDependencies()
|
||||||
|
*/
|
||||||
|
public Stream<ResourceLocation> getDependencies() {
|
||||||
|
return resourceLocation == null ? Stream.empty() : Stream.of(resourceLocation);
|
||||||
|
}
|
||||||
|
}
|
@ -13,30 +13,47 @@ import net.minecraft.client.resources.model.ModelResourceLocation;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A model to render, combined with a transformation matrix to apply.
|
* A model to render, combined with a transformation matrix to apply.
|
||||||
|
*
|
||||||
|
* @param model The model.
|
||||||
|
* @param matrix The transformation matrix.
|
||||||
*/
|
*/
|
||||||
public final class TransformedModel {
|
public record TransformedModel(BakedModel model, Transformation matrix) {
|
||||||
private final BakedModel model;
|
|
||||||
private final Transformation matrix;
|
|
||||||
|
|
||||||
public TransformedModel(BakedModel model, Transformation matrix) {
|
|
||||||
this.model = Objects.requireNonNull(model);
|
|
||||||
this.matrix = Objects.requireNonNull(matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransformedModel(BakedModel model) {
|
public TransformedModel(BakedModel model) {
|
||||||
this.model = Objects.requireNonNull(model);
|
this(model, Transformation.identity());
|
||||||
matrix = Transformation.identity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up a model in the model bakery and construct a {@link TransformedModel} with no transformation.
|
||||||
|
*
|
||||||
|
* @param location The location of the model to load.
|
||||||
|
* @return The new {@link TransformedModel} instance.
|
||||||
|
*/
|
||||||
|
public static TransformedModel of(ModelLocation location) {
|
||||||
|
var modelManager = Minecraft.getInstance().getModelManager();
|
||||||
|
return new TransformedModel(location.getModel(modelManager));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up a model in the model bakery and construct a {@link TransformedModel} with no transformation.
|
||||||
|
*
|
||||||
|
* @param location The location of the model to load.
|
||||||
|
* @return The new {@link TransformedModel} instance.
|
||||||
|
* @see ModelLocation#ofModel(ModelResourceLocation)
|
||||||
|
*/
|
||||||
public static TransformedModel of(ModelResourceLocation location) {
|
public static TransformedModel of(ModelResourceLocation location) {
|
||||||
var modelManager = Minecraft.getInstance().getModelManager();
|
var modelManager = Minecraft.getInstance().getModelManager();
|
||||||
return new TransformedModel(modelManager.getModel(location));
|
return new TransformedModel(modelManager.getModel(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up a model in the model bakery and construct a {@link TransformedModel} with no transformation.
|
||||||
|
*
|
||||||
|
* @param location The location of the model to load.
|
||||||
|
* @return The new {@link TransformedModel} instance.
|
||||||
|
* @see ModelLocation#ofResource(ResourceLocation)
|
||||||
|
*/
|
||||||
public static TransformedModel of(ResourceLocation location) {
|
public static TransformedModel of(ResourceLocation location) {
|
||||||
var modelManager = Minecraft.getInstance().getModelManager();
|
var modelManager = Minecraft.getInstance().getModelManager();
|
||||||
return new TransformedModel(ClientPlatformHelper.get().getModel(modelManager, location));
|
return new TransformedModel(ClientPlatformHelper.get().getModel(modelManager, location));
|
||||||
@ -46,12 +63,4 @@ public final class TransformedModel {
|
|||||||
var model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel(item);
|
var model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel(item);
|
||||||
return new TransformedModel(model, transform);
|
return new TransformedModel(model, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BakedModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Transformation getMatrix() {
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package dan200.computercraft.api.client.turtle;
|
package dan200.computercraft.api.client.turtle;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.client.ModelLocation;
|
||||||
import dan200.computercraft.api.client.TransformedModel;
|
import dan200.computercraft.api.client.TransformedModel;
|
||||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||||
@ -77,6 +78,18 @@ public interface TurtleUpgradeModeller<T extends ITurtleUpgrade> {
|
|||||||
* @return The constructed modeller.
|
* @return The constructed modeller.
|
||||||
*/
|
*/
|
||||||
static <T extends ITurtleUpgrade> TurtleUpgradeModeller<T> sided(ResourceLocation left, ResourceLocation right) {
|
static <T extends ITurtleUpgrade> TurtleUpgradeModeller<T> sided(ResourceLocation left, ResourceLocation right) {
|
||||||
|
return sided(ModelLocation.ofResource(left), ModelLocation.ofResource(right));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a {@link TurtleUpgradeModeller} which has a single model for the left and right side.
|
||||||
|
*
|
||||||
|
* @param left The model to use on the left.
|
||||||
|
* @param right The model to use on the right.
|
||||||
|
* @param <T> The type of the turtle upgrade.
|
||||||
|
* @return The constructed modeller.
|
||||||
|
*/
|
||||||
|
static <T extends ITurtleUpgrade> TurtleUpgradeModeller<T> sided(ModelLocation left, ModelLocation right) {
|
||||||
return new TurtleUpgradeModeller<>() {
|
return new TurtleUpgradeModeller<>() {
|
||||||
@Override
|
@Override
|
||||||
public TransformedModel getModel(T upgrade, @Nullable ITurtleAccess turtle, TurtleSide side, DataComponentPatch data) {
|
public TransformedModel getModel(T upgrade, @Nullable ITurtleAccess turtle, TurtleSide side, DataComponentPatch data) {
|
||||||
@ -85,7 +98,7 @@ public interface TurtleUpgradeModeller<T extends ITurtleUpgrade> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<ResourceLocation> getDependencies() {
|
public Stream<ResourceLocation> getDependencies() {
|
||||||
return Stream.of(left, right);
|
return Stream.of(left, right).flatMap(ModelLocation::getDependencies);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package dan200.computercraft.impl.client;
|
package dan200.computercraft.impl.client;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.client.ModelLocation;
|
||||||
import dan200.computercraft.impl.Services;
|
import dan200.computercraft.impl.Services;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
@ -17,13 +18,28 @@ import javax.annotation.Nullable;
|
|||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public interface ClientPlatformHelper {
|
public interface ClientPlatformHelper {
|
||||||
/**
|
/**
|
||||||
* Equivalent to {@link ModelManager#getModel(ModelResourceLocation)} but for arbitrary {@link ResourceLocation}s.
|
* Get a model from a resource.
|
||||||
*
|
*
|
||||||
* @param manager The model manager.
|
* @param manager The model manager.
|
||||||
* @param location The model location.
|
* @param resourceLocation The model resourceLocation.
|
||||||
* @return The baked model.
|
* @return The baked model.
|
||||||
|
* @see ModelLocation
|
||||||
*/
|
*/
|
||||||
BakedModel getModel(ModelManager manager, ResourceLocation location);
|
BakedModel getModel(ModelManager manager, ResourceLocation resourceLocation);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a model from a {@link ModelResourceLocation} or {@link ResourceLocation}.
|
||||||
|
* <p>
|
||||||
|
* This is largely equivalent to {@code resourceLocation == null ? manager.getModel(modelLocation) : getModel(manager, resourceLocation)},
|
||||||
|
* but allows pre-computing {@code modelLocation} (if needed).
|
||||||
|
*
|
||||||
|
* @param manager The model manager.
|
||||||
|
* @param modelLocation The location of the model to load.
|
||||||
|
* @param resourceLocation The location of the resource, if trying to load from a resource.
|
||||||
|
* @return The baked model.
|
||||||
|
* @see ModelLocation
|
||||||
|
*/
|
||||||
|
BakedModel getModel(ModelManager manager, ModelResourceLocation modelLocation, @Nullable ResourceLocation resourceLocation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap this model in a version which renders a foil/enchantment glint.
|
* Wrap this model in a version which renders a foil/enchantment glint.
|
||||||
|
@ -46,7 +46,7 @@ public class ComputerCraftTags {
|
|||||||
public static final TagKey<Item> DYEABLE = make("dyeable");
|
public static final TagKey<Item> DYEABLE = make("dyeable");
|
||||||
|
|
||||||
private static TagKey<Item> make(String name) {
|
private static TagKey<Item> make(String name) {
|
||||||
return TagKey.create(Registries.ITEM, new ResourceLocation(ComputerCraftAPI.MOD_ID, name));
|
return TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class ComputerCraftTags {
|
|||||||
public static final TagKey<Block> TURTLE_CAN_USE = make("turtle_can_use");
|
public static final TagKey<Block> TURTLE_CAN_USE = make("turtle_can_use");
|
||||||
|
|
||||||
private static TagKey<Block> make(String name) {
|
private static TagKey<Block> make(String name) {
|
||||||
return TagKey.create(Registries.BLOCK, new ResourceLocation(ComputerCraftAPI.MOD_ID, name));
|
return TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,13 @@ package dan200.computercraft.api.media;
|
|||||||
import dan200.computercraft.api.ComputerCraftAPI;
|
import dan200.computercraft.api.ComputerCraftAPI;
|
||||||
import dan200.computercraft.api.filesystem.Mount;
|
import dan200.computercraft.api.filesystem.Mount;
|
||||||
import dan200.computercraft.api.filesystem.WritableMount;
|
import dan200.computercraft.api.filesystem.WritableMount;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.JukeboxSong;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -25,11 +27,12 @@ public interface IMedia {
|
|||||||
/**
|
/**
|
||||||
* Get a string representing the label of this item. Will be called via {@code disk.getLabel()} in lua.
|
* Get a string representing the label of this item. Will be called via {@code disk.getLabel()} in lua.
|
||||||
*
|
*
|
||||||
|
* @param registries The currently loaded registries.
|
||||||
* @param stack The {@link ItemStack} to inspect.
|
* @param stack The {@link ItemStack} to inspect.
|
||||||
* @return The label. ie: "Dan's Programs".
|
* @return The label. ie: "Dan's Programs".
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
String getLabel(ItemStack stack);
|
String getLabel(HolderLookup.Provider registries, ItemStack stack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
|
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
|
||||||
@ -43,26 +46,15 @@ public interface IMedia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
|
* If this disk represents an item with audio (like a record), get the corresponding {@link JukeboxSong}.
|
||||||
* "Jonathan Coulton - Still Alive"
|
|
||||||
*
|
*
|
||||||
* @param stack The {@link ItemStack} to modify.
|
* @param registries The currently loaded registries.
|
||||||
* @return The name, or null if this item does not represent an item with audio.
|
* @param stack The {@link ItemStack} to query.
|
||||||
|
* @return The song, or null if this item does not represent an item with audio.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
default String getAudioTitle(ItemStack stack) {
|
default Holder<JukeboxSong> getAudio(HolderLookup.Provider registries, ItemStack stack) {
|
||||||
return null;
|
return JukeboxSong.fromStack(registries, stack).orElse(null);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
|
|
||||||
*
|
|
||||||
* @param stack The {@link ItemStack} to modify.
|
|
||||||
* @return The name, or null if this item does not represent an item with audio.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
default SoundEvent getAudio(ItemStack stack) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ import javax.annotation.Nullable;
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public interface IPocketUpgrade extends UpgradeBase {
|
public interface IPocketUpgrade extends UpgradeBase {
|
||||||
ResourceKey<Registry<IPocketUpgrade>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_upgrade"));
|
ResourceKey<Registry<IPocketUpgrade>> REGISTRY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "pocket_upgrade"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The registry key for pocket upgrade types.
|
* The registry key for pocket upgrade types.
|
||||||
|
@ -57,7 +57,7 @@ public interface ITurtleUpgrade extends UpgradeBase {
|
|||||||
/**
|
/**
|
||||||
* The registry in which turtle upgrades are stored.
|
* The registry in which turtle upgrades are stored.
|
||||||
*/
|
*/
|
||||||
ResourceKey<Registry<ITurtleUpgrade>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_upgrade"));
|
ResourceKey<Registry<ITurtleUpgrade>> REGISTRY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "turtle_upgrade"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link ResourceKey} for a turtle upgrade given a {@link ResourceLocation}.
|
* Create a {@link ResourceKey} for a turtle upgrade given a {@link ResourceLocation}.
|
||||||
|
@ -35,7 +35,7 @@ import java.util.Optional;
|
|||||||
* import net.minecraft.world.item.Items;
|
* import net.minecraft.world.item.Items;
|
||||||
*
|
*
|
||||||
* public void registerTool(BootstrapContext<ITurtleUpgrade> upgrades) {
|
* public void registerTool(BootstrapContext<ITurtleUpgrade> upgrades) {
|
||||||
* TurtleToolBuilder.tool(new ResourceLocation("my_mod", "wooden_pickaxe"), Items.WOODEN_PICKAXE).register(upgrades);
|
* TurtleToolBuilder.tool(ResourceLocation.fromNamespaceAndPath("my_mod", "wooden_pickaxe"), Items.WOODEN_PICKAXE).register(upgrades);
|
||||||
* }
|
* }
|
||||||
*}
|
*}
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +55,7 @@ import java.util.function.Function;
|
|||||||
* public void generate(DataGenerator.PackGenerator output, CompletableFuture<HolderLookup.Provider> registries) {
|
* public void generate(DataGenerator.PackGenerator output, CompletableFuture<HolderLookup.Provider> registries) {
|
||||||
* var newRegistries = RegistryPatchGenerator.createLookup(registries, Util.make(new RegistrySetBuilder(), builder -> {
|
* var newRegistries = RegistryPatchGenerator.createLookup(registries, Util.make(new RegistrySetBuilder(), builder -> {
|
||||||
* builder.add(ITurtleUpgrade.REGISTRY, upgrades -> {
|
* builder.add(ITurtleUpgrade.REGISTRY, upgrades -> {
|
||||||
* upgrades.register(ITurtleUpgrade.createKey(new ResourceLocation("my_mod", "my_upgrade")), new MyUpgrade());
|
* upgrades.register(ITurtleUpgrade.createKey(ResourceLocation.fromNamespaceAndPath("my_mod", "my_upgrade")), new MyUpgrade());
|
||||||
* });
|
* });
|
||||||
* }));
|
* }));
|
||||||
* output.addProvider(o -> new DatapackBuiltinEntriesProvider(o, newRegistries, Set.of("my_mod")));
|
* output.addProvider(o -> new DatapackBuiltinEntriesProvider(o, newRegistries, Set.of("my_mod")));
|
||||||
|
@ -118,12 +118,12 @@ public final class ClientRegistry {
|
|||||||
|
|
||||||
public static void registerTurtleModellers(RegisterTurtleUpgradeModeller register) {
|
public static void registerTurtleModellers(RegisterTurtleUpgradeModeller register) {
|
||||||
register.register(ModRegistry.TurtleUpgradeTypes.SPEAKER.get(), TurtleUpgradeModeller.sided(
|
register.register(ModRegistry.TurtleUpgradeTypes.SPEAKER.get(), TurtleUpgradeModeller.sided(
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_left"),
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_left"),
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_right")
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_right")
|
||||||
));
|
));
|
||||||
register.register(ModRegistry.TurtleUpgradeTypes.WORKBENCH.get(), TurtleUpgradeModeller.sided(
|
register.register(ModRegistry.TurtleUpgradeTypes.WORKBENCH.get(), TurtleUpgradeModeller.sided(
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_left"),
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_left"),
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_right")
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_right")
|
||||||
));
|
));
|
||||||
register.register(ModRegistry.TurtleUpgradeTypes.WIRELESS_MODEM.get(), new TurtleModemModeller());
|
register.register(ModRegistry.TurtleUpgradeTypes.WIRELESS_MODEM.get(), new TurtleModemModeller());
|
||||||
register.register(ModRegistry.TurtleUpgradeTypes.TOOL.get(), TurtleUpgradeModeller.flatItem());
|
register.register(ModRegistry.TurtleUpgradeTypes.TOOL.get(), TurtleUpgradeModeller.flatItem());
|
||||||
@ -131,7 +131,7 @@ public final class ClientRegistry {
|
|||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
private static void registerItemProperty(RegisterItemProperty itemProperties, String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items) {
|
private static void registerItemProperty(RegisterItemProperty itemProperties, String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items) {
|
||||||
var id = new ResourceLocation(ComputerCraftAPI.MOD_ID, name);
|
var id = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name);
|
||||||
for (var item : items) itemProperties.register(item.get(), id, getter);
|
for (var item : items) itemProperties.register(item.get(), id, getter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ public final class ClientRegistry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void registerExtraModels(Consumer<ResourceLocation> register) {
|
public static void registerExtraModels(Consumer<ResourceLocation> register) {
|
||||||
for (var model : EXTRA_MODELS) register.accept(new ResourceLocation(ComputerCraftAPI.MOD_ID, model));
|
for (var model : EXTRA_MODELS) register.accept(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, model));
|
||||||
TurtleUpgradeModellers.getDependencies().forEach(register);
|
TurtleUpgradeModellers.getDependencies().forEach(register);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import net.minecraft.world.entity.player.Inventory;
|
|||||||
* The GUI for disk drives.
|
* The GUI for disk drives.
|
||||||
*/
|
*/
|
||||||
public class DiskDriveScreen extends AbstractContainerScreen<DiskDriveMenu> {
|
public class DiskDriveScreen extends AbstractContainerScreen<DiskDriveMenu> {
|
||||||
private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/disk_drive.png");
|
private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/disk_drive.png");
|
||||||
|
|
||||||
public DiskDriveScreen(DiskDriveMenu container, Inventory player, Component title) {
|
public DiskDriveScreen(DiskDriveMenu container, Inventory player, Component title) {
|
||||||
super(container, player, title);
|
super(container, player, title);
|
||||||
|
@ -21,7 +21,7 @@ import java.util.stream.Stream;
|
|||||||
* Sprite sheet for all GUI texutres in the mod.
|
* Sprite sheet for all GUI texutres in the mod.
|
||||||
*/
|
*/
|
||||||
public final class GuiSprites extends TextureAtlasHolder {
|
public final class GuiSprites extends TextureAtlasHolder {
|
||||||
public static final ResourceLocation SPRITE_SHEET = new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui");
|
public static final ResourceLocation SPRITE_SHEET = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui");
|
||||||
public static final ResourceLocation TEXTURE = SPRITE_SHEET.withPath(x -> "textures/atlas/" + x + ".png");
|
public static final ResourceLocation TEXTURE = SPRITE_SHEET.withPath(x -> "textures/atlas/" + x + ".png");
|
||||||
|
|
||||||
public static final ButtonTextures TURNED_OFF = button("turned_off");
|
public static final ButtonTextures TURNED_OFF = button("turned_off");
|
||||||
@ -35,16 +35,16 @@ public final class GuiSprites extends TextureAtlasHolder {
|
|||||||
|
|
||||||
private static ButtonTextures button(String name) {
|
private static ButtonTextures button(String name) {
|
||||||
return new ButtonTextures(
|
return new ButtonTextures(
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name),
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name),
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name + "_hover")
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name + "_hover")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ComputerTextures computer(String name, boolean pocket, boolean sidebar) {
|
private static ComputerTextures computer(String name, boolean pocket, boolean sidebar) {
|
||||||
return new ComputerTextures(
|
return new ComputerTextures(
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/border_" + name),
|
ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/border_" + name),
|
||||||
pocket ? new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/pocket_bottom_" + name) : null,
|
pocket ? ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/pocket_bottom_" + name) : null,
|
||||||
sidebar ? new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/sidebar_" + name) : null
|
sidebar ? ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/sidebar_" + name) : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
* A {@link Toast} implementation which displays an arbitrary message along with an optional {@link ItemStack}.
|
* A {@link Toast} implementation which displays an arbitrary message along with an optional {@link ItemStack}.
|
||||||
*/
|
*/
|
||||||
public class ItemToast implements Toast {
|
public class ItemToast implements Toast {
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation("toast/recipe");
|
private static final ResourceLocation TEXTURE = ResourceLocation.withDefaultNamespace("toast/recipe");
|
||||||
public static final Object TRANSFER_NO_RESPONSE_TOKEN = new Object();
|
public static final Object TRANSFER_NO_RESPONSE_TOKEN = new Object();
|
||||||
|
|
||||||
private static final long DISPLAY_TIME = 7000L;
|
private static final long DISPLAY_TIME = 7000L;
|
||||||
|
@ -24,7 +24,7 @@ import static dan200.computercraft.core.util.Nullability.assertNonNull;
|
|||||||
* When closed, it returns to the previous screen.
|
* When closed, it returns to the previous screen.
|
||||||
*/
|
*/
|
||||||
public final class OptionScreen extends Screen {
|
public final class OptionScreen extends Screen {
|
||||||
private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/blank_screen.png");
|
private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/blank_screen.png");
|
||||||
|
|
||||||
public static final int BUTTON_WIDTH = 100;
|
public static final int BUTTON_WIDTH = 100;
|
||||||
public static final int BUTTON_HEIGHT = 20;
|
public static final int BUTTON_HEIGHT = 20;
|
||||||
|
@ -15,7 +15,7 @@ import net.minecraft.world.entity.player.Inventory;
|
|||||||
* The GUI for printers.
|
* The GUI for printers.
|
||||||
*/
|
*/
|
||||||
public class PrinterScreen extends AbstractContainerScreen<PrinterMenu> {
|
public class PrinterScreen extends AbstractContainerScreen<PrinterMenu> {
|
||||||
private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/printer.png");
|
private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/printer.png");
|
||||||
|
|
||||||
public PrinterScreen(PrinterMenu container, Inventory player, Component title) {
|
public PrinterScreen(PrinterMenu container, Inventory player, Component title) {
|
||||||
super(container, player, title);
|
super(container, player, title);
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client.gui;
|
package dan200.computercraft.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
|
||||||
import dan200.computercraft.core.terminal.TextBuffer;
|
import dan200.computercraft.core.terminal.TextBuffer;
|
||||||
import dan200.computercraft.shared.ModRegistry;
|
import dan200.computercraft.shared.ModRegistry;
|
||||||
import dan200.computercraft.shared.common.HeldItemMenu;
|
import dan200.computercraft.shared.common.HeldItemMenu;
|
||||||
@ -12,7 +11,6 @@ import dan200.computercraft.shared.media.items.PrintoutData;
|
|||||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
@ -90,10 +88,8 @@ public class PrintoutScreen extends AbstractContainerScreen<HeldItemMenu> {
|
|||||||
graphics.pose().pushPose();
|
graphics.pose().pushPose();
|
||||||
graphics.pose().translate(0, 0, 1);
|
graphics.pose().translate(0, 0, 1);
|
||||||
|
|
||||||
var renderer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
drawBorder(graphics.pose(), graphics.bufferSource(), leftPos, topPos, 0, page, pages, book, FULL_BRIGHT_LIGHTMAP);
|
||||||
drawBorder(graphics.pose(), renderer, leftPos, topPos, 0, page, pages, book, FULL_BRIGHT_LIGHTMAP);
|
drawText(graphics.pose(), graphics.bufferSource(), leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, PrintoutData.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
|
||||||
drawText(graphics.pose(), renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, PrintoutData.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
|
|
||||||
renderer.endBatch();
|
|
||||||
|
|
||||||
graphics.pose().popPose();
|
graphics.pose().popPose();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import static dan200.computercraft.shared.turtle.inventory.TurtleMenu.*;
|
|||||||
* The GUI for turtles.
|
* The GUI for turtles.
|
||||||
*/
|
*/
|
||||||
public class TurtleScreen extends AbstractComputerScreen<TurtleMenu> {
|
public class TurtleScreen extends AbstractComputerScreen<TurtleMenu> {
|
||||||
private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_normal.png");
|
private static final ResourceLocation BACKGROUND_NORMAL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_normal.png");
|
||||||
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_advanced.png");
|
private static final ResourceLocation BACKGROUND_ADVANCED = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_advanced.png");
|
||||||
|
|
||||||
private static final int TEX_WIDTH = 278;
|
private static final int TEX_WIDTH = 278;
|
||||||
private static final int TEX_HEIGHT = 217;
|
private static final int TEX_HEIGHT = 217;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client.gui.widgets;
|
package dan200.computercraft.client.gui.widgets;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
|
||||||
import dan200.computercraft.client.render.RenderTypes;
|
import dan200.computercraft.client.render.RenderTypes;
|
||||||
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
@ -16,7 +15,6 @@ import net.minecraft.client.gui.components.AbstractWidget;
|
|||||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
@ -259,15 +257,12 @@ public class TerminalWidget extends AbstractWidget {
|
|||||||
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (!visible) return;
|
if (!visible) return;
|
||||||
|
|
||||||
var bufferSource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
var emitter = FixedWidthFontRenderer.toVertexConsumer(graphics.pose(), graphics.bufferSource().getBuffer(RenderTypes.TERMINAL));
|
||||||
var emitter = FixedWidthFontRenderer.toVertexConsumer(graphics.pose(), bufferSource.getBuffer(RenderTypes.TERMINAL));
|
|
||||||
|
|
||||||
FixedWidthFontRenderer.drawTerminal(
|
FixedWidthFontRenderer.drawTerminal(
|
||||||
emitter,
|
emitter,
|
||||||
(float) innerX, (float) innerY, terminal, (float) MARGIN, (float) MARGIN, (float) MARGIN, (float) MARGIN
|
(float) innerX, (float) innerY, terminal, (float) MARGIN, (float) MARGIN, (float) MARGIN, (float) MARGIN
|
||||||
);
|
);
|
||||||
|
|
||||||
bufferSource.endBatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client.model.turtle;
|
package dan200.computercraft.client.model.turtle;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
|
||||||
import com.mojang.math.Transformation;
|
import com.mojang.math.Transformation;
|
||||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||||
|
import net.minecraft.client.renderer.block.model.FaceBakery;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
@ -29,8 +27,8 @@ import java.util.List;
|
|||||||
public class ModelTransformer {
|
public class ModelTransformer {
|
||||||
private static final int[] INVERSE_ORDER = new int[]{ 3, 2, 1, 0 };
|
private static final int[] INVERSE_ORDER = new int[]{ 3, 2, 1, 0 };
|
||||||
|
|
||||||
private static final int STRIDE = DefaultVertexFormat.BLOCK.getIntegerSize();
|
private static final int STRIDE = FaceBakery.VERTEX_INT_SIZE;
|
||||||
private static final int POS_OFFSET = findOffset(DefaultVertexFormat.BLOCK, DefaultVertexFormat.ELEMENT_POSITION);
|
private static final int POS_OFFSET = 0;
|
||||||
|
|
||||||
protected final Matrix4f transformation;
|
protected final Matrix4f transformation;
|
||||||
protected final boolean invert;
|
protected final boolean invert;
|
||||||
@ -91,13 +89,4 @@ public class ModelTransformer {
|
|||||||
|
|
||||||
private record TransformedQuads(List<BakedQuad> original, List<BakedQuad> transformed) {
|
private record TransformedQuads(List<BakedQuad> original, List<BakedQuad> transformed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int findOffset(VertexFormat format, VertexFormatElement element) {
|
|
||||||
var offset = 0;
|
|
||||||
for (var other : format.getElements()) {
|
|
||||||
if (other == element) return offset / Integer.BYTES;
|
|
||||||
offset += element.getByteSize();
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Cannot find " + element + " in " + format);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public final class TurtleModelParts<T> {
|
|||||||
public TurtleModelParts(BakedModel familyModel, BakedModel colourModel, ModelTransformer transformer, Function<List<BakedModel>, T> combineModel) {
|
public TurtleModelParts(BakedModel familyModel, BakedModel colourModel, ModelTransformer transformer, Function<List<BakedModel>, T> combineModel) {
|
||||||
this.familyModel = familyModel;
|
this.familyModel = familyModel;
|
||||||
this.colourModel = colourModel;
|
this.colourModel = colourModel;
|
||||||
this.transformer = x -> transformer.transform(x.getModel(), x.getMatrix());
|
this.transformer = x -> transformer.transform(x.model(), x.matrix());
|
||||||
buildModel = x -> combineModel.apply(buildModel(x));
|
buildModel = x -> combineModel.apply(buildModel(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public final class TurtleModelParts<T> {
|
|||||||
private void addUpgrade(List<BakedModel> parts, Transformation transformation, TurtleSide side, @Nullable UpgradeData<ITurtleUpgrade> upgrade) {
|
private void addUpgrade(List<BakedModel> parts, Transformation transformation, TurtleSide side, @Nullable UpgradeData<ITurtleUpgrade> upgrade) {
|
||||||
if (upgrade == null) return;
|
if (upgrade == null) return;
|
||||||
var model = TurtleUpgradeModellers.getModel(upgrade.upgrade(), upgrade.data(), side);
|
var model = TurtleUpgradeModellers.getModel(upgrade.upgrade(), upgrade.data(), side);
|
||||||
parts.add(transform(model.getModel(), transformation.compose(model.getMatrix())));
|
parts.add(transform(model.model(), transformation.compose(model.matrix())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BakedModel transform(BakedModel model, Transformation transformation) {
|
private BakedModel transform(BakedModel model, Transformation transformation) {
|
||||||
|
@ -21,10 +21,11 @@ import dan200.computercraft.shared.peripheral.speaker.EncodedAudio;
|
|||||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
|
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.JukeboxSong;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -60,10 +61,12 @@ public final class ClientNetworkContextImpl implements ClientNetworkContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayRecord(BlockPos pos, @Nullable SoundEvent sound, @Nullable String name) {
|
public void handlePlayRecord(BlockPos pos, @Nullable Holder<JukeboxSong> song) {
|
||||||
var mc = Minecraft.getInstance();
|
if (song == null) {
|
||||||
ClientPlatformHelper.get().playStreamingMusic(pos, sound);
|
Minecraft.getInstance().levelRenderer.stopJukeboxSongAndNotifyNearby(pos);
|
||||||
if (name != null) mc.gui.setNowPlaying(Component.literal(name));
|
} else {
|
||||||
|
Minecraft.getInstance().levelRenderer.playJukeboxSong(song, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,8 +7,6 @@ package dan200.computercraft.client.platform;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -28,13 +26,4 @@ public interface ClientPlatformHelper extends dan200.computercraft.impl.client.C
|
|||||||
* @param tints Block colour tints to apply to the model.
|
* @param tints Block colour tints to apply to the model.
|
||||||
*/
|
*/
|
||||||
void renderBakedModel(PoseStack transform, MultiBufferSource buffers, BakedModel model, int lightmapCoord, int overlayLight, @Nullable int[] tints);
|
void renderBakedModel(PoseStack transform, MultiBufferSource buffers, BakedModel model, int lightmapCoord, int overlayLight, @Nullable int[] tints);
|
||||||
|
|
||||||
/**
|
|
||||||
* Play a record at a particular position.
|
|
||||||
*
|
|
||||||
* @param pos The position to play this record.
|
|
||||||
* @param sound The record to play, or {@code null} to stop it.
|
|
||||||
* @see net.minecraft.client.renderer.LevelRenderer#playStreamingMusic(SoundEvent, BlockPos)
|
|
||||||
*/
|
|
||||||
void playStreamingMusic(BlockPos pos, @Nullable SoundEvent sound);
|
|
||||||
}
|
}
|
||||||
|
@ -62,15 +62,13 @@ public final class CableHighlightRenderer {
|
|||||||
zDelta = zDelta / len;
|
zDelta = zDelta / len;
|
||||||
|
|
||||||
buffer
|
buffer
|
||||||
.vertex(matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset))
|
.addVertex(matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset))
|
||||||
.color(0, 0, 0, 0.4f)
|
.setColor(0, 0, 0, 0.4f)
|
||||||
.normal(transform.last(), xDelta, yDelta, zDelta)
|
.setNormal(transform.last(), xDelta, yDelta, zDelta);
|
||||||
.endVertex();
|
|
||||||
buffer
|
buffer
|
||||||
.vertex(matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset))
|
.addVertex(matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset))
|
||||||
.color(0, 0, 0, 0.4f)
|
.setColor(0, 0, 0, 0.4f)
|
||||||
.normal(transform.last(), xDelta, yDelta, zDelta)
|
.setNormal(transform.last(), xDelta, yDelta, zDelta);
|
||||||
.endVertex();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -50,28 +50,23 @@ public final class ModelRenderer {
|
|||||||
if (idx >= 0 && idx < tints.length) tint = tints[bakedquad.getTintIndex()];
|
if (idx >= 0 && idx < tints.length) tint = tints[bakedquad.getTintIndex()];
|
||||||
}
|
}
|
||||||
|
|
||||||
var r = (float) (tint >> 16 & 255) / 255.0F;
|
putBulkQuad(buffer, matrix, bakedquad, tint, lightmapCoord, overlayLight, inverted);
|
||||||
var g = (float) (tint >> 8 & 255) / 255.0F;
|
|
||||||
var b = (float) (tint & 255) / 255.0F;
|
|
||||||
putBulkQuad(buffer, matrix, bakedquad, r, g, b, lightmapCoord, overlayLight, inverted);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A version of {@link VertexConsumer#putBulkData(PoseStack.Pose, BakedQuad, float, float, float, int, int)} which
|
* A version of {@link VertexConsumer#putBulkData(PoseStack.Pose, BakedQuad, float, float, float, float, int, int)} which
|
||||||
* will reverse vertex order when the matrix is inverted.
|
* will reverse vertex order when the matrix is inverted.
|
||||||
*
|
*
|
||||||
* @param buffer The buffer to draw to.
|
* @param buffer The buffer to draw to.
|
||||||
* @param pose The current matrix stack.
|
* @param pose The current matrix stack.
|
||||||
* @param quad The quad to draw.
|
* @param quad The quad to draw.
|
||||||
* @param red The red tint of this quad.
|
* @param colour The tint for this quad.
|
||||||
* @param green The green tint of this quad.
|
|
||||||
* @param blue The blue tint of this quad.
|
|
||||||
* @param lightmapCoord The lightmap coordinate
|
* @param lightmapCoord The lightmap coordinate
|
||||||
* @param overlayLight The overlay light.
|
* @param overlayLight The overlay light.
|
||||||
* @param invert Whether to reverse the order of this quad.
|
* @param invert Whether to reverse the order of this quad.
|
||||||
*/
|
*/
|
||||||
private static void putBulkQuad(VertexConsumer buffer, PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, int lightmapCoord, int overlayLight, boolean invert) {
|
private static void putBulkQuad(VertexConsumer buffer, PoseStack.Pose pose, BakedQuad quad, int colour, int lightmapCoord, int overlayLight, boolean invert) {
|
||||||
var matrix = pose.pose();
|
var matrix = pose.pose();
|
||||||
// It's a little dubious to transform using this matrix rather than the normal matrix. This mirrors the logic in
|
// It's a little dubious to transform using this matrix rather than the normal matrix. This mirrors the logic in
|
||||||
// Direction.rotate (so not out of nowhere!), but is a little suspicious.
|
// Direction.rotate (so not out of nowhere!), but is a little suspicious.
|
||||||
@ -93,9 +88,9 @@ public final class ModelRenderer {
|
|||||||
|
|
||||||
var u = Float.intBitsToFloat(vertices[i + 4]);
|
var u = Float.intBitsToFloat(vertices[i + 4]);
|
||||||
var v = Float.intBitsToFloat(vertices[i + 5]);
|
var v = Float.intBitsToFloat(vertices[i + 5]);
|
||||||
buffer.vertex(
|
buffer.addVertex(
|
||||||
vector.x(), vector.y(), vector.z(),
|
vector.x(), vector.y(), vector.z(),
|
||||||
red, green, blue, 1.0F, u, v, overlayLight, lightmapCoord,
|
colour, u, v, overlayLight, lightmapCoord,
|
||||||
normalX, normalY, normalZ
|
normalX, normalY, normalZ
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public final class PrintoutRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void vertex(VertexConsumer buffer, Matrix4f matrix, float x, float y, float z, float u, float v, int light) {
|
private static void vertex(VertexConsumer buffer, Matrix4f matrix, float x, float y, float z, float u, float v, int light) {
|
||||||
buffer.vertex(matrix, x, y, z).color(255, 255, 255, 255).uv(u, v).uv2(light).endVertex();
|
buffer.addVertex(matrix, x, y, z).setColor(255, 255, 255, 255).setUv(u, v).setLight(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float offsetAt(int page) {
|
public static float offsetAt(int page) {
|
||||||
|
@ -52,7 +52,7 @@ public class RenderTypes {
|
|||||||
* Printout's background texture. {@link RenderType#text(ResourceLocation)} is a <em>little</em> questionable, but
|
* Printout's background texture. {@link RenderType#text(ResourceLocation)} is a <em>little</em> questionable, but
|
||||||
* it is what maps use, so should behave the same as vanilla in both item frames and in-hand.
|
* it is what maps use, so should behave the same as vanilla in both item frames and in-hand.
|
||||||
*/
|
*/
|
||||||
public static final RenderType PRINTOUT_BACKGROUND = RenderType.text(new ResourceLocation("computercraft", "textures/gui/printout.png"));
|
public static final RenderType PRINTOUT_BACKGROUND = RenderType.text(ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/printout.png"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render type for {@linkplain GuiSprites GUI sprites}.
|
* Render type for {@linkplain GuiSprites GUI sprites}.
|
||||||
|
@ -118,10 +118,10 @@ public class SpriteRenderer {
|
|||||||
*/
|
*/
|
||||||
public void blit(
|
public void blit(
|
||||||
int x, int y, int width, int height, float u0, float v0, float u1, float v1) {
|
int x, int y, int width, int height, float u0, float v0, float u1, float v1) {
|
||||||
builder.vertex(transform, x, y + height, z).color(r, g, b, 255).uv(u0, v1).uv2(light).endVertex();
|
builder.addVertex(transform, x, y + height, z).setColor(r, g, b, 255).setUv(u0, v1).setLight(light);
|
||||||
builder.vertex(transform, x + width, y + height, z).color(r, g, b, 255).uv(u1, v1).uv2(light).endVertex();
|
builder.addVertex(transform, x + width, y + height, z).setColor(r, g, b, 255).setUv(u1, v1).setLight(light);
|
||||||
builder.vertex(transform, x + width, y, z).color(r, g, b, 255).uv(u1, v0).uv2(light).endVertex();
|
builder.addVertex(transform, x + width, y, z).setColor(r, g, b, 255).setUv(u1, v0).setLight(light);
|
||||||
builder.vertex(transform, x, y, z).color(r, g, b, 255).uv(u0, v0).uv2(light).endVertex();
|
builder.addVertex(transform, x, y, z).setColor(r, g, b, 255).setUv(u0, v0).setLight(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float u(TextureAtlasSprite sprite, int x, int width) {
|
public static float u(TextureAtlasSprite sprite, int x, int width) {
|
||||||
|
@ -27,8 +27,8 @@ import net.minecraft.world.phys.HitResult;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBlockEntity> {
|
public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBlockEntity> {
|
||||||
private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
|
private static final ResourceLocation COLOUR_TURTLE_MODEL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
|
||||||
private static final ResourceLocation ELF_OVERLAY_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");
|
private static final ResourceLocation ELF_OVERLAY_MODEL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");
|
||||||
|
|
||||||
private final BlockEntityRenderDispatcher renderer;
|
private final BlockEntityRenderDispatcher renderer;
|
||||||
private final Font font;
|
private final Font font;
|
||||||
@ -121,8 +121,8 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
|
|||||||
transform.translate(0.0f, -0.5f, -0.5f);
|
transform.translate(0.0f, -0.5f, -0.5f);
|
||||||
|
|
||||||
var model = TurtleUpgradeModellers.getModel(upgrade, turtle.getAccess(), side);
|
var model = TurtleUpgradeModellers.getModel(upgrade, turtle.getAccess(), side);
|
||||||
applyTransformation(transform, model.getMatrix());
|
applyTransformation(transform, model.matrix());
|
||||||
renderModel(transform, buffers, lightmapCoord, overlayLight, model.getModel(), null);
|
renderModel(transform, buffers, lightmapCoord, overlayLight, model.model(), null);
|
||||||
|
|
||||||
transform.popPose();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
package dan200.computercraft.client.render.monitor;
|
package dan200.computercraft.client.render.monitor;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.platform.MemoryTracker;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.*;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import dan200.computercraft.annotations.ForgeOverride;
|
import dan200.computercraft.annotations.ForgeOverride;
|
||||||
import dan200.computercraft.client.FrameInfo;
|
import dan200.computercraft.client.FrameInfo;
|
||||||
@ -18,6 +20,7 @@ import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
|||||||
import dan200.computercraft.client.render.vbo.DirectBuffers;
|
import dan200.computercraft.client.render.vbo.DirectBuffers;
|
||||||
import dan200.computercraft.client.render.vbo.DirectVertexBuffer;
|
import dan200.computercraft.client.render.vbo.DirectVertexBuffer;
|
||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
|
import dan200.computercraft.core.util.Nullability;
|
||||||
import dan200.computercraft.shared.config.Config;
|
import dan200.computercraft.shared.config.Config;
|
||||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||||
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
import dan200.computercraft.shared.peripheral.monitor.MonitorBlockEntity;
|
||||||
@ -31,6 +34,7 @@ import org.joml.Matrix4f;
|
|||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL20;
|
import org.lwjgl.opengl.GL20;
|
||||||
import org.lwjgl.opengl.GL31;
|
import org.lwjgl.opengl.GL31;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -160,13 +164,12 @@ public class MonitorBlockEntityRenderer implements BlockEntityRenderer<MonitorBl
|
|||||||
var shader = RenderTypes.getMonitorTextureBufferShader();
|
var shader = RenderTypes.getMonitorTextureBufferShader();
|
||||||
shader.setupUniform(renderState.tboUniform);
|
shader.setupUniform(renderState.tboUniform);
|
||||||
|
|
||||||
var buffer = Tesselator.getInstance().getBuilder();
|
var buffer = Tesselator.getInstance().begin(RenderTypes.MONITOR_TBO.mode(), RenderTypes.MONITOR_TBO.format());
|
||||||
buffer.begin(RenderTypes.MONITOR_TBO.mode(), RenderTypes.MONITOR_TBO.format());
|
|
||||||
tboVertex(buffer, matrix, -xMargin, -yMargin);
|
tboVertex(buffer, matrix, -xMargin, -yMargin);
|
||||||
tboVertex(buffer, matrix, -xMargin, pixelHeight + yMargin);
|
tboVertex(buffer, matrix, -xMargin, pixelHeight + yMargin);
|
||||||
tboVertex(buffer, matrix, pixelWidth + xMargin, -yMargin);
|
tboVertex(buffer, matrix, pixelWidth + xMargin, -yMargin);
|
||||||
tboVertex(buffer, matrix, pixelWidth + xMargin, pixelHeight + yMargin);
|
tboVertex(buffer, matrix, pixelWidth + xMargin, pixelHeight + yMargin);
|
||||||
RenderTypes.MONITOR_TBO.end(buffer, VertexSorting.DISTANCE_TO_ORIGIN);
|
RenderTypes.MONITOR_TBO.draw(Nullability.assertNonNull(buffer.build()));
|
||||||
}
|
}
|
||||||
case VBO -> {
|
case VBO -> {
|
||||||
var backgroundBuffer = assertNonNull(renderState.backgroundBuffer);
|
var backgroundBuffer = assertNonNull(renderState.backgroundBuffer);
|
||||||
@ -242,13 +245,13 @@ public class MonitorBlockEntityRenderer implements BlockEntityRenderer<MonitorBl
|
|||||||
|
|
||||||
private static void tboVertex(VertexConsumer builder, Matrix4f matrix, float x, float y) {
|
private static void tboVertex(VertexConsumer builder, Matrix4f matrix, float x, float y) {
|
||||||
// We encode position in the UV, as that's not transformed by the matrix.
|
// We encode position in the UV, as that's not transformed by the matrix.
|
||||||
builder.vertex(matrix, x, y, 0).uv(x, y).endVertex();
|
builder.addVertex(matrix, x, y, 0).setUv(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ByteBuffer getBuffer(int capacity) {
|
private static ByteBuffer getBuffer(int capacity) {
|
||||||
var buffer = backingBuffer;
|
var buffer = backingBuffer;
|
||||||
if (buffer == null || buffer.capacity() < capacity) {
|
if (buffer == null || buffer.capacity() < capacity) {
|
||||||
buffer = backingBuffer = buffer == null ? MemoryTracker.create(capacity) : MemoryTracker.resize(buffer, capacity);
|
buffer = backingBuffer = buffer == null ? MemoryUtil.memAlloc(capacity) : MemoryUtil.memRealloc(buffer, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
|
@ -72,18 +72,16 @@ public final class MonitorHighlightRenderer {
|
|||||||
|
|
||||||
private static void line(VertexConsumer buffer, Matrix4f transform, PoseStack.Pose normal, float x, float y, float z, Direction direction) {
|
private static void line(VertexConsumer buffer, Matrix4f transform, PoseStack.Pose normal, float x, float y, float z, Direction direction) {
|
||||||
buffer
|
buffer
|
||||||
.vertex(transform, x, y, z)
|
.addVertex(transform, x, y, z)
|
||||||
.color(0, 0, 0, 0.4f)
|
.setColor(0, 0, 0, 0.4f)
|
||||||
.normal(normal, direction.getStepX(), direction.getStepY(), direction.getStepZ())
|
.setNormal(normal, direction.getStepX(), direction.getStepY(), direction.getStepZ());
|
||||||
.endVertex();
|
|
||||||
buffer
|
buffer
|
||||||
.vertex(transform,
|
.addVertex(transform,
|
||||||
x + direction.getStepX(),
|
x + direction.getStepX(),
|
||||||
y + direction.getStepY(),
|
y + direction.getStepY(),
|
||||||
z + direction.getStepZ()
|
z + direction.getStepZ()
|
||||||
)
|
)
|
||||||
.color(0, 0, 0, 0.4f)
|
.setColor(0, 0, 0, 0.4f)
|
||||||
.normal(normal, direction.getStepX(), direction.getStepY(), direction.getStepZ())
|
.setNormal(normal, direction.getStepX(), direction.getStepY(), direction.getStepZ());
|
||||||
.endVertex();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client.render.text;
|
package dan200.computercraft.client.render.text;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.MemoryTracker;
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
@ -28,7 +27,7 @@ import static org.lwjgl.system.MemoryUtil.*;
|
|||||||
* <ul>
|
* <ul>
|
||||||
* <li>No transformation matrix (not needed for VBOs).</li>
|
* <li>No transformation matrix (not needed for VBOs).</li>
|
||||||
* <li>Only works with {@link DefaultVertexFormat#POSITION_COLOR_TEX_LIGHTMAP}.</li>
|
* <li>Only works with {@link DefaultVertexFormat#POSITION_COLOR_TEX_LIGHTMAP}.</li>
|
||||||
* <li>The buffer <strong>MUST</strong> be allocated with {@link MemoryTracker}, and not through any other means.</li>
|
* <li>The buffer <strong>MUST</strong> be allocated with {@link MemoryUtil}, and not through any other means.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Note this is almost an exact copy of {@link FixedWidthFontRenderer}. While the code duplication is unfortunate,
|
* Note this is almost an exact copy of {@link FixedWidthFontRenderer}. While the code duplication is unfortunate,
|
||||||
|
@ -32,7 +32,7 @@ import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMA
|
|||||||
* {@link DirectFixedWidthFontRenderer}.
|
* {@link DirectFixedWidthFontRenderer}.
|
||||||
*/
|
*/
|
||||||
public final class FixedWidthFontRenderer {
|
public final class FixedWidthFontRenderer {
|
||||||
public static final ResourceLocation FONT = new ResourceLocation("computercraft", "textures/gui/term_font.png");
|
public static final ResourceLocation FONT = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/term_font.png");
|
||||||
|
|
||||||
public static final int FONT_HEIGHT = 9;
|
public static final int FONT_HEIGHT = 9;
|
||||||
public static final int FONT_WIDTH = 6;
|
public static final int FONT_WIDTH = 6;
|
||||||
@ -221,9 +221,9 @@ public final class FixedWidthFontRenderer {
|
|||||||
var consumer = c.consumer();
|
var consumer = c.consumer();
|
||||||
byte r = rgba[0], g = rgba[1], b = rgba[2], a = rgba[3];
|
byte r = rgba[0], g = rgba[1], b = rgba[2], a = rgba[3];
|
||||||
|
|
||||||
consumer.vertex(poseMatrix, x1, y1, z).color(r, g, b, a).uv(u1, v1).uv2(light).endVertex();
|
consumer.addVertex(poseMatrix, x1, y1, z).setColor(r, g, b, a).setUv(u1, v1).setLight(light);
|
||||||
consumer.vertex(poseMatrix, x1, y2, z).color(r, g, b, a).uv(u1, v2).uv2(light).endVertex();
|
consumer.addVertex(poseMatrix, x1, y2, z).setColor(r, g, b, a).setUv(u1, v2).setLight(light);
|
||||||
consumer.vertex(poseMatrix, x2, y2, z).color(r, g, b, a).uv(u2, v2).uv2(light).endVertex();
|
consumer.addVertex(poseMatrix, x2, y2, z).setColor(r, g, b, a).setUv(u2, v2).setLight(light);
|
||||||
consumer.vertex(poseMatrix, x2, y1, z).color(r, g, b, a).uv(u2, v1).uv2(light).endVertex();
|
consumer.addVertex(poseMatrix, x2, y1, z).setColor(r, g, b, a).setUv(u2, v1).setLight(light);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import javax.annotation.Nullable;
|
|||||||
* An instance of a speaker, which is either playing a {@link DfpwmStream} stream or a normal sound.
|
* An instance of a speaker, which is either playing a {@link DfpwmStream} stream or a normal sound.
|
||||||
*/
|
*/
|
||||||
public class SpeakerInstance {
|
public class SpeakerInstance {
|
||||||
public static final ResourceLocation DFPWM_STREAM = new ResourceLocation(ComputerCraftAPI.MOD_ID, "speaker.dfpwm_fake_audio_should_not_be_played");
|
public static final ResourceLocation DFPWM_STREAM = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "speaker.dfpwm_fake_audio_should_not_be_played");
|
||||||
|
|
||||||
private @Nullable DfpwmStream currentStream;
|
private @Nullable DfpwmStream currentStream;
|
||||||
private @Nullable SpeakerSound sound;
|
private @Nullable SpeakerSound sound;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package dan200.computercraft.client.turtle;
|
package dan200.computercraft.client.turtle;
|
||||||
|
|
||||||
import dan200.computercraft.api.ComputerCraftAPI;
|
import dan200.computercraft.api.ComputerCraftAPI;
|
||||||
|
import dan200.computercraft.api.client.ModelLocation;
|
||||||
import dan200.computercraft.api.client.TransformedModel;
|
import dan200.computercraft.api.client.TransformedModel;
|
||||||
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
||||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||||
@ -38,23 +39,23 @@ public class TurtleModemModeller implements TurtleUpgradeModeller<TurtleModem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private record ModemModels(
|
private record ModemModels(
|
||||||
ResourceLocation leftOffModel, ResourceLocation rightOffModel,
|
ModelLocation leftOffModel, ModelLocation rightOffModel,
|
||||||
ResourceLocation leftOnModel, ResourceLocation rightOnModel
|
ModelLocation leftOnModel, ModelLocation rightOnModel
|
||||||
) {
|
) {
|
||||||
private static final ModemModels NORMAL = create("normal");
|
private static final ModemModels NORMAL = create("normal");
|
||||||
private static final ModemModels ADVANCED = create("advanced");
|
private static final ModemModels ADVANCED = create("advanced");
|
||||||
|
|
||||||
public static ModemModels create(String type) {
|
public static ModemModels create(String type) {
|
||||||
return new ModemModels(
|
return new ModemModels(
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_left"),
|
ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_left")),
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_right"),
|
ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_right")),
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_left"),
|
ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_left")),
|
||||||
new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_right")
|
ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_right"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<ResourceLocation> getDependencies() {
|
public Stream<ResourceLocation> getDependencies() {
|
||||||
return Stream.of(leftOffModel, rightOffModel, leftOnModel, rightOnModel);
|
return Stream.of(leftOffModel, rightOffModel, leftOnModel, rightOnModel).flatMap(ModelLocation::getDependencies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public final class ClientDataProviders {
|
|||||||
|
|
||||||
public static void add(DataProviders.GeneratorSink generator) {
|
public static void add(DataProviders.GeneratorSink generator) {
|
||||||
generator.addFromCodec("Block atlases", PackType.CLIENT_RESOURCES, "atlases", SpriteSources.FILE_CODEC, out -> {
|
generator.addFromCodec("Block atlases", PackType.CLIENT_RESOURCES, "atlases", SpriteSources.FILE_CODEC, out -> {
|
||||||
out.accept(new ResourceLocation("blocks"), List.of(
|
out.accept(ResourceLocation.withDefaultNamespace("blocks"), List.of(
|
||||||
new SingleFile(UpgradeSlot.LEFT_UPGRADE, Optional.empty()),
|
new SingleFile(UpgradeSlot.LEFT_UPGRADE, Optional.empty()),
|
||||||
new SingleFile(UpgradeSlot.RIGHT_UPGRADE, Optional.empty())
|
new SingleFile(UpgradeSlot.RIGHT_UPGRADE, Optional.empty())
|
||||||
));
|
));
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user