Compare commits

..
12 Commits
Author SHA1 Message Date
Connor Colenso 2e8ce92f66 Fix bug 2023-12-24 01:30:13 +00:00
Martin Robertz 34ebb71357 Delete .github/workflows/buildscript-maintenance.yml 2023-12-23 14:52:00 +01:00
Martin Robertz 17ab9ecd89 updated dep 2023-12-23 14:50:16 +01:00
Martin Robertz 1ced0aa1bf update gradle
set link from Gradle 8.5
2023-12-23 14:40:47 +01:00
GTNH-Colen a09cb976d6 Build fixes 2023-12-23 04:37:08 +00:00
GTNH-Colen 3c929a7792 Update dep 2023-12-23 04:30:52 +00:00
GTNH-Colen 1b96a07a74 Give world context to block conversion. 2023-12-20 02:00:48 +00:00
GTNH-Colen 15a5806887 Spotless 2023-12-20 01:34:19 +00:00
GTNH-Colen 9f6ded0b1a Refactor for meta expansion by NEID 2023-12-20 01:32:20 +00:00
GTNH-Colen 74d4151d00 Refactor for meta expansion by NEID 2023-12-20 01:11:18 +00:00
GTNH-Colen 7352e2dc56 Add NEID dep 2023-12-15 01:17:12 +00:00
GTNH-Colen 7b79649dc2 Remove example 2023-12-15 01:16:54 +00:00
8 changed files with 42 additions and 139 deletions

No files matched your search

+5 -3
View File
@@ -1,4 +1,4 @@
//version: 1701530445 //version: 1702141377
/* /*
DO NOT CHANGE THIS FILE! DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available. Also, you may replace this file at any time if there is an update available.
@@ -54,7 +54,7 @@ plugins {
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
id 'com.modrinth.minotaur' version '2.+' apply false id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24' id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26'
} }
print("You might want to check out './gradlew :faq' if your build fails.\n") print("You might want to check out './gradlew :faq' if your build fails.\n")
@@ -613,7 +613,7 @@ repositories {
} }
maven { maven {
name = "ic2" name = "ic2"
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/") url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
content { content {
includeGroup "net.industrial-craft" includeGroup "net.industrial-craft"
} }
@@ -672,6 +672,8 @@ configurations.all {
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods") substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods") substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier") substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
} }
} }
+2 -38
View File
@@ -1,40 +1,4 @@
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies { dependencies {
// api("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") api('com.github.GTNewHorizons:NotEnoughIds:1.5.4-pre:dev')
// api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.104:dev')
api('com.github.GTNewHorizons:NotEnoughIds:1.5.3:dev')
} }
-1
View File
@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
+1 -1
View File
@@ -1,5 +1,5 @@
// Add any additional repositories for your dependencies here // Add any additional repositories for your dependencies here
repositories { repositories {
mavenLocal()
} }
@@ -2,30 +2,31 @@ package com.colen.postea.API;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.BiFunction;
import net.minecraft.world.World;
import com.colen.postea.Utility.BlockConversionInfo; import com.colen.postea.Utility.BlockConversionInfo;
public class BlockReplacementManager { public class BlockReplacementManager {
private static final Map<String, Function<BlockConversionInfo, BlockConversionInfo>> blockReplacementMap = new HashMap<>(); private static final Map<String, BiFunction<BlockConversionInfo, World, BlockConversionInfo>> blockReplacementMap = new HashMap<>();
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static void addBlockReplacement(String blockNameIn, public static void addBlockReplacement(String blockNameIn,
Function<BlockConversionInfo, BlockConversionInfo> transformer) { BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer) {
blockReplacementMap.put(blockNameIn, transformer); blockReplacementMap.put(blockNameIn, transformer);
} }
@SuppressWarnings("unused") public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo, World world) {
public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo) {
Function<BlockConversionInfo, BlockConversionInfo> transformer = blockReplacementMap BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer = blockReplacementMap
.getOrDefault(blockConversionInfo.blocKName, null); .getOrDefault(blockConversionInfo.blockName, null);
if (transformer == null) { if (transformer == null) {
return null; return null;
} else { } else {
return transformer.apply(blockConversionInfo); return transformer.apply(blockConversionInfo, world);
} }
} }
@@ -1,16 +1,6 @@
package com.colen.postea; package com.colen.postea;
import java.util.function.Function;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import com.colen.postea.API.BlockReplacementManager;
import com.colen.postea.Utility.BlockConversionInfo;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]") @Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]")
@@ -20,49 +10,6 @@ public class Postea {
@Mod.EventHandler @Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
ModContainer activeMod = Loader.instance()
.activeModContainer();
String modID = activeMod.getModId();
String v = activeMod.getVersion();
Function<BlockConversionInfo, BlockConversionInfo> blockTransformer = (blockConversionInfoOld) -> {
BlockConversionInfo blockConversionInfoNew = new BlockConversionInfo();
if ((blockConversionInfoOld.x == -1) && (blockConversionInfoOld.y == 3)
&& (blockConversionInfoOld.z == -1)) {
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
blockConversionInfoNew.metadata = 1;
return blockConversionInfoNew;
}
if ((blockConversionInfoOld.x == -1) && (blockConversionInfoOld.y == 3)
&& (blockConversionInfoOld.z == 1)) {
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
blockConversionInfoNew.metadata = 1;
return blockConversionInfoNew;
}
if ((blockConversionInfoOld.x == 1) && (blockConversionInfoOld.y == 3) && (blockConversionInfoOld.z == 1)) {
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
blockConversionInfoNew.metadata = 1;
return blockConversionInfoNew;
}
if ((blockConversionInfoOld.x == 1) && (blockConversionInfoOld.y == 3)
&& (blockConversionInfoOld.z == -1)) {
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
blockConversionInfoNew.metadata = 1;
return blockConversionInfoNew;
}
blockConversionInfoNew.blockID = blockConversionInfoOld.blockID;
blockConversionInfoNew.metadata = blockConversionInfoOld.metadata;
return blockConversionInfoNew;
};
BlockReplacementManager.addBlockReplacement("minecraft:grass", blockTransformer);
} }
} }
@@ -15,5 +15,5 @@ public final class BlockConversionInfo {
public World world; public World world;
public NBTTagCompound tileEntityNBT; public NBTTagCompound tileEntityNBT;
public String blocKName; public String blockName;
} }
@@ -27,39 +27,42 @@ public class ChunkFixerUtility {
NBTTagCompound level = compound.getCompoundTag("Level"); NBTTagCompound level = compound.getCompoundTag("Level");
NBTTagList sections = level.getTagList("Sections", 10); NBTTagList sections = level.getTagList("Sections", 10);
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis int chunkXPos = level.getInteger("xPos") * 16;
int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis int chunkZPos = level.getInteger("zPos") * 16;
for (int i = 0; i < sections.tagCount(); i++) { for (int i = 0; i < sections.tagCount(); i++) {
NBTTagCompound section = sections.getCompoundTagAt(i); NBTTagCompound section = sections.getCompoundTagAt(i);
// Blocks16 and Data16 exist only because of NEID.
byte[] blockArray = section.getByteArray("Blocks16"); byte[] blockArray = section.getByteArray("Blocks16");
byte[] metadataArray = section.getByteArray("Data"); byte[] metadataArray = section.getByteArray("Data16");
byte sectionY = section.getByte("Y"); byte sectionY = section.getByte("Y");
for (int index = 0; index < blockArray.length / 2; index++) { for (int index = 0; index < blockArray.length / 2; index++) {
int blockId = ((blockArray[index * 2] & 0xFF) << 8) | (blockArray[index * 2 + 1] & 0xFF); int blockId = ((blockArray[index * 2] & 0xFF) << 8) | (blockArray[index * 2 + 1] & 0xFF);
byte metadata = (byte) ((index & 1) == 0 ? (metadataArray[index / 2] & 0x0F) int metadata = ((metadataArray[index * 2] & 0xFF) << 8) | (metadataArray[index * 2 + 1] & 0xFF);
: ((metadataArray[index / 2] & 0xF0) >> 4));
Block block = Block.getBlockById(blockId); Block block = Block.getBlockById(blockId);
String blockName = GameRegistry.findUniqueIdentifierFor(block) String blockName = GameRegistry.findUniqueIdentifierFor(block)
.toString(); .toString();
BlockConversionInfo blockConversionInfo = new BlockConversionInfo(); BlockConversionInfo blockConversionInfo = new BlockConversionInfo();
blockConversionInfo.blocKName = blockName; blockConversionInfo.blockName = blockName;
blockConversionInfo.blockID = blockId; blockConversionInfo.blockID = blockId;
blockConversionInfo.metadata = metadata; blockConversionInfo.metadata = (byte) metadata; // Updated
blockConversionInfo.world = world; blockConversionInfo.world = world;
int x = index % 16; int x = index % 16;
int y = (index / 256) + (sectionY * 16); // Add the offset of the current section in Y direction int y = (index / 256) + (sectionY * 16);
int z = (index / 16) % 16; int z = (index / 16) % 16;
blockConversionInfo.x = x + chunkXPos + 1; blockConversionInfo.x = x + chunkXPos + 1;
blockConversionInfo.y = y; // Y remains unchanged as it's already global blockConversionInfo.y = y;
blockConversionInfo.z = z + chunkZPos + 1; blockConversionInfo.z = z + chunkZPos + 1;
BlockConversionInfo output = BlockReplacementManager.getBlockReplacement(blockConversionInfo); BlockConversionInfo output = BlockReplacementManager.getBlockReplacement(blockConversionInfo, world);
if (output != null) { if (output != null) {
int newBlockId = output.blockID; int newBlockId = output.blockID;
int newMetadata = output.metadata; int newMetadata = output.metadata;
@@ -67,13 +70,8 @@ public class ChunkFixerUtility {
blockArray[index * 2] = (byte) ((newBlockId >> 8) & 0xFF); blockArray[index * 2] = (byte) ((newBlockId >> 8) & 0xFF);
blockArray[index * 2 + 1] = (byte) (newBlockId & 0xFF); blockArray[index * 2 + 1] = (byte) (newBlockId & 0xFF);
if ((index & 1) == 0) { // Even metadataArray[index * 2] = (byte) ((newMetadata >> 8) & 0xFF);
metadataArray[index / 2] &= 0xF0; metadataArray[index * 2 + 1] = (byte) (newMetadata & 0xFF);
metadataArray[index / 2] |= (newMetadata & 0x0F);
} else { // Odd
metadataArray[index / 2] &= 0x0F;
metadataArray[index / 2] |= ((newMetadata << 4) & 0xF0);
}
} }
} }
} }
@@ -84,11 +82,9 @@ public class ChunkFixerUtility {
Pair<List<ConversionInfo>, NBTTagList> output = adjustTileEntities(level.getTagList("TileEntities", 10), world); Pair<List<ConversionInfo>, NBTTagList> output = adjustTileEntities(level.getTagList("TileEntities", 10), world);
List<ConversionInfo> conversionInfoList = output.first(); List<ConversionInfo> conversionInfoList = output.first();
NBTTagList tileEntities = output.second();
if (tileEntities.tagCount() > 0) { NBTTagList tileEntities = output.second();
level.setTag("TileEntities", tileEntities); level.setTag("TileEntities", tileEntities);
}
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis
int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
@@ -103,7 +99,7 @@ public class ChunkFixerUtility {
private static void processSection(NBTTagCompound section, List<ConversionInfo> conversionInfoList, int chunkXPos, private static void processSection(NBTTagCompound section, List<ConversionInfo> conversionInfoList, int chunkXPos,
int chunkZPos) { int chunkZPos) {
byte[] blockArray = section.getByteArray("Blocks16"); byte[] blockArray = section.getByteArray("Blocks16");
byte[] metadataArray = section.getByteArray("Data"); byte[] metadataArray = section.getByteArray("Data16"); // Updated to use Data16
byte y = section.getByte("Y"); byte y = section.getByte("Y");
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y); List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
@@ -112,7 +108,7 @@ public class ChunkFixerUtility {
int[] localCoords = convertToChunkLocalCoordinates(info, y, chunkXPos, chunkZPos); int[] localCoords = convertToChunkLocalCoordinates(info, y, chunkXPos, chunkZPos);
int index = computeBlockIndex(localCoords); int index = computeBlockIndex(localCoords);
setBlockInfo(info.blockInfo.block, index, blockArray); setBlockInfo(info.blockInfo.block, index, blockArray);
setMetadata(info.blockInfo.metadata, index, metadataArray); setMetadata(info.blockInfo.metadata, index, metadataArray); // This uses the updated setMetadata
} }
} }
@@ -140,18 +136,12 @@ public class ChunkFixerUtility {
} }
private static void setMetadata(int metadata, int index, byte[] metadataArray) { private static void setMetadata(int metadata, int index, byte[] metadataArray) {
int metadataIndex = index / 2; // Since each metadata is now two bytes, multiply the index by 2 to get the correct position.
byte currentMetadataByte = metadataArray[metadataIndex]; int metadataStartIndex = index * 2;
if ((index & 1) == 0) { // Even // Split the 16-bit metadata into two bytes and store them in the array.
currentMetadataByte &= 0xF0; metadataArray[metadataStartIndex] = (byte) ((metadata >> 8) & 0xFF); // Higher 8 bits
currentMetadataByte |= (metadata & 0x0F); metadataArray[metadataStartIndex + 1] = (byte) (metadata & 0xFF); // Lower 8 bits
} else { // Odd
currentMetadataByte &= 0x0F;
currentMetadataByte |= ((metadata << 4) & 0xF0);
}
metadataArray[metadataIndex] = currentMetadataByte;
} }
private static Pair<List<ConversionInfo>, NBTTagList> adjustTileEntities(NBTTagList tileEntities, World world) { private static Pair<List<ConversionInfo>, NBTTagList> adjustTileEntities(NBTTagList tileEntities, World world) {