-
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.
refactor: fishing is FishingHelper now; refactor: Event for cancellin…
…g block breaking in creative;
- Loading branch information
Showing
12 changed files
with
204 additions
and
327 deletions.
There are no files selected for viewing
13 changes: 6 additions & 7 deletions
13
src/main/java/io/github/mjaroslav/mjutils/asm/mixin/MixinForgeHooks.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 |
---|---|---|
@@ -1,23 +1,22 @@ | ||
package io.github.mjaroslav.mjutils.asm.mixin; | ||
|
||
import io.github.mjaroslav.mjutils.event.BlockDestroyedInCreativeEvent; | ||
import io.github.mjaroslav.mjutils.event.player.PlayerDestroyBlockInCreativeEvent; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.common.ForgeHooks; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ForgeHooks.class) | ||
public abstract class MixinForgeHooks { | ||
// Disabling block breaking for configurable items in creative mode | ||
@Redirect(method = "onBlockBreakEvent", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;", | ||
ordinal = 0)) | ||
private static Item injected(ItemStack stack) { | ||
return MinecraftForge.EVENT_BUS.post(new BlockDestroyedInCreativeEvent(stack)) ? | ||
@Redirect(method = "onBlockBreakEvent", at = @At(value = "INVOKE", ordinal = 0, | ||
target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;")) | ||
private static @NotNull Item overrideCreativeBlockBreakCancellingByEvent(@NotNull ItemStack stack) { | ||
return MinecraftForge.EVENT_BUS.post(new PlayerDestroyBlockInCreativeEvent(stack)) ? | ||
Items.diamond_sword : Items.stick; | ||
} | ||
} |
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
67 changes: 0 additions & 67 deletions
67
src/main/java/io/github/mjaroslav/mjutils/event/FishingSuccessEvent.java
This file was deleted.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
src/main/java/io/github/mjaroslav/mjutils/event/world/FishingSuccessEvent.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,32 @@ | ||
package io.github.mjaroslav.mjutils.event.world; | ||
|
||
import cpw.mods.fml.common.eventhandler.Cancelable; | ||
import cpw.mods.fml.common.eventhandler.Event; | ||
import lombok.AllArgsConstructor; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.projectile.EntityFishHook; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.common.FishingHooks.FishableCategory; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.jetbrains.annotations.Range; | ||
|
||
@AllArgsConstructor | ||
@Cancelable | ||
public class FishingSuccessEvent extends Event { | ||
public final @Nullable Entity fisher; | ||
public final @NotNull EntityFishHook fishHook; | ||
public @Nullable FishableCategory category; | ||
public @Nullable ItemStack itemStack; | ||
public int experience; | ||
@Range(from = 0, to = 1) | ||
public final float chance; | ||
public final int luck; | ||
public final int lure; | ||
public boolean incStat; | ||
|
||
@Override | ||
public boolean isCanceled() { | ||
return super.isCanceled() || category == null || itemStack == null; | ||
} | ||
} |
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
Oops, something went wrong.