Skip to content

Commit

Permalink
1.18 support. took a while to figure out
Browse files Browse the repository at this point in the history
  • Loading branch information
nad2040 committed May 27, 2024
1 parent dedcb56 commit 21ece0e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.22
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.15.11

# Mod Properties
mod_version = 1.1.0
maven_group = com.nad2040
archives_base_name = [1.19+]-elytrabombing
archives_base_name = [1.18+]-elytrabombing
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.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/nad2040/elytrabombing/ElytraBombingMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -34,10 +33,6 @@ public void onInitialize() {
LOGGER.info("Elytra Bombing Mod initialized!");
}

public static BlockPos VEC_3D_TO_POS(Vec3d vec3d) {
return new BlockPos(vec3d.x, vec3d.y, vec3d.z);
}

public static void log(Hand hand, Hand other_hand, ItemStack usedItemStack, ItemStack otherItemStack, Vec3d position, Vec3d velocity) {
LOGGER.info("right click action detected");
LOGGER.info("hand is " + ((hand == Hand.MAIN_HAND) ? "main hand" : "off hand"));
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/nad2040/elytrabombing/mixin/ItemMixin.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.nad2040.elytrabombing.mixin;

import com.nad2040.elytrabombing.ElytraBombingMod;
import net.minecraft.block.AnvilBlock;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.FallingBlockEntity;
Expand All @@ -13,7 +12,6 @@
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;
Expand All @@ -37,8 +35,9 @@ public void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnabl
TntEntity tntEntity = new TntEntity(world, position.x, position.y, position.z, user);
tntEntity.setVelocity(velocity.multiply(1.2));
world.spawnEntity(tntEntity);
world.playSound(null, tntEntity.getX(), tntEntity.getY(), tntEntity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0f, 1.0f);
world.emitGameEvent(user, GameEvent.PRIME_FUSE, position);
// changed methods signatures to ones that are also supported in 1.18*
world.playSound(tntEntity.getX(), tntEntity.getY(), tntEntity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0f, 1.0f, false);
user.emitGameEvent(GameEvent.PRIME_FUSE, tntEntity);
if (!user.getAbilities().creativeMode) {
usedItemStack.damage(1, user, p -> p.sendToolBreakStatus(hand));
otherItemStack.decrement(1);
Expand All @@ -47,14 +46,15 @@ public void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnabl
cir.setReturnValue(TypedActionResult.success(user.getStackInHand(hand), world.isClient()));
} else if ((usedItemStack.isOf(Items.ANVIL) || usedItemStack.isOf(Items.CHIPPED_ANVIL) || usedItemStack.isOf(Items.DAMAGED_ANVIL)) && otherItemStack.isEmpty()) {
FallingBlockEntity anvilEntity = new FallingBlockEntity(EntityType.FALLING_BLOCK, world);
anvilEntity.timeFalling = 1; // allows anvils to work on 1.18* by avoiding `(this.timeFalling++ == 0)`
anvilEntity.setPosition(position);
anvilEntity.setVelocity(velocity.multiply(1.2));
if (usedItemStack.isOf(Items.ANVIL)) ((ElytraBombingMod.FBEInterface) anvilEntity).setBlock(Blocks.ANVIL.getDefaultState());
if (usedItemStack.isOf(Items.CHIPPED_ANVIL)) ((ElytraBombingMod.FBEInterface) anvilEntity).setBlock(Blocks.CHIPPED_ANVIL.getDefaultState());
if (usedItemStack.isOf(Items.DAMAGED_ANVIL)) ((ElytraBombingMod.FBEInterface) anvilEntity).setBlock(Blocks.DAMAGED_ANVIL.getDefaultState());
anvilEntity.setFallingBlockPos(anvilEntity.getBlockPos());
world.spawnEntity(anvilEntity);
world.playSound(null, anvilEntity.getX(), anvilEntity.getY(), anvilEntity.getZ(), SoundEvents.BLOCK_ANVIL_FALL, SoundCategory.BLOCKS, 1.0f, 1.0f);
world.playSound(anvilEntity.getX(), anvilEntity.getY(), anvilEntity.getZ(), SoundEvents.BLOCK_ANVIL_FALL, SoundCategory.BLOCKS, 1.0f, 1.0f, false);
if (!user.getAbilities().creativeMode) {
usedItemStack.decrement(1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

"depends": {
"fabricloader": ">=0.7",
"minecraft": ">=1.19",
"minecraft": ">=1.18",
"java": ">=17"
},
"suggests": {
Expand Down

0 comments on commit 21ece0e

Please sign in to comment.