generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
106 additions
and
0 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
Empty file.
24 changes: 24 additions & 0 deletions
24
...n/java/io/github/fabricators_of_create/porting_lib/blocks/extensions/OnExplodedBlock.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,24 @@ | ||
package io.github.fabricators_of_create.porting_lib.blocks.extensions; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.Explosion; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public interface OnExplodedBlock { | ||
/** | ||
* Called when the block is destroyed by an explosion. | ||
* Useful for allowing the block to take into account tile entities, | ||
* state, etc. when exploded, before it is removed. | ||
* | ||
* @param level The current level | ||
* @param pos Block position in level | ||
* @param explosion The explosion instance affecting the block | ||
*/ | ||
default void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) { | ||
level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); | ||
((Block) this).wasExploded(level, pos, explosion); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...rc/main/java/io/github/fabricators_of_create/porting_lib/blocks/mixin/ExplosionMixin.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,35 @@ | ||
package io.github.fabricators_of_create.porting_lib.blocks.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
|
||
import io.github.fabricators_of_create.porting_lib.blocks.extensions.OnExplodedBlock; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.Explosion; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
@Mixin(Explosion.class) | ||
public class ExplosionMixin { | ||
@WrapOperation(method = "finalizeExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;wasExploded(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/Explosion;)V")) | ||
private void onBlockExploded(Block instance, Level level, BlockPos blockPos, Explosion explosion, Operation<Void> original, @Local(index = 7) BlockState state) { | ||
if (state.getBlock() instanceof OnExplodedBlock onExplodedBlock) { | ||
onExplodedBlock.onBlockExploded(state, level, blockPos, explosion); | ||
} else { | ||
original.call(instance, level, blockPos, explosion); | ||
} | ||
} | ||
|
||
@WrapWithCondition(method = "finalizeExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) | ||
private boolean dontSetBlockOnCustom(Level level, BlockPos pos, BlockState airState, int flag, @Local(index = 7) BlockState state) { | ||
if (state.getBlock() instanceof OnExplodedBlock) | ||
return false; | ||
return 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,7 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "porting_lib_blocks", | ||
"version": "${version}", | ||
"name": "Porting Lib Blocks", | ||
"description": "Adds extra block extensions." | ||
} |
12 changes: 12 additions & 0 deletions
12
modules/blocks/src/main/resources/porting_lib_blocks.mixins.json
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,12 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "io.github.fabricators_of_create.porting_lib.blocks.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"injectors": { | ||
"defaultRequire": 1 | ||
}, | ||
"mixins": [ | ||
"ExplosionMixin" | ||
] | ||
} |
Empty file.
10 changes: 10 additions & 0 deletions
10
...ils/src/main/java/io/github/fabricators_of_create/porting_lib/gui/utils/ModdedButton.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,10 @@ | ||
package io.github.fabricators_of_create.porting_lib.gui.utils; | ||
|
||
import net.minecraft.client.gui.components.Button; | ||
|
||
public class ModdedButton extends Button { | ||
protected ModdedButton(Builder builder) { | ||
super(builder.x, builder.y, builder.width, builder.height, builder.message, builder.onPress, builder.createNarration); | ||
setTooltip(builder.tooltip); // Forge: Make use of the Builder tooltip | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "porting_lib_gui_utils", | ||
"version": "${version}", | ||
"name": "Porting Lib Gui Utils", | ||
"description": "Adds additional utility classes and methods for screens and guis." | ||
} |
9 changes: 9 additions & 0 deletions
9
modules/gui_utils/src/main/resources/porting_lib_gui_utils.accesswidener
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,9 @@ | ||
accessWidener v2 named | ||
accessible field net/minecraft/client/gui/components/Button$Builder message Lnet/minecraft/network/chat/Component; | ||
accessible field net/minecraft/client/gui/components/Button$Builder onPress Lnet/minecraft/client/gui/components/Button$OnPress; | ||
accessible field net/minecraft/client/gui/components/Button$Builder tooltip Lnet/minecraft/client/gui/components/Tooltip; | ||
accessible field net/minecraft/client/gui/components/Button$Builder x I | ||
accessible field net/minecraft/client/gui/components/Button$Builder y I | ||
accessible field net/minecraft/client/gui/components/Button$Builder width I | ||
accessible field net/minecraft/client/gui/components/Button$Builder height I | ||
accessible field net/minecraft/client/gui/components/Button$Builder createNarration Lnet/minecraft/client/gui/components/Button$CreateNarration; |