Skip to content

Commit

Permalink
Merge pull request #1 from boterop/v0.1
Browse files Browse the repository at this point in the history
Release for v0.1.0
  • Loading branch information
boterop authored Jan 27, 2023
2 parents 7c01b96 + 00e7aa3 commit 703889d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 99 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
apply plugin: 'net.minecraftforge.gradle'


version = '1.0'
version = '0.1.0'
group = 'com.boterop.xphealth' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'xphealth'

Expand Down
27 changes: 3 additions & 24 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
# Changelog

## 0.7.0 (09.11.2022)
## 0.1.0 (27.01.2023)

* Added JSONPayload protocol
* Implemented JSONPayload protocol in [LocalRequestBody](https://github.com/kommitters/kadena.ex/issues/119)
* Implemented JSONPayload protocol in [SendRequestBody](https://github.com/kommitters/kadena.ex/issues/117)
* Implemented JSONPayload protocol in [PollRequestBody](https://github.com/kommitters/kadena.ex/issues/123)
* Implemented JSONPayload protocol in [ListenRequestBody](https://github.com/kommitters/kadena.ex/issues/124)
* Implemented JSONPayload protocol in [SPVRequestBody](https://github.com/kommitters/kadena.ex/issues/125)

## 0.6.1 (27.10.2022)

* Bump ossf/scorecard-action to v2.0.6

## 0.6.0 (26.10.2022)

* Added [Kadena Chainweb Client](https://github.com/kommitters/kadena.ex/issues/59) functions
* Added [Chainweb Pact Behaviour](https://github.com/kommitters/kadena.ex/issues/96)
* Added [Error struct](https://github.com/kommitters/kadena.ex/pull/111) for the `Chainweb.Client` boundary

## 0.5.0 (21.10.2022)

* Added [Kadena Pact](https://github.com/kommitters/kadena.ex/issues/55) functions
## 0.1.0 (26.01.2023)

* Initial release
* Initial release
* Mod working in single player
72 changes: 0 additions & 72 deletions src/main/java/com/boterop/xphealth/XPHealth.java
Original file line number Diff line number Diff line change
@@ -1,81 +1,9 @@
package com.boterop.xphealth;

import com.mojang.logging.LogUtils;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;

import java.util.stream.Collectors;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("xphealth")
public class XPHealth
{
// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();

public XPHealth()
{
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the enqueueIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);

// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}

private void setup(final FMLCommonSetupEvent event)
{
// some preinit code
LOGGER.info("HELLO FROM PREINIT");
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
}

private void enqueueIMC(final InterModEnqueueEvent event)
{
// Some example code to dispatch IMC to another mod
InterModComms.sendTo("xphealth", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
}

private void processIMC(final InterModProcessEvent event)
{
// Some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.messageSupplier().get()).
collect(Collectors.toList()));
}

// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event)
{
// Do something when the server starts
LOGGER.info("HELLO from server starting");
}

// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents
{
@SubscribeEvent
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
{
// Register a new block here
LOGGER.info("HELLO from Register Block");
}
}
}
48 changes: 48 additions & 0 deletions src/main/java/com/boterop/xphealth/events/XPEventHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.boterop.xphealth.events;

import java.util.Set;

import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerXpEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraft.world.entity.ai.attributes.Attributes;

@Mod.EventBusSubscriber(value = Dist.CLIENT, modid="xphealth", bus= Mod.EventBusSubscriber.Bus.FORGE)
public class XPEventHandler {
@SubscribeEvent
public static void onXPChange(PlayerXpEvent.XpChange event) {
updateHealth(event.getPlayer());
}

@SubscribeEvent
public static void onLogged(PlayerEvent.PlayerLoggedInEvent event) {
updateHealth(event.getPlayer());
}

private static void updateHealth(Player player)
{
int playerExp = player.experienceLevel;
float difficulty = 0.4f;
int hearts = (int) Math.floor(playerExp * difficulty);

hearts = hearts < 0 ? 0 : hearts;

AttributeModifier maxHealth = new AttributeModifier("MaxHealth", hearts, AttributeModifier.Operation.ADDITION);

AttributeInstance attributeInstance = player.getAttribute(Attributes.MAX_HEALTH);

Set<AttributeModifier> modifiers = attributeInstance.getModifiers();

if(modifiers.size() >= 1)
{
attributeInstance.removeModifiers();
}

attributeInstance.addPermanentModifier(maxHealth);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ license="All rights reserved"
[[mods]] #mandatory
modId="xphealth" #mandatory
version="${file.jarVersion}" #mandatory
displayName="XR Health" #mandatory
displayName="XP Health" #mandatory
logoFile="xphealth.png" #optional
credits="" #optional
authors="boterop" #optional
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "examplemod resources",
"description": "xphealth resources",
"pack_format": 9,
"forge:resource_pack_format": 8,
"forge:data_pack_format": 9
Expand Down

0 comments on commit 703889d

Please sign in to comment.