Skip to content

Commit

Permalink
Patchouli implementation started.
Browse files Browse the repository at this point in the history
Signed-off-by: SuperScary
  • Loading branch information
SuperScary committed Oct 26, 2024
1 parent 7832106 commit 19d5469
Show file tree
Hide file tree
Showing 27 changed files with 306 additions and 20 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ dependencies {
implementation("mcjty.theoneprobe:theoneprobe:${top_version}")

// PATCHOULI
implementation("vazkii.patchouli:Patchouli:${patchouli_version}")
compileOnly("vazkii.patchouli:Patchouli:${patchouli_version}:api")
localRuntime("vazkii.patchouli:Patchouli:${patchouli_version}")

}

Expand Down
18 changes: 13 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
org.gradle.jvmargs=-Xmx1G
#########################################################
# Gradle Options
#########################################################
org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true

#########################################################
# Minecraft versions
#########################################################
parchment_minecraft_version=1.21
parchment_mappings_version=2024.07.28

# Environment Properties
minecraft_version=1.21.1
minecraft_version_range=[1.21.1, 1.22)
neo_version=21.1.69
neo_version_range=[21.1.0,)
loader_version_range=[4,)

# Dependencies
#########################################################
# API versions
#########################################################
jei_version=19.21.0.246
top_version=1.21_neo-12.0.4-6
patchouli_version=1.21-87-NEOFORGE

## Mod Properties
#########################################################
# Mod version
#########################################################
mod_id=fluxmachines
mod_name=Flux Machines
mod_license=All Rights Reserved
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.superscary.fluxmachines.api.energy;

public interface Decays {

int decayPercentageChance ();

int decayAmount ();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.superscary.fluxmachines.api.energy;

public interface EnergyDecay {

default void decayEnergy (int decay, FMEnergyStorage storage) {
if (storage.getEnergyStored() > 0) {
storage.setStored(storage.getEnergyStored() - decay);
}
}

default void decayEnergy (int decay, FMEnergyStorage storage, int maxDecay) {
if (storage.getEnergyStored() > 0) {
storage.setStored(storage.getEnergyStored() - Math.min(decay, maxDecay));
}
}

default void decayEnergy (int decay, FMEnergyStorage storage, int maxDecay, int minDecay) {
if (storage.getEnergyStored() > 0) {
storage.setStored(storage.getEnergyStored() - Math.min(Math.max(decay, minDecay), maxDecay));
}
}

default boolean decayChance (int chance) {
return Math.random() * 100 < chance;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.superscary.fluxmachines.api.energy.Decays;
import net.superscary.fluxmachines.api.energy.EnergyDecay;
import net.superscary.fluxmachines.api.energy.FMEnergyStorage;
import net.superscary.fluxmachines.block.base.FMBaseEntityBlock;
import net.superscary.fluxmachines.core.registries.FMDataComponents;
import net.superscary.fluxmachines.core.util.keys.Keys;
import org.jetbrains.annotations.Nullable;

public abstract class FMBasePoweredBlockEntity extends FMBaseBlockEntity {
public abstract class FMBasePoweredBlockEntity extends FMBaseBlockEntity implements EnergyDecay, Decays {

private final FMEnergyStorage energyStorage;
private int energy = 0;
Expand Down Expand Up @@ -66,7 +68,12 @@ public InteractionResult disassemble (Player player, Level level, BlockHitResult
return super.disassemble(player, level, hitResult, stack, itemstack);
}

public abstract void tick (Level pLevel, BlockPos pPos, BlockState pState);
public void tick (Level pLevel, BlockPos pPos, BlockState pState) {
if (decayChance(decayPercentageChance())) {
decayEnergy(decayAmount(), getEnergyStorage());
}
setChanged();
}

@Override
public void setData (ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public void loadClientData (CompoundTag tag, HolderLookup.Provider registries) {

@Override
public void tick (Level pLevel, BlockPos pPos, BlockState pState) {
var block = (FluxFurnaceBlock) pState.getBlock();
if (TESTING) getEnergyStorage().receiveEnergy(10000, false); // TODO: not for production
if (hasRecipe()) {
isCrafting = true;
Expand All @@ -97,7 +96,7 @@ public void tick (Level pLevel, BlockPos pPos, BlockState pState) {
isCrafting = false;
progress = 0;
}
setChanged();
super.tick(pLevel, pPos, pState);
}

@Override
Expand Down Expand Up @@ -188,4 +187,13 @@ public int getScaledProgress () {
return max != 0 && progress != 0 ? progress * arrowSize / max : 0;
}

@Override
public int decayPercentageChance () {
return 30;
}

@Override
public int decayAmount () {
return 4;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ protected void misc () {
add("gui.fluxmachines.itemlist", "Slot %s: %sx %s");
add("gui.fluxmachines.press_shift", "Hold §e[SHIFT]§r for more info.");

add("item.fluxmachines.patchouli.book.name", "Flux Machines");
add("item.fluxmachines.patchouli.book.subtitle", "Flux Machines & You");

add("armor.status.effect.tooltip", "§7§nFull Set Status Effect:§r");
add("armor.status.effect.kb2.tooltip", "§8- Knockback II§r");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.level.block.Blocks;
import net.neoforged.neoforge.common.Tags;
import net.superscary.fluxmachines.core.FluxMachines;
import net.superscary.fluxmachines.core.registries.FMItems;
import net.superscary.fluxmachines.core.util.tags.FMTag;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -52,7 +53,7 @@ protected void misc (RecipeOutput consumer) {
.pattern("D D")
.pattern(" G ")
.pattern(" D ")
.define('D', FMTag.Items.STEEL)
.define('D', STEEL_INGOT)
.define('G', Items.GOLD_INGOT)
.unlockedBy("has_steel", has(STEEL_INGOT))
.save(consumer, FluxMachines.getResource("tool/wrench"));
Expand Down Expand Up @@ -91,7 +92,7 @@ protected void machineParts (RecipeOutput consumer) {
.pattern("WGW")
.pattern("DWD")
.define('D', STEEL_INGOT)
.define('W', ItemTags.PLANKS)
.define('W', Items.IRON_INGOT)
.define('G', Tags.Items.GLASS_BLOCKS)
.unlockedBy("has_steel_ingot", has(STEEL_INGOT))
.save(consumer, FluxMachines.getResource("machine_part/machine_casing"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Armor",
"description": "A suit of armor to protect you from the dangers of the world. Full steel armor adds Knockback Resistance II.",
"icon": "fluxmachines:steel_helmet",
"sortnum": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Basic Concepts",
"description": "Some basic concepts for $(fm).",
"icon": "minecraft:knowledge_book",
"sortnum": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Machines",
"description": "The backbone of Flux Machines. Create automated systems, massive power generation, and more.",
"icon": "fluxmachines:flux_furnace",
"sortnum": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Tools",
"description": "These tools will make your life a lot easier.",
"icon": "fluxmachines:wrench",
"sortnum": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Steel Boots",
"icon": "fluxmachines:steel_boots",
"category": "fluxmachines:armor",
"pages": [
{
"type": "text",
"text": "Steel Boots are a piece of armor that provides protection to the player. It is crafted using Steel Ingots, and provides more protection than a regular Iron Boots."
},
{
"type": "patchouli:crafting",
"recipe": "fluxmachines:armor/steel_boots",
"text": "Steel Boots can be crafted using the following recipe: 4 Steel Ingots."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Steel Chestplate",
"icon": "fluxmachines:steel_chestplate",
"category": "fluxmachines:armor",
"pages": [
{
"type": "text",
"text": "The Steel Chestplate is a piece of armor that provides protection to the player. It is crafted using Steel Ingots, and provides more protection than a regular Iron Chestplate."
},
{
"type": "patchouli:crafting",
"recipe": "fluxmachines:armor/steel_chestplate",
"text": "The Steel Chestplate can be crafted using the following recipe: 8 Steel Ingots."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Steel Helmet",
"icon": "fluxmachines:steel_helmet",
"category": "fluxmachines:armor",
"pages": [
{
"type": "text",
"text": "The Steel Helmet is a piece of armor that provides protection to the player. It is crafted using Steel Ingots, and provides more protection than a regular Iron Helmet."
},
{
"type": "patchouli:crafting",
"recipe": "fluxmachines:armor/steel_helmet",
"text": "The Steel Helmet can be crafted using the following recipe: 5 Steel Ingots."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Steel Leggings",
"icon": "fluxmachines:steel_leggings",
"category": "fluxmachines:armor",
"pages": [
{
"type": "text",
"text": "Steel Leggings are piece of armor that provides protection to the player. It is crafted using Steel Ingots, and provides more protection than a regular Iron Leggings."
},
{
"type": "patchouli:crafting",
"recipe": "fluxmachines:armor/steel_leggings",
"text": "Steel Leggings can be crafted using the following recipe: 7 Steel Ingots."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Energy Decay",
"icon": "minecraft:nether_star",
"category": "fluxmachines:basics",
"pages": [
{
"type": "text",
"text": "Energy Decay is a mechanic in Flux Machines that causes energy to be lost when transferring power over long distances or when a machine is powered and working/idle. Energy Decay is caused by the resistance of the power transfer method, and can be reduced by using better cables and power transfer methods."
},
{
"type": "text",
"text": "Energy Decay can be reduced by using Flux Cables, which have a lower resistance than other power transfer methods. Energy Decay can be reduced by using energy storage blocks, such as batteries and energy cells, to store energy and reduce the amount of energy lost. Machines can be modified to reduce Energy Decay by using energy efficiency upgrades, which reduce the amount of energy lost when working/idle. "
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Forge Energy (FE)",
"icon": "minecraft:nether_star",
"category": "fluxmachines:basics",
"pages": [
{
"type": "text",
"text": "Forge Energy (FE) is a power system used by many mods in Minecraft. It is a universal power system that can be used to power machines and other devices. Forge Energy is measured in FE, and can be transferred using cables and other power transfer methods. Flux Machines uses Forge Energy as its power system. "
},
{
"type": "text",
"text": "Forge Energy can be generated using various methods, such as generators, solar panels, and other power sources. It can be stored in energy storage blocks, such as batteries and energy cells. Forge Energy can be transferred using cables, such as Flux Cables, and other power transfer methods."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Getting Started",
"icon": "minecraft:nether_star",
"category": "fluxmachines:basics",
"priority": "true",
"pages": [
{
"type": "text",
"text": "Hey $(playername)! Welcome to $(fm). Flux Machines is a mod about automation and ease of life. In this book, you will learn about the basics of Flux Machines and how to get started with the mod. Let's get started!"
},
{
"type": "text",
"text": "Flux Machines is a mod that adds new machines, blocks, and items to Minecraft. These machines can be used to automate tasks, such as ore processing, item sorting, and energy generation. Flux Machines is designed to be easy to use and understand, with a focus on simplicity and efficiency with a touch of complexity. To get started, smelt some Iron Ingots in a furnace!"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Flux Furnace",
"icon": "fluxmachines:flux_furnace",
"category": "fluxmachines:machines",
"pages": [
{
"type": "text",
"text": "The Flux Furnace is a machine that can smelt items at a faster rate than a regular furnace. It requires FE to operate, and can be upgraded to smelt items even faster."
},
{
"type": "text",
"text": "The Flux Furnace has 3 upgrade slots, which can be used to upgrade the speed of the furnace. The upgrades can be crafted and placed in the upgrade slots to increase the speed of the furnace."
},
{
"type": "text",
"text": "The Flux Furnace can be powered by connecting it to a Flux Generator or any other FE power source. The Flux Furnace will not work without power."
},
{
"type": "patchouli:crafting",
"recipe": "fluxmachines:machine/flux_furnace",
"text": "The Flux Furnace can be crafted using the following recipe: 6 Steel Ingots, 1 Furnace, 1 Redstone Torch, 1 Machine Casing."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Machine Casing",
"icon": "fluxmachines:machine_casing",
"category": "fluxmachines:machines",
"pages": [
{
"type": "text",
"text": "The Machine Casing is a block that is used to craft machines in the Flux Machines mod. It is used as the basis for all mechanical machines."
},
{
"type": "patchouli:crafting",
"recipe": "fluxmachines:machine_part/machine_casing",
"text": "The Flux Furnace can be crafted using the following recipe: 4 Steel Ingots, 4 Iron Ingots, 1 Glass."
}
]
}
Loading

0 comments on commit 19d5469

Please sign in to comment.