Skip to content

Commit

Permalink
Config, solid fuel and automatic fluid input.
Browse files Browse the repository at this point in the history
The fluid input part may still be a bit buggy, but we've come a long
way.
  • Loading branch information
gazotti committed Mar 9, 2021
1 parent 82a7aed commit f2114c5
Show file tree
Hide file tree
Showing 11 changed files with 330 additions and 195 deletions.
42 changes: 22 additions & 20 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:\Users\gazotti\git\borkler\build\natives"/>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:\Users\gazotti\git\borkler\build\natives"/>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre8"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:\Users\gazotti\git\borkler\build\natives"/>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:\Users\gazotti\git\borkler\build\natives"/>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre8"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="lib" path="CraftTweaker-1.16.3-[7.0.0.48]_mapped_snapshot_20201028-1.16.3.jar"/>
<classpathentry kind="lib" path="ZenScript-1.0.0.jar"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
2 changes: 1 addition & 1 deletion .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=C\:/Program Files/jre8
java.home=/lib/jvm/java-8-openjdk
jvm.arguments=
offline.mode=false
override.workspace.settings=true
Expand Down
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Binary file added ZenScript-1.0.0.jar
Binary file not shown.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
runtimeOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:[7.1.0.141]")
runtimeOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.3:[7.0.0.48]")
}

version = '1.0'
Expand Down Expand Up @@ -148,11 +148,11 @@ jar {
manifest {
attributes([
"Specification-Title": "borkler",
"Specification-Vendor": "borklersareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"borklersareus",
"Specification-Vendor": "gazcreations",
"Specification-Version": "0.0.1", // We are version 1 of ourselves
"Implementation-Title": "borkler",
"Implementation-Version": "0.0.1",
"Implementation-Vendor" :"gazcreations",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/gazcreations/borkler/Borkler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package gazcreations.borkler;

import static net.minecraftforge.fml.loading.LogMarkers.FORGEMOD;

import java.util.HashSet;
import java.util.function.Supplier;

Expand All @@ -36,14 +34,14 @@
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
Expand Down Expand Up @@ -76,7 +74,7 @@ public class Borkler {
/**
* Just a constructor. Nothing to see here, move along.
* <p>
* JK. Here we set listeners for the basic methods of the mod, and may do other
* JK. Here we set listeners for the basic methods of the mod, register our config file, and may do other
* stuff. WIP.
* </p>
*/
Expand All @@ -85,13 +83,15 @@ public Borkler() {
// Register the setup method for modloading
BUS.addListener(this::setup);
// Register the enqueueIMC method for modloading
BUS.addListener(this::enqueueIMC);
//BUS.addListener(this::enqueueIMC);
// Register the processIMC method for modloading
BUS.addListener(this::processIMC);
//BUS.addListener(this::processIMC);
// Registers methods for running on the client only
DistExecutor.safeRunWhenOn(Dist.CLIENT, new ClientProxy());
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, BorklerConfig.SPEC,
"borkler.toml");

}

Expand All @@ -108,9 +108,14 @@ private void setup(final FMLCommonSetupEvent event) {
steamTypes.add(() -> Index.Fluids.STEAM);
steamTypes.add(() -> Index.Fluids.STEAMSOURCE);
FluidTags.createOptional(steam, steamTypes);
LOGGER.fatal(BorklerConfig.CONFIG.WATER_USE.get());
}

private void onPlayerLogin(final PlayerLoggedInEvent event) {
//generateServerBurnTimeConfig()
//sendServerBurnTimesToPlayers(List)
//updateClientBurnablesList
}

private void enqueueIMC(final InterModEnqueueEvent event) {
// some example code to dispatch IMC to another mod
// InterModComms.sendTo("borkler", "helloworld", () -> {
Expand Down
53 changes: 12 additions & 41 deletions src/main/java/gazcreations/borkler/BorklerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,11 @@
package gazcreations.borkler;

import java.io.File;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

import org.apache.commons.lang3.tuple.Pair;

import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.file.FileConfig;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.Builder;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.loading.FMLPaths;

public class BorklerConfig {
Expand All @@ -46,14 +38,16 @@ public class BorklerConfig {
.configure(BorklerConfig::new);
CONFIG = specPair.getKey();
SPEC = specPair.getValue();
SPEC.setConfig((CommentedConfig.copy(FileConfig.of(configPath))));
//SPEC.save();
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, SPEC,
"borkler.toml");

// SPEC.setConfig((CommentedConfig.copy(FileConfig.of(configPath))));
// SPEC.save();
/*
* ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.
* ModConfig.Type.COMMON, SPEC, "borkler.toml");
*/

}
//public final ForgeConfigSpec.Builder BUILDER;


public final ForgeConfigSpec.BooleanValue HUNGRY;

/**
*
Expand All @@ -71,48 +65,25 @@ public class BorklerConfig {
public final ForgeConfigSpec.DoubleValue CONVERSION_RATE;

protected BorklerConfig(ForgeConfigSpec.Builder builder) {
Borkler.LOGGER.fatal(configPath);
setup();
//BUILDER = builder;
// BUILDER.push("options");
HUNGRY = builder.comment(
"If true, the boiler will automatically attempt to pull burnable items from connected containers.")
.define("hungry", false);
THIRSTY = builder.comment(
"If true, the boiler will automatically attempt to pull water and fuel from connected suppliers.")
.define("thirsty", true);
WATER_USE = builder.comment("How much water will be consumed by a powered boiler, in mB/tick.")
.defineInRange("water_use", 25, 5, 500);
CONVERSION_RATE = builder.comment("The ratio of conversion of water into steam.")
.defineInRange("conversion_rate", 1.0, 0.1, 10.0);
// BUILDER.pop();
//SPEC = builder.build();

}

/*
* You know what? Fuck this shit. Forge is refusing to create a default config
* file with that constructor. Instead of figuring out why and doing so
* appropriately, i'm just going to hardcode the hell out of this shit. Sue me.
*/
public static void createDefaultFile() throws Exception {
final String content = "# If true, the boiler will automatically attempt to pull water and fuel from connected suppliers.\n"
+ "thirsty = true\n" + "# How much water will be consumed by a powered boiler, in mB/tick.\n"
+ "water_use = 25\n" + "# The ratio of conversion of water to steam.\n" + "conversion_ratio = 1.0\n";
Files.write(configPath, content.getBytes(), StandardOpenOption.CREATE);

}

public static void sendConfigToClient() {
}

protected final void setup() {
// Create the config folder
try {
if (!Files.exists(configPath))
createDefaultFile();
} catch (FileAlreadyExistsException e) {
// nice
} catch (Exception e) {
Borkler.LOGGER.error("An error has occurred while trying to create the Borkler config file.", e);
}

}
}
12 changes: 5 additions & 7 deletions src/main/java/gazcreations/borkler/blocks/BorklerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
import gazcreations.borkler.entities.BorklerTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.DirectionalBlock;
import net.minecraft.block.ILiquidContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.piglin.PiglinTasks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
Expand All @@ -40,7 +38,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
Expand Down Expand Up @@ -147,9 +144,9 @@ public boolean hasTileEntity(BlockState state) {
}

/**
* Executes a quick check to see if this block's new neighbor is a {@link TileEntity}. If so, forces this Borkler's {@link BorklerTileEntity} to update
* its list of possible adjacent FluidHandlers, regarding direction.
* <br>
* Executes a quick check to see if this block's new neighbor is a
* {@link TileEntity}. If so, forces this Borkler's {@link BorklerTileEntity} to
* update its list of possible adjacent FluidHandlers, regarding direction. <br>
* See {@link BorklerTileEntity#updateFluidConnections()}.
*/
@Override
Expand All @@ -163,7 +160,7 @@ public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos,
*/
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new BorklerTileEntity(world);
return new BorklerTileEntity(world);
}

/**
Expand Down Expand Up @@ -237,6 +234,7 @@ public boolean receiveFluid(IWorld arg0, BlockPos arg1, BlockState arg2, FluidSt
@Override
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
super.onBlockHarvested(worldIn, pos, state, player);
getTileEntity(worldIn, pos).remove();
InventoryHelper.dropInventoryItems(worldIn, pos, getTileEntity(worldIn, pos));
}

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/gazcreations/borkler/compat/BorklerTweaker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright 2021, B. Gazotti
*
* This file is part of Borkler.
*
* Borkler is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Borkler is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Borkler. If not, see <https://www.gnu.org/licenses/>.
*/

package gazcreations.borkler.compat;

/**
* So, I can't possibly know what y'all will want to fuel this bad boy.
* Hopefully, CraftTweaker allows for quick, in-game editing of recipes, and why
* not make our boiler extra steamy and versatile?
*
* @author gazotti
*
*/
public class BorklerTweaker {

public BorklerTweaker() {
// TODO Auto-generated constructor stub
}

}
Loading

0 comments on commit f2114c5

Please sign in to comment.