Add support for Buttons

Currently just a "Fill network" button
This commit is contained in:
Nicholas Ignoffo 2016-09-01 19:33:49 -07:00
parent 44cf949e91
commit 59135f5142
6 changed files with 73 additions and 2 deletions

View file

@ -0,0 +1,25 @@
package WayofTime.bloodmagic.compat.buttons;
import WayofTime.bloodmagic.compat.buttons.button.ButtonFillNetwork;
import net.minecraft.util.ResourceLocation;
import tehnut.buttons.api.ButtonsPlugin;
import tehnut.buttons.api.IWidgetPlugin;
import tehnut.buttons.api.IWidgetRegistry;
import tehnut.buttons.api.WidgetTexture;
@ButtonsPlugin
public class BloodMagicPlugin extends IWidgetPlugin.Base {
public static final WidgetTexture FILL_BUTTON = new WidgetTexture(
new ResourceLocation("bloodmagic", "textures/gui/buttons_compat.png"),
0,
0,
20,
20
);
@Override
public void register(IWidgetRegistry widgetRegistry) {
widgetRegistry.addUtilityButton(new ButtonFillNetwork());
}
}

View file

@ -0,0 +1,41 @@
package WayofTime.bloodmagic.compat.buttons.button;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.compat.buttons.BloodMagicPlugin;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import tehnut.buttons.api.button.utility.Button;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class ButtonFillNetwork extends Button {
public ButtonFillNetwork() {
super(BloodMagicPlugin.FILL_BUTTON);
setServerRequired();
}
@Nullable
@Override
public List<? extends ITextComponent> getTooltip() {
return Collections.singletonList(new TextComponentTranslation("button.bloodmagic.tooltip.fill"));
}
@Override
public void onServerClick(EntityPlayerMP player) {
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
network.setCurrentEssence(Integer.MAX_VALUE);
}
@Override
public ResourceLocation getButtonId() {
return new ResourceLocation(Constants.Mod.MODID, "button_fillnetwork");
}
}