-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
385 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
|
||
!/build.gradle | ||
!/.gitignore | ||
|
||
!/1.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Ignore All | ||
/* | ||
|
||
# Sources | ||
!/src | ||
|
||
# github | ||
!/.gitignore | ||
!/README.md | ||
|
||
# gradle | ||
!/build.gradle | ||
!/build.properties | ||
!/settings.gradle | ||
!/gradle.properties | ||
!/gradlew* | ||
!/gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
apply plugin: "maven-publish" | ||
apply plugin: "com.jfrog.artifactory" | ||
apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" | ||
|
||
idea.module.name = "Energy-MC-1.11" | ||
archivesBaseName = "NOVA-Energy-Wrapper-MC1.11" | ||
|
||
publishing { | ||
publications { | ||
main(MavenPublication) { | ||
from components.java | ||
|
||
artifactId archivesBaseName | ||
|
||
artifact sourcesJar | ||
artifact javadocJar | ||
|
||
pom.withXml(writePom(project.properties)) | ||
} | ||
} | ||
} | ||
|
||
artifactory { | ||
publish { | ||
defaults { | ||
publications("main") | ||
publishPom = true | ||
} | ||
} | ||
} | ||
|
||
task deobfJar(type: Jar) { | ||
from sourceSets.main.output | ||
classifier = 'deobf' | ||
} | ||
|
||
artifacts { | ||
archives jar | ||
archives deobfJar | ||
} | ||
|
||
apply plugin: 'net.minecraftforge.gradle.forge' | ||
|
||
minecraft { | ||
version = property("minecraft.version") + "-" + property("forge.version") | ||
mappings = 'snapshot_20161220' | ||
runDir = "run" | ||
} | ||
|
||
dependencies { | ||
compile rootProject | ||
compile group: "nova.core", name: "NOVA-Core", version: property("nova_version"), changing: true | ||
compile group: "nova.core", name: "NOVA-Core-Wrapper-MC1.11", version: property("nova_version"), classifier: 'deobf', changing: true | ||
} | ||
|
||
processResources { | ||
// this will ensure that this task is redone when the versions change. | ||
inputs.property "version", project.version | ||
inputs.property "mcversion", project.minecraft.version | ||
|
||
// replace stuff in mcmod.info, nothing else | ||
from(sourceSets.main.resources.srcDirs) { | ||
include "mcmod.info" | ||
|
||
// replace version and mcversion | ||
expand "version": project.version, "mcversion": project.minecraft.version | ||
} | ||
|
||
// copy everything else, thats not the mcmod.info | ||
from(sourceSets.main.resources.srcDirs) { | ||
exclude "mcmod.info" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
group = nova.energy | ||
|
||
minecraft.version = 1.11 | ||
forge.version = 13.19.1.2189 | ||
forgeGradleVersion = 2.2-SNAPSHOT | ||
|
||
packaging = jar | ||
info.inceptionYear = 2016 | ||
info.description = The NOVA-Minecraft Minecraft 1.11 wrapper. | ||
info.organization.name = NOVA |
102 changes: 102 additions & 0 deletions
102
...craft/1.11/src/main/java/nova/energy/wrapper/mc/forge/v1_11/launch/NovaEnergyWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (c) 2015 NOVA, All rights reserved. | ||
* This library is free software, licensed under GNU Lesser General Public License version 3 | ||
* | ||
* This file is part of NOVA. | ||
* | ||
* NOVA is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NOVA is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with NOVA. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package nova.energy.wrapper.mc.forge.v1_11.launch; | ||
|
||
import net.minecraft.util.EnumFacing; | ||
import net.minecraftforge.energy.CapabilityEnergy; | ||
import net.minecraftforge.energy.IEnergyStorage; | ||
import nova.core.event.bus.GlobalEvents; | ||
import nova.core.loader.Loadable; | ||
import nova.core.loader.Mod; | ||
import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; | ||
import nova.energy.EnergyStorage; | ||
import nova.energy.wrapper.mc.forge.v1_11.wrapper.energy.backward.BWEnergyStorage; | ||
import nova.energy.wrapper.mc.forge.v1_11.wrapper.energy.forward.FWEnergyStorage; | ||
|
||
/** | ||
* Compatibility with Forge Energy, which has been in Minecraft Forge since Minecraft 1.10.2. | ||
* | ||
* @author ExE Boss | ||
*/ | ||
@Mod(id = NovaEnergyWrapper.id, name = NovaEnergyWrapper.name, version = NovaEnergyWrapper.version, novaVersion = "0.1.0") | ||
public class NovaEnergyWrapper implements Loadable { | ||
|
||
public static final String version = "0.0.1"; | ||
public static final String id = "nova-energy-wrapper"; | ||
public static final String name = "NOVA Energy"; | ||
|
||
private final GlobalEvents events; | ||
|
||
public NovaEnergyWrapper(GlobalEvents events) { | ||
this.events = events; | ||
} | ||
|
||
@Override | ||
public void preInit() { | ||
events.on(WrapperEvent.BWBlockCreate.class).bind(evt -> { | ||
if (evt.novaBlock.getTileEntity() == null) | ||
return; | ||
|
||
IEnergyStorage energyCapability = null; | ||
for (EnumFacing facing : EnumFacing.values()) { | ||
if (!evt.novaBlock.getTileEntity().hasCapability(CapabilityEnergy.ENERGY, facing)) | ||
continue; | ||
|
||
energyCapability = evt.novaBlock.getTileEntity().getCapability(CapabilityEnergy.ENERGY, facing); | ||
if (energyCapability != null) | ||
break; // NOVA-Energy is Unsided | ||
} | ||
|
||
if (energyCapability == null && evt.novaBlock.getTileEntity().hasCapability(CapabilityEnergy.ENERGY, null)) | ||
energyCapability = evt.novaBlock.getTileEntity().getCapability(CapabilityEnergy.ENERGY, null); | ||
|
||
if (energyCapability != null) | ||
evt.novaBlock.components.add(new BWEnergyStorage(energyCapability)); | ||
}); | ||
|
||
events.on(WrapperEvent.BWItemCreate.class).bind(evt -> { | ||
if (evt.itemStack.isPresent() && evt.itemStack.get().hasCapability(CapabilityEnergy.ENERGY, null)) | ||
evt.novaItem.components.add(new BWEnergyStorage(evt.itemStack.get().getCapability(CapabilityEnergy.ENERGY, null))); | ||
}); | ||
|
||
events.on(WrapperEvent.BWEntityCreate.class).bind(evt -> { | ||
if (evt.mcEntity.hasCapability(CapabilityEnergy.ENERGY, null)) | ||
evt.novaEntity.components.add(new BWEnergyStorage(evt.mcEntity.getCapability(CapabilityEnergy.ENERGY, null))); | ||
}); | ||
|
||
events.on(WrapperEvent.FWTileCreate.class).bind(evt -> { | ||
if (evt.tileEntity == null) | ||
return; | ||
|
||
if (evt.novaBlock.components.has(EnergyStorage.class)) // Components are unsided | ||
evt.tileEntity.addCapability(CapabilityEnergy.ENERGY, new FWEnergyStorage(evt.novaBlock.components.get(EnergyStorage.class)), null); | ||
}); | ||
|
||
events.on(WrapperEvent.FWItemInitCapabilities.class).bind(evt -> { | ||
if (evt.novaItem.components.has(EnergyStorage.class)) // Components are unsided | ||
evt.capabilityProvider.addCapability(CapabilityEnergy.ENERGY, new FWEnergyStorage(evt.novaItem.components.get(EnergyStorage.class)), null); | ||
}); | ||
|
||
events.on(WrapperEvent.FWEntityCreate.class).bind(evt -> { | ||
if (evt.novaEntity.components.has(EnergyStorage.class)) // Components are unsided | ||
evt.mcEntity.addCapability(CapabilityEnergy.ENERGY, new FWEnergyStorage(evt.novaEntity.components.get(EnergyStorage.class)), null); | ||
}); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...main/java/nova/energy/wrapper/mc/forge/v1_11/wrapper/energy/backward/BWEnergyStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2015 NOVA, All rights reserved. | ||
* This library is free software, licensed under GNU Lesser General Public License version 3 | ||
* | ||
* This file is part of NOVA. | ||
* | ||
* NOVA is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NOVA is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with NOVA. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package nova.energy.wrapper.mc.forge.v1_11.wrapper.energy.backward; | ||
|
||
import net.minecraftforge.energy.IEnergyStorage; | ||
import nova.energy.EnergyStorage; | ||
import nova.energy.Unit; | ||
import nova.energy.UnitConversion; | ||
|
||
/** | ||
* | ||
* @author ExE Boss | ||
*/ | ||
public class BWEnergyStorage extends EnergyStorage { | ||
|
||
private static final UnitConversion RF_JOULE = UnitConversion.getConvertion(Unit.REDFLUX, Unit.JOULE).get(); | ||
private static final UnitConversion JOULE_RF = RF_JOULE.reverse(); | ||
|
||
private final IEnergyStorage mcEnergyStorage; | ||
|
||
public BWEnergyStorage(IEnergyStorage mcEnergyStorage) { | ||
this.mcEnergyStorage = mcEnergyStorage; | ||
} | ||
|
||
@Override | ||
public double recharge(double energy, boolean doRecharge) { | ||
return RF_JOULE.convert(mcEnergyStorage.receiveEnergy((int) Math.round(JOULE_RF.convert(energy)), !doRecharge)); | ||
} | ||
|
||
@Override | ||
public double discharge(double energy, boolean doDischarge) { | ||
return RF_JOULE.convert(mcEnergyStorage.extractEnergy((int) Math.round(JOULE_RF.convert(energy)), !doDischarge)); | ||
} | ||
|
||
@Override | ||
public double getEnergy() { | ||
return RF_JOULE.convert(mcEnergyStorage.getEnergyStored()); | ||
} | ||
|
||
@Override | ||
public void setEnergy(double energy) { | ||
int rf = (int) Math.round(JOULE_RF.convert(energy)) - mcEnergyStorage.getEnergyStored(); | ||
if (rf > 0) { | ||
mcEnergyStorage.receiveEnergy(rf, false); | ||
} else if (rf < 0) { | ||
mcEnergyStorage.extractEnergy(-rf, false); | ||
} | ||
} | ||
|
||
@Override | ||
public double getEnergyCapacity() { | ||
return RF_JOULE.convert(mcEnergyStorage.getMaxEnergyStored()); | ||
} | ||
|
||
@Override | ||
public boolean canDischarge() { | ||
return mcEnergyStorage.canExtract(); | ||
} | ||
|
||
@Override | ||
public boolean canRecharge() { | ||
return mcEnergyStorage.canReceive(); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
.../main/java/nova/energy/wrapper/mc/forge/v1_11/wrapper/energy/forward/FWEnergyStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package nova.energy.wrapper.mc.forge.v1_11.wrapper.energy.forward; | ||
|
||
import net.minecraftforge.energy.IEnergyStorage; | ||
import nova.energy.EnergyStorage; | ||
import nova.energy.Unit; | ||
import nova.energy.UnitConversion; | ||
|
||
/** | ||
* A FWEnergyStorage is a NOVA energy capability. | ||
* | ||
* @author ExE Boss | ||
*/ | ||
public class FWEnergyStorage implements IEnergyStorage { | ||
|
||
private static final UnitConversion RF_JOULE = UnitConversion.getConvertion(Unit.REDFLUX, Unit.JOULE).get(); | ||
private static final UnitConversion JOULE_RF = RF_JOULE.reverse(); | ||
|
||
private final EnergyStorage energyStorage; | ||
|
||
public FWEnergyStorage(EnergyStorage energyStorage) { | ||
this.energyStorage = energyStorage; | ||
} | ||
|
||
@Override | ||
public int receiveEnergy(int maxReceive, boolean simulate) { | ||
if (energyStorage != null) | ||
return (int) Math.round(JOULE_RF.convert(energyStorage.recharge(RF_JOULE.convert(maxReceive), !simulate))); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int extractEnergy(int maxExtract, boolean simulate) { | ||
if (energyStorage != null) | ||
return (int) Math.round(JOULE_RF.convert(energyStorage.discharge(RF_JOULE.convert(maxExtract), !simulate))); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getEnergyStored() { | ||
if (energyStorage != null) | ||
return (int) Math.round(JOULE_RF.convert(energyStorage.getEnergy())); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getMaxEnergyStored() { | ||
if (energyStorage != null) | ||
return (int) Math.round(JOULE_RF.convert(energyStorage.getEnergyCapacity())); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean canExtract() { | ||
if (energyStorage != null) | ||
return energyStorage.canDischarge(); | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canReceive() { | ||
if (energyStorage != null) | ||
return energyStorage.canRecharge(); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
subprojects { | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
maven { | ||
name "forge" | ||
url "http://files.minecraftforge.net/maven" | ||
} | ||
maven { | ||
name "sonatype" | ||
url "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
} | ||
dependencies { | ||
// Minecraft 1.11 requires newer ForgeGradle, while 1.7 and 1.8 require older. | ||
classpath 'net.minecraftforge.gradle:ForgeGradle:' + property('forgeGradleVersion') | ||
} | ||
} | ||
} |
Oops, something went wrong.