Skip to content

Commit

Permalink
Update deps and make use of a few changes exposed in forge and accoun…
Browse files Browse the repository at this point in the history
…t for changes made in APIs of some deps that have now updated to 1.20
  • Loading branch information
pupnewfster committed Jun 27, 2023
1 parent 36e984f commit 0216c22
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 135 deletions.
14 changes: 9 additions & 5 deletions annotation-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ version '1.1.1'
java.toolchain.languageVersion = JavaLanguageVersion.of("${java_version}")

repositories {
maven {
def repo = maven {
name 'CraftTweaker'
url "https://maven.blamejared.com"
content {
includeGroup 'com.blamejared.crafttweaker'
url 'https://maven.blamejared.com'
}
exclusiveContent {
forRepositories(repo)
filter { InclusiveRepositoryContentDescriptor f ->
f.includeGroup 'com.blamejared.crafttweaker'
f.includeGroup 'org.openzen.zencode'
}
}
mavenCentral()
}

dependencies {
implementation "com.blamejared.crafttweaker:CraftTweaker-forge-${previous_minecraft_version}:${crafttweaker_version}"
implementation "com.blamejared.crafttweaker:CraftTweaker-forge-${minecraft_version}:${crafttweaker_version}"
//Version of GSON used by vanilla (and thus packed and already downloaded)
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
}
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,11 @@ repositories { RepositoryHandler handler ->
exclusiveRepo(handler, 'https://maven.blamejared.com', filter -> {
filter.includeGroupByRegex 'com\\.blamejared.*'
filter.includeGroup 'mezz.jei'
filter.includeGroup 'org.openzen.zencode'
})
exclusiveRepo(handler, 'https://maven.theillusivec4.top/', 'top.theillusivec4.curios')
exclusiveRepo(handler, 'https://maven.tterrag.com/', 'team.chisel.ctm')
exclusiveRepo(handler, 'https://squiddev.cc/maven/', 'org.squiddev')
exclusiveRepo(handler, 'https://squiddev.cc/maven/', 'cc.tweaked')
exclusiveRepo(handler, 'https://maven2.bai.lol', 'mcp.mobius.waila')//WTHIT
exclusiveRepo(handler, 'https://www.cursemaven.com', 'curse.maven')
exclusiveRepo(handler, 'https://modmaven.dev/', 'appeng', 'mcjty.theoneprobe')
Expand Down Expand Up @@ -397,20 +398,21 @@ dependencies {
runtimeOnly fg.deobf("curse.maven:jade-324717:${jade_id}")
compileOnly fg.deobf("mcp.mobius.waila:wthit-api:forge-${wthit_version}")

//TODO - 1.20: Switch these two back to implementation when they update
compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-forge-${previous_minecraft_version}:${crafttweaker_version}")
implementation fg.deobf("com.blamejared.crafttweaker:CraftTweaker-forge-${minecraft_version}:${crafttweaker_version}")
//TODO - 1.20: Switch these two back to implementation when it updates
compileOnly fg.deobf("com.blamejared.jeitweaker:JeiTweaker-forge-${previous_minecraft_version}:${jeitweaker_version}")

//Mods we have dependencies on but don't bother loading into the dev environment
compileOnly fg.deobf("curse.maven:projecte-api-226410:${projecte_api_id}")
compileOnly fg.deobf("curse.maven:flux-networks-248020:${flux_networks_id}")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${previous_minecraft_version}-${curios_version}:api")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api")
compileOnly fg.deobf("com.blamejared.recipestages:RecipeStages:${recipe_stages_version}")
compileOnly fg.deobf("curse.maven:opencomputers2-437654:${oc2_id}")
def cc = fg.deobf("org.squiddev:cc-tweaked-${previous_minecraft_version}:${cc_tweaked_version}:api")
compileOnly cc
compileOnly fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-forge-api:${cc_tweaked_version}")
def ccCoreAPI = fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-core-api:${cc_tweaked_version}")
compileOnly ccCoreAPI
//We require cc tweaked so that our CCArgumentWrapper tests can load, so expose it to the test runtime
testRuntimeOnly cc
testRuntimeOnly ccCoreAPI
compileOnly fg.deobf("curse.maven:female-gender-forge-481655:${wildfire_gender_mod_id}")

//Dependencies for data generators for mod compat reference
Expand Down
28 changes: 14 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ minecraft_version=1.20.1
#Used as a helper for porting when deps we use have not updated yet
previous_minecraft_version=1.19.2
previous_minor_minecraft_version=1.20
mappings_version=2022.11.27-1.20.1
mappings_channel=parchment_previous
mappings_version=2023.06.26-1.20.1
mappings_channel=parchment
loader_version_range=[47,)
forge_version=47.0.18
forge_version=47.0.34
mod_version=10.3.9
#This determines the minimum version of forge required to use Mekanism
# Only bump it whenever we need access to a feature in forge that is not available in earlier versions
forge_version_range=[47.0.11,)
forge_version_range=[47.0.34,)
minecraft_version_range=[1.20.1]
#This specifies what type of release it will be uploaded to CurseForge and Modrinth as
# options are: alpha, beta, release
Expand All @@ -25,33 +25,33 @@ junit_version=5.9.2
quicktheories_version=0.26

#Mod dependencies
cc_tweaked_version=1.105.0
crafttweaker_version=14.0.2
curios_version=5.2.0-beta.3+1.20.1
jade_api_id=4573194
jade_id=4573193
jei_version=15.2.0.20
jei_version=15.2.0.22
top_version=1.20.0-9.0.0-1
wildfire_gender_mod_id=4603538
wthit_version=8.1.1

#Mod dependency min version ranges
crafttweaker_version_range=[10.0.6,)
crafttweaker_version_range=[14.0.2,)
curios_version_range=[1.19-5.1.0.0,)
jei_version_range=[15.2.0.20,)

#Mod dependencies for recipes (only used by our data generators)
ae2_version=15.0.2-alpha
biomesoplenty_api_id=4598879
biomesoplenty_id=4598877
terrablender_id=4590487
ae2_version=15.0.3-alpha
biomesoplenty_api_id=4611518
biomesoplenty_id=4611516
terrablender_id=4608122

#Outdated mod dependencies
cc_tweaked_version=1.101.2
crafttweaker_version=10.1.44
ctm_version=1.1.7+11
curios_version=5.1.4.1
flux_networks_id=4353161
jeitweaker_version=4.0.11
projecte_api_id=3955049
recipe_stages_version=4.0.0.4
wildfire_gender_mod_id=3920268
oc2_id=3896581

#Outdated mod dependencies for recipes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.19.2 2022-10-04T17:21:34.9142429 Texture Provider
// 1.20.1 2023-06-27T14:19:09.4407713 Robit Texture Provider
a690228431c6f9152778550a0653a8157cd48915 assets/mekanism/textures/entity/robit/ace.png
7a78a23777c4a1927ec3e44bd499ce59f89b6083 assets/mekanism/textures/entity/robit/ace2.png
4961398c7ccb3a77d8ed734540a0c180a34cb58d assets/mekanism/textures/entity/robit/ace3.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public PrideRobitTextureProvider(PackOutput output, ExistingFileHelper helper) {
@Override
@SuppressWarnings("UnstableApiUsage")
public CompletableFuture<?> run(@NotNull CachedOutput cache) {
//TODO - 1.20: Test this???
return CompletableFuture.runAsync(() -> {
PathProvider pathProvider = output.createPathProvider(Target.RESOURCE_PACK, ROBIT_SKIN_PATH);
try {
Expand Down Expand Up @@ -87,7 +86,6 @@ public CompletableFuture<?> run(@NotNull CachedOutput cache) {
}
}
} catch (IOException exception) {
//TODO - 1.20: Should this be rethrowing or something instead? Evaluate how other providers handle exceptions
Mekanism.logger.error("Couldn't create robit textures", exception);
}
}, Util.ioPool());
Expand Down Expand Up @@ -118,6 +116,6 @@ private int abgr(int stripeIndex, int chainIndex, int rotationIndex, RobitPrideS
@NotNull
@Override
public String getName() {
return "Texture Provider";
return "Robit Texture Provider";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import mekanism.client.texture.PrideRobitTextureProvider;
import mekanism.common.advancements.MekanismAdvancementProvider;
import mekanism.common.advancements.MekanismCriteriaTriggers;
import mekanism.common.integration.crafttweaker.MekanismCrTExampleProvider;
import mekanism.common.loot.MekanismLootProvider;
import mekanism.common.recipe.impl.MekanismRecipeProvider;
import mekanism.common.registries.MekanismDatapackRegistryProvider;
Expand Down Expand Up @@ -58,9 +59,8 @@ public static void gatherData(GatherDataEvent event) {
gen.addProvider(event.includeServer(), recipeProvider);
gen.addProvider(event.includeServer(), new MekanismAdvancementProvider(output, existingFileHelper));
//TODO - 1.20: Re-enable after updating ProjectE
//addProvider(gen, event.includeServer(), output -> new MekanismCustomConversions(output));
//TODO - 1.20: Re-enable once CrT updates
//addProvider(gen, event.includeServer(), output -> new MekanismCrTExampleProvider(output, existingFileHelper));
//addProvider(gen, event.includeServer(), MekanismCustomConversions::new);
gen.addProvider(event.includeServer(), new MekanismCrTExampleProvider(output, existingFileHelper));
//Data generator to help with persisting data when porting across MC versions when optional deps aren't updated yet
gen.addProvider(true, new PersistingDisabledProvidersProvider(output, recipeProvider.getDisabledCompats()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public static void captureGlobalCache(HashCache cache) {
}

private static final Set<String> PATHS_TO_SKIP = Set.of(
"/scripts/"//CraftTweaker script files
, "/pe_custom_conversions/"//ProjectE custom conversion files
//"/scripts/",//CraftTweaker script files
"/pe_custom_conversions/"//ProjectE custom conversion files
);
private static final List<String> FAKE_PROVIDERS = List.of(
"CraftTweaker Examples: mekanism"
, "Custom EMC Conversions: mekanism"
//"CraftTweaker Examples: mekanism",
"Custom EMC Conversions: mekanism"
);


Expand All @@ -64,10 +64,6 @@ public CompletableFuture<?> run(@NotNull CachedOutput cache) {
}

private <PROVIDER_CACHE> void tryPersist(HashCache cache) {
FieldReflectionHelper<HashCache, Set<String>> cachesToWrite = new FieldReflectionHelper<>(HashCache.class, "f_236083_", () -> null);
Set<String> toWrite = cachesToWrite.getValue(cache);
//Skip writing a cache for this data generator
toWrite.remove(getName());
if (compatRecipesToSkip.isEmpty() && PATHS_TO_SKIP.isEmpty() && FAKE_PROVIDERS.isEmpty()) {
//Skip if we don't have any things to override and persist
return;
Expand Down Expand Up @@ -124,7 +120,8 @@ private <PROVIDER_CACHE> void tryPersist(HashCache cache) {
int totalAdditionalWrites = additionalWrites;
writes.transformValue(cache, ConstantPredicates.alwaysTrue(), c -> c + totalAdditionalWrites);


FieldReflectionHelper<HashCache, Set<String>> cachesToWrite = new FieldReflectionHelper<>(HashCache.class, "f_236083_", () -> null);
Set<String> toWrite = cachesToWrite.getValue(cache);
Map<String, PROVIDER_CACHE> fakeCaches = new HashMap<>();
Set<Path> paths = cachePaths.getValue(cache);
Path cacheDir = baseOutputPath.resolve(".cache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,17 +434,15 @@ private <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<CHEMIC
/**
* Basically a copy of {@link DataProvider#saveStable(CachedOutput, JsonElement, Path)} but it takes the contents as a string instead of serializes json using GSON.
*/
@SuppressWarnings("UnstableApiUsage")
@SuppressWarnings({"UnstableApiUsage", "deprecation"})
private static CompletableFuture<?> save(CachedOutput cache, String contents, Path path) {
return CompletableFuture.runAsync(() -> {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
HashingOutputStream hashingOutputStream = new HashingOutputStream(Hashing.sha1(), outputStream)) {
hashingOutputStream.write(contents.getBytes(StandardCharsets.UTF_8));
cache.writeIfNeeded(path, outputStream.toByteArray(), hashingOutputStream.hash());
} catch (IOException ioexception) {
//TODO - 1.20: Should this throw the exception on somehow instead
LOGGER.error("Failed to save file to {}", path, ioexception);
//throw new RuntimeException("Couldn't save example script: " + examplePath, e);
}
}, Util.backgroundExecutor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import mekanism.common.lib.FieldReflectionHelper;
import net.minecraft.core.Holder;
import net.minecraft.core.Holder.Reference;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.registries.RegistriesDatapackGenerator;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -27,21 +25,13 @@

public abstract class BaseDatapackRegistryProvider extends DatapackBuiltinEntriesProvider {

@SuppressWarnings("deprecation")
private static final FieldReflectionHelper<RegistriesDatapackGenerator, CompletableFuture<HolderLookup.Provider>> REGISTRIES = new FieldReflectionHelper<>(RegistriesDatapackGenerator.class, "f_254747_", () -> null);

private final String modid;

protected BaseDatapackRegistryProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, RegistrySetBuilder registrySetBuilder, String modid) {
super(output, registries, registrySetBuilder, Set.of(modid));
this.modid = modid;
}

public CompletableFuture<HolderLookup.Provider> getRegistryProvider() {
//TODO - 1.20: Replace with https://github.com/MinecraftForge/MinecraftForge/pull/9580 if it gets merged
return REGISTRIES.getValue(this);
}

@NotNull
@Override
public String getName() {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/mekanism/client/ClientRegistration.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,18 +590,16 @@ public static void registerItemDecorations(RegisterItemDecorationsEvent event) {
public static void addLayers(EntityRenderersEvent.AddLayers event) {
//Add our own custom armor layer to the various player renderers
for (String skinName : event.getSkins()) {
//TODO - 1.20: Switch to get model manager from event https://github.com/MinecraftForge/MinecraftForge/pull/9562
addCustomLayers(EntityType.PLAYER, (PlayerRenderer) event.getSkin(skinName), Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getModelManager());
addCustomLayers(EntityType.PLAYER, (PlayerRenderer) event.getSkin(skinName), event.getContext().getModelManager());
}
//Add our own custom armor layer to everything that has an armor layer
//Note: This includes any modded mobs that have vanilla's BipedArmorLayer added to them
for (Entry<EntityType<?>, EntityRenderer<?>> entry : Minecraft.getInstance().getEntityRenderDispatcher().renderers.entrySet()) {
EntityRenderer<?> renderer = entry.getValue();
if (renderer instanceof LivingEntityRenderer) {
EntityType<?> entityType = entry.getKey();
//TODO - 1.20: Switch to get model manager from event https://github.com/MinecraftForge/MinecraftForge/pull/9562
//noinspection unchecked,rawtypes
addCustomLayers(entityType, event.getRenderer((EntityType) entityType), Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getModelManager());
addCustomLayers(entityType, event.getRenderer((EntityType) entityType), event.getContext().getModelManager());
}
}
}
Expand Down
32 changes: 24 additions & 8 deletions src/main/java/mekanism/common/block/BlockBounding.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,37 @@ public void onBlockExploded(BlockState state, Level world, BlockPos pos, Explosi
BlockState mainState = world.getBlockState(mainPos);
if (!mainState.isAir()) {
//Proxy the explosion to the main block which, will set it to air causing it to invalidate the rest of the bounding blocks
LootParams.Builder lootContextBuilder = new LootParams.Builder((ServerLevel) world)
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(mainPos))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, mainState.hasBlockEntity() ? WorldUtils.getTileEntity(world, mainPos) : null)
.withOptionalParameter(LootContextParams.THIS_ENTITY, explosion.getExploder());
if (explosion.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY) {
lootContextBuilder.withParameter(LootContextParams.EXPLOSION_RADIUS, explosion.radius);
if (world instanceof ServerLevel serverLevel) {
LootParams.Builder lootContextBuilder = new LootParams.Builder(serverLevel)
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(mainPos))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, mainState.hasBlockEntity() ? WorldUtils.getTileEntity(serverLevel, mainPos) : null)
.withOptionalParameter(LootContextParams.THIS_ENTITY, explosion.getExploder());
if (explosion.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY) {
lootContextBuilder.withParameter(LootContextParams.EXPLOSION_RADIUS, explosion.radius);
}
mainState.getDrops(lootContextBuilder).forEach(stack -> Block.popResource(serverLevel, mainPos, stack));
}
mainState.getDrops(lootContextBuilder).forEach(stack -> Block.popResource(world, mainPos, stack));
mainState.onBlockExploded(world, mainPos, explosion);
}
}
super.onBlockExploded(state, world, pos, explosion);
}

@Override
@Deprecated
public void spawnAfterBreak(@NotNull BlockState state, @NotNull ServerLevel level, @NotNull BlockPos pos, @NotNull ItemStack stack, boolean dropExperience) {
BlockPos mainPos = getMainBlockPos(level, pos);
if (mainPos != null) {
BlockState mainState = level.getBlockState(mainPos);
if (!mainState.isAir()) {
//Proxy the call to the main block even though none of our blocks currently make use of this method
mainState.spawnAfterBreak(level, mainPos, stack, dropExperience);
}
}
super.spawnAfterBreak(state, level, pos, stack, dropExperience);
}

@Override
public void playerDestroy(@NotNull Level world, @NotNull Player player, @NotNull BlockPos pos, @NotNull BlockState state, BlockEntity te,
@NotNull ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected String formatError(String messageFormat, Object... args) {
public abstract EXCEPTION error(String messageFormat, Object... args);

@Nullable
public abstract Object getArgument(int index);
public abstract Object getArgument(int index) throws EXCEPTION;

/**
* Allows implementers to override and add in various extra "implicit" casts that are not in Java's default conversions. This method will only be called if the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public LuaException error(String messageFormat, Object... args) {

@Nullable
@Override
public Object getArgument(int index) {
public Object getArgument(int index) throws LuaException {
return arguments.get(index);
}

Expand Down
Loading

0 comments on commit 0216c22

Please sign in to comment.