Skip to content

Commit

Permalink
Update to MC 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 12, 2024
1 parent 3613d2a commit 6e26ff0
Show file tree
Hide file tree
Showing 65 changed files with 385 additions and 280 deletions.
25 changes: 19 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'net.neoforged.gradle.userdev' version '7.0.97'
id 'net.neoforged.gradle.userdev' version '7.0.145'
id 'net.darkhax.curseforgegradle' version '1.0.8'
id 'com.github.kt3k.coveralls' version '2.12.0'
id 'com.diffplug.spotless' version '5.14.3'
Expand Down Expand Up @@ -34,7 +34,7 @@ base {
}

// Set Java details
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
compileJava.options.compilerArgs << "-Xmaxerrs" << "9999"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

Expand Down Expand Up @@ -117,13 +117,14 @@ dependencies {


// Project lombok
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'

testImplementation "junit:junit:4.12"
testImplementation "org.mockito:mockito-core:1.+"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.8.2"
}

runs {
Expand Down Expand Up @@ -322,6 +323,8 @@ publishing {

idea {
module {
downloadSources = true
downloadJavadoc = true
for (String excludeDirName in ["run", "out", "logs", "gradle"]) {
File excludeDir = new File(projectDir, excludeDirName)
excludeDirs.add(excludeDir)
Expand Down Expand Up @@ -356,3 +359,13 @@ compileJava.dependsOn updateGitHooks
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}

// The following is required to fix running unit tests during build phase
tasks.configureEach { task ->
if (task.name.startsWith("test")) {
task.enabled = true
}
if (task.name.startsWith("testJunit")) {
task.enabled = false
}
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod_id=integratedscripting
mod_version=1.0.3
minecraft_version=1.20.4
neoforge_version=20.4.160-beta
cyclopscore_version=1.19.0-429
integrateddynamics_version=1.21.2-748
minecraft_version=1.21
neoforge_version=21.0.43-beta
cyclopscore_version=1.19.1-462
integrateddynamics_version=1.21.4-774
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

commoncapabilities_version=2.9.1-116
commoncapabilities_version=2.9.1-126

# Workaround for Spotless bug
# https://github.com/diffplug/spotless/issues/834
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
*/
public class Capabilities {
public static final class ScriptingNetwork {
public static final NetworkCapability<IScriptingNetwork> NETWORK = NetworkCapability.create(new ResourceLocation(Reference.MOD_ID, "scripting_network"), IScriptingNetwork.class);
public static final NetworkCapability<IScriptingNetwork> NETWORK = NetworkCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "scripting_network"), IScriptingNetwork.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.cyclops.integratedscripting;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
Expand All @@ -12,9 +14,9 @@
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
import net.neoforged.neoforge.registries.NewRegistryEvent;
import org.apache.logging.log4j.Level;
import org.cyclops.cyclopscore.config.ConfigHandler;
Expand All @@ -33,6 +35,7 @@
import org.cyclops.integratedscripting.blockentity.BlockEntityScriptingDriveConfig;
import org.cyclops.integratedscripting.capability.ScriptingNetworkCapabilityConstructors;
import org.cyclops.integratedscripting.command.CommandTestScript;
import org.cyclops.integratedscripting.component.DataComponentDiskIdConfig;
import org.cyclops.integratedscripting.core.client.model.ScriptingVariableModelProviders;
import org.cyclops.integratedscripting.core.evaluate.ScriptVariableFacadeHandler;
import org.cyclops.integratedscripting.core.language.LanguageHandlerRegistry;
Expand Down Expand Up @@ -87,8 +90,8 @@ public void onRegistriesCreate(NewRegistryEvent event) {
}

@Override
protected LiteralArgumentBuilder<CommandSourceStack> constructBaseCommand() {
LiteralArgumentBuilder<CommandSourceStack> root = super.constructBaseCommand();
protected LiteralArgumentBuilder<CommandSourceStack> constructBaseCommand(Commands.CommandSelection selection, CommandBuildContext context) {
LiteralArgumentBuilder<CommandSourceStack> root = super.constructBaseCommand(selection, context);

root.then(CommandTestScript.make());

Expand Down Expand Up @@ -117,11 +120,9 @@ protected void onServerStopping(ServerStoppingEvent event) {
}

@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if(event.phase == TickEvent.Phase.START) {
if (this.scriptingData != null) {
this.scriptingData.tick();
}
public void onServerTick(ServerTickEvent.Pre event) {
if (this.scriptingData != null) {
this.scriptingData.tick();
}
}

Expand Down Expand Up @@ -156,6 +157,8 @@ protected void onConfigsRegister(ConfigHandler configHandler) {

configHandler.addConfigurable(new ContainerScriptingDriveConfig());
configHandler.addConfigurable(new ContainerTerminalScriptingConfig());

configHandler.addConfigurable(new DataComponentDiskIdConfig());
}

@OnlyIn(Dist.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cyclops.integratedscripting;

import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.MenuType;
Expand All @@ -16,13 +17,15 @@
* @author rubensworks
*/
public class RegistryEntries {
public static final DeferredHolder<Item, Item> ITEM_SCRIPTING_DISK = DeferredHolder.create(Registries.ITEM, new ResourceLocation("integratedscripting:scripting_disk"));
public static final DeferredHolder<Item, Item> ITEM_SCRIPTING_DISK = DeferredHolder.create(Registries.ITEM, ResourceLocation.parse("integratedscripting:scripting_disk"));

public static final DeferredHolder<Block, Block> BLOCK_SCRIPTING_DRIVE = DeferredHolder.create(Registries.BLOCK, new ResourceLocation("integratedscripting:scripting_drive"));
public static final DeferredHolder<Block, Block> BLOCK_PART_TERMINAL_SCRIPTING = DeferredHolder.create(Registries.BLOCK, new ResourceLocation("integratedscripting:part_terminal_scripting"));
public static final DeferredHolder<Block, Block> BLOCK_SCRIPTING_DRIVE = DeferredHolder.create(Registries.BLOCK, ResourceLocation.parse("integratedscripting:scripting_drive"));
public static final DeferredHolder<Block, Block> BLOCK_PART_TERMINAL_SCRIPTING = DeferredHolder.create(Registries.BLOCK, ResourceLocation.parse("integratedscripting:part_terminal_scripting"));

public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityVariablestore>> BLOCK_ENTITY_SCRIPTING_DRIVE = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, new ResourceLocation("integratedscripting:scripting_drive"));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityVariablestore>> BLOCK_ENTITY_SCRIPTING_DRIVE = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("integratedscripting:scripting_drive"));

public static final DeferredHolder<MenuType<?>, MenuType<ContainerScriptingDrive>> CONTAINER_SCRIPTING_DRIVE = DeferredHolder.create(Registries.MENU, new ResourceLocation("integratedscripting:scripting_drive"));
public static final DeferredHolder<MenuType<?>, MenuType<ContainerTerminalScripting>> CONTAINER_TERMINAL_SCRIPTING = DeferredHolder.create(Registries.MENU, new ResourceLocation("integratedscripting:part_terminal_scripting"));
public static final DeferredHolder<MenuType<?>, MenuType<ContainerScriptingDrive>> CONTAINER_SCRIPTING_DRIVE = DeferredHolder.create(Registries.MENU, ResourceLocation.parse("integratedscripting:scripting_drive"));
public static final DeferredHolder<MenuType<?>, MenuType<ContainerTerminalScripting>> CONTAINER_TERMINAL_SCRIPTING = DeferredHolder.create(Registries.MENU, ResourceLocation.parse("integratedscripting:part_terminal_scripting"));

public static final DeferredHolder<DataComponentType<?>, DataComponentType<Integer>> DATACOMPONENT_DISK_ID = DeferredHolder.create(Registries.DATA_COMPONENT_TYPE, ResourceLocation.parse("integratedscripting:disk_id"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;

Expand All @@ -19,9 +20,9 @@ public interface IValueTranslator<V extends IValue> {

boolean canTranslateNbt();

public Value translateToGraal(Context context, V value, IEvaluationExceptionFactory exceptionFactory) throws EvaluationException;
public Value translateToGraal(Context context, V value, IEvaluationExceptionFactory exceptionFactory, ValueDeseralizationContext valueDeseralizationContext) throws EvaluationException;

public V translateFromGraal(Context context, Value value, IEvaluationExceptionFactory exceptionFactory) throws EvaluationException;
public V translateFromGraal(Context context, Value value, IEvaluationExceptionFactory exceptionFactory, ValueDeseralizationContext valueDeseralizationContext) throws EvaluationException;

public Tag translateToNbt(Context context, V value, IEvaluationExceptionFactory exceptionFactory) throws EvaluationException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;

Expand All @@ -21,12 +22,12 @@ public interface IValueTranslatorRegistry extends IRegistry {
@Nullable
public <V extends IValue> IValueTranslator getValueTypeTranslator(IValueType<V> valueType);

public <V extends IValue> Value translateToGraal(Context context, V value, IEvaluationExceptionFactory exceptionFactory) throws EvaluationException;
public <V extends IValue> Value translateToGraal(Context context, V value, IEvaluationExceptionFactory exceptionFactory, ValueDeseralizationContext valueDeseralizationContext) throws EvaluationException;

@Nullable
public IValueTranslator getScriptValueTranslator(Value scriptValue);

public <V extends IValue> V translateFromGraal(Context context, Value value, IEvaluationExceptionFactory exceptionFactory) throws EvaluationException;
public <V extends IValue> V translateFromGraal(Context context, Value value, IEvaluationExceptionFactory exceptionFactory, ValueDeseralizationContext valueDeseralizationContext) throws EvaluationException;

public <V extends IValue> Tag translateToNbt(Context context, V value, IEvaluationExceptionFactory exceptionFactory) throws EvaluationException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cyclops.integratedscripting.blockentity;

import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
Expand Down Expand Up @@ -78,14 +79,14 @@ public INetworkElement createNetworkElement(Level world, BlockPos blockPos) {
}

@Override
public void read(CompoundTag tag) {
super.read(tag);
public void read(CompoundTag tag, HolderLookup.Provider provider) {
super.read(tag, provider);
this.exposedDiskId = tag.getInt("exposedDiskId");
}

@Override
public void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
public void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.saveAdditional(tag, provider);
tag.putInt("exposedDiskId", this.exposedDiskId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public class WidgetDialog extends AbstractWidget implements GuiEventListener {

private static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MOD_ID, "textures/gui/dialog.png");
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/dialog.png");
public static final int WIDTH = 216;
private static final int HEIGHT = 71;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.StringSplitter;
Expand All @@ -27,6 +28,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.util.StringUtil;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -322,7 +324,7 @@ public boolean charTyped(char typedChar, int keyCode) {
if (super.charTyped(typedChar, keyCode)) {
this.setFocused(true);
return true;
} else if (SharedConstants.isAllowedChatCharacter(typedChar)) {
} else if (StringUtil.isAllowedChatCharacter(typedChar)) {
this.textFieldHelper.insertText(Character.toString(typedChar));
this.clearDisplayCache();
this.setFocused(true);
Expand Down Expand Up @@ -492,25 +494,27 @@ private void renderCursor(GuiGraphics guiGraphics, Pos2i pos, boolean cursorAtEn

private void renderHighlight(Rect2i[] p_98139_) {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferbuilder = tesselator.getBuilder();
BufferBuilder bufferbuilder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShaderColor(0.0F, 0.0F, this.isFocused() ? 255.0F : 100.0F /* changed */, 255.0F);
RenderSystem.enableColorLogicOp();
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);

for(Rect2i rect2i : p_98139_) {
int i = rect2i.getX();
int j = rect2i.getY();
int k = i + rect2i.getWidth();
int l = j + rect2i.getHeight();
bufferbuilder.vertex((double)i, (double)l, 0.0D).endVertex();
bufferbuilder.vertex((double)k, (double)l, 0.0D).endVertex();
bufferbuilder.vertex((double)k, (double)j, 0.0D).endVertex();
bufferbuilder.vertex((double)i, (double)j, 0.0D).endVertex();
bufferbuilder.addVertex(i, l, 0.0F);
bufferbuilder.addVertex(k, l, 0.0F);
bufferbuilder.addVertex(k, j, 0.0F);
bufferbuilder.addVertex(i, j, 0.0F);
}

tesselator.end();
MeshData meshData = bufferbuilder.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
RenderSystem.disableColorLogicOp();

RenderSystem.setShaderColor(1, 1, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ContainerScreenScriptingDrive(ContainerScriptingDrive container, Inventor

@Override
protected ResourceLocation constructGuiTexture() {
return new ResourceLocation(Reference.MOD_ID, "textures/gui/scripting_drive.png");
return ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/scripting_drive.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void onClose() {

@Override
protected ResourceLocation constructGuiTexture() {
return new ResourceLocation(Reference.MOD_ID, "textures/gui/scripting_terminal.png");
return ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/scripting_terminal.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class ScriptImages {

public static final ResourceLocation ICONS = new ResourceLocation(IntegratedScripting._instance.getModId(),
public static final ResourceLocation ICONS = ResourceLocation.fromNamespaceAndPath(IntegratedScripting._instance.getModId(),
IntegratedScripting._instance.getReferenceValue(ModBase.REFKEY_TEXTURE_PATH_GUI) + "icons.png");

public static final Image FILE_OTHER = new Image(ICONS, 0, 0, 12, 12);
Expand Down
Loading

0 comments on commit 6e26ff0

Please sign in to comment.