generated from Turnip-Labs/bta-example-mod
-
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.
- Loading branch information
Showing
12 changed files
with
201 additions
and
88 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/deus/stanleytemperature/StanleyRecipeRegistries.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,13 @@ | ||
package deus.stanleytemperature; | ||
|
||
import net.minecraft.core.data.registry.recipe.RecipeNamespace; | ||
import net.minecraft.core.data.registry.recipe.RecipeRegistry; | ||
|
||
public class StanleyRecipeRegistries extends RecipeRegistry { | ||
public static final RecipeNamespace STANLEY = new RecipeNamespace(); | ||
|
||
public StanleyRecipeRegistries() { | ||
|
||
} | ||
|
||
} |
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,4 +1,20 @@ | ||
package deus.stanleytemperature; | ||
|
||
import deus.stanleytemperature.items.StanleyItems; | ||
import net.minecraft.core.block.Blocks; | ||
import net.minecraft.core.item.Item; | ||
import turniplabs.halplibe.helper.RecipeBuilder; | ||
|
||
public class StanleyRecipes { | ||
public static void initialize() { | ||
|
||
RecipeBuilder.Shaped(StanleyTemperature.MOD_ID) | ||
.setShape( | ||
" ", | ||
"ppp", | ||
" ") | ||
.addInput('p', Blocks.PERMAFROST.asItem()) | ||
.create("StanleyRecipeIceCubes", StanleyItems.iceCubes.getDefaultStack()); | ||
|
||
} | ||
} |
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
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
6 changes: 6 additions & 0 deletions
6
src/main/java/deus/stanleytemperature/items/StanleyFoodType.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,6 @@ | ||
package deus.stanleytemperature.items; | ||
|
||
public enum StanleyFoodType { | ||
HOT, | ||
COLD | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/deus/stanleytemperature/items/StanleyItemFood.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,55 @@ | ||
package deus.stanleytemperature.items; | ||
|
||
import deus.stanleytemperature.StanleyTemperature; | ||
import deus.stanleytemperature.enums.PlayerTemperatureState; | ||
import deus.stanleytemperature.interfaces.IStanleyPlayerEntity; | ||
import net.minecraft.core.entity.player.Player; | ||
import net.minecraft.core.item.*; | ||
import net.minecraft.core.world.World; | ||
|
||
public class StanleyItemFood extends ItemFood { | ||
|
||
protected double sAmount; | ||
protected StanleyFoodType type; | ||
|
||
public StanleyItemFood(String name, String namespaceId, int id, int healAmount, int ticksPerHeal, boolean favouriteWolfMeat, int maxStackSize, double sAmount, StanleyFoodType type) { | ||
super(name, namespaceId, id, healAmount, ticksPerHeal, favouriteWolfMeat, maxStackSize); | ||
this.sAmount = sAmount; | ||
} | ||
|
||
@Override | ||
public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { | ||
|
||
PlayerTemperatureState state = ((IStanleyPlayerEntity) entityplayer).stanley$getState(); | ||
String soundEffect = this.getTicksPerHeal() >= 10 ? "random.bite_extended" : "random.bite"; | ||
|
||
boolean canConsumeIceCream = entityplayer.getHealth() < entityplayer.getMaxHealth() | ||
&& entityplayer.getHealth() + entityplayer.getTotalHealingRemaining() < entityplayer.getMaxHealth() | ||
&& itemstack.consumeItem(entityplayer); | ||
|
||
|
||
if (canConsumeIceCream) { | ||
entityplayer.eatFood(this); | ||
} | ||
|
||
|
||
if (StanleyFoodType.COLD.equals(type)) { | ||
((IStanleyPlayerEntity)entityplayer).stanley$decreasePlayerTemperature(sAmount); | ||
|
||
} else { | ||
((IStanleyPlayerEntity)entityplayer).stanley$increasePlayerTemperature(sAmount); | ||
|
||
} | ||
|
||
playSound(world, entityplayer, soundEffect); | ||
|
||
return new ItemStack(this, itemstack.stackSize-1); | ||
} | ||
|
||
// Helper method to play sound at the entity | ||
private void playSound(World world, Player entityplayer, String soundEffect) { | ||
world.playSoundAtEntity(entityplayer, entityplayer, soundEffect, | ||
0.5F + (itemRand.nextFloat() - itemRand.nextFloat()) * 0.1F, | ||
1.1F + (itemRand.nextFloat() - itemRand.nextFloat()) * 0.1F); | ||
} | ||
} |
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
Oops, something went wrong.