This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
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
0 parents
commit 9690598
Showing
7 changed files
with
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.guntram.mcmod.beenfo; | ||
|
||
import net.fabricmc.api.ClientModInitializer; | ||
|
||
|
||
public class Beenfo implements ClientModInitializer | ||
{ | ||
public static final String MODID = "beenfo"; | ||
public static final String MODNAME = "Beenfo"; | ||
public static final String VERSION = "1.15-fabric0.4.23-1.0"; | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/de/guntram/mcmod/beenfo/mixin/TooltipMixin.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,58 @@ | ||
package de.guntram.mcmod.beenfo.mixin; | ||
|
||
import java.util.List; | ||
import net.minecraft.client.item.TooltipContext; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.text.LiteralText; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(ItemStack.class) | ||
public abstract class TooltipMixin { | ||
|
||
@Shadow public abstract boolean isEmpty(); | ||
@Shadow public abstract Item getItem(); | ||
@Shadow public abstract CompoundTag getTag(); | ||
|
||
// @Inject(method="getTooltip(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/client/util/ITooltipFlag;)Ljava/util/List", | ||
@Inject(method="getTooltip", | ||
at=@At("RETURN"), locals=LocalCapture.CAPTURE_FAILHARD, cancellable=true) | ||
private void getTooltipdone(PlayerEntity playerIn, TooltipContext advanced, | ||
CallbackInfoReturnable<List> ci, | ||
List<Text> list) { | ||
|
||
try { | ||
if (!this.isEmpty() && (this.getItem() == Items.BEE_HIVE || this.getItem() == Items.BEE_NEST)) { | ||
CompoundTag tag = this.getTag(); | ||
if (tag != null) { | ||
String honeyLevel = tag.getCompound("BlockStateTag").getString("honey_level"); // wtf this is a string ??? | ||
int beeCount = tag.getCompound("BlockEntityTag").getList("Bees", 10).size(); | ||
list.add(new LiteralText(honeyLevel+" honey")); | ||
list.add(new LiteralText(beeCount+ " bees")); | ||
} | ||
} | ||
} catch (NullPointerException ex) { | ||
System.out.println("NPE in getTooltipdone"); | ||
try { | ||
Item item = this.getItem(); | ||
if (item == null) { | ||
System.out.println("item is null"); | ||
} else { | ||
System.out.println("item is "+this.getItem().getTranslationKey()); | ||
} | ||
} catch (NullPointerException ex2) { | ||
|
||
} | ||
} | ||
ci.setReturnValue(list); | ||
} | ||
} |
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,30 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "beenfo", | ||
"version": "1.15-fabric0.4.23-1.0", | ||
"environment": "client", | ||
"entrypoints": { | ||
"client": [ "de.guntram.mcmod.beenfo.Beenfo" ] | ||
}, | ||
"custom": { | ||
"modmenu:clientsideOnly": true | ||
}, | ||
"mixins": [ | ||
"mixins.beenfo.json" | ||
], | ||
"depends": { | ||
"fabric": "*" | ||
}, | ||
"recommends": { | ||
"modmenu" : "*" | ||
}, | ||
"name": "Beenfo", | ||
"description": "Adds a tooltip to bee nests and hives that shows how much honey, and how many bees, are contained.\n\n.If you like bees, and like this mod, please consider getting more information about them at https://beyondpesticides.org/programs/bee-protective-pollinators-and-pesticides/bee-protective.", | ||
"icon": "pack.png", | ||
"authors": [ "Giselbaer" ], | ||
"contact": { | ||
"homepage": "https://minecraft.curseforge.com/projects/beenfo", | ||
"sources": "https://github.com/gbl/Beenfo", | ||
"issues": "https://github.com/gbl/Beenfo/issues" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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, | ||
"package": "de.guntram.mcmod.beenfo.mixin", | ||
"refmap": "Beenfo-refmap.json", | ||
"minVersion": "0.6", | ||
"client": [ | ||
"TooltipMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"pack": { | ||
"pack_format": 4, | ||
"description": "Beenfo" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.