-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mixin processor for PowderSnowBlock
Signed-off-by: AlasDiablo <[email protected]>
- Loading branch information
1 parent
7a61a0c
commit 7bdfb2b
Showing
6 changed files
with
86 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/fr/alasdiablo/diolib/mixin/PowderSnowBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fr.alasdiablo.diolib.mixin; | ||
|
||
import fr.alasdiablo.diolib.tag.DioTags; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.level.block.PowderSnowBlock; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(value = PowderSnowBlock.class, priority = 0) | ||
public class PowderSnowBlockMixin { | ||
|
||
@Inject(method = "canEntityWalkOnPowderSnow", at = @At("RETURN"), cancellable = true) | ||
private static void canEntityWalkOnPowderSnow(Entity entity, @NotNull CallbackInfoReturnable<Boolean> callback) { | ||
if (!callback.getReturnValue()) { | ||
if (entity instanceof LivingEntity livingEntity) { | ||
var boots = livingEntity.getItemBySlot(EquipmentSlot.FEET); | ||
if (DioTags.BOOTS_WALK_ON_POWDER_SNOW.contains(boots.getItem())) { | ||
callback.setReturnValue(true); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.alasdiablo.diolib.tag; | ||
|
||
import fr.alasdiablo.diolib.DiaboloLib; | ||
import fr.alasdiablo.diolib.registries.RegistryHelper; | ||
import net.minecraft.tags.ItemTags; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraftforge.common.Tags; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DioTags { | ||
public static final Tags.IOptionalNamedTag<Item> BOOTS_WALK_ON_POWDER_SNOW = tag("boots_walk_on_powder_snow"); | ||
|
||
public static void init() {} | ||
|
||
private static @NotNull Tags.IOptionalNamedTag<Item> tag(String name) { | ||
return ItemTags.createOptional(RegistryHelper.rl(DiaboloLib.MOD_ID, name)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"minVersion": "0.8", | ||
"required": true, | ||
"compatibilityLevel": "JAVA_17", | ||
"refmap": "diolib.mixins.refmap.json", | ||
"package": "fr.alasdiablo.diolib.mixin", | ||
"mixins": [ | ||
"PowderSnowBlockMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |