Skip to content

Commit

Permalink
Merge branch 'refs/heads/mc1.18/fabric/dev' into mc1.19/fabric/dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
  • Loading branch information
IThundxr committed Jul 9, 2024
2 parents b371ca6 + 8e0b03f commit 812fea0
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 36 deletions.
43 changes: 40 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.util.jar.JarEntry
import java.util.jar.JarOutputStream

//file:noinspection GrMethodMayBeStatic
plugins {
id "fabric-loom" version "1.5.+"
Expand Down Expand Up @@ -64,9 +67,6 @@ def dependencies(DependencyHandler deps) {
exclude(group: "io.github.fabricators_of_create") // avoid duplicate Porting Lib
}

// Stub mod to allow addons to depend on a constant version between sub-patches
deps.include(project(":stubMod"))

deps.modApi(deps.include("com.electronwill.night-config:core:$night_config_version"))
deps.modApi(deps.include("com.electronwill.night-config:toml:$night_config_version"))
deps.modApi(deps.include("net.minecraftforge:forgeconfigapiport-fabric:$forge_config_api_port_version"))
Expand Down Expand Up @@ -234,6 +234,43 @@ jar {
}
}

tasks.register("createStubJar") {
outputs.upToDateWhen { false }

ByteArrayOutputStream byteStream = new ByteArrayOutputStream()
JarOutputStream jarStream = new JarOutputStream(byteStream)

try {
File fabricModJson = file("$projectDir/stubMod/fabric.mod.json")
if (fabricModJson.exists()) {
String content = fabricModJson.text.replace('${version}', mod_version)
jarStream.putNextEntry(new JarEntry("fabric.mod.json"))
jarStream.write(content.bytes)
jarStream.closeEntry()
} else {
throw new FileNotFoundException("Warning: fabric.mod.json not found at ${fabricModJson.path}")
}
} finally {
jarStream.close()
}

File baseDir = file("$projectDir/build/stub")
baseDir.mkdirs()
File outputFile = file("$baseDir/create-stub-${mod_version}.jar")
outputFile.withOutputStream { os ->
byteStream.writeTo(os)
}

outputs.file(outputFile)

println "Stub jar created at: ${outputFile.path}"
}

tasks.remapJar.configure {
dependsOn tasks.createStubJar
tasks.remapJar.nestedJars.from(createStubJar.outputs)
}

// see gradle/publishing.gradle for publishing
apply from: "gradle/publishing/publishing.gradle"
apply from: "gradle/compat/compat.gradle"
2 changes: 0 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ pluginManagement {
gradlePluginPortal()
}
}

include "stubMod"
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
Expand All @@ -31,6 +32,10 @@
import net.minecraft.world.entity.projectile.ProjectileUtil;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
Expand Down Expand Up @@ -158,22 +163,13 @@ public static void dontMissEntitiesWhenYouHaveHighReachDistance(/*ClickInputEven
}
}

// @SubscribeEvent(priority = EventPriority.LOWEST)
// public static void consumeDurabilityOnBlockBreak(BreakEvent event) {
// findAndDamageExtendoGrip(event.getPlayer());
// }
//
// @SubscribeEvent(priority = EventPriority.LOWEST)
// public static void consumeDurabilityOnPlace(EntityPlaceEvent event) {
// Entity entity = event.getEntity();
// if (entity instanceof Player)
// findAndDamageExtendoGrip((Player) entity);
// }
public static void consumeDurabilityOnBlockBreak(Level level, Player player, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) {
findAndDamageExtendoGrip(player);
}

// @SubscribeEvent(priority = EventPriority.LOWEST)
// public static void consumeDurabilityOnPlace(PlayerInteractEvent event) {
// findAndDamageExtendoGrip(event.getPlayer());
// }
public static void consumeDurabilityOnPlace(BlockPlaceContext blockPlaceContext, BlockPos blockPos, BlockState blockState) {
findAndDamageExtendoGrip(blockPlaceContext.getPlayer());
}

private static void findAndDamageExtendoGrip(Player player) {
if (player == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,7 @@ public static void register() {
MinecartEvents.WRITE.register(AbstractMinecartExtensions::minecartWrite);
MinecartEvents.REMOVE.register(AbstractMinecartExtensions::minecartRemove);
PlayerBlockBreakEvents.BEFORE.register(SymmetryHandler::onBlockDestroyed);
PlayerBlockBreakEvents.AFTER.register(ExtendoGripItem::consumeDurabilityOnBlockBreak);
BlockEvents.POST_PROCESS_PLACE.register(ExtendoGripItem::consumeDurabilityOnPlace);
}
}
16 changes: 0 additions & 16 deletions stubMod/build.gradle

This file was deleted.

File renamed without changes.

0 comments on commit 812fea0

Please sign in to comment.