This commit is contained in:
DrMangoTea
2025-05-10 21:40:22 +02:00
parent 304d3fb9ac
commit 2b1120cf38
101 changed files with 19891 additions and 20696 deletions

View File

@@ -27,6 +27,16 @@ public class TFMGShapes {
.add(0, 5, -1, 3, 7, 1)
.add(15, 5, 9, 15, 11, 9)
.forDirectional(NORTH),
TURBINE_ENGINE_FRONT = shape(2, 2, 0, 14, 14, 16)
.add(3, 0, 8, 13, 2, 16)
.forHorizontal(SOUTH),
TURBINE_ENGINE_MIDDLE = shape(11, 0, 2, 16, 5, 14)
.add(1, 1, 0, 15, 15, 16)
.add(0, 0, 2, 5, 5, 14)
.forHorizontal(SOUTH),
TURBINE_ENGINE_BACK = shape(5.3, 0, 5, 11.3, 3, 14)
.add(3, 3, 2, 13, 13, 16)
.forHorizontal(SOUTH),
ENGINE_CONTROLLER = shape(0, 0, 0, 4, 5, 16)
.add(2, 5, 5, 14, 12, 14)
.add(4, 0, 5, 15, 5, 16)

View File

@@ -8,7 +8,6 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
@@ -31,7 +30,6 @@ public class ElectricBlockEntity extends SmartBlockEntity implements IElectric,
}
@Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
}
@@ -60,14 +58,14 @@ public class ElectricBlockEntity extends SmartBlockEntity implements IElectric,
@Override
public void lazyTick() {
super.lazyTick();
if(data.failTimer >=4){
this.blockFail();
data.failTimer = 0;
sendStuff();
} else if((data.voltage>getMaxVoltage()&&getMaxVoltage()>0)||(getCurrent()>getMaxCurrent()&&getMaxCurrent()>0)){
blockFail();
data.failTimer++;
}
//if (data.failTimer >= 4) {
// this.blockFail();
// data.failTimer = 0;
// sendStuff();
//} else if ((data.voltage > getMaxVoltage() && getMaxVoltage() > 0) || (getCurrent() > getMaxCurrent())) {
// blockFail();
// data.failTimer++;
//}
}
@Override
@@ -118,7 +116,9 @@ public class ElectricBlockEntity extends SmartBlockEntity implements IElectric,
for (Direction direction : Direction.values()) {
if (hasElectricitySlot(direction)) {
if (level.getBlockEntity(getBlockPos().relative(direction)) instanceof VoltageAlteringBlockEntity be) {
if (level.getBlockEntity(getBlockPos().relative(direction)) instanceof VoltageAlteringBlockEntity be&&be.canWork()) {
if (be.getData().getId() != getData().getId())
if (be.getData().getVoltage() != 0)
if (be.hasElectricitySlot(direction)) {

View File

@@ -1,5 +1,9 @@
package com.drmangotea.tfmg.content.electricity.base;
import com.drmangotea.tfmg.content.electricity.utilities.diode.ElectricDiodeBlockEntity;
import com.drmangotea.tfmg.content.electricity.utilities.electric_motor.ElectricMotorBlockEntity;
import com.drmangotea.tfmg.content.electricity.utilities.transformer.TransformerBlockEntity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -54,7 +58,9 @@ public class ElectricalNetwork {
int powerPercentage = resistance > 0 ? (int) (Math.min(((float) power / (float) resistance * 100f), 100)) : 100;
for (IElectric member : members) {
List<IElectric> list = new ArrayList<>(members);
for (IElectric member : list) {
int oldVoltage = member.getData().getVoltage();
int oldPower = member.getPowerUsage();
@@ -76,16 +82,23 @@ public class ElectricalNetwork {
for (IElectric member : members) {
member.getData().highestCurrent = getCableCurrent(member);
member.updateNearbyNetworks(member);
if (member instanceof KineticElectricBlockEntity be)
be.updateGeneratedRotation();
// if (member instanceof KineticElectricBlockEntity be) {
// be.updateGeneratedRotation();
// }
}
if (!members.isEmpty())
if (members.get(0).getNetworkPowerUsage() > members.get(0).getNetworkPowerGeneration()) {
for (IElectric member : members) {
member.getData().notEnoughtPower = true;
if (member instanceof KineticElectricBlockEntity be)
if (member instanceof ElectricMotorBlockEntity be) {
be.updateGeneratedRotation();
be.preventSpeedUpdate = 20;
}
if (member instanceof ElectricDiodeBlockEntity be)
be.updateInFront=true;
if (member instanceof TransformerBlockEntity be)
be.updateInFront();
}
}
}

View File

@@ -5,6 +5,7 @@ import com.drmangotea.tfmg.base.TFMGUtils;
import com.drmangotea.tfmg.registry.TFMGPackets;
import com.simibubi.create.foundation.utility.CreateLang;
import net.createmod.catnip.theme.Color;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -76,7 +77,6 @@ public interface IElectric {
default void onConnected() {
BlockPos pos = BlockPos.of(getPos());
for (Direction d : Direction.values()) {
if (hasElectricitySlot(d))
@@ -98,7 +98,6 @@ public interface IElectric {
}
sendStuff();
}
@@ -107,6 +106,12 @@ public interface IElectric {
.style(ChatFormatting.WHITE)
.forGoggles(tooltip);
if(getData().notEnoughtPower) {
CreateLang.text("NOT ENOUGHT POWER")
.color(Color.RED)
.forGoggles(tooltip, 1);
// return true;
}
if (voltageGeneration() > 0) {
CreateLang.translate("multimeter.power_generated")
.add(Component.literal(TFMGUtils.formatUnits(powerGeneration(), "W")))
@@ -121,9 +126,6 @@ public interface IElectric {
.forGoggles(tooltip);
}
CreateLang.text(" R = " + TFMGUtils.formatUnits(voltageGeneration() > 0 ? getGeneratorResistance() : resistance(), "Ω"))
.color(0xc98969)
.forGoggles(tooltip, 1);
@@ -146,6 +148,20 @@ public interface IElectric {
.forGoggles(tooltip, 1);
}
if(isPlayerSneaking) {
CreateLang.text("----------------------------")
.style(ChatFormatting.WHITE)
.forGoggles(tooltip);
CreateLang.text("Network Power Generation: " + TFMGUtils.formatUnits(getNetworkPowerGeneration(), "W"))
.color(0xcc4b74)
.forGoggles(tooltip, 1);
CreateLang.text("Network Power Consumption: " + TFMGUtils.formatUnits(getNetworkPowerUsage(), "W"))
.color(0xcc4b74)
.forGoggles(tooltip, 1);
}
return true;
}
@@ -170,7 +186,7 @@ public interface IElectric {
}
default void blockFail() {
getLevelAccessor().destroyBlock(BlockPos.of(getPos()), false);
//getLevelAccessor().destroyBlock(BlockPos.of(getPos()), false);
}
default int getPowerUsage() {
@@ -207,6 +223,10 @@ public interface IElectric {
default float getGeneratorResistance() {
if (getData().voltageSupply == 0)
return 0;
if((float) getData().networkPowerGeneration * (float) getNetworkResistance()==0)
return 0;
return (float) powerGeneration() / (float) getData().networkPowerGeneration * (float) getNetworkResistance();
}

View File

@@ -31,6 +31,8 @@ public class KineticElectricBlockEntity extends GeneratingKineticBlockEntity imp
data.connectNextTick = true;
}
//@Override
//public boolean addToTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
// CreateLang.text("MAX POWER: "+getNetworkPowerGeneration()).forGoggles(tooltip);
@@ -224,12 +226,12 @@ public class KineticElectricBlockEntity extends GeneratingKineticBlockEntity imp
public void tick() {
super.tick();
if(timer == 2){
updateNextTick();
}
if(timer<=2){
timer++;
}
//if(timer == 2){
// updateNextTick();
//}
//if(timer<=2){
// timer++;
//}
if(data.connectNextTick) {
@@ -270,11 +272,17 @@ public class KineticElectricBlockEntity extends GeneratingKineticBlockEntity imp
}
@Override
public void onSpeedChanged(float previousSpeed) {
super.onSpeedChanged(previousSpeed);
updateNextTick();
TFMG.LOGGER.debug("SPEEED CHANGED "+getBlockPos().getX()+" "+getBlockPos().getY()+" "+getBlockPos().getZ());
notifyNetworkAboutSpeedChange();
timer = 0;
}
public void notifyNetworkAboutSpeedChange(){
updateNextTick();
}
}

View File

@@ -28,6 +28,7 @@ public class UpdateInFrontPacket extends BlockEntityDataPacket<SmartBlockEntity>
if(blockEntity instanceof ElectricDiodeBlockEntity be) {
be.updateInFrontNextTick();
}
}

View File

@@ -1,16 +1,12 @@
package com.drmangotea.tfmg.content.electricity.electrians_wrench;
package com.drmangotea.tfmg.content.electricity.configuration_wrench;
import com.drmangotea.tfmg.base.TFMGUtils;
import com.drmangotea.tfmg.content.electricity.base.IElectric;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public class ElectricBlockItem extends BlockItem {
public ElectricBlockItem(Block p_40565_, Properties p_40566_) {

View File

@@ -1,15 +1,11 @@
package com.drmangotea.tfmg.content.electricity.electrians_wrench;
package com.drmangotea.tfmg.content.electricity.configuration_wrench;
import com.drmangotea.tfmg.TFMG;
import com.drmangotea.tfmg.base.TFMGUtils;
import com.drmangotea.tfmg.content.electricity.base.ConnectNeightborsPacket;
import com.drmangotea.tfmg.content.electricity.base.IElectric;
import com.drmangotea.tfmg.content.electricity.base.KineticElectricBlockEntity;
import com.drmangotea.tfmg.content.engines.base.AbstractEngineBlockEntity;
import com.drmangotea.tfmg.registry.TFMGPackets;
import com.simibubi.create.content.equipment.symmetryWand.SymmetryWandScreen;
import net.createmod.catnip.gui.ScreenOpener;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
@@ -23,7 +19,6 @@ import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.network.PacketDistributor;
public class ElectriciansWrenchItem extends Item {
public ElectriciansWrenchItem(Properties p_41383_) {
@@ -58,6 +53,8 @@ public class ElectriciansWrenchItem extends Item {
be.getData().group.id = context.getItemInHand().getOrCreateTag().getInt("Number");
TFMGUtils.playSound(level, pos, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, context.getPlayer());
if(be instanceof KineticElectricBlockEntity kineticBE)
kineticBE.updateGeneratedRotation();
be.updateNextTick();
be.sendStuff();

View File

@@ -1,8 +1,7 @@
package com.drmangotea.tfmg.content.electricity.electrians_wrench;
package com.drmangotea.tfmg.content.electricity.configuration_wrench;
import com.drmangotea.tfmg.TFMG;
import com.simibubi.create.content.equipment.zapper.ZapperItem;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;

View File

@@ -1,4 +1,4 @@
package com.drmangotea.tfmg.content.electricity.electrians_wrench;
package com.drmangotea.tfmg.content.electricity.configuration_wrench;
import com.drmangotea.tfmg.registry.TFMGGuiTextures;
import com.drmangotea.tfmg.registry.TFMGPackets;

View File

@@ -9,22 +9,13 @@ import net.minecraft.network.FriendlyByteBuf;
public class CableRemovalPacket extends BlockEntityDataPacket<SmartBlockEntity> {
public CableRemovalPacket(BlockPos pos) {
super(pos);
}
public CableRemovalPacket(FriendlyByteBuf buffer) {
super(buffer);
}
@Override
protected void writeData(FriendlyByteBuf buffer) {}
@@ -34,8 +25,5 @@ public class CableRemovalPacket extends BlockEntityDataPacket<SmartBlockEntity>
if(blockEntity instanceof CableConnectorBlockEntity be) {
// be.removeConnections(true);
}
}
}
}

View File

@@ -7,6 +7,7 @@ import com.drmangotea.tfmg.content.electricity.connection.cables.CableConnection
import com.drmangotea.tfmg.content.electricity.connection.cables.CableConnectorBlockEntity;
import com.drmangotea.tfmg.content.engines.base.AbstractEngineBlockEntity;
import com.drmangotea.tfmg.content.engines.engine_controller.EngineControllerBlockEntity;
import com.drmangotea.tfmg.content.engines.types.AbstractSmallEngineBlockEntity;
import com.drmangotea.tfmg.content.engines.types.large_engine.LargeEngineBlockEntity;
import com.drmangotea.tfmg.content.engines.types.regular_engine.RegularEngineBlockEntity;
import com.drmangotea.tfmg.content.machinery.metallurgy.blast_stove.BlastStoveBlockEntity;
@@ -63,6 +64,7 @@ public class DebugCinderBlockItem extends Item {
} else {
TFMG.LOGGER.debug(be.shift.name());
TFMGUtils.debugMessage(level, "ENGINE "+(be.engine!=null));
}
return InteractionResult.SUCCESS;
}
@@ -99,7 +101,7 @@ public class DebugCinderBlockItem extends Item {
}
if (level.getBlockEntity(pos) instanceof IElectric be) {
be.onPlaced();
// be.onPlaced();
if (context.getPlayer().isShiftKeyDown()) {
@@ -111,7 +113,7 @@ public class DebugCinderBlockItem extends Item {
TFMG.LOGGER.debug("Group " + be.getData().group.id);
TFMG.LOGGER.debug("///////////////////////////////");
} else {
be.updateNextTick();
TFMGUtils.debugMessage(level, "Power " + be.getNetworkPowerUsage());
TFMGUtils.debugMessage(level, "Voltage " + be.getData().getVoltage());
@@ -151,11 +153,15 @@ public class DebugCinderBlockItem extends Item {
}
}
if (level.getBlockEntity(pos) instanceof AbstractEngineBlockEntity be) {
be.highestSignal=0;
be.controlled = false;
be.updateGeneratedRotation();
TFMGUtils.debugMessage(level, "RPM "+be.rpm);
if (level.getBlockEntity(pos) instanceof AbstractSmallEngineBlockEntity be) {
//be.getControllerBE().highestSignal=0;
//be.getControllerBE().rpm = 0;
//be.getControllerBE().engineController = null;
//be.getControllerBE().updateGeneratedRotation();
TFMGUtils.debugMessage(level, "RPM "+be.getControllerBE().rpm);
TFMGUtils.debugMessage(level, "SIGNAL "+be.getControllerBE().signal);
TFMGUtils.debugMessage(level, "HSIGNAL "+be.getControllerBE().highestSignal);
TFMGUtils.debugMessage(level, "RATE "+be.getControllerBE().fuelInjectionRate);
}
if (level.getBlockEntity(pos) instanceof CastingBasinBlockEntity be) {
be.findRecipe();

View File

@@ -1,5 +1,6 @@
package com.drmangotea.tfmg.content.electricity.generators;
import com.drmangotea.tfmg.TFMG;
import com.drmangotea.tfmg.config.TFMGConfigs;
import com.drmangotea.tfmg.content.electricity.base.KineticElectricBlockEntity;
import net.minecraft.core.BlockPos;
@@ -42,6 +43,7 @@ public class GeneratorBlockEntity extends KineticElectricBlockEntity {
@Override
public void onNetworkChanged(int oldVoltage, int oldPower) {
super.onNetworkChanged(oldVoltage, oldPower);

View File

@@ -3,6 +3,7 @@ package com.drmangotea.tfmg.content.electricity.generators.large_generator;
import com.drmangotea.tfmg.config.TFMGConfigs;
import com.drmangotea.tfmg.content.electricity.base.KineticElectricBlockEntity;
import com.drmangotea.tfmg.content.electricity.generators.large_generator.StatorBlock.StatorState;
import com.drmangotea.tfmg.registry.TFMGBlocks;
import net.createmod.catnip.animation.LerpedFloat;
import net.minecraft.core.BlockPos;
@@ -11,7 +12,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import com.drmangotea.tfmg.content.electricity.generators.large_generator.StatorBlock.StatorState;
import java.util.*;
@@ -25,15 +25,13 @@ import static net.minecraft.world.level.block.DirectionalBlock.FACING;
public class RotorBlockEntity extends KineticElectricBlockEntity {
LerpedFloat visualSpeed = LerpedFloat.linear();
float angle;
List<BlockPos> stators = new ArrayList<>();
public static final Map<Axis,Map<StatorOffset, BlockState>> statorPosition = setStatorPositons();
public static final Map<Axis, Map<StatorOffset, BlockState>> statorPosition = setStatorPositons();
public RotorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
@@ -47,7 +45,7 @@ public class RotorBlockEntity extends KineticElectricBlockEntity {
@Override
protected void read(CompoundTag compound, boolean clientPacket) {
super.read(compound, clientPacket);
visualSpeed.chase(getGeneratedSpeed(), 1 / 128f, LerpedFloat.Chaser.EXP);
visualSpeed.chase(getGeneratedSpeed(), 1 / 128f, LerpedFloat.Chaser.EXP);
}
@Override
@@ -55,34 +53,42 @@ public class RotorBlockEntity extends KineticElectricBlockEntity {
super.tick();
manageRotation();
}
@Override
public void lazyTick() {
super.lazyTick();
findStators();
}
@Override
public void onPlaced() {
super.onPlaced();
findStators();
}
@Override
public int voltageGeneration() {
return (int) Math.min(3000,generation()*3);
return (int) Math.min(3000, generation() * 3);
}
public int generation() {
if (stators.size() != 8)
return 0;
float modifier = TFMGConfigs.common().machines.largeGeneratorModifier.getF();
float maxSpeed = TFMGConfigs.common().machines.largeGeneratorMinSpeed.getF();
return (int) Math.max(0,((Math.abs(getSpeed())-maxSpeed)*modifier));
return (int) Math.max(0, ((Math.abs(getSpeed()) - maxSpeed) * modifier));
}
@Override
public int powerGeneration() {
return generation()*40;
return generation() * 40;
}
public void findStators(){
public void findStators() {
Axis axis = getBlockState().getValue(AXIS);
Map<StatorOffset, BlockState> position = statorPosition.get(axis);
@@ -96,22 +102,21 @@ public class RotorBlockEntity extends KineticElectricBlockEntity {
if (be.rotor == null || be.rotor == getBlockPos()) {
stators.add(pos);
level.setBlock(pos, state, 2);
be.rotor = getBlockPos();
stators.add(pos);
level.setBlock(pos, state, 2);
be.rotor = getBlockPos();
} else {
} else {
stators = new ArrayList<>();
updateNextTick();
}
} else {
stators = new ArrayList<>();
updateNextTick();
}
}));
}
public void manageRotation(){
public void manageRotation() {
float targetSpeed = getSpeed();
visualSpeed.updateChaseTarget(targetSpeed);
visualSpeed.tickChaser();
@@ -122,67 +127,66 @@ public class RotorBlockEntity extends KineticElectricBlockEntity {
@Override
public boolean hasElectricitySlot(Direction direction) {
return direction.getAxis()!=getBlockState().getValue(AXIS);
return direction.getAxis() != getBlockState().getValue(AXIS);
}
public static Map<Axis,Map<StatorOffset, BlockState>> setStatorPositons(){
Map<Axis,Map<StatorOffset, BlockState>> statorPositions = new HashMap<>();
public static Map<Axis, Map<StatorOffset, BlockState>> setStatorPositons() {
Map<Axis, Map<StatorOffset, BlockState>> statorPositions = new HashMap<>();
BlockState defaultState = TFMGBlocks.STATOR.getDefaultState();
BlockState cornerState = defaultState.setValue(STATOR_STATE,StatorState.CORNER);
BlockState horizontal = defaultState.setValue(STATOR_STATE,StatorState.CORNER_HORIZONTAL);
BlockState sideState = defaultState.setValue(STATOR_STATE,StatorState.SIDE);
BlockState cornerState = defaultState.setValue(STATOR_STATE, StatorState.CORNER);
BlockState horizontal = defaultState.setValue(STATOR_STATE, StatorState.CORNER_HORIZONTAL);
BlockState sideState = defaultState.setValue(STATOR_STATE, StatorState.SIDE);
BlockState cornerFlipped = cornerState.setValue(VALUE, false);
BlockState sideFlipped = sideState.setValue(VALUE, false);
Map<StatorOffset, BlockState> xPos = new HashMap<>();
xPos.put(pos(UP ), sideFlipped .setValue(FACING,DOWN ));
xPos.put(pos(DOWN ), sideFlipped .setValue(FACING,UP ));
xPos.put(pos(NORTH ), sideFlipped .setValue(FACING,SOUTH ));
xPos.put(pos(SOUTH ), sideFlipped .setValue(FACING,NORTH ));
xPos.put(pos(UP,NORTH ), cornerState .setValue(FACING,EAST ));
xPos.put(pos(UP,SOUTH ), cornerState .setValue(FACING,WEST ));
xPos.put(pos(DOWN,NORTH ), cornerFlipped.setValue(FACING,EAST ));
xPos.put(pos(DOWN,SOUTH ), cornerFlipped.setValue(FACING,WEST ));
xPos.put(pos(UP), sideFlipped.setValue(FACING, DOWN));
xPos.put(pos(DOWN), sideFlipped.setValue(FACING, UP));
xPos.put(pos(NORTH), sideFlipped.setValue(FACING, SOUTH));
xPos.put(pos(SOUTH), sideFlipped.setValue(FACING, NORTH));
xPos.put(pos(UP, NORTH), cornerState.setValue(FACING, EAST));
xPos.put(pos(UP, SOUTH), cornerState.setValue(FACING, WEST));
xPos.put(pos(DOWN, NORTH), cornerFlipped.setValue(FACING, EAST));
xPos.put(pos(DOWN, SOUTH), cornerFlipped.setValue(FACING, WEST));
Map<StatorOffset, BlockState> yPos = new HashMap<>();
yPos.put(pos(EAST ), sideState .setValue(FACING,WEST ));
yPos.put(pos(WEST ), sideState .setValue(FACING,EAST ));
yPos.put(pos(SOUTH ), sideState .setValue(FACING,NORTH ));
yPos.put(pos(NORTH ), sideState .setValue(FACING,SOUTH ));
yPos.put(pos(NORTH,WEST ), horizontal .setValue(FACING,NORTH));
yPos.put(pos(SOUTH,EAST ), horizontal .setValue(FACING,SOUTH));
yPos.put(pos(SOUTH,WEST ), horizontal .setValue(FACING,WEST ));
yPos.put(pos(NORTH,EAST ), horizontal .setValue(FACING,EAST ));
yPos.put(pos(EAST), sideState.setValue(FACING, WEST));
yPos.put(pos(WEST), sideState.setValue(FACING, EAST));
yPos.put(pos(SOUTH), sideState.setValue(FACING, NORTH));
yPos.put(pos(NORTH), sideState.setValue(FACING, SOUTH));
yPos.put(pos(NORTH, WEST), horizontal.setValue(FACING, NORTH));
yPos.put(pos(SOUTH, EAST), horizontal.setValue(FACING, SOUTH));
yPos.put(pos(SOUTH, WEST), horizontal.setValue(FACING, WEST));
yPos.put(pos(NORTH, EAST), horizontal.setValue(FACING, EAST));
Map<StatorOffset, BlockState> zPos = new HashMap<>();
zPos.put(pos(UP ), sideState .setValue(FACING,DOWN ));
zPos.put(pos(DOWN ), sideState .setValue(FACING,UP ));
zPos.put(pos(WEST ), sideFlipped .setValue(FACING,EAST ));
zPos.put(pos(EAST ), sideFlipped .setValue(FACING,WEST ));
zPos.put(pos(UP,WEST ), cornerState .setValue(FACING,UP ));
zPos.put(pos(UP,EAST ), cornerState .setValue(FACING,SOUTH ));
zPos.put(pos(DOWN,WEST ), cornerFlipped.setValue(FACING,UP ));
zPos.put(pos(DOWN,EAST ), cornerFlipped.setValue(FACING,SOUTH ));
statorPositions.put(Axis.X,xPos);
statorPositions.put(Axis.Y,yPos);
statorPositions.put(Axis.Z,zPos);
zPos.put(pos(UP), sideState.setValue(FACING, DOWN));
zPos.put(pos(DOWN), sideState.setValue(FACING, UP));
zPos.put(pos(WEST), sideFlipped.setValue(FACING, EAST));
zPos.put(pos(EAST), sideFlipped.setValue(FACING, WEST));
zPos.put(pos(UP, WEST), cornerState.setValue(FACING, UP));
zPos.put(pos(UP, EAST), cornerState.setValue(FACING, SOUTH));
zPos.put(pos(DOWN, WEST), cornerFlipped.setValue(FACING, UP));
zPos.put(pos(DOWN, EAST), cornerFlipped.setValue(FACING, SOUTH));
statorPositions.put(Axis.X, xPos);
statorPositions.put(Axis.Y, yPos);
statorPositions.put(Axis.Z, zPos);
return statorPositions;
}
private static StatorOffset pos(Direction dir1){
private static StatorOffset pos(Direction dir1) {
return new StatorOffset(dir1, Optional.empty());
}
private static StatorOffset pos(Direction dir1,Direction dir2){
private static StatorOffset pos(Direction dir1, Direction dir2) {
return new StatorOffset(dir1, Optional.of(dir2));
}
private static class StatorOffset{
private static class StatorOffset {
public final Direction direction1;
public final Optional<Direction> direction2;
public StatorOffset(Direction dir1,Optional<Direction> dir2){
public StatorOffset(Direction dir1, Optional<Direction> dir2) {
this.direction1 = dir1;
this.direction2 = dir2;
@@ -192,5 +196,4 @@ public class RotorBlockEntity extends KineticElectricBlockEntity {
}
}

View File

@@ -6,11 +6,7 @@ import com.drmangotea.tfmg.config.TFMGConfigs;
import com.drmangotea.tfmg.content.electricity.base.ElectricBlockEntity;
import com.drmangotea.tfmg.content.electricity.base.IElectric;
import com.drmangotea.tfmg.content.electricity.utilities.converter.ConverterBlockEntity;
import com.drmangotea.tfmg.content.engines.base.AbstractEngineBlockEntity;
import com.drmangotea.tfmg.registry.TFMGBlocks;
import com.simibubi.create.foundation.utility.CreateLang;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@@ -38,28 +34,31 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
public BlockPos controller = getBlockPos();
int signal;
boolean signalChanged;
public AccumulatorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
energyCapability = LazyOptional.of(() -> energy);
}
@Override
public void lazyTick() {
super.lazyTick();
neighbourChanged();
}
public void neighbourChanged() {
if (!hasLevel())
return;
if(isController()){
if (isController()) {
int power = level.getBestNeighborSignal(worldPosition);
if (power != signal)
signalChanged = true;
}
if(level.getBlockEntity(controller) instanceof AccumulatorBlockEntity be) {
if (level.getBlockEntity(controller) instanceof AccumulatorBlockEntity be) {
int power = level.getBestNeighborSignal(worldPosition);
@@ -69,7 +68,6 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
}
@Override
public void remove() {
super.remove();
@@ -82,6 +80,28 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
refreshController();
}
@Override
public boolean makeMultimeterTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
super.makeMultimeterTooltip(tooltip, isPlayerSneaking);
CreateLang.text("Capacity ")
.add(Component.literal(TFMGUtils.formatUnits(energy.getEnergyStored(), "FE")))
.color(0x127799)
.forGoggles(tooltip, 1);
CreateLang.text("Charging Rate ")
.add(CreateLang.number(getChargingRate()))
.color(0x127799)
.forGoggles(tooltip, 1);
CreateLang.text("Max Capacity ")
.add(CreateLang.number(getMaxCapacity()))
.color(0x127799)
.forGoggles(tooltip, 1);
return true;
}
public void refreshController() {
Direction facing = getBlockState().getValue(FACING);
@@ -114,12 +134,12 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
length = newLength;
int oldEnergy = energy.getEnergyStored();
energy = createEnergyStorage(length);
energy.setEnergy(Math.min(oldEnergy,energy.getMaxEnergyStored()*length));
energy.setEnergy(Math.min(oldEnergy, energy.getMaxEnergyStored() * length));
refreshCapability();
updateNextTick();
for (int i = 1; i < length; i++) {
BlockPos pos = getBlockPos().relative(getBlockState().getValue(FACING).getOpposite(), i);
if(level.getBlockEntity(pos) instanceof AccumulatorBlockEntity be){
if (level.getBlockEntity(pos) instanceof AccumulatorBlockEntity be) {
be.refreshCapability();
be.sendStuff();
}
@@ -146,16 +166,17 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
}
return super.getCapability(cap, side);
}
public boolean isController() {
return controller == getBlockPos();
}
public TFMGForgeEnergyStorage createEnergyStorage(int multiplier) {
return new TFMGForgeEnergyStorage(getMaxCapacity()*multiplier, 10000) {
return new TFMGForgeEnergyStorage(getMaxCapacity() * multiplier, 10000) {
@Override
public void onEnergyChanged(int amount, int oldAmount) {
if((oldAmount==0&&amount>0)||(this.energy==0)) {
if ((oldAmount == 0 && amount > 0) || (this.energy == 0)) {
updateNextTick();
}
sendStuff();
@@ -166,19 +187,20 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
public void setCapacity(ItemStack stack) {
energy.setEnergy(stack.getOrCreateTag().getInt("Storage"));
}
protected void analogSignalChanged() {
if(!isController()) {
if (!isController()) {
signal = level.getBestNeighborSignal(controller);
return;
}
int newSignal = 0;
for(int i = 0;i<length;i++){
BlockPos pos = getBlockPos().relative(getBlockState().getValue(FACING).getOpposite(),i);
for (int i = 0; i < length; i++) {
BlockPos pos = getBlockPos().relative(getBlockState().getValue(FACING).getOpposite(), i);
newSignal = Math.max(newSignal,level.getBestNeighborSignal(pos));
newSignal = Math.max(newSignal, level.getBestNeighborSignal(pos));
}
@@ -187,6 +209,7 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
signal = newSignal;
}
@Override
public void tick() {
super.tick();
@@ -246,25 +269,30 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
int power = 0;
for (IElectric member : getOrCreateElectricNetwork().members)
if (!(member instanceof ConverterBlockEntity)&&!(member instanceof AccumulatorBlockEntity))
if (!(member instanceof ConverterBlockEntity) && !(member instanceof AccumulatorBlockEntity))
power += member.getPowerUsage();
if (energy.getEnergyStored() == getMaxCapacity() || getData().getVoltage() <= getOutputVoltage() || canPower())
return 0;
if(Math.min(Math.max((data.networkPowerGeneration - power), 0), getMaxChargingRate())==0){
return 0;
}
return (float) (data.voltage * data.voltage) /Math.min(Math.max((data.networkPowerGeneration - power), 0), getMaxChargingRate());
return (float) Math.min((Math.pow(data.voltage, 2)) / Math.min(Math.max((data.networkPowerGeneration - power), 0), getMaxChargingRate()),750);
}
public boolean canPower() {
return getData().networkResistance > 0 && (getData().getVoltage() <= getOutputVoltage()) && energy.getEnergyStored() > 0&&signal ==0;
return getData().networkResistance > 0 && (getData().getVoltage() <= getOutputVoltage()) && energy.getEnergyStored() > 0 && signal == 0;
}
public int getChargingRate() {
int chargingRate = Math.max((data.networkPowerGeneration - getNetworkPowerUsage()), 0);
if (energy.getEnergyStored() == getMaxCapacity() || getData().getVoltage() < getOutputVoltage() || canPower())
//
// int chargingRate = Math.max((data.networkPowerGeneration - getNetworkPowerUsage()), 0);
if (energy.getEnergyStored() == getMaxCapacity() || getData().getVoltage() < getOutputVoltage() || canPower()|| data.notEnoughtPower)
return 0;
return Math.min(chargingRate, getMaxChargingRate());
//return Math.min(chargingRate, getMaxChargingRate());
return getMaxChargingRate();
}
@Override
@@ -280,7 +308,7 @@ public class AccumulatorBlockEntity extends ElectricBlockEntity {
}
public int getMaxCapacity() {
return TFMGConfigs.common().machines.accumulatorStorage.get();
return TFMGConfigs.common().machines.accumulatorStorage.get()*length;
}
//in FE per tick

View File

@@ -108,7 +108,9 @@ public class ConverterBlockEntity extends ElectricBlockEntity {
power += member.getPowerUsage();
if (energy.getEnergyStored() == getMaxCapacity() || getData().getVoltage() <= voltageGenerated.getValue() || canPower())
return 0;
if(Math.min(Math.max((data.networkPowerGeneration - power), 0), getMaxChargingRate())==0){
return 0;
}
return (float) (data.voltage * data.voltage) /Math.min(Math.max((data.networkPowerGeneration - power), 0), getMaxChargingRate());
@@ -125,10 +127,13 @@ public class ConverterBlockEntity extends ElectricBlockEntity {
public int getChargingRate() {
int chargingRate = Math.max((data.networkPowerGeneration - getNetworkPowerUsage()), 0);
if (energy.getEnergyStored() == getMaxCapacity() || getData().getVoltage() < voltageGenerated.getValue() || canPower())
//
// int chargingRate = Math.max((data.networkPowerGeneration - getNetworkPowerUsage()), 0);
if (energy.getEnergyStored() == getMaxCapacity() || getData().getVoltage() < voltageGenerated.value || canPower()|| data.notEnoughtPower)
return 0;
return Math.min(chargingRate, getMaxChargingRate());
//return Math.min(chargingRate, getMaxChargingRate());
return getMaxChargingRate();
}
@Override

View File

@@ -43,6 +43,8 @@ public class ElectricMotorBlock extends DirectionalKineticBlock implements IBE<E
return defaultBlockState().setValue(FACING, preferred);
}
@Override
public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) {
return face == state.getValue(FACING);

View File

@@ -51,6 +51,10 @@ public class ElectricMotorBlockEntity extends KineticElectricBlockEntity {
return direction == getBlockState().getValue(FACING).getOpposite() || (direction.getAxis().isHorizontal() && direction == Direction.DOWN);
}
@Override
public void notifyNetworkAboutSpeedChange() {
super.notifyNetworkAboutSpeedChange();
}
@Override
public void onNetworkChanged(int oldVoltage, int oldPower) {
@@ -70,7 +74,8 @@ public class ElectricMotorBlockEntity extends KineticElectricBlockEntity {
return 0;
//if(getPowerUsage() >= machineConfig.electricMotorMinimumPower.get()){
return Math.min(Math.abs(generatedSpeed.getValue()), data.getVoltage() / 2);
return generatedSpeed.getValue() <0 ? -Math.min(Math.abs(data.getVoltage()/2),Math.abs(generatedSpeed.getValue())) : Math.min(Math.abs(data.getVoltage()/2),Math.abs(generatedSpeed.getValue()));
//}
@@ -127,6 +132,8 @@ public class ElectricMotorBlockEntity extends KineticElectricBlockEntity {
.rotateZ(-AngleHelper.horizontalAngle(facing) + 180);
}
@Override
protected boolean isSideActive(BlockState state, Direction direction) {
Direction facing = state.getValue(FACING);

View File

@@ -241,7 +241,7 @@ public class ElectricPumpBlockEntity extends PumpBlockEntity implements IElectri
@Override
public float resistance() {
return 50;
return 100;
}

View File

@@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.DirectionalBlock;
import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -50,6 +51,20 @@ public class TransformerBlockEntity extends VoltageAlteringBlockEntity {
}
}
@Override
public void destroy() {
super.destroy();
BlockPos pos = this.getBlockPos();
if(!primaryCoil.isEmpty()){
ItemEntity item = new ItemEntity(level, pos.getX()+.5f,pos.getY()+.5f,pos.getZ()+.5f,primaryCoil);
level.addFreshEntity(item);
}
if(!secondaryCoil.isEmpty()){
ItemEntity item = new ItemEntity(level, pos.getX()+.5f,pos.getY()+.5f,pos.getZ()+.5f,secondaryCoil);
level.addFreshEntity(item);
}
}
@Override
public int getPowerUsage() {
@@ -85,7 +100,21 @@ public class TransformerBlockEntity extends VoltageAlteringBlockEntity {
}
@Override
public boolean makeMultimeterTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
super.makeMultimeterTooltip(tooltip, isPlayerSneaking);
if(coilRatio!=0) {
CreateLang.text("----------------------------")
.style(ChatFormatting.WHITE)
.forGoggles(tooltip);
CreateLang.translate("multimeter.transformer_ration")
.add(CreateLang.number(coilRatio))
.color(0xc6e82c)
.forGoggles(tooltip, 1);
}
return true;
}
@Override
public float resistance() {

View File

@@ -1,5 +1,6 @@
package com.drmangotea.tfmg.content.engines.base;
import com.drmangotea.tfmg.TFMG;
import com.drmangotea.tfmg.config.TFMGConfigs;
import com.drmangotea.tfmg.content.electricity.base.KineticElectricBlockEntity;
import com.drmangotea.tfmg.content.engines.fuels.BaseFuelTypes;
@@ -52,7 +53,7 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
public int highestSignal;
public int signal;
//
public boolean controlled = false;
public BlockPos engineController;
//
//
@@ -85,16 +86,25 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
public void tankUpdated(FluidStack stack) {
sendData();
setChanged();
}
public boolean hasEngineController() {
return engineController != null;
}
@Override
public void updateNetwork() {
//TFMG.LOGGER.debug("UPDATE ENGINE NETWORK");
super.updateNetwork();
}
protected void analogSignalChanged() {
if (controlled) {
if (hasEngineController()) {
fuelInjectionRate = highestSignal / 15f;
return;
}
@@ -131,6 +141,8 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
neighbourChanged();
manageFuelAndExhaust();
}
@@ -172,7 +184,7 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
public boolean canWork() {
if(fuelTank.isEmpty())
if (fuelTank.isEmpty())
return false;
if (exhaustTank.getSpace() == 0)
@@ -265,7 +277,8 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
reverse = compound.getBoolean("Reverse");
signal = compound.getInt("Signal");
controlled = compound.getBoolean("Controlled");
if (hasEngineController())
engineController = BlockPos.of(compound.getLong("EngineController"));
rpm = compound.getFloat("RPM");
// if (isController()) {
@@ -277,7 +290,7 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
highestSignal = compound.getInt("HighestSignal");
signalChanged = true;
//signalChanged = true;
updateRotation();
updateGeneratedRotation();
@@ -291,7 +304,8 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
compound.putBoolean("Reverse", reverse);
compound.putInt("Signal", signal);
compound.putBoolean("Controlled", controlled);
if (hasEngineController())
compound.putLong("EngineController", engineController.asLong());
compound.putFloat("RPM", rpm);
@@ -304,8 +318,6 @@ public abstract class AbstractEngineBlockEntity extends KineticElectricBlockEnti
}
public abstract int getFuelConsumption();

View File

@@ -2,11 +2,13 @@ package com.drmangotea.tfmg.content.engines.base;
import com.drmangotea.tfmg.TFMG;
import com.drmangotea.tfmg.base.TFMGShapes;
import com.drmangotea.tfmg.content.electricity.base.UpdateInFrontPacket;
import com.drmangotea.tfmg.content.engines.engine_controller.EngineControllerBlockEntity;
import com.drmangotea.tfmg.content.engines.types.AbstractSmallEngineBlockEntity;
import com.drmangotea.tfmg.content.engines.upgrades.EnginePipingUpgrade;
import com.drmangotea.tfmg.content.engines.upgrades.TransmissionUpgrade;
import com.drmangotea.tfmg.registry.TFMGBlocks;
import com.drmangotea.tfmg.registry.TFMGPackets;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.kinetics.base.HorizontalKineticBlock;
import net.minecraft.core.BlockPos;
@@ -29,6 +31,7 @@ import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.network.PacketDistributor;
import java.util.Optional;
@@ -56,17 +59,26 @@ public class EngineBlock extends HorizontalKineticBlock {
if (be.upgrade.isPresent()) {
if (be.upgrade.get() instanceof TransmissionUpgrade) {
if (be.getControllerBE().controller != null){
if (level.getBlockEntity(be.getControllerBE().controller) instanceof EngineControllerBlockEntity engineController) {
if (be.getControllerBE().engineController != null){
if (level.getBlockEntity(be.getControllerBE().engineController) instanceof EngineControllerBlockEntity engineController) {
engineController.engineStarted = false;
engineController.accelerationRate = 0;
engineController.shift = TransmissionUpgrade.TransmissionState.NEUTRAL;
engineController.engine = null;
engineController.enginePos = null;
engineController.disconnectEngine();
engineController.sendData();
}
}
be.getControllerBE().controlled =false;
//if(!level.isClientSide)
// TFMGPackets.getChannel().send(PacketDistributor.ALL.noArg(), new UpdateInFrontPacket(BlockPos.of(be.getPos())));
be.getControllerBE().engineController =null;
be.getControllerBE().highestSignal = 0;
be.getControllerBE().connectNextTick=true;
be.getControllerBE().fuelInjectionRate=0;
be.updateGeneratedRotation();
be.getControllerBE().updateGeneratedRotation();
be.getControllerBE().updateRotation();
be.getControllerBE().controller = null;
be.getControllerBE().sendData();
}

View File

@@ -49,7 +49,7 @@ public class EngineControllerBlock extends TFMGHorizontalDirectionalBlock implem
@Override
public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p_60557_, CollisionContext p_60558_) {
return TFMGShapes.ENGINE_CONTROLLER.get(p_60555_.getValue(FACING));
return TFMGShapes.ENGINE_CONTROLLER.get(p_60555_.getValue(FACING).getOpposite());
}
@Override

View File

@@ -131,6 +131,14 @@ public class EngineControllerBlockEntity extends SmartBlockEntity implements IHa
setChanged();
}
@Override
public void destroy() {
super.destroy();
Entity playerEntity = ((ServerLevel) level).getEntity(user);
if (playerEntity instanceof Player)
stopUsing((Player) playerEntity);
}
public void shiftBack() {
int max = TransmissionUpgrade.TransmissionState.values().length;
for (int i = 0; i < max; i++) {
@@ -246,11 +254,9 @@ public class EngineControllerBlockEntity extends SmartBlockEntity implements IHa
tickRendering();
}
if (enginePos != null && (engine == null)) {
if (level.getBlockEntity(enginePos) instanceof AbstractSmallEngineBlockEntity be) {
engine = be;
TFMG.LOGGER.debug("TICK");
engine.getControllerBE().highestSignal=4;
}
}
@@ -279,8 +285,7 @@ public class EngineControllerBlockEntity extends SmartBlockEntity implements IHa
public void updateEngine() {
if (engine == null)
return;
TFMG.LOGGER.debug("Update Engine "+accelerationRate);
engine.getControllerBE().controlled = true;
engine.getControllerBE().engineController = this.getBlockPos();
engine.getControllerBE().highestSignal = accelerationRate;
engine.getControllerBE().fuelInjectionRate = engine.getControllerBE().highestSignal / 15f;
engine.getControllerBE().updateRotation();
@@ -291,9 +296,8 @@ public class EngineControllerBlockEntity extends SmartBlockEntity implements IHa
public void disconnectEngine() {
if (engine == null)
return;
TFMG.LOGGER.debug("DISCONNECT");
engine.getControllerBE().highestSignal = 0;
engine.getControllerBE().controlled = false;
engine.getControllerBE().engineController = null;
engine.getControllerBE().updateGeneratedRotation();
}
@@ -304,17 +308,11 @@ public class EngineControllerBlockEntity extends SmartBlockEntity implements IHa
steeringWheelAngle.chase(isPressed(2) ? -40 : isPressed(3) ? 40 : 0, 0.25, LerpedFloat.Chaser.EXP);
clutchPedalMotion.chase(isPressed(4) ? 2 / 16f : 0, 0.25, LerpedFloat.Chaser.EXP);
gasPedalMotion.chase(isPressed(0) ? 2 / 16f : 0, 0.25, LerpedFloat.Chaser.EXP);
brakePedalMotion.chase(isPressed(1) ? 2 / 16f : 0, 0.25, LerpedFloat.Chaser.EXP);
transmissionLeverAngle.chase(shift == TransmissionUpgrade.TransmissionState.REVERSE ? -20 : (shift.value * 20), 0.25, LerpedFloat.Chaser.EXP);
fuelDial.chase(engine == null ? 0 : ((double) engine.getControllerBE().fuelTank.getFluidAmount() / (double) engine.fuelTank.getCapacity()) * 180f, 0.25, LerpedFloat.Chaser.EXP);
rpmDial.chase(engine == null ? 0 : ((double) engine.getControllerBE().rpm / 6000f) * 180f, 0.25, LerpedFloat.Chaser.EXP);
transmissionLeverAngle.tickChaser();
@@ -340,7 +338,6 @@ public class EngineControllerBlockEntity extends SmartBlockEntity implements IHa
}
public void tryStopUsing(Player player) {
TFMG.LOGGER.debug("Try Stop Using");
if (isUsedBy(player))
stopUsing(player);
}

View File

@@ -0,0 +1,29 @@
package com.drmangotea.tfmg.content.engines.engine_controller;
import com.drmangotea.tfmg.content.engines.base.AbstractEngineBlockEntity;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.networking.BlockEntityDataPacket;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
public class TransmissionRemovePacket extends BlockEntityDataPacket<SmartBlockEntity> {
public TransmissionRemovePacket(BlockPos pos) {
super(pos);
}
public TransmissionRemovePacket(FriendlyByteBuf buffer) {
super(buffer);
}
@Override
protected void writeData(FriendlyByteBuf buffer) {}
@Override
protected void handlePacket(SmartBlockEntity blockEntity) {
if(blockEntity instanceof AbstractEngineBlockEntity be) {
be.highestSignal = 0;
}
}
}

View File

@@ -27,7 +27,7 @@ public class EngineGearboxBlock extends HorizontalKineticBlock implements IBE<En
@Override
public VoxelShape getShape(BlockState state, BlockGetter blockGetter, BlockPos pos, CollisionContext context) {
return TFMGShapes.ENGINE_GEARBOX.get(state.getValue(HORIZONTAL_FACING).getOpposite());
return TFMGShapes.ENGINE_GEARBOX.get(state.getValue(HORIZONTAL_FACING));
}
@Override

View File

@@ -130,7 +130,6 @@ public abstract class AbstractSmallEngineBlockEntity extends AbstractEngineBlock
super.lazyTick();
upgrade.ifPresent(engineUpgrade -> engineUpgrade.lazyTickUpgrade(this));
}
@@ -192,7 +191,7 @@ public abstract class AbstractSmallEngineBlockEntity extends AbstractEngineBlock
if (controller == null)
return;
if (controlled) {
if (hasEngineController()) {
fuelInjectionRate = highestSignal / 15f;
return;
}
@@ -387,35 +386,35 @@ public abstract class AbstractSmallEngineBlockEntity extends AbstractEngineBlock
return true;
}
}
if (EngineUpgrade.getUpgrades().containsKey(itemStack.getItem())) {
Optional<? extends EngineUpgrade> itemUpgrade = EngineUpgrade.getUpgrades().get(itemStack.getItem()).createUpgrade();
if (upgrade.isEmpty())
if (EngineUpgrade.getUpgrades().containsKey(itemStack.getItem())) {
Optional<? extends EngineUpgrade> itemUpgrade = EngineUpgrade.getUpgrades().get(itemStack.getItem()).createUpgrade();
if (itemUpgrade.isPresent() && isUpgradeFirst(itemUpgrade.get())) {
upgrade = itemUpgrade;
playInsertionSound();
updateRotation();
upgrade.ifPresent(u -> u.updateUpgrade(this));
itemStack.shrink(1);
if (upgrade.isPresent())
if (upgrade.get() instanceof TransmissionUpgrade transmissionUpgrade) {
if (itemStack.getOrCreateTag().contains("Position") && itemStack.getOrCreateTag().get("Position") != null) {
BlockPos pos = BlockPos.of(itemStack.getOrCreateTag().getLong("Position"));
if (level.getBlockEntity(pos) instanceof EngineControllerBlockEntity engineControllerBE) {
if (itemUpgrade.isPresent() && isUpgradeFirst(itemUpgrade.get())) {
upgrade = itemUpgrade;
playInsertionSound();
updateRotation();
upgrade.ifPresent(u -> u.updateUpgrade(this));
itemStack.shrink(1);
if (upgrade.isPresent())
if (upgrade.get() instanceof TransmissionUpgrade transmissionUpgrade) {
if (itemStack.getOrCreateTag().contains("Position") && itemStack.getOrCreateTag().get("Position") != null) {
BlockPos pos = BlockPos.of(itemStack.getOrCreateTag().getLong("Position"));
if (level.getBlockEntity(pos) instanceof EngineControllerBlockEntity engineControllerBE) {
this.getControllerBE().updateGeneratedRotation();
this.getControllerBE().updateGeneratedRotation();
getControllerBE().controller = pos;
engineControllerBE.enginePos = this.getBlockPos();
TFMG.LOGGER.debug("INSERT ITEM");
getControllerBE().highestSignal = 0;
getControllerBE().controller = pos;
engineControllerBE.enginePos = this.getBlockPos();
getControllerBE().highestSignal = 0;
}
}
}
}
setChanged();
sendData();
return true;
setChanged();
sendData();
return true;
}
}
}
if (!isController())
return false;

View File

@@ -1,15 +1,19 @@
package com.drmangotea.tfmg.content.engines.types.turbine_engine;
import com.drmangotea.tfmg.base.TFMGShapes;
import com.drmangotea.tfmg.content.electricity.base.IElectric;
import com.drmangotea.tfmg.content.engines.base.EngineBlock;
import com.drmangotea.tfmg.registry.TFMGBlockEntities;
import com.simibubi.create.foundation.block.IBE;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
public class TurbineEngineBlock extends EngineBlock implements IBE<TurbineEngineBlockEntity> {
public TurbineEngineBlock(Properties properties) {
@@ -23,6 +27,16 @@ public class TurbineEngineBlock extends EngineBlock implements IBE<TurbineEngine
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
IBE.onRemove(state, level, pos, newState);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter p_60556_, BlockPos pos, CollisionContext p_60558_) {
return switch (state.getValue(ENGINE_STATE)){
case NORMAL -> TFMGShapes.TURBINE_ENGINE_MIDDLE.get(state.getValue(SHAFT_FACING));
case SHAFT, SINGLE -> TFMGShapes.TURBINE_ENGINE_BACK.get(state.getValue(SHAFT_FACING));
case BACK -> TFMGShapes.TURBINE_ENGINE_FRONT.get(state.getValue(SHAFT_FACING));
};
}
@Override
public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) {
return face==state.getValue(SHAFT_FACING)&&state.getValue(ENGINE_STATE)==EngineState.BACK;

View File

@@ -1,11 +1,22 @@
package com.drmangotea.tfmg.content.engines.upgrades;
import com.drmangotea.tfmg.content.engines.types.AbstractSmallEngineBlockEntity;
import com.drmangotea.tfmg.content.engines.types.regular_engine.RegularEngineBlockEntity;
import com.drmangotea.tfmg.registry.TFMGItems;
import com.drmangotea.tfmg.registry.TFMGPartialModels;
import com.mojang.blaze3d.vertex.PoseStack;
import net.createmod.catnip.render.CachedBuffers;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.state.BlockState;
import java.util.Optional;
import static net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING;
public class TransmissionUpgrade extends EngineUpgrade{
TransmissionState shift = TransmissionState.NEUTRAL;
@@ -18,6 +29,30 @@ public class TransmissionUpgrade extends EngineUpgrade{
}
@Override
public void render(AbstractSmallEngineBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light) {
BlockState state = be.getBlockState();
Direction facing = state.getValue(FACING);
boolean side = false;
ms.pushPose();
if (be instanceof RegularEngineBlockEntity blockEntity) {
side = blockEntity.type.upgradesOnSide;
}
CachedBuffers.partial(TFMGPartialModels.TRANSMISSION, state)
.center()
.translateY(side ? -2/16f :0)
.rotateYDegrees(facing.toYRot())
.rotateZDegrees(side ? 90 : 0)
.translateY(side ? 4 / 16f : 0)
.uncenter()
.light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
ms.popPose();
}
@Override
public Item getItem() {

View File

@@ -0,0 +1,63 @@
package com.drmangotea.tfmg.content.machinery.misc.winding_machine;
import com.drmangotea.tfmg.content.engines.types.AbstractSmallEngineBlockEntity;
import com.simibubi.create.AllPartialModels;
import com.simibubi.create.content.kinetics.base.IRotate;
import com.simibubi.create.content.kinetics.base.KineticBlockEntityVisual;
import com.simibubi.create.content.kinetics.base.RotatingInstance;
import com.simibubi.create.foundation.render.AllInstanceTypes;
import dev.engine_room.flywheel.api.instance.Instance;
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
import dev.engine_room.flywheel.lib.model.Models;
import net.createmod.catnip.data.Iterate;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;
import java.util.function.Consumer;
import static com.simibubi.create.content.kinetics.base.HorizontalKineticBlock.HORIZONTAL_FACING;
public class WindingMachineVisual extends KineticBlockEntityVisual<WindingMachineBlockEntity> {
protected final RotatingInstance shaft;
public WindingMachineVisual(VisualizationContext context, WindingMachineBlockEntity blockEntity, float partialTick) {
super(context, blockEntity, partialTick);
Direction facing = blockEntity.getBlockState().getValue(HORIZONTAL_FACING).getCounterClockWise();
shaft = instancerProvider().instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.SHAFT_HALF))
.createInstance();
shaft.setup(blockEntity)
.setPosition(getVisualPosition())
.rotateToFace(Direction.SOUTH, facing)
.setChanged();
}
@Override
public void update(float pt) {
shaft.setup(blockEntity)
.setChanged();
}
@Override
public void updateLight(float partialTick) {
Direction facing = blockEntity.getBlockState().getValue(HORIZONTAL_FACING).getCounterClockWise();
BlockPos behind = pos.relative(facing);
relight(behind, shaft);
}
@Override
protected void _delete() {
shaft.delete();
}
@Override
public void collectCrumblingInstances(Consumer<Instance> consumer) {
consumer.accept(shaft);
}
}

View File

@@ -21,7 +21,8 @@ import java.util.Objects;
public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements IVatMachine {
ElectrodeType electrodeType = ElectrodeType.NONE;
boolean isTallEnough=true;
boolean isTallEnough = true;
public ElectrodeHolderBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
@@ -41,7 +42,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
} else return true;
}
}
if (!simulate&&hasLevel())
if (!simulate && hasLevel())
VatBlock.updateVatState(getBlockState(), getLevel(), getBlockPos().relative(Direction.DOWN));
sendData();
return false;
@@ -51,18 +52,18 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
@Override
public float resistance() {
if(electrodeType !=ElectrodeType.NONE){
if(electrodeType == ElectrodeType.GRAPHITE){
return 5;
}else {
return 20;
}
if (electrodeType != ElectrodeType.NONE) {
return 20;
}
return 0;
}
@Override
public boolean canBeInGroups() {
return true;
}
public boolean setElectrode(String name, boolean simulate) {
for (ElectrodeType type : ElectrodeType.values()) {
if (Objects.equals(type.name, name)) {
@@ -71,7 +72,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
} else return true;
}
}
if (!simulate&&hasLevel())
if (!simulate && hasLevel())
VatBlock.updateVatState(getBlockState(), getLevel(), getBlockPos().relative(Direction.DOWN));
sendData();
return false;
@@ -83,17 +84,19 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
VatBlock.updateVatState(getBlockState(), level, getBlockPos().relative(Direction.DOWN));
}
boolean isSuperheated(){
boolean isSuperheated() {
return electrodeType == ElectrodeType.GRAPHITE && getCurrent() >= TFMGConfigs.common().machines.graphiteElectrodeCurrent.get();
}
boolean isOperational(){
return getCurrent() >= TFMGConfigs.common().machines.electrolysisMinimumCurrent.get();
boolean isOperational() {
return getCurrent() >= TFMGConfigs.common().machines.electrolysisMinimumCurrent.get()&&canWork();
}
@Override
public AABB getRenderBoundingBox() {
return new AABB(getBlockPos()).setMinY(getBlockPos().getY()-2);
return new AABB(getBlockPos()).setMinY(getBlockPos().getY() - 2);
}
@Override
public void write(CompoundTag compound, boolean clientPacket) {
for (ElectrodeType electrode : ElectrodeType.values()) {
@@ -108,12 +111,16 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
protected void read(CompoundTag compound, boolean clientPacket) {
super.read(compound, clientPacket);
setElectrode(compound.getString("Electrode"),false);
setElectrode(compound.getString("Electrode"), false);
}
@Override
public String getOperationId() {
return switch (electrodeType){
return switch (electrodeType) {
case NONE -> "";
case COPPER, ZINC -> isOperational() ? "tfmg:electrode" : "";
@@ -123,7 +130,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
@Override
public int getWorkPercentage() {
return (getPowerUsage()/5000)*100;
return (getPowerUsage() / 5000) * 100;
}
@Override
@@ -137,9 +144,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
NONE("none", ItemStack.EMPTY, null),
COPPER("copper", TFMGItems.COPPER_ELECTRODE.asStack(), TFMGPartialModels.COPPER_ELECTRODE),
ZINC("zinc", TFMGItems.ZINC_ELECTRODE.asStack(), TFMGPartialModels.ZINC_ELECTRODE),
GRAPHITE("graphite", TFMGItems.GRAPHITE_ELECTRODE.asStack(), TFMGPartialModels.GRAPHITE_ELECTRODE)
;
GRAPHITE("graphite", TFMGItems.GRAPHITE_ELECTRODE.asStack(), TFMGPartialModels.GRAPHITE_ELECTRODE);
public final String name;
public final ItemStack item;

View File

@@ -1211,6 +1211,16 @@ public class TFMGStandardRecipeGen extends TFMGRecipeProvider {
.pattern("WTR")
.pattern("WLR")),
MULTIMETER = create(TFMGItems.MULTIMETER)
.unlockedBy(TFMGBlocks.VOLTMETER::get)
.viaShaped(b -> b
.define('G', TFMGBlocks.VOLTMETER)
.define('W', copperWire())
.define('B', brassSheet())
.pattern("BGB")
.pattern("BWB")
.pattern("BWB")),
COPPER_CABLE_HUB = create(TFMGBlocks.COPPER_CABLE_HUB).returns(2)
.unlockedBy(TFMGItems.MAGNET::get)
.viaShaped(b -> b
@@ -1831,6 +1841,109 @@ public class TFMGStandardRecipeGen extends TFMGRecipeProvider {
.requires(ItemTags.WOODEN_DOORS)),
////////
WHITE_MULTIMETER = create(TFMGItems.MULTIMETERS.get("white")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("white"))),
YELLOW_MULTIMETER = create(TFMGItems.MULTIMETERS.get("yellow")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("yellow"))),
BROWN_MULTIMETER = create(TFMGItems.MULTIMETERS.get("brown")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("brown"))),
ORANGE_MULTIMETER = create(TFMGItems.MULTIMETERS.get("orange")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("orange"))),
BLACK_MULTIMETER = create(TFMGItems.MULTIMETERS.get("black")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("black"))),
CYAN_MULTIMETER = create(TFMGItems.MULTIMETERS.get("cyan")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("cyan"))),
BLUE_MULTIMETER = create(TFMGItems.MULTIMETERS.get("blue")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("blue"))),
LIGHT_BLUE_MULTIMETER = create(TFMGItems.MULTIMETERS.get("light_blue")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("light_blue"))),
GRAY_MULTIMETER = create(TFMGItems.MULTIMETERS.get("gray")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("gray"))),
LIGHT_GRAY_MULTIMETER = create(TFMGItems.MULTIMETERS.get("light_gray")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("light_gray"))),
GREEN_MULTIMETER = create(TFMGItems.MULTIMETERS.get("green")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("green"))),
LIME_MULTIMETER = create(TFMGItems.MULTIMETERS.get("lime")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("lime"))),
PINK_MULTIMETER = create(TFMGItems.MULTIMETERS.get("pink")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("pink"))),
PURPLE_MULTIMETER = create(TFMGItems.MULTIMETERS.get("purple")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("purple"))),
MAGENTA_MULTIMETER = create(TFMGItems.MULTIMETERS.get("magenta")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("magenta"))),
RED_MULTIMETER = create(TFMGItems.MULTIMETERS.get("red")::get)
.unlockedBy(() -> TFMGItems.MULTIMETER)
.viaShapeless(b -> b
.requires(TFMGItems.MULTIMETER)
.requires(DYES_FROM_COLOR.get("red"))),
////////
WHITE_CONCRETE = create(TFMGBlocks.COLORED_CONCRETE.get("white").block).returns(8)
.unlockedBy(TFMGBlocks.CONCRETE.block::get)
.viaShaped(b -> b

View File

@@ -0,0 +1,53 @@
package com.drmangotea.tfmg.datagen.recipes.values.create;
import com.drmangotea.tfmg.datagen.recipes.TFMGProcessingRecipeGen;
import com.drmangotea.tfmg.registry.TFMGBlocks;
import com.drmangotea.tfmg.registry.TFMGItems;
import com.drmangotea.tfmg.registry.TFMGPaletteStoneTypes;
import com.simibubi.create.AllRecipeTypes;
import net.minecraft.data.PackOutput;
import static com.drmangotea.tfmg.datagen.recipes.TFMGRecipeProvider.I.*;
public class TFMGCrushingRecipeGen extends TFMGProcessingRecipeGen {
GeneratedRecipe
COPPER_SULFATE = create(I::copperSulfate, b -> b
.output(boneMeal(), 4)
.output(.25f, boneMeal(), 3)
.output(.5f, cyanDye(), 1)
.output(.75f, blueDye(), 1)
),
LIGNITE = create(TFMGBlocks.LIGNITE::get, b -> b
.output(.75f,coal(), 1)
.output(.2f,coal(), 1)
),
BAUXITE = create(TFMGPaletteStoneTypes.BAUXITE.getBaseBlock()::get, b -> b
.output(.75f, TFMGItems.BAUXITE_POWDER, 2)
.output(.2f,TFMGItems.BAUXITE_POWDER, 1)
),
LIMESAND = create(I::limestone, b -> b
.output(limesand(), 1)
),
COAL_COKE = create(I::coalCoke, b -> b
.output(coalCokeDust(), 1)
),
SALTPETER = create(I::dirt, b -> b
.output(.05f, nitrateDust(), 1)
),
SULFUR = create(() -> TFMGBlocks.SULFUR, b -> b
.output(.2f, sulfurDust(), 1)
.output(.1f, sulfurDust(), 1)
);
public TFMGCrushingRecipeGen(PackOutput output) {
super(output);
}
@Override
protected AllRecipeTypes getRecipeType() {
return AllRecipeTypes.CRUSHING;
}
}

View File

@@ -102,7 +102,6 @@ public class GoggleOverlayRendererMixin {
if(isElectricBlock&&!hasGoggles) {
ItemStack item = TFMGItems.MULTIMETER.asStack();
List<Component> tooltip = new ArrayList<>();
tooltip.add(CreateLang.number(1).component());
((IElectric) be).makeMultimeterTooltip(tooltip, isShifting);
@@ -111,8 +110,7 @@ public class GoggleOverlayRendererMixin {
tfmg$hoverTicks = 0;
} else {
//
//
if (tooltip.isEmpty()) {
tfmg$hoverTicks = 0;
} else {

View File

@@ -0,0 +1,147 @@
package com.drmangotea.tfmg.ponder;
import com.drmangotea.tfmg.TFMG;
import com.drmangotea.tfmg.registry.TFMGBlocks;
import com.drmangotea.tfmg.registry.TFMGItems;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.tterrag.registrate.util.entry.RegistryEntry;
import net.createmod.catnip.platform.CatnipServices;
import net.createmod.ponder.api.registration.PonderTagRegistrationHelper;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;
public class TFMGPonderTags {
public static final ResourceLocation
OIL_PROCESSING = loc("oil_processing"),
ENGINES = loc("engines"),
METALLURGY = loc("metallurgy"),
ELECTRIC_MACHINERY = loc("electric_machinery"),
CHEMICAL_VAT = loc("chemical_vat")
;
private static ResourceLocation loc(String id) {
return TFMG.asResource(id);
}
public static void register(PonderTagRegistrationHelper<ResourceLocation> helper) {
PonderTagRegistrationHelper<RegistryEntry<?>> HELPER = helper.withKeyFunction(RegistryEntry::getId);
PonderTagRegistrationHelper<ItemLike> itemHelper = helper.withKeyFunction(
CatnipServices.REGISTRIES::getKeyOrThrow);
helper.registerTag(OIL_PROCESSING)
.addToIndex()
.item(TFMGBlocks.STEEL_DISTILLATION_CONTROLLER, true, false)
.title("Oil Processing Machinery")
.description("Block used for refining and mining oil")
.register();
helper.registerTag(ENGINES)
.addToIndex()
.item(TFMGBlocks.TURBINE_ENGINE, true, false)
.title("Engines")
.description("Engines and equipment related to them")
.register();
helper.registerTag(METALLURGY)
.addToIndex()
.item(TFMGBlocks.BLAST_FURNACE_OUTPUT, true, false)
.title("Metallurgy")
.description("Blocks related to processing metal")
.register();
helper.registerTag(ELECTRIC_MACHINERY)
.addToIndex()
.item(TFMGBlocks.ROTOR, true, true)
.title("Electric Machinery")
.description("Block which use, produce or transfer electricity")
.register();
helper.registerTag(CHEMICAL_VAT)
.addToIndex()
.item(TFMGBlocks.STEEL_CHEMICAL_VAT, true, false)
.title("Chemical Vat")
.description("Chemical vat and machines that expand it")
.register();
HELPER.addToTag(OIL_PROCESSING)
.add(TFMGBlocks.STEEL_DISTILLATION_CONTROLLER)
.add(TFMGBlocks.STEEL_DISTILLATION_OUTPUT)
.add(TFMGBlocks.INDUSTRIAL_PIPE)
.add(TFMGBlocks.SURFACE_SCANNER)
.add(TFMGBlocks.PUMPJACK_BASE)
.add(TFMGBlocks.PUMPJACK_CRANK)
.add(TFMGBlocks.PUMPJACK_HAMMER)
.add(TFMGBlocks.PUMPJACK_HAMMER_CONNECTOR)
.add(TFMGBlocks.PUMPJACK_HAMMER_HEAD)
.add(TFMGBlocks.PUMPJACK_HAMMER_PART)
.add(TFMGBlocks.LARGE_PUMPJACK_HAMMER_CONNECTOR)
.add(TFMGBlocks.LARGE_PUMPJACK_HAMMER_HEAD)
.add(TFMGBlocks.LARGE_PUMPJACK_HAMMER_PART)
;
HELPER.addToTag(ENGINES)
.add(TFMGBlocks.REGULAR_ENGINE)
.add(TFMGBlocks.TURBINE_ENGINE)
.add(TFMGBlocks.RADIAL_ENGINE)
.add(TFMGBlocks.LARGE_ENGINE)
.add(TFMGBlocks.SIMPLE_LARGE_ENGINE)
.add(TFMGBlocks.ENGINE_CONTROLLER)
.add(TFMGBlocks.ENGINE_GEARBOX)
.add(TFMGBlocks.EXHAUST)
.add(TFMGBlocks.AIR_INTAKE)
.add(TFMGItems.OIL_CAN)
.add(TFMGItems.COOLING_FLUID_BOTTLE)
.add(TFMGItems.TRANSMISSION)
.add(TFMGItems.TURBO);
HELPER.addToTag(METALLURGY)
.add(TFMGBlocks.BLAST_FURNACE_OUTPUT)
.add(TFMGBlocks.BLAST_FURNACE_HATCH)
.add(TFMGBlocks.FIREPROOF_BRICKS)
.add(TFMGBlocks.FIREPROOF_BRICK_REINFORCEMENT)
.add(TFMGBlocks.BLAST_FURNACE_REINFORCEMENT)
.add(TFMGBlocks.RUSTED_BLAST_FURNACE_REINFORCEMENT)
.add(TFMGBlocks.BLAST_STOVE)
.add(TFMGBlocks.CASTING_BASIN);
HELPER.addToTag(ELECTRIC_MACHINERY)
.add(TFMGBlocks.ROTOR)
.add(TFMGBlocks.STATOR)
.add(TFMGBlocks.GENERATOR)
.add(TFMGBlocks.ELECTRIC_MOTOR)
.add(TFMGBlocks.CABLE_CONNECTOR)
.add(TFMGBlocks.GLASS_CABLE_CONNECTOR)
.add(TFMGBlocks.POLARIZER)
.add(TFMGBlocks.ACCUMULATOR)
.add(TFMGBlocks.TRANSFORMER)
.add(TFMGBlocks.ELECTRICAL_SWITCH)
.add(TFMGBlocks.DIODE)
.add(TFMGBlocks.POTENTIOMETER)
.add(TFMGBlocks.ELECTRIC_PUMP)
.add(TFMGBlocks.LIGHT_BULB)
.add(TFMGBlocks.BRASS_CABLE_HUB)
.add(TFMGBlocks.SEGMENTED_DISPLAY)
.add(TFMGBlocks.CONVERTER)
.add(TFMGBlocks.TRAFFIC_LIGHT)
.add(TFMGItems.COPPER_SPOOL)
.add(TFMGItems.ALUMINUM_SPOOL)
;
HELPER.addToTag(CHEMICAL_VAT)
.add(TFMGBlocks.STEEL_CHEMICAL_VAT)
.add(TFMGBlocks.CAST_IRON_CHEMICAL_VAT)
.add(TFMGBlocks.FIREPROOF_CHEMICAL_VAT)
.add(TFMGBlocks.INDUSTRIAL_MIXER)
.add(TFMGBlocks.ELECTRODE_HOLDER)
.add(TFMGItems.COPPER_ELECTRODE)
.add(TFMGItems.ZINC_ELECTRODE)
.add(TFMGItems.GRAPHITE_ELECTRODE)
.add(TFMGItems.MIXER_BLADE)
.add(TFMGItems.CENTRIFUGE)
;
}
}

View File

@@ -84,6 +84,7 @@ import com.drmangotea.tfmg.content.machinery.misc.machine_input.MachineInputBloc
import com.drmangotea.tfmg.content.machinery.misc.smokestack.SmokestackBlockEntity;
import com.drmangotea.tfmg.content.machinery.misc.winding_machine.WindingMachineBlockEntity;
import com.drmangotea.tfmg.content.machinery.misc.winding_machine.WindingMachineRenderer;
import com.drmangotea.tfmg.content.machinery.misc.winding_machine.WindingMachineVisual;
import com.drmangotea.tfmg.content.machinery.oil_processing.distillation_tower.controller.DistillationControllerBlockEntity;
import com.drmangotea.tfmg.content.machinery.oil_processing.distillation_tower.controller.DistillationControllerRenderer;
import com.drmangotea.tfmg.content.machinery.oil_processing.distillation_tower.output.DistillationOutputBlockEntity;
@@ -536,7 +537,7 @@ public class TFMGBlockEntities {
public static final BlockEntityEntry<WindingMachineBlockEntity> WINDING_MACHINE = REGISTRATE
.blockEntity("winding_machine", WindingMachineBlockEntity::new)
.visual(() -> OrientedRotatingVisual.of(AllPartialModels.SHAFT_HALF),true)
.visual(() -> WindingMachineVisual::new,true)
.validBlocks(TFMGBlocks.WINDING_MACHINE)
.renderer(() -> WindingMachineRenderer::new)
.register();

View File

@@ -6,7 +6,7 @@ import com.drmangotea.tfmg.base.TFMGTiers;
import com.drmangotea.tfmg.content.decoration.gearbox.SteelVerticalGearboxItem;
import com.drmangotea.tfmg.content.electricity.connection.cables.CableConnection;
import com.drmangotea.tfmg.content.electricity.debug.DebugCinderBlockItem;
import com.drmangotea.tfmg.content.electricity.electrians_wrench.ElectriciansWrenchItem;
import com.drmangotea.tfmg.content.electricity.configuration_wrench.ElectriciansWrenchItem;
import com.drmangotea.tfmg.content.electricity.measurement.MultimeterItem;
import com.drmangotea.tfmg.content.electricity.utilities.fuse_block.FuseItem;
import com.drmangotea.tfmg.content.electricity.utilities.resistor.ResistorItem;
@@ -35,6 +35,7 @@ import com.simibubi.create.foundation.data.CreateRegistrate;
import com.tterrag.registrate.builders.ItemBuilder;
import com.tterrag.registrate.util.DataIngredient;
import com.tterrag.registrate.util.entry.ItemEntry;
import com.tterrag.registrate.util.entry.RegistryEntry;
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.tags.TagKey;
@@ -43,7 +44,9 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.Tags;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.drmangotea.tfmg.TFMG.REGISTRATE;
import static com.drmangotea.tfmg.base.TFMGBuilderTransformers.COLORS;
@@ -253,9 +256,9 @@ public class TFMGItems {
.properties(p -> p.stacksTo(1))
.register();
static {
multimeters();
}
public static final Map<String, RegistryEntry<MultimeterItem>> MULTIMETERS = multimeters();
public static final ItemEntry<MultimeterItem> MULTIMETER = REGISTRATE.item("multimeter", MultimeterItem::new)
.register();
@@ -408,13 +411,16 @@ public class TFMGItems {
.register();
}
public static void multimeters() {
public static Map<String, RegistryEntry<MultimeterItem>> multimeters() {
Map<String, RegistryEntry<MultimeterItem>> map = new HashMap<>();
for (String color : COLORS) {
REGISTRATE.item(color + "_multimeter", MultimeterItem::new)
.register();
map.put(color,REGISTRATE.item(color + "_multimeter", MultimeterItem::new)
.register());
}
return map;
}
public static ItemBuilder<SpoolItem, CreateRegistrate> spoolItem(String name, PartialModel model, int barColor, CableConnection.CableType type) {

View File

@@ -7,8 +7,8 @@ import com.drmangotea.tfmg.content.electricity.base.ConnectionPacket;
import com.drmangotea.tfmg.content.electricity.base.NetworkUpdatePacket;
import com.drmangotea.tfmg.content.electricity.base.UpdateInFrontPacket;
import com.drmangotea.tfmg.content.electricity.connection.cables.CablePlacePacket;
import com.drmangotea.tfmg.content.electricity.connection.cables.CableRemovalPacket;
import com.drmangotea.tfmg.content.electricity.electrians_wrench.ElectriciansWrenchPacket;
import com.drmangotea.tfmg.content.electricity.configuration_wrench.ElectriciansWrenchPacket;
import com.drmangotea.tfmg.content.engines.engine_controller.TransmissionRemovePacket;
import com.drmangotea.tfmg.content.engines.engine_controller.packets.*;
import com.drmangotea.tfmg.content.items.weapons.advanced_potato_cannon.AdvancedPotatoCannonPacket;
import com.drmangotea.tfmg.content.items.weapons.quad_potato_cannon.QuadPotatoCannonPacket;
@@ -42,7 +42,7 @@ public enum TFMGPackets {
VAT_EVALUATION(VatEvaluationPacket.class, VatEvaluationPacket::new, PLAY_TO_CLIENT),
COKE_OVEN_PACKET(CokeOvenPacket.class, CokeOvenPacket::new, PLAY_TO_CLIENT),
UPDATE_IN_FRONT_PACKET(UpdateInFrontPacket.class, UpdateInFrontPacket::new, PLAY_TO_CLIENT),
CABLE_PACKET(CableRemovalPacket.class, CableRemovalPacket::new, PLAY_TO_CLIENT),
TRANSMISSION_REMOVE(TransmissionRemovePacket.class, TransmissionRemovePacket::new, PLAY_TO_CLIENT),
CABLE_PLACE_PACKET(CablePlacePacket.class, CablePlacePacket::new, PLAY_TO_CLIENT),
ELECTRICIANS_WRENCH_PACKET(ElectriciansWrenchPacket.class, ElectriciansWrenchPacket::new, PLAY_TO_SERVER),
ENGINE_CONTROLLER_INPUT(EngineControllerInputPacket.class, EngineControllerInputPacket::new, PLAY_TO_SERVER),

View File

@@ -89,6 +89,7 @@ public class TFMGPartialModels {
MIXER = block("industrial_mixer/mixer"),
MIXER_SHAFT = block("industrial_mixer/mixer_shaft"),
ENGINE_GENERATOR = block("engine_upgrades/generator"),
TRANSMISSION = PartialModel.of(TFMG.asResource("item/transmission_model")),
TURBO = block("engine_upgrades/turbo"),
TURBO_PROPELLER = block("engine_upgrades/turbo_propeller"),
GOLDEN_TURBO = block("engine_upgrades/golden_turbo"),

View File

@@ -80,6 +80,9 @@
"death.attack.tfmg.acid": "%1$s took an acid bath",
"death.attack.tfmg.acid.player": "%1$s took an acid bath",
"death.attack.tfmg.blast_furnace": "%1$s was turned in carbon steel",
"death.attack.tfmg.blast_furnace.player": "%1$s was thrown into a blast furnace",
"create.tooltip.fuse": "Rating: %1$s",
"create.tooltip.resistor": "Resistance: %1$s",
"create.tooltip.coils": "Turns: %1$s",

View File

@@ -7,9 +7,9 @@
},
"elements": [
{
"from": [5, 11, 4],
"to": [11, 14, 13],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [5, 11, 3],
"to": [11, 14, 12],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [3, 3, 4.5, 6], "rotation": 270, "texture": "#2"},
"east": {"uv": [1.5, 7.5, 0, 3], "rotation": 90, "texture": "#2"},
@@ -20,9 +20,9 @@
}
},
{
"from": [5, 11, 3],
"to": [10, 14, 4],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [5, 11, 2],
"to": [10, 14, 3],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [7.5, 0, 9, 2.5], "rotation": 270, "texture": "#2"},
"east": {"uv": [9, 2.5, 7.5, 2], "rotation": 90, "texture": "#2"},
@@ -33,9 +33,9 @@
}
},
{
"from": [4, 11, 13],
"to": [12, 15, 15],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [4, 11, 12],
"to": [12, 15, 14],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [4.5, 0, 6.5, 4], "rotation": 270, "texture": "#2"},
"east": {"uv": [11, 2, 9, 1], "rotation": 90, "texture": "#2"},
@@ -46,9 +46,9 @@
}
},
{
"from": [4, 15, 8],
"to": [12, 15, 10],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [4, 15, 7],
"to": [12, 15, 9],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 4], "rotation": 270, "texture": "#2"},
"east": {"uv": [0, 1, 0, 0], "rotation": 90, "texture": "#2"},
@@ -59,9 +59,9 @@
}
},
{
"from": [12, 11, 8],
"to": [12, 15, 10],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [12, 11, 7],
"to": [12, 15, 9],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [0, 0, 2, 0], "rotation": 270, "texture": "#2"},
"east": {"uv": [11, 0, 9, 1], "rotation": 90, "texture": "#2"},
@@ -72,9 +72,9 @@
}
},
{
"from": [4, 11, 8],
"to": [4, 15, 10],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [4, 11, 7],
"to": [4, 15, 9],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [0, 0, 2, 0], "rotation": 270, "texture": "#2"},
"east": {"uv": [11, 0, 9, 1], "rotation": 90, "texture": "#2"},
@@ -85,9 +85,9 @@
}
},
{
"from": [12, 11, 11],
"to": [12, 15, 12],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [12, 11, 10],
"to": [12, 15, 11],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [0, 0, 2, 0], "rotation": 270, "texture": "#2"},
"east": {"uv": [11, 1, 9, 0.5], "rotation": 90, "texture": "#2"},
@@ -98,9 +98,9 @@
}
},
{
"from": [4, 15, 11],
"to": [12, 15, 12],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [4, 15, 10],
"to": [12, 15, 11],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 4], "rotation": 270, "texture": "#2"},
"east": {"uv": [0, 0.5, 0, 0], "rotation": 90, "texture": "#2"},
@@ -111,9 +111,9 @@
}
},
{
"from": [4, 11, 11],
"to": [4, 15, 12],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [4, 11, 10],
"to": [4, 15, 11],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [0, 0, 2, 0], "rotation": 270, "texture": "#2"},
"east": {"uv": [11.5, 0.5, 9.5, 0], "rotation": 90, "texture": "#2"},
@@ -124,9 +124,9 @@
}
},
{
"from": [11, 12, 4],
"to": [12, 13, 13],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [11, 12, 3],
"to": [12, 13, 12],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [1.5, 10.5, 2, 11], "rotation": 270, "texture": "#2"},
"east": {"uv": [3.5, 7.5, 3, 3], "rotation": 90, "texture": "#2"},
@@ -137,9 +137,9 @@
}
},
{
"from": [10, 12, 3],
"to": [12, 13, 4],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 9]},
"from": [10, 12, 2],
"to": [12, 13, 3],
"rotation": {"angle": 0, "axis": "z", "origin": [9, 4, 8]},
"faces": {
"north": {"uv": [3, 3.5, 3.5, 4.5], "rotation": 270, "texture": "#2"},
"east": {"uv": [3.5, 6, 3, 5.5], "rotation": 90, "texture": "#2"},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 467 B