-
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.
Merge pull request #1 from boterop/v0.1
Release for v0.1.0
- Loading branch information
Showing
6 changed files
with
54 additions
and
99 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
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,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 |
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,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
48
src/main/java/com/boterop/xphealth/events/XPEventHandler.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,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); | ||
} | ||
} |
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