Skip to content

Commit 22e9d7a

Browse files
committed
Update to 1.21.3
1 parent 58c7a0e commit 22e9d7a

File tree

10 files changed

+62
-59
lines changed

10 files changed

+62
-59
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.6-SNAPSHOT'
2+
id 'fabric-loom' version '1.7-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -25,13 +25,13 @@ processResources {
2525
}
2626

2727
tasks.withType(JavaCompile).configureEach {
28-
it.options.release = 17
28+
it.options.release = 20
2929
}
3030

3131
java {
3232
withSourcesJar()
33-
sourceCompatibility = JavaVersion.VERSION_17
34-
targetCompatibility = JavaVersion.VERSION_17
33+
sourceCompatibility = JavaVersion.VERSION_20
34+
targetCompatibility = JavaVersion.VERSION_20
3535
}
3636

3737
jar {

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Done to increase the memory available to gradle.
2-
org.gradle.jvmargs=-Xmx1G
2+
org.gradle.jvmargs=-Xmx2G
33
org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21
8-
yarn_mappings=1.21+build.1
9-
loader_version=0.15.11
7+
minecraft_version=1.21.3
8+
yarn_mappings=1.21.3+build.2
9+
loader_version=0.16.9
10+
11+
# Fabric API
12+
fabric_version=0.107.3+1.21.3
1013

1114
# Mod Properties
1215
mod_version=1.0.0
1316
maven_group=btw.lowercase.blocking_component
14-
archives_base_name=blocking-component
15-
16-
# Dependencies
17-
fabric_version=0.100.1+1.21
17+
archives_base_name=blocking-component

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/btw/lowercase/blocking_component/Blocking.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import net.fabricmc.api.ModInitializer;
55

66
public class Blocking implements ModInitializer {
7-
@Override
8-
public void onInitialize() {
9-
Components.initalize();
10-
}
7+
@Override
8+
public void onInitialize() {
9+
Components.initalize();
10+
}
1111
}

src/main/java/btw/lowercase/blocking_component/component/Components.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import net.minecraft.registry.Registry;
66

77
public class Components {
8-
public static ComponentType<BlockingComponent> BLOCKING_COMPONENT_TYPE = ComponentType.<BlockingComponent>builder().codec(BlockingComponent.CODEC).build();
8+
public static ComponentType<BlockingComponent> BLOCKING = ComponentType.<BlockingComponent>builder().codec(BlockingComponent.CODEC).build();
99

1010
public static void initalize() {
11-
Registry.register(Registries.DATA_COMPONENT_TYPE, "blocking", Components.BLOCKING_COMPONENT_TYPE);
11+
Registry.register(Registries.DATA_COMPONENT_TYPE, "blocking", Components.BLOCKING);
1212
}
1313
}

src/main/java/btw/lowercase/blocking_component/mixin/entity/MixinLivingEntity.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,53 @@
55
import net.minecraft.entity.LivingEntity;
66
import net.minecraft.entity.damage.DamageSource;
77
import net.minecraft.item.ItemStack;
8-
import net.minecraft.item.ShieldItem;
98
import org.spongepowered.asm.mixin.Mixin;
109
import org.spongepowered.asm.mixin.Shadow;
1110
import org.spongepowered.asm.mixin.injection.At;
1211
import org.spongepowered.asm.mixin.injection.Inject;
13-
import org.spongepowered.asm.mixin.injection.ModifyVariable;
1412
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1513

1614
import java.util.Objects;
1715

1816
@Mixin(LivingEntity.class)
1917
public abstract class MixinLivingEntity {
20-
@Shadow public abstract ItemStack getActiveItem();
18+
@Shadow
19+
public abstract ItemStack getActiveItem();
2120

22-
@Shadow public abstract boolean isBlocking();
21+
@Shadow
22+
public abstract boolean isBlocking();
2323

24-
@Shadow public abstract ItemStack getMainHandStack();
24+
@Shadow
25+
public abstract ItemStack getMainHandStack();
2526

2627
@Inject(method = "blockedByShield", at = @At("RETURN"), cancellable = true)
2728
public void blockedByShield$denyDamageIfValueGreaterThanOrEqualToOne(DamageSource source, CallbackInfoReturnable<Boolean> cir) {
2829
ItemStack stack = this.getActiveItem();
29-
if (!stack.getComponents().contains(Components.BLOCKING_COMPONENT_TYPE)) {
30+
if (!stack.getComponents().contains(Components.BLOCKING)) {
3031
cir.setReturnValue(false);
3132
return;
3233
}
33-
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING_COMPONENT_TYPE));
34+
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING));
3435
cir.setReturnValue(isBlocking() && component.getDamageReduceMultiplier() == 1.0F);
3536
}
3637

37-
@ModifyVariable(method = "damage", at = @At("HEAD"), argsOnly = true, index = 2)
38-
public float damage$modifyAmount(float value) {
39-
ItemStack stack = this.getActiveItem();
40-
if (!stack.getComponents().contains(Components.BLOCKING_COMPONENT_TYPE) || !isBlocking())
41-
return value;
42-
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING_COMPONENT_TYPE));
43-
return value * component.getDamageReduceMultiplier();
44-
}
38+
// @ModifyVariable(method = "damage", at = @At("HEAD"), argsOnly = true, index = 2)
39+
// public DamageSource damage$modifyAmount(DamageSource damageSource) {
40+
// ItemStack stack = this.getActiveItem();
41+
// if (!stack.getComponents().contains(Components.BLOCKING) || !isBlocking())
42+
// return damageSource;
43+
// BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING));
44+
// return value * component.getDamageReduceMultiplier();
45+
// }
4546

4647
@Inject(method = "disablesShield", at = @At("RETURN"), cancellable = true)
4748
public void component$axeDisables(CallbackInfoReturnable<Boolean> cir) {
4849
ItemStack stack = this.getMainHandStack();
49-
if (!stack.getComponents().contains(Components.BLOCKING_COMPONENT_TYPE))
50-
return;
51-
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING_COMPONENT_TYPE));
52-
cir.setReturnValue(stack.getItem() instanceof ShieldItem && component.canAxeDisable());
50+
if (!stack.getComponents().contains(Components.BLOCKING)) {
51+
cir.setReturnValue(false);
52+
} else {
53+
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING));
54+
cir.setReturnValue(component.canAxeDisable());
55+
}
5356
}
5457
}

src/main/java/btw/lowercase/blocking_component/mixin/entity/MixinPlayerEntity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
@Mixin(PlayerEntity.class)
1616
public abstract class MixinPlayerEntity {
17-
@Shadow @NotNull public abstract ItemStack getWeaponStack();
17+
@Shadow
18+
@NotNull
19+
public abstract ItemStack getWeaponStack();
1820

19-
@ModifyArg(method = "disableShield", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ItemCooldownManager;set(Lnet/minecraft/item/Item;I)V"), index = 1)
21+
@ModifyArg(method = "disableShield", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ItemCooldownManager;set(Lnet/minecraft/item/ItemStack;I)V"), index = 1)
2022
public int component$disabledTicks(int duration) {
2123
ItemStack stack = this.getWeaponStack();
22-
if (!stack.getComponents().contains(Components.BLOCKING_COMPONENT_TYPE))
24+
if (!stack.getComponents().contains(Components.BLOCKING))
2325
return duration;
24-
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING_COMPONENT_TYPE));
26+
BlockingComponent component = Objects.requireNonNull(stack.getComponents().get(Components.BLOCKING));
2527
return component.getTotalDisabledTicks();
2628
}
2729
}

src/main/java/btw/lowercase/blocking_component/mixin/item/MixinItem.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import net.minecraft.entity.player.PlayerEntity;
77
import net.minecraft.item.Item;
88
import net.minecraft.item.ItemStack;
9+
import net.minecraft.item.consume.UseAction;
10+
import net.minecraft.util.ActionResult;
911
import net.minecraft.util.Hand;
10-
import net.minecraft.util.TypedActionResult;
11-
import net.minecraft.util.UseAction;
1212
import net.minecraft.world.World;
1313
import org.spongepowered.asm.mixin.Mixin;
1414
import org.spongepowered.asm.mixin.injection.At;
@@ -19,24 +19,24 @@
1919
public abstract class MixinItem {
2020
@Inject(method = "getUseAction", at = @At("RETURN"), cancellable = true)
2121
public void component$action(ItemStack stack, CallbackInfoReturnable<UseAction> cir) {
22-
if (!stack.contains(Components.BLOCKING_COMPONENT_TYPE) || stack.contains(DataComponentTypes.FOOD))
22+
if (!stack.contains(Components.BLOCKING) || stack.contains(DataComponentTypes.FOOD))
2323
return;
2424
cir.setReturnValue(UseAction.BLOCK);
2525
}
2626

2727
@Inject(method = "getMaxUseTime", at = @At("RETURN"), cancellable = true)
2828
public void component$useTime(ItemStack stack, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
29-
if (!stack.contains(Components.BLOCKING_COMPONENT_TYPE) || stack.contains(DataComponentTypes.FOOD))
29+
if (!stack.contains(Components.BLOCKING) || stack.contains(DataComponentTypes.FOOD))
3030
return;
3131
cir.setReturnValue(72000);
3232
}
3333

3434
@Inject(method = "use", at = @At("RETURN"), cancellable = true)
35-
public void component$use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
35+
public void component$use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
3636
ItemStack stack = user.getStackInHand(hand);
37-
if (stack.contains(Components.BLOCKING_COMPONENT_TYPE) && !stack.contains(DataComponentTypes.FOOD)) {
37+
if (stack.contains(Components.BLOCKING) && !stack.contains(DataComponentTypes.FOOD)) {
3838
user.setCurrentHand(hand);
39-
cir.setReturnValue(TypedActionResult.consume(stack));
39+
cir.setReturnValue(ActionResult.CONSUME);
4040
}
4141
}
4242
}

src/main/java/btw/lowercase/blocking_component/mixin/item/MixinShieldItem.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import net.minecraft.item.Item;
88
import net.minecraft.item.ItemStack;
99
import net.minecraft.item.ShieldItem;
10+
import net.minecraft.item.consume.UseAction;
11+
import net.minecraft.util.ActionResult;
1012
import net.minecraft.util.Hand;
11-
import net.minecraft.util.TypedActionResult;
12-
import net.minecraft.util.UseAction;
1313
import net.minecraft.world.World;
1414
import org.spongepowered.asm.mixin.Mixin;
1515
import org.spongepowered.asm.mixin.injection.At;
@@ -21,28 +21,28 @@
2121
public abstract class MixinShieldItem {
2222
@ModifyVariable(method = "<init>", at = @At("HEAD"), argsOnly = true, index = 1)
2323
private static Item.Settings component$default(Item.Settings settings) {
24-
return settings.component(Components.BLOCKING_COMPONENT_TYPE, new BlockingComponent());
24+
return settings.component(Components.BLOCKING, new BlockingComponent());
2525
}
2626

2727
@Inject(method = "getUseAction", at = @At("RETURN"), cancellable = true)
2828
public void component$action(ItemStack stack, CallbackInfoReturnable<UseAction> cir) {
29-
if (!stack.contains(Components.BLOCKING_COMPONENT_TYPE)) {
29+
if (!stack.contains(Components.BLOCKING)) {
3030
cir.setReturnValue(UseAction.NONE);
3131
}
3232
}
3333

3434
@Inject(method = "getMaxUseTime", at = @At("RETURN"), cancellable = true)
3535
public void component$useTime(ItemStack stack, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
36-
if (!stack.contains(Components.BLOCKING_COMPONENT_TYPE)) {
36+
if (!stack.contains(Components.BLOCKING)) {
3737
cir.setReturnValue(0);
3838
}
3939
}
4040

4141
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
42-
public void component$useTime(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
42+
public void component$useTime(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
4343
ItemStack stack = user.getStackInHand(hand);
44-
if (!stack.contains(Components.BLOCKING_COMPONENT_TYPE)) {
45-
cir.setReturnValue(TypedActionResult.pass(stack));
44+
if (!stack.contains(Components.BLOCKING)) {
45+
cir.setReturnValue(ActionResult.PASS);
4646
}
4747
}
4848
}

src/main/java/btw/lowercase/blocking_component/mixin/render/MixinHeldItemRenderer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public class MixinHeldItemRenderer {
2525
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25F));
2626
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(k * 13.365F));
2727
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(k * 78.05F));
28-
} else {
29-
// TODO: Go and remove the blocking model predicate from shield item to fix the issue
3028
}
3129
}
3230
}

0 commit comments

Comments
 (0)