Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gbl committed Jan 4, 2020
0 parents commit 9690598
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/de/guntram/mcmod/beenfo/Beenfo.java
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 src/main/java/de/guntram/mcmod/beenfo/mixin/TooltipMixin.java
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);
}
}
30 changes: 30 additions & 0 deletions src/main/resources/fabric.mod.json
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"
}
}
Binary file added src/main/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/main/resources/mixins.beenfo.json
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
}
}
6 changes: 6 additions & 0 deletions src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 4,
"description": "Beenfo"
}
}
Binary file added src/main/resources/pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9690598

Please sign in to comment.