This commit is contained in:
LordMZTE 2023-06-13 20:04:55 +02:00
parent 9ff3d2fa1e
commit 0413e777aa
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
26 changed files with 423 additions and 4 deletions

130
.clang-format Normal file
View File

@ -0,0 +1,130 @@
---
AccessModifierOffset: 0
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveMacros: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros: []
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: After
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterJavaFieldAnnotations: true
#BreakArrays: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 90
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false # wtf
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros: ["BOOST_FOREACH"]
IfMacros: []
IncludeBlocks: Regroup
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
#IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
#InsertBraces: false
InsertTrailingCommas: Wrapped
JavaImportGroups: ["java"]
JavaScriptQuotes: Double
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: OuterScope
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PackConstructorInitializers: NextLine
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
#RemoveSemicolon: true
#RequiresClausePosition: OwnLine
#RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: After
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
StatementAttributeLikeMacros: []
StatementMacros: []
TabWidth: 4
TypenameMacros: []
UseCRLF: false # wtf
UseTab: Never
WhitespaceSensitiveMacros: ["BOOST_PP_STRINGSIZE"]

4
.gitignore vendored
View File

@ -1,4 +1,8 @@
.settings
.project
.classpath
.gradle
.idea
bin
build
run

View File

@ -24,8 +24,8 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.0"
group= "modgroup"
archivesBaseName = "modid"
group= "net.anvilcraft"
archivesBaseName = "pccompat"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
@ -34,10 +34,17 @@ minecraft {
repositories {
maven { url = "https://maven.tilera.xyz" }
maven {
url = "https://s3.tilera.xyz/cdn/minecraft/libs/"
metadataSources { artifact() }
}
}
dependencies {
implementation "covers1624:PowerConverters:1.7.10-2.11:deobf"
implementation "cofh:CoFHCore:[1.7.10]3.1.4-329:dev"
implementation "universalelectricity:universalelectricity:5.2.2:deobf"
implementation "universalelectricity:basiccomponents:2.0.1:deobf"
}
processResources {
@ -85,4 +92,4 @@ publishing {
mavenLocal()
}
}
}
}

View File

@ -0,0 +1,19 @@
package net.anvilcraft.pccompat;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.pccompat.blocks.BlockPowerConverterUniversalElectricity;
import net.anvilcraft.pccompat.items.ItemBlockPowerConverterUniversalElectricity;
import net.minecraft.block.Block;
public class PCCBlocks {
public static Block powerConverterUniversalElectricity;
public static void register() {
GameRegistry.registerBlock(
powerConverterUniversalElectricity
= new BlockPowerConverterUniversalElectricity(),
ItemBlockPowerConverterUniversalElectricity.class,
"power_converter_universal_electrictity"
);
}
}

View File

@ -0,0 +1,37 @@
package net.anvilcraft.pccompat;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import covers1624.powerconverters.api.registry.PowerSystemRegistry.PowerSystem;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityConsumer;
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityProducer;
@Mod(modid = "pccompat", name = "PC Compat", version = "0.1.0")
public class PCCompat {
public static PowerSystem universalElectricityPowerSystem;
@Mod.EventHandler
public static void preInit(FMLPreInitializationEvent ev) {
PowerSystemRegistry.registerPowerSystem(
universalElectricityPowerSystem = new PowerSystem(
"Universal Electricity",
"UE",
2500,
new String[] { "LV", "MV", "HV", "EV" },
new int[] { 60, 120, 240, 480 },
"W"
)
);
GameRegistry.registerTileEntity(
TileEntityUniversalElectricityConsumer.class, "universal_electricity_consumer"
);
GameRegistry.registerTileEntity(
TileEntityUniversalElectricityProducer.class, "universal_electricity_producer"
);
PCCBlocks.register();
}
}

View File

@ -0,0 +1,56 @@
package net.anvilcraft.pccompat.blocks;
import covers1624.powerconverters.block.BlockPowerConverter;
import covers1624.powerconverters.gui.PCCreativeTab;
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityConsumer;
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityProducer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockPowerConverterUniversalElectricity extends BlockPowerConverter {
public IIcon[] icons;
public BlockPowerConverterUniversalElectricity() {
super(8); // 4 Consumers, 4 Producers
this.setCreativeTab(PCCreativeTab.tab);
}
@Override
public void registerBlockIcons(IIconRegister reg) {
for (int i = 0; i < 16; i++) {
String state = i % 2 == 0 ? "off" : "on";
String type = (i / 2) % 2 == 0 ? "producer" : "consumer";
String voltage;
switch (i / 4) {
case 0:
voltage = "lv";
break;
case 1:
voltage = "mv";
break;
case 2:
voltage = "hv";
break;
default:
voltage = "ev";
break;
}
String texture_name = "pccompat:ue_" + voltage + "_" + type + "_" + state;
this._icons[i] = reg.registerIcon(texture_name);
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return meta % 2 != 0 ? new TileEntityUniversalElectricityProducer(meta / 2)
: new TileEntityUniversalElectricityConsumer(meta / 2);
}
}

View File

@ -0,0 +1,38 @@
package net.anvilcraft.pccompat.items;
import java.util.List;
import java.util.stream.IntStream;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPowerConverterUniversalElectricity extends ItemBlock {
public ItemBlockPowerConverterUniversalElectricity(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public int getMetadata(int meta) {
return meta;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
int meta = stack.getItemDamage();
return "pccompat:power_converter_ue_" + meta;
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item alec1, CreativeTabs alec2, List list) {
IntStream.range(0, 8)
.mapToObj((i) -> new ItemStack(this, 1, i))
.forEach(list::add);
}
}

View File

@ -0,0 +1,72 @@
package net.anvilcraft.pccompat.tiles;
import covers1624.powerconverters.api.registry.PowerSystemRegistry.PowerSystem;
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
import net.anvilcraft.pccompat.PCCompat;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IVoltage;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.core.electricity.ElectricityPack;
public class TileEntityUniversalElectricityConsumer
extends TileEntityEnergyConsumer<IConductor> implements IConnector, IVoltage {
private double wattsLastTick;
public TileEntityUniversalElectricityConsumer(int voltageNameIndex) {
super(
PCCompat.universalElectricityPowerSystem, voltageNameIndex, IConductor.class);
}
// TODO: WTF
public TileEntityUniversalElectricityConsumer() {
this(0);
}
@Override
public void updateEntity() {
super.updateEntity();
if (this.worldObj.isRemote)
return;
double desiredWatts = this.getTotalEnergyDemand() / this.getPowerSystem().getScaleAmmount();
ElectricityPack powerRequested = new ElectricityPack(desiredWatts / this.getVoltage(), this.getVoltage());
ElectricityPack powerPack = ElectricityNetworkHelper.consumeFromMultipleSides(this, powerRequested);
if (UniversalElectricity.isVoltageSensitive
&& powerPack.voltage > this.getVoltage()) {
this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
this.worldObj.createExplosion(
null, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, 1f, true);
}
double watts = powerPack.getWatts();
this.storeEnergy(
MathHelper.floor_double(watts * this.getPowerSystem().getScaleAmmount()),
false);
this.wattsLastTick = watts;
}
@Override
public boolean canConnect(ForgeDirection from) {
return true;
}
@Override
public double getInputRate() {
return wattsLastTick;
}
@Override
public double getVoltage() {
return this.getPowerSystem().getVoltageValues()[this.getVoltageIndex()];
}
}

View File

@ -0,0 +1,48 @@
package net.anvilcraft.pccompat.tiles;
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
import net.anvilcraft.pccompat.PCCompat;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IVoltage;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.core.electricity.ElectricityPack;
public class TileEntityUniversalElectricityProducer
extends TileEntityEnergyProducer<IConductor> implements IConnector, IVoltage {
public TileEntityUniversalElectricityProducer(int voltageNameIndex) {
super(
PCCompat.universalElectricityPowerSystem, voltageNameIndex, IConductor.class
);
}
// TODO: WTF
public TileEntityUniversalElectricityProducer() {
this(0);
}
@Override
public double getVoltage() {
return this.getPowerSystem().getVoltageValues()[this.getVoltageIndex()];
}
@Override
public boolean canConnect(ForgeDirection from) {
return true;
}
@Override
public double produceEnergy(double energy) {
double watts = energy / this.getPowerSystem().getScaleAmmount();
ElectricityPack powerRemaining
= ElectricityNetworkHelper.produceFromMultipleSides(
this, new ElectricityPack(watts / this.getVoltage(), this.getVoltage())
);
return MathHelper.floor_double(
powerRemaining.getWatts() * this.getPowerSystem().getScaleAmmount()
);
}
}

View File

@ -0,0 +1,8 @@
pccompat:power_converter_ue_0.name=UE 60V Consumer
pccompat:power_converter_ue_1.name=UE 60V Producer
pccompat:power_converter_ue_2.name=UE 120V Consumer
pccompat:power_converter_ue_3.name=UE 120V Producer
pccompat:power_converter_ue_4.name=UE 240V Consumer
pccompat:power_converter_ue_5.name=UE 240V Producer
pccompat:power_converter_ue_6.name=UE 480V Consumer
pccompat:power_converter_ue_7.name=UE 480V Producer

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B