Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
// Needed for Forge+Fabric
id "architectury-plugin" version "3.4.146"
Expand Down Expand Up @@ -137,9 +139,11 @@ allprojects {
options.release = 17
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile).configureEach {
tasks.withType(KotlinJvmCompile).configureEach {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += "-Xjvm-default=all"

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package org.valkyrienskies.clockwork.mixin;
package org.valkyrienskies.clockwork.mixin.content.gas;

import com.simibubi.create.AllEnchantments;
import com.simibubi.create.content.equipment.armor.BacktankUtil;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.valkyrienskies.clockwork.ClockworkItems;
import org.valkyrienskies.clockwork.content.logistics.gas.backtank.GasBackTankItem;

@Mixin(BacktankUtil.class)
public class MixinBacktankUtil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package org.valkyrienskies.clockwork.mixin.content.gas;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import org.joml.Vector3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.valkyrienskies.clockwork.ClockworkMod;
import org.valkyrienskies.clockwork.content.logistics.gas.INodeBlock;
import org.valkyrienskies.clockwork.content.logistics.gas.duct.IDuct;
import org.valkyrienskies.clockwork.util.Vector3dUtilsKt;
import org.valkyrienskies.kelvin.KelvinMod;
import org.valkyrienskies.kelvin.api.*;
import org.valkyrienskies.kelvin.api.nodes.PipeDuctNode;
import org.valkyrienskies.kelvin.api.nodes.TankDuctNode;
import org.valkyrienskies.kelvin.impl.DuctNetworkServer;
import org.valkyrienskies.kelvin.impl.GasTypeRegistry;
import org.valkyrienskies.kelvin.util.KelvinExtensions;
import org.valkyrienskies.mod.common.VSGameUtilsKt;

import java.util.HashSet;
import java.util.Random;

@Mixin(ComposterBlock.class)
public class MixinComposterBlock extends Block implements INodeBlock {

@Unique
Double vs_clockwork$$maxPressure = 100000.0;


public MixinComposterBlock(Properties properties) {
super(properties);
}

@Inject(method = "tick", at = @At("HEAD"))
public void vs_clockwork$$tick(BlockState state, ServerLevel level, BlockPos pos, Random random, CallbackInfo ci) {
if (state.getValue(ComposterBlock.LEVEL) == 7) {
DuctNetwork kelvin = ClockworkMod.getKelvin();
ResourceLocation location = VSGameUtilsKt.getResourceKey(VSGameUtilsKt.getDimensionId(level)).location();
DuctNodePos ductNodePos = new DuctNodePos(pos.getX(), pos.getY(), pos.getZ(), location);

double pressure = kelvin.getPressureAt(ductNodePos);

GasType gas = GasTypeRegistry.INSTANCE.getGasType(KelvinMod.MOD_ID,"methane");

if (pressure <= vs_clockwork$$maxPressure && gas != null) {
kelvin.modGasMassOfTemperature(ductNodePos, gas, 10, 305);
}
}
}


@NotNull
@Override
public DuctNode createNode(@NotNull DuctNodePos pos) {
return new PipeDuctNode(pos, NodeBehaviorType.PIPE, new HashSet<>(),0.05, 16375049.0, 1478.0);
}

@Override
public boolean canConnectTo(@NotNull BlockPos self, @NotNull BlockPos other, @NotNull Direction direction, @NotNull BlockGetter level) {
return self.distSqr(other) <= 1.0 && direction != Direction.UP;
}

@Override
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
nodeRemove(pState, pLevel, pPos, pState, pIsMoving);
super.onRemove(pState, pLevel, pPos, pState, pIsMoving);
}

@Override
public void onPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
nodePlace(pState,pLevel,pPos,pState,pIsMoving);
super.onPlace(pState, pLevel, pPos, pState, pIsMoving);

}

@Override
public void nodePlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
if (!level.isClientSide()) {
if (state.isAir() || !(state.getBlock() instanceof INodeBlock)) {
return;
}
ClockworkMod.getKelvin().addNode(KelvinExtensions.INSTANCE.toDuctNodePos(pos, level.dimension().location()), createNode(KelvinExtensions.INSTANCE.toDuctNodePos(pos, level.dimension().location())));
}
}

@Override
public void nodeRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
if (!level.isClientSide()) {
if (newState.isAir() || !(newState.getBlock() instanceof INodeBlock)) {
ClockworkMod.getKelvin().removeNode(KelvinExtensions.INSTANCE.toDuctNodePos(pos, level.dimension().location()));
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ object ClockworkMod {

}

@JvmStatic
fun getKelvin(): DuctNetworkServer {
return KelvinMod.getKelvin() as DuctNetworkServer
}
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/resources/vs_clockwork-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"MixinAbstractContraptionEntity",
"MixinBacktankUtil",
"MixinBlockStateInfoProvider",
"MixinEntity",
"MixinLivingEntity",
Expand All @@ -15,6 +14,8 @@
"accessors.IMixinClockworkContraption",
"accessors.IMixinPistonContraption",
"content.fan.MixinEncasedFanTileEntity",
"content.gas.MixinBacktankUtil",
"content.gas.MixinComposterBlock",
"content.universal_joint.MixinRotationPropagator",
"content.wing.MixinAbstractCauldronBlock"
],
Expand Down