mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Merge remote-tracking branch 'upstream/1.11' into 1.12
This commit is contained in:
commit
c9dc4c0ac0
468 files changed
+1602
-9935
No files matched your search
+73
-20
@@ -65,6 +65,14 @@ repositories {
|
||||
name 'buildcraft'
|
||||
url 'https://mod-buildcraft.com/maven/'
|
||||
}
|
||||
maven {
|
||||
name 'tterrag'
|
||||
url 'http://maven.tterrag.com/'
|
||||
}
|
||||
maven {
|
||||
name 'ic2'
|
||||
url 'http://maven.ic2.player.to'
|
||||
}
|
||||
}
|
||||
|
||||
// Define properties file
|
||||
@@ -96,11 +104,14 @@ dependencies {
|
||||
deobfProvided "mezz.jei:jei_${config.minecraft_version}:${config.jei_version}:api"
|
||||
runtime "mezz.jei:jei_${config.minecraft_version}:${config.jei_version}"
|
||||
compile "net.darkhax.tesla:Tesla-${config.minecraft_version}:${config.tesla_version}"
|
||||
compile "inventory-tweaks:InventoryTweaks:${config.invtweak_version}:api" // Not updated yet
|
||||
compile "inventory-tweaks:InventoryTweaks:${config.invtweak_version}:api"
|
||||
compile "li.cil.oc:OpenComputers:MC1.11.2-${config.opencomputers_version}:api" // Not updated yet
|
||||
deobfCompile "mcp.mobius.waila:Hwyla:${config.hwyla_version}"
|
||||
deobfCompile "cofh:RedstoneFlux:${config.minecraft_version}-${config.redstoneflux_version}:universal"
|
||||
deobfCompile "com.mod-buildcraft:buildcraft-api:${config.buildcraft_version}"
|
||||
deobfProvided "team.chisel.ctm:CTM:MC${config.minecraft_version}-${config.ctm_version}:api"
|
||||
runtime "team.chisel.ctm:CTM:MC${config.minecraft_version}-${config.ctm_version}"
|
||||
compile "net.industrial-craft:industrialcraft-2:${config.ic2_version}:api"
|
||||
}
|
||||
|
||||
processResources
|
||||
@@ -113,7 +124,9 @@ processResources
|
||||
}
|
||||
|
||||
task coreJar(type: Jar) {
|
||||
baseName = 'Mekanism'
|
||||
archiveName = "Mekanism-${project.version}.jar"
|
||||
dependsOn 'reobfJar'
|
||||
classifier "core"
|
||||
|
||||
from('etc/core') {
|
||||
include '*.info'
|
||||
@@ -126,7 +139,9 @@ task coreJar(type: Jar) {
|
||||
}
|
||||
|
||||
task toolsJar(type: Jar) {
|
||||
baseName = 'MekanismTools'
|
||||
archiveName = "MekanismTools-${project.version}.jar"
|
||||
dependsOn 'reobfJar'
|
||||
classifier "tools"
|
||||
|
||||
from('etc/tools') {
|
||||
include '*.info'
|
||||
@@ -139,7 +154,9 @@ task toolsJar(type: Jar) {
|
||||
}
|
||||
|
||||
task generatorsJar(type: Jar) {
|
||||
baseName = 'MekanismGenerators'
|
||||
archiveName = "MekanismGenerators-${project.version}.jar"
|
||||
dependsOn 'reobfJar'
|
||||
classifier "generators"
|
||||
|
||||
from('etc/generators') {
|
||||
include '*.info'
|
||||
@@ -151,28 +168,64 @@ task generatorsJar(type: Jar) {
|
||||
}
|
||||
}
|
||||
|
||||
coreJar.dependsOn('reobfJar')
|
||||
toolsJar.dependsOn('reobfJar')
|
||||
generatorsJar.dependsOn('reobfJar')
|
||||
|
||||
task MDKZip(type: Zip) {
|
||||
baseName = 'MDK'
|
||||
from sourceSets.main.java.srcDirs
|
||||
task apiJar(type: Jar) {
|
||||
classifier "api"
|
||||
baseName "Mekanism"
|
||||
dependsOn "sourceMainJava"
|
||||
include 'mekanism/api/**'
|
||||
from sourceSets.main.java.srcDirs
|
||||
from sourceSets.main.output
|
||||
}
|
||||
|
||||
task releaseJars(type: Copy) {
|
||||
from coreJar
|
||||
from toolsJar
|
||||
from generatorsJar
|
||||
from MDKZip
|
||||
rename '-(.*)jar', '.jar'
|
||||
rename '-(.*)zip', '.zip'
|
||||
into '.'
|
||||
artifacts {
|
||||
archives apiJar
|
||||
archives coreJar
|
||||
archives toolsJar
|
||||
archives generatorsJar
|
||||
}
|
||||
|
||||
task fullBuild(type: Delete) {
|
||||
delete jar
|
||||
dependsOn "build"
|
||||
}
|
||||
|
||||
fullBuild.dependsOn('releaseJars')
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
uploadArchives {
|
||||
if(System.getenv("LOCAL_MAVEN") != null) {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
repository(url: "file://"+System.getenv("LOCAL_MAVEN"))
|
||||
pom {
|
||||
groupId = project.group
|
||||
version = project.version
|
||||
if (System.getenv("MAVEN_ARTIFACT") != null) {
|
||||
artifactId = System.getenv("MAVEN_ARTIFACT")
|
||||
} else {
|
||||
artifactId = "Mekanism"
|
||||
}
|
||||
project {
|
||||
name "Mekanism"
|
||||
packaging 'jar'
|
||||
description 'Mekanism is a Minecraft add-on featuring high-tech machinery that can be used to create powerful tools, armor, and weapons.'
|
||||
url 'http://aidancbrady.com/mekanism/'
|
||||
scm {
|
||||
url 'https://github.com/aidancbrady/Mekanism.git'
|
||||
}
|
||||
issueManagement {
|
||||
system 'github'
|
||||
url 'https://github.com/aidancbrady/Mekanism/issues'
|
||||
}
|
||||
licenses {
|
||||
license {
|
||||
name 'MIT'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -3,10 +3,12 @@ mappings_version=snapshot_20170625
|
||||
forge_version=14.21.1.2387
|
||||
mcmp_version=2.2.1_36
|
||||
jei_version=4.7.0.67
|
||||
mod_version=9.3.3
|
||||
mod_version=9.3.4
|
||||
tesla_version=1.0.59
|
||||
invtweak_version=1.62+beta.89
|
||||
invtweak_version=1.63+beta.107
|
||||
opencomputers_version=1.7.0.24
|
||||
hwyla_version=1.8.18-B32_1.12
|
||||
redstoneflux_version=2.0.0.1
|
||||
buildcraft_version=7.99.6
|
||||
ctm_version=0.2.1.5
|
||||
ic2_version=2.8.9-ex112
|
||||
Binary file not shown.
@@ -1,57 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
/**
|
||||
* Base agriculture seed. Used to determine the state of a plant once it is planted from an item.
|
||||
*/
|
||||
public class BaseSeed {
|
||||
/**
|
||||
* Create a BaseSeed object.
|
||||
*
|
||||
* @param crop plant
|
||||
* @param size plant size
|
||||
* @param statGrowth plant growth stat
|
||||
* @param statGain plant gain stat
|
||||
* @param statResistance plant resistance stat
|
||||
* @param stackSize for internal usage only
|
||||
*/
|
||||
public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance) {
|
||||
this.crop = crop;
|
||||
this.size = size;
|
||||
this.statGrowth = statGrowth;
|
||||
this.statGain = statGain;
|
||||
this.statResistance = statResistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use the other constructor instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance, int stackSize) {
|
||||
this(crop, size, statGrowth, statGain, statResistance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plant.
|
||||
*/
|
||||
public final CropCard crop;
|
||||
|
||||
/**
|
||||
* Plant size.
|
||||
*/
|
||||
public int size;
|
||||
|
||||
/**
|
||||
* Plant growth stat.
|
||||
*/
|
||||
public int statGrowth;
|
||||
|
||||
/**
|
||||
* Plant gain stat.
|
||||
*/
|
||||
public int statGain;
|
||||
|
||||
/**
|
||||
* Plant resistance stat.
|
||||
*/
|
||||
public int statResistance;
|
||||
}
|
||||
Binary file not shown.
@@ -1,383 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Base agriculture crop.
|
||||
*
|
||||
* Any crop extending this can be registered using registerCrop to be added into the game.
|
||||
*/
|
||||
public abstract class CropCard {
|
||||
public CropCard() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Plant id for identifying this crop within your mod.
|
||||
* <br/>
|
||||
* The id has to be unique within the mod and is used for saving.
|
||||
* <br/>
|
||||
* By default this id will be also used to determine {@link #getUnlocalizedName()} and {@link #getTexturesLocation()}.
|
||||
*
|
||||
* @note changing the id or owner will cause existing crops in users' worlds to disappear.
|
||||
*
|
||||
* @return Plant id
|
||||
*/
|
||||
public abstract String getId();
|
||||
|
||||
/**
|
||||
* Determine the mod owning this crop.
|
||||
*
|
||||
* The owner serves as a name space. With every mod using a different owner, a mod only has to
|
||||
* make sure it doesn't have getId() conflicts within itself. The identifier has to be lower
|
||||
* case to ensure compatibility with future versions.
|
||||
* <br/>
|
||||
* It's recommended to hard code this to your lower case mod id as specified in the @Mod
|
||||
* annotation, as {@link #getUnlocalizedName()} will use it by default.
|
||||
* <br/>
|
||||
* <b>Do not use IC2's mod id here.</b>
|
||||
*
|
||||
* @note changing the id or owner will cause existing crops in users' worlds to disappear.
|
||||
*
|
||||
* @return owning mod identifier, lower case.
|
||||
*/
|
||||
public abstract String getOwner();
|
||||
|
||||
/**
|
||||
* Translation key for display to the player.
|
||||
*
|
||||
* It's recommended to specify a valid key from your language file here.
|
||||
* <br/>
|
||||
* e.g. Add <code>"yourmod.crop.yourCropName = Your crop's name"</code> to the language file,
|
||||
* override {@link #getId()} to return "yourCropName" and override {@link #getOwner()} to return "yourmod".
|
||||
*
|
||||
* @return Unlocalized name.
|
||||
*/
|
||||
public String getUnlocalizedName() {
|
||||
return getOwner() + ".crop." + getId(); //Good enough default
|
||||
}
|
||||
|
||||
/**
|
||||
* Your name here, will be shown in "Discovered by:" when analyzing seeds.
|
||||
*
|
||||
* @return Your name
|
||||
*/
|
||||
public String getDiscoveredBy() {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of your plant. Keep it short, a few characters per line for up to two lines.
|
||||
* Default is showing attributes of your plant, 2 per line.
|
||||
*
|
||||
* @param i line to get, starting from 0
|
||||
* @return The line
|
||||
*/
|
||||
public String desc(int i) {
|
||||
String[] att = getAttributes();
|
||||
|
||||
if (att == null || att.length == 0) return "";
|
||||
|
||||
if (i == 0) {
|
||||
String s = att[0];
|
||||
if (att.length >= 2) {
|
||||
s += ", " + att[1];
|
||||
if (att.length >= 3) s += ",";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
if (att.length < 3) return "";
|
||||
String s = att[2];
|
||||
if (att.length >= 4) s += ", " + att[3];
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop roots length. Maximum roots length should be 5.
|
||||
* @param cropTile reference to ICropTile
|
||||
* @return roots length use in isBlockBelow
|
||||
*/
|
||||
public int getRootsLength(ICropTile cropTile) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object containing the crop properties info - See {@link CropProperties} for more info.
|
||||
*/
|
||||
public abstract CropProperties getProperties();
|
||||
|
||||
/**
|
||||
* Additional attributes of the plant, also influencing breeding.
|
||||
* Plants sharing stats and attributes will tend to cross-breed more often.
|
||||
*
|
||||
* @return Attributes as an array of strings
|
||||
*/
|
||||
public String[] getAttributes() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the max crop size.
|
||||
*
|
||||
* Currently used for texture allocation, growth and harvesting control (by default).
|
||||
*/
|
||||
public abstract int getMaxSize();
|
||||
|
||||
/**
|
||||
* Amount of growth points needed to increase the plant's size.
|
||||
* Default is 200 * tier.
|
||||
*/
|
||||
public int getGrowthDuration(ICropTile cropTile) {
|
||||
return getProperties().getTier() * 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the plant can grow further.
|
||||
*
|
||||
* Consider:
|
||||
* - Humidity, nutrients and air quality
|
||||
* - Current size
|
||||
* - Light level
|
||||
* - Special biomes or conditions, accessible through crop.worldObj
|
||||
*
|
||||
* This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @return Whether the crop can grow
|
||||
*/
|
||||
public boolean canGrow(ICropTile cropTile) {
|
||||
return cropTile.getCurrentSize() < getMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the influence for the plant to grow based on humidity, nutrients and air.
|
||||
* Normal behavior is rating the three stats "normal", with each of them ranging from 0-30.
|
||||
* Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4)
|
||||
*
|
||||
* Default is humidity + nutrients + air (no factors).
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @param humidity ground humidity, influenced by hydration
|
||||
* @param nutrients nutrient quality in ground, based on fertilizers
|
||||
* @param air air quality, influences by open gardens and less crops surrounding this one
|
||||
* @return 0-30
|
||||
*/
|
||||
public int getWeightInfluences(ICropTile crop, int humidity, int nutrients, int air) {
|
||||
return humidity + nutrients + air;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to determine whether the plant can crossbreed with another crop.
|
||||
* Default is allow crossbreeding if the size is greater or equal than 3.
|
||||
*
|
||||
* @param crop crop to crossbreed with
|
||||
*/
|
||||
public boolean canCross(ICropTile crop) {
|
||||
return crop.getCurrentSize() >= 3;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the plant is rightclicked by a player.
|
||||
* Default action is harvesting.
|
||||
*
|
||||
* Only called Serverside.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @param player player rightclicking the crop
|
||||
* @return Whether the plant has changed
|
||||
*/
|
||||
public boolean onRightClick(ICropTile cropTile, EntityPlayer player) {
|
||||
return cropTile.performManualHarvest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use in Crop Harvester with insert Cropnalyzer to get best Output.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @return need crop size for best output.
|
||||
*/
|
||||
|
||||
public int getOptimalHarvestSize(ICropTile cropTile) {
|
||||
return getMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the crop can be harvested.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @return Whether the crop can be harvested in its current state.
|
||||
*/
|
||||
public boolean canBeHarvested(ICropTile cropTile) {
|
||||
return cropTile.getCurrentSize() == getMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops.
|
||||
* Default is 0.95^tier.
|
||||
*
|
||||
* @return Chance to drop the gains
|
||||
*/
|
||||
public double dropGainChance() {
|
||||
return Math.pow(0.95, getProperties().getTier());
|
||||
}
|
||||
|
||||
/**
|
||||
* Item obtained from harvesting the plant.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Item obtained
|
||||
*/
|
||||
public abstract ItemStack getGain(ICropTile crop);
|
||||
|
||||
/**
|
||||
* Get the size of the plant after harvesting.
|
||||
* Default is 1.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @return Plant size after harvesting
|
||||
*/
|
||||
public int getSizeAfterHarvest(ICropTile cropTile) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the plant is left clicked by a player.
|
||||
* Default action is picking the plant.
|
||||
*
|
||||
* Only called server side.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @param player player left clicked the crop
|
||||
* @return Whether the plant has changed
|
||||
*/
|
||||
public boolean onLeftClick(ICropTile cropTile, EntityPlayer player) {
|
||||
return cropTile.pick();
|
||||
}
|
||||
|
||||
/**
|
||||
* Base chance for dropping seeds when the plant is picked.
|
||||
* Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Chance to drop the seeds
|
||||
*/
|
||||
public float dropSeedChance(ICropTile crop) {
|
||||
if (crop.getCurrentSize() == 1) return 0;
|
||||
float base = 0.5F;
|
||||
if (crop.getCurrentSize() == 2) base /= 2F;
|
||||
for (int i = 0; i < getProperties().getTier(); i++) {
|
||||
base *= 0.8;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain seeds dropped when the plant is picked.
|
||||
* Multiple drops of the returned ItemStack can occur.
|
||||
* Default action is generating a seed from this crop.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Seeds
|
||||
*/
|
||||
public ItemStack getSeeds(ICropTile crop) {
|
||||
return crop.generateSeeds(crop.getCrop(), crop.getStatGrowth(), crop.getStatGain(), crop.getStatResistance(), crop.getScanLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a neighbor block to the crop has changed.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
*/
|
||||
public void onNeighbourChange(ICropTile crop) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the crop emits a redstone signal.
|
||||
*
|
||||
* @return Whether the crop emits a redstone signal.
|
||||
*/
|
||||
public boolean isRedstoneSignalEmitter(ICropTile cropTile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the emitted redstone signal strength.
|
||||
*
|
||||
* @return The redstone signal strength.
|
||||
*/
|
||||
public int getEmittedRedstoneSignal(ICropTile cropTile) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the crop is destroyed.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
*/
|
||||
public void onBlockDestroyed(ICropTile crop) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the light value emitted by the plant.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Light value emitted
|
||||
*/
|
||||
public int getEmittedLight(ICropTile crop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default is true if the entity is an EntityLiving in jumping or sprinting state.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @param entity entity colliding
|
||||
* @return Whether trampling calculation should happen, return false if the plant is no longer valid.
|
||||
*/
|
||||
public boolean onEntityCollision(ICropTile crop, Entity entity) {
|
||||
return (entity instanceof EntityLivingBase && entity.isSprinting());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called every time the crop ticks.
|
||||
* Should be called every 256 ticks or around 13 seconds.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
*/
|
||||
public void tick(ICropTile cropTile) {
|
||||
// nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this plant spreads weed to surrounding tiles.
|
||||
* Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2.
|
||||
*
|
||||
* @param cropTile reference to ICropTile
|
||||
* @return Whether the plant spreads weed
|
||||
*/
|
||||
public boolean isWeed(ICropTile cropTile) {
|
||||
return cropTile.getCurrentSize() >= 2 && (cropTile.getCrop() == Crops.weed || cropTile.getStatGrowth() >= 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the crop world.
|
||||
* @param cropTile reference to ICropTile.
|
||||
* @return The crop world object.
|
||||
*/
|
||||
public World getWorld(ICropTile cropTile) {
|
||||
return cropTile.getWorldObj();
|
||||
}
|
||||
|
||||
public abstract List<ResourceLocation> getTexturesLocation();
|
||||
}
|
||||
Binary file not shown.
@@ -1,78 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
/**
|
||||
* Describe the plant through a set of properties, influencing breeding.
|
||||
* Plants sharing properties and attributes will tend to cross-breed more often.
|
||||
*
|
||||
* Properties:
|
||||
* - Tier (Tier of the plant. Ranges from 1 to 16, 0 is Weed. Valuable and powerful crops have higher tiers, useless and
|
||||
* weak ones have lower tiers.)
|
||||
* - Chemistry (Industrial uses based on chemical plant components)
|
||||
* - Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used)
|
||||
* - Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general)
|
||||
* - Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects)
|
||||
* - Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here)
|
||||
*
|
||||
* @author IC2 Team
|
||||
*/
|
||||
public class CropProperties {
|
||||
|
||||
/**
|
||||
* Create a CropProperties object.
|
||||
*
|
||||
* @param tier Tier property value
|
||||
* @param chemistry Chemistry property value
|
||||
* @param consumable Consumable property value
|
||||
* @param defensive Defensive property value
|
||||
* @param colorful Colorful property value
|
||||
* @param weed Weed property value
|
||||
*/
|
||||
public CropProperties(int tier, int chemistry, int consumable, int defensive,
|
||||
int colorful, int weed) {
|
||||
this.tier = tier;
|
||||
this.chemistry = chemistry;
|
||||
this.consumable = consumable;
|
||||
this.defensive = defensive;
|
||||
this.colorful = colorful;
|
||||
this.weed = weed;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return this.tier;
|
||||
}
|
||||
|
||||
public int getChemistry() {
|
||||
return this.chemistry;
|
||||
}
|
||||
|
||||
public int getConsumable() {
|
||||
return this.consumable;
|
||||
}
|
||||
|
||||
public int getDefensive() {
|
||||
return this.defensive;
|
||||
}
|
||||
|
||||
public int getColorful() {
|
||||
return this.colorful;
|
||||
}
|
||||
|
||||
public int getWeed() {
|
||||
return this.weed;
|
||||
}
|
||||
|
||||
public int[] getAllProperties() {
|
||||
return new int[] { this.getChemistry(), this.getConsumable(), this.getDefensive(),
|
||||
this.getColorful(), this.getWeed() };
|
||||
}
|
||||
|
||||
/**
|
||||
* Fields
|
||||
*/
|
||||
private final int tier;
|
||||
private final int chemistry;
|
||||
private final int consumable;
|
||||
private final int defensive;
|
||||
private final int colorful;
|
||||
private final int weed;
|
||||
}
|
||||
Binary file not shown.
@@ -1,42 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
/**
|
||||
* List of possible blocks to be used as soil for a crop.
|
||||
* @author estebes
|
||||
*/
|
||||
public enum CropSoilType {
|
||||
//DIRT(Blocks.DIRT),
|
||||
FARMLAND(Blocks.FARMLAND),
|
||||
MYCELIUM(Blocks.MYCELIUM),
|
||||
SAND(Blocks.SAND),
|
||||
SOULSAND(Blocks.SOUL_SAND);
|
||||
|
||||
private CropSoilType(@Nonnull Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block can be used as soil.
|
||||
* @param block the block
|
||||
* @return true if the block is a possible crop soil
|
||||
*/
|
||||
public static boolean contais(Block block) {
|
||||
for (CropSoilType aux : CropSoilType.values()) {
|
||||
if (aux.getBlock() == block) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final Block block;
|
||||
}
|
||||
Binary file not shown.
@@ -1,113 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary.Type;
|
||||
|
||||
/**
|
||||
* General management of the crop system.
|
||||
*/
|
||||
public abstract class Crops {
|
||||
public static Crops instance;
|
||||
|
||||
public static CropCard weed; // weed has special properties, thus it's exposed here
|
||||
|
||||
/**
|
||||
* Adds a crop nutrient biome bonus.
|
||||
*
|
||||
* +10/-10 0 indicates no bonus and negative values indicate a penalty.
|
||||
*
|
||||
* @param type Forge biome type to apply the bonus in
|
||||
* @param nutrientsBonus Nutrient stat bonus
|
||||
*/
|
||||
public abstract void addBiomenutrientsBonus(Type type, int nutrientsBonus);
|
||||
|
||||
/**
|
||||
* Adds a crop humidity biome bonus.
|
||||
*
|
||||
* +10/-10 0 indicates no bonus and negative values indicate a penalty.
|
||||
*
|
||||
* @param type Forge biome type to apply the bonus in
|
||||
* @param humidityBonus Humidity stat bonus
|
||||
*/
|
||||
public abstract void addBiomehumidityBonus(Type type, int humidityBonus);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the humidity bonus for a biome.
|
||||
*
|
||||
* @param biome Biome to check
|
||||
* @return Humidity bonus or 0 if none
|
||||
*/
|
||||
public abstract int getHumidityBiomeBonus(Biome biome);
|
||||
|
||||
/**
|
||||
* Gets the nutrient bonus for a biome.
|
||||
*
|
||||
* @param biome Biome to check
|
||||
* @return Nutrient bonus or 0 if none
|
||||
*/
|
||||
public abstract int getNutrientBiomeBonus(Biome biome);
|
||||
|
||||
/**
|
||||
* Get the crop card for the specified owner and name.
|
||||
*
|
||||
* @param owner CropCard owner mod id.
|
||||
* @param name CropCard name.
|
||||
* @return Matching CropCard.
|
||||
*/
|
||||
public abstract CropCard getCropCard(String owner, String name);
|
||||
|
||||
/**
|
||||
* Get the crop card for the specified seed item stack.
|
||||
*
|
||||
* @param stack ItemStack containing seeds for the crop.
|
||||
* @return Matching CropCard.
|
||||
*/
|
||||
public abstract CropCard getCropCard(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Returns a list of all crops.
|
||||
*
|
||||
* @return All registered crops.
|
||||
*/
|
||||
public abstract Collection<CropCard> getCrops();
|
||||
|
||||
/**
|
||||
* Register a plant and provide a legacy id for migration.
|
||||
*
|
||||
* @param crop Plant to register.
|
||||
*/
|
||||
public abstract void registerCrop(CropCard crop);
|
||||
|
||||
/**
|
||||
* Registers a base seed, an item used to plant a crop.
|
||||
*
|
||||
* @param stack item
|
||||
* @param crop crop
|
||||
* @param size initial size
|
||||
* @param growth initial growth stat
|
||||
* @param gain initial gain stat
|
||||
* @param resistance initial resistance stat
|
||||
* @return True if successful
|
||||
*/
|
||||
public abstract boolean registerBaseSeed(ItemStack stack, CropCard crop, int size, int growth, int gain, int resistance);
|
||||
|
||||
/**
|
||||
* Finds a base seed from the given item.
|
||||
*
|
||||
* @return Base seed or null if none found
|
||||
*/
|
||||
public abstract BaseSeed getBaseSeed(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Execute registerSprites for all registered crop cards.
|
||||
*
|
||||
* This method will get called by IC2, don't call it yourself.
|
||||
*/
|
||||
//@SideOnly(Side.CLIENT)
|
||||
//public abstract void startSpriteRegistration(IIconRegister iconRegister);
|
||||
}
|
||||
Binary file not shown.
@@ -1,53 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CropCard example
|
||||
* @author estebes
|
||||
*/
|
||||
public class ExampleCropCard extends CropCard {
|
||||
@Override
|
||||
public String getId() {
|
||||
return "example";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return "myaddon";
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link CropProperties} for more info.
|
||||
*/
|
||||
@Override
|
||||
public CropProperties getProperties() {
|
||||
return new CropProperties(1, 0, 4, 0, 0, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSize() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getGain(ICropTile crop) {
|
||||
return new ItemStack(Items.DIAMOND, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceLocation> getTexturesLocation() {
|
||||
List<ResourceLocation> ret = new ArrayList<ResourceLocation>(getMaxSize());
|
||||
|
||||
for (int size = 1; size <= getMaxSize(); size++) {
|
||||
ret.add(new ResourceLocation("myaddon", "blocks/crop/" + getId() + "_" + size));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,81 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Interface implemented by ItemCropSeed.
|
||||
* @author estebes
|
||||
*/
|
||||
public interface ICropSeed {
|
||||
/**
|
||||
* Get the seed's crop.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @return Seed's crop.
|
||||
*/
|
||||
public CropCard getCropFromStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Set the seed's crop.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @param crop New CropCard object.
|
||||
*/
|
||||
public void setCropFromStack(ItemStack itemStack, CropCard crop);
|
||||
|
||||
/**
|
||||
* Get the seed's growth.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @return Seed's growth.
|
||||
*/
|
||||
public int getGrowthFromStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Set the seed's growth.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @param value New growth value.
|
||||
*/
|
||||
public void setGrowthFromStack(ItemStack itemStack, int value);
|
||||
|
||||
/**
|
||||
* Get the seed's gain.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @return Seed's gain.
|
||||
*/
|
||||
public int getGainFromStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Set the seed's growth.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @param value New growth value.
|
||||
*/
|
||||
public void setGainFromStack(ItemStack itemStack, int value);
|
||||
|
||||
/**
|
||||
* Get the seed's resistance.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @return Seed's resistance.
|
||||
*/
|
||||
public int getResistanceFromStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Set the seed's resistance.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @param value New resistance value.
|
||||
*/
|
||||
public void setResistanceFromStack(ItemStack itemStack, int value);
|
||||
|
||||
/**
|
||||
* Get the seed's scan level.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @return Seed's scan level.
|
||||
*/
|
||||
public int getScannedFromStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Set the seed's scan level.
|
||||
* @param itemStack The seed's itemstack.
|
||||
* @param value New scan level value.
|
||||
*/
|
||||
public void setScannedFromStack(ItemStack itemStack, int value);
|
||||
|
||||
public void incrementScannedFromStack(ItemStack itemStack);
|
||||
}
|
||||
Binary file not shown.
@@ -1,284 +0,0 @@
|
||||
package ic2.api.crops;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ic2.api.info.ILocatable;
|
||||
|
||||
/**
|
||||
* Interface implemented by the crop tile entity.
|
||||
*/
|
||||
public interface ICropTile extends ILocatable {
|
||||
/**
|
||||
* Get the crop.
|
||||
*
|
||||
* @return CropCard, or null if there is no plant currently on the crop
|
||||
*/
|
||||
public CropCard getCrop();
|
||||
|
||||
/**
|
||||
* Set the crop.
|
||||
*
|
||||
* @param cropCard CropCard or null for no plant
|
||||
*/
|
||||
public void setCrop(CropCard cropCard);
|
||||
|
||||
/**
|
||||
* Get the crop's plant size.
|
||||
*
|
||||
* @return Plant size, starting with 1 and maximum varies depending on plant
|
||||
*/
|
||||
public int getCurrentSize();
|
||||
|
||||
/**
|
||||
* Set the crop's plant size.
|
||||
*
|
||||
* @param size Plant size
|
||||
*/
|
||||
public void setCurrentSize(int size);
|
||||
|
||||
/**
|
||||
* Get the crop's plant growth stat.
|
||||
* Higher values indicate faster growth.
|
||||
*
|
||||
* @return Plant growth stat
|
||||
*/
|
||||
public int getStatGrowth();
|
||||
|
||||
/**
|
||||
* Set the crop's plant growth stat.
|
||||
*
|
||||
* @param growth Plant growth stat
|
||||
*/
|
||||
public void setStatGrowth(int growth);
|
||||
|
||||
/**
|
||||
* Get the crop's plant gain stat.
|
||||
* Higher values indicate more drops.
|
||||
*
|
||||
* @return Plant gain stat
|
||||
*/
|
||||
public int getStatGain();
|
||||
|
||||
/**
|
||||
* Set the crop's plant gain stat.
|
||||
*
|
||||
* @param gain Plant gain stat
|
||||
*/
|
||||
public void setStatGain(int gain);
|
||||
|
||||
/**
|
||||
* Get the crop's plant resistance stat.
|
||||
* Higher values indicate more resistance against trampling.
|
||||
*
|
||||
* @return Plant resistance stat
|
||||
*/
|
||||
public int getStatResistance();
|
||||
|
||||
/**
|
||||
* Set the crop's plant resistance stat.
|
||||
*
|
||||
* @param resistance Plant resistance stat
|
||||
*/
|
||||
public void setStatResistance(int resistance);
|
||||
|
||||
/**
|
||||
* Get the crop's nutrient storage.
|
||||
* Ranges from 0 to 100.
|
||||
*
|
||||
* @return Crop nutrient storage
|
||||
*/
|
||||
public int getStorageNutrients();
|
||||
|
||||
/**
|
||||
* Set the crop's nutrient storage.
|
||||
*
|
||||
* @param nutrients Crop nutrient storage
|
||||
*/
|
||||
public void setStorageNutrients(int nutrients);
|
||||
|
||||
/**
|
||||
* Get the crop's hydration storage.
|
||||
* 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells.
|
||||
*
|
||||
* @return Crop hydration storage
|
||||
*/
|
||||
public int getStorageWater();
|
||||
|
||||
/**
|
||||
* Set the crop's water storage.
|
||||
*
|
||||
* @param water Crop water storage
|
||||
*/
|
||||
public void setStorageWater(int water);
|
||||
|
||||
/**
|
||||
* Get the crop's Weed-Ex storage.
|
||||
*
|
||||
* @return Crop Weed-Ex storage
|
||||
*/
|
||||
public int getStorageWeedEX();
|
||||
|
||||
/**
|
||||
* Set the crop's Weed-Ex storage.
|
||||
*
|
||||
* @param weedEX Crop Weed-Ex storage
|
||||
*/
|
||||
public void setStorageWeedEX(int weedEX);
|
||||
|
||||
/**
|
||||
* Get the crop's plant scan level.
|
||||
* Increases every time the seed is analyzed.
|
||||
*
|
||||
* @return Plant scan level
|
||||
*/
|
||||
public int getScanLevel();
|
||||
|
||||
/**
|
||||
* Set the crop's plant scan level.
|
||||
*
|
||||
* @param scanLevel Plant scan level
|
||||
*/
|
||||
public void setScanLevel(int scanLevel);
|
||||
|
||||
public int getGrowthPoints();
|
||||
|
||||
public void setGrowthPoints(int growthPoints);
|
||||
|
||||
public boolean isCrossingBase();
|
||||
|
||||
public void setCrossingBase(boolean crossingBase);
|
||||
|
||||
/**
|
||||
* Get the crop's plant custom data, stored alongside the crop.
|
||||
* Can be modified in place.
|
||||
*
|
||||
* @return Plant custom data
|
||||
*/
|
||||
public NBTTagCompound getCustomData();
|
||||
|
||||
/**
|
||||
* Get the crop's humidity.
|
||||
* Ranges from 0 (dry) to 10 (humid).
|
||||
* Updates every couple of seconds or when an update is requested.
|
||||
*
|
||||
* @see #updateState()
|
||||
*
|
||||
* @return Crop humidity level
|
||||
*/
|
||||
public int getTerrainHumidity();
|
||||
|
||||
/**
|
||||
* Get the crop's nutrient level.
|
||||
* Ranges from 0 (empty) to 10 (full).
|
||||
* Updates every couple of seconds or when an update is requested.
|
||||
*
|
||||
* @see #updateState()
|
||||
*
|
||||
* @return Crop nutrient level
|
||||
*/
|
||||
public int getTerrainNutrients();
|
||||
|
||||
/**
|
||||
* Get the crop's air quality.
|
||||
* Ranges from 0 (cluttered) to 10 (fresh).
|
||||
* Updates every couple of seconds or when an update is requested.
|
||||
*
|
||||
* @see #updateState()
|
||||
*
|
||||
* @return Crop air quality
|
||||
*/
|
||||
public int getTerrainAirQuality();
|
||||
|
||||
/**
|
||||
* Get the crop's world.
|
||||
* @deprecated This method causes a MethodNotFoundException in a obfuscated environment.
|
||||
* Use {@link #getWorldObj()} instead
|
||||
*
|
||||
* @return Crop world
|
||||
*/
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the crop's location.
|
||||
* @deprecated Use {@link #getPosition()} instead.
|
||||
*
|
||||
* @return Crop location
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockPos getLocation();
|
||||
|
||||
/**
|
||||
* Get the crop's light level.
|
||||
*
|
||||
* @return Crop light level
|
||||
*/
|
||||
public int getLightLevel();
|
||||
|
||||
/**
|
||||
* Pick the crop, removing and giving seeds for the plant.
|
||||
*
|
||||
* @return true if successfully picked
|
||||
*/
|
||||
public boolean pick();
|
||||
|
||||
/**
|
||||
* Harvest the crop, turning it into gain and resetting its size.
|
||||
* drop output on ground
|
||||
*/
|
||||
public boolean performManualHarvest();
|
||||
|
||||
/**
|
||||
* Harvest the crop, turning it into gain and resetting its size.
|
||||
* drop output on ground
|
||||
* @return List<ItemStack> of harvest output
|
||||
*/
|
||||
|
||||
public List<ItemStack> performHarvest();
|
||||
|
||||
/**
|
||||
* Fully clears the crop without dropping anything.
|
||||
*/
|
||||
public void reset();
|
||||
|
||||
/**
|
||||
* Request a texture and lighting update.
|
||||
*/
|
||||
public void updateState();
|
||||
|
||||
/**
|
||||
* Check if a block is under the farmland containing the crop.
|
||||
* Searches up to 4 blocks below the farmland or an air space, whichever appears first.
|
||||
*
|
||||
* @param block block to search
|
||||
* @return Whether the block was found
|
||||
*/
|
||||
public boolean isBlockBelow(Block block);
|
||||
|
||||
/**
|
||||
* Check if a block is under the farmland containing the crop.
|
||||
* Searches up to 4 blocks below the farmland or an air space, whichever appears first.
|
||||
*
|
||||
* @param oreDictionaryName blocks to search
|
||||
* @return Whether the blocks were found
|
||||
*/
|
||||
public boolean isBlockBelow(String oreDictionaryName);
|
||||
|
||||
/**
|
||||
* Generate plant seeds with the given parameters.
|
||||
*
|
||||
* @param crop plant
|
||||
* @param growth plant growth stat
|
||||
* @param gain plant gain stat
|
||||
* @param resistance plant resistance stat
|
||||
* @param scan plant scan level
|
||||
* @return Plant seed item
|
||||
*/
|
||||
public ItemStack generateSeeds(CropCard crop, int growth, int gain, int resistance, int scan);
|
||||
}
|
||||
Binary file not shown.
@@ -1,18 +0,0 @@
|
||||
package ic2.api.energy;
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to the energy network.
|
||||
*
|
||||
* The old EnergyNet methods missing in IEnergyNet have been migrated to events (load, unload) or
|
||||
* removed (tiles no longer emit energy actively, the energy net implementation requests it).
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public final class EnergyNet {
|
||||
/**
|
||||
* Instance of the global EnergyNet class.
|
||||
*/
|
||||
public static IEnergyNet instance;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,90 +0,0 @@
|
||||
package ic2.api.energy;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.info.ILocatable;
|
||||
|
||||
/**
|
||||
* Interface representing the methods provided by the global EnergyNet class.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyNet {
|
||||
/**
|
||||
* Get the EnergyNet-registered tile for the specified position.
|
||||
*
|
||||
* The returned tile is always the main tile implementing IEnergySource/-Sink/-Conductor, which
|
||||
* is also what was registered to the energy net.
|
||||
*
|
||||
* For multi-blocks (IMetaDelegate) the connectivity handling is being done by sub tiles that
|
||||
* may or may not include the main tile. Sub tiles have to be queried separately through the
|
||||
* getSubTile method.
|
||||
*
|
||||
* As a consequence of always returning the main tile, the supplied position may not match the
|
||||
* returned tile's position.
|
||||
*
|
||||
* Connectivity checking -> IEnergyEmitter/IEnergyAcceptor -> getSubTile
|
||||
* Logic like energy I/O -> IEnergySource/IEnergySink/IEnergyConductor -> getTile
|
||||
*
|
||||
* @param world World containing the tile
|
||||
* @param pos position
|
||||
* @return main tile for the specified position or null if none is registered
|
||||
*/
|
||||
IEnergyTile getTile(World world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Get the sub tile at the specified position.
|
||||
*
|
||||
* See the description of {@link #getTile} about whether getTile or getSubTile is applicable.
|
||||
*
|
||||
* @param world World containing the tile
|
||||
* @param pos position
|
||||
* @return sub tile at the specified position or null if none is registered
|
||||
*/
|
||||
IEnergyTile getSubTile(World world, BlockPos pos);
|
||||
|
||||
<T extends TileEntity & IEnergyTile> void addTile(T tile);
|
||||
<T extends ILocatable & IEnergyTile> void addTile(T tile);
|
||||
|
||||
void removeTile(IEnergyTile tile);
|
||||
|
||||
World getWorld(IEnergyTile tile);
|
||||
|
||||
BlockPos getPos(IEnergyTile tile);
|
||||
|
||||
/**
|
||||
* Retrieve statistics for the tile entity specified.
|
||||
*
|
||||
* The statistics apply to the last simulated tick.
|
||||
*
|
||||
* @param tile Tile entity to check.
|
||||
* @return Statistics for the tile entity.
|
||||
*/
|
||||
NodeStats getNodeStats(IEnergyTile tile);
|
||||
|
||||
boolean dumpDebugInfo(World world, BlockPos pos, PrintStream console, PrintStream chat);
|
||||
|
||||
/**
|
||||
* Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2.
|
||||
*
|
||||
* @param tier tier
|
||||
* @return power in eu/t
|
||||
*/
|
||||
double getPowerFromTier(int tier);
|
||||
|
||||
/**
|
||||
* Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t.
|
||||
*
|
||||
* @param power in eu/t
|
||||
* @return tier
|
||||
*/
|
||||
int getTierFromPower(double power);
|
||||
|
||||
void registerEventReceiver(IEnergyNetEventReceiver receiver);
|
||||
void unregisterEventReceiver(IEnergyNetEventReceiver receiver);
|
||||
}
|
||||
Binary file not shown.
@@ -1,20 +0,0 @@
|
||||
package ic2.api.energy;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Interface for handlers being invoked after energy net changes.
|
||||
*
|
||||
* <p>Normally it's enough to listen for the neighbor update, which also happens, but using this
|
||||
* mechanism allows listening to events that are not adjacent. Mechanisms that inject energy over
|
||||
* a distance or provide compatibility with 3rd party energy may benefit from it.
|
||||
*
|
||||
* <p>The events will be fired after validation and only for successful changes.
|
||||
*
|
||||
* <p>WARNING: The events may (and will) be invoked from arbitrary threads. It's up to the
|
||||
* implementation of IEnergyNetEventReceiver to properly synchronize them.
|
||||
*/
|
||||
public interface IEnergyNetEventReceiver {
|
||||
void onAdd(IEnergyTile tile);
|
||||
void onRemove(IEnergyTile tile);
|
||||
}
|
||||
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
package ic2.api.energy;
|
||||
|
||||
public class NodeStats {
|
||||
public NodeStats(double energyIn, double energyOut, double voltage) {
|
||||
this.energyIn = energyIn;
|
||||
this.energyOut = energyOut;
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public double getEnergyIn() {
|
||||
return energyIn;
|
||||
}
|
||||
|
||||
public double getEnergyOut() {
|
||||
return energyOut;
|
||||
}
|
||||
|
||||
public double getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
protected double energyIn;
|
||||
protected double energyOut;
|
||||
protected double voltage;
|
||||
}
|
||||
Binary file not shown.
@@ -1,24 +0,0 @@
|
||||
package ic2.api.energy.event;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Base class for energy net events, don't use it directly.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public class EnergyTileEvent extends WorldEvent {
|
||||
public EnergyTileEvent(IEnergyTile tile) {
|
||||
super(EnergyNet.instance.getWorld(tile));
|
||||
|
||||
if (getWorld() == null) throw new NullPointerException("world is null");
|
||||
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public final IEnergyTile tile;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,26 +0,0 @@
|
||||
package ic2.api.energy.event;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Event announcing new energy tiles.
|
||||
*
|
||||
* This event notifies subscribers of loaded energy tiles, e.g. after getting
|
||||
* loaded through the chunk they are in or after being placed down by the
|
||||
* player or another deployer mechanism.
|
||||
*
|
||||
* Every energy tile which wants to get connected to the IC2 Energy Network has
|
||||
* to either post this event or alternatively call EnergyNet.addTileEntity().
|
||||
*
|
||||
* You may use this event to build a static representation of energy tiles for
|
||||
* your own energy grid implementation if you need to. It's not required if you
|
||||
* always lookup energy paths on demand.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public class EnergyTileLoadEvent extends EnergyTileEvent {
|
||||
public EnergyTileLoadEvent(IEnergyTile energyTile1) {
|
||||
super(energyTile1);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,27 +0,0 @@
|
||||
package ic2.api.energy.event;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Event announcing terminated energy tiles.
|
||||
*
|
||||
* This event notifies subscribers of unloaded energy tiles, e.g. after getting
|
||||
* unloaded through the chunk they are in or after being destroyed by the
|
||||
* player or another block pick/destruction mechanism.
|
||||
*
|
||||
* Every energy tile which wants to get disconnected from the IC2 Energy
|
||||
* Network has to either post this event or alternatively call
|
||||
* EnergyNet.removeTileEntity().
|
||||
*
|
||||
* You may use this event to build a static representation of energy tiles for
|
||||
* your own energy grid implementation if you need to. It's not required if you
|
||||
* always lookup energy paths on demand.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public class EnergyTileUnloadEvent extends EnergyTileEvent {
|
||||
public EnergyTileUnloadEvent(IEnergyTile energyTile1) {
|
||||
super(energyTile1);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,104 +0,0 @@
|
||||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* BasicEnergyTe.Sink and BasicEnergyTe.Source allow integrating tile entities into the energy net
|
||||
* by using them as the super class.
|
||||
*
|
||||
* <p>They implement the necessary forwards to make BasicSink/BasicSource work, provided the sub
|
||||
* classes always call those forwards when overriding them.
|
||||
*
|
||||
* <p>If it's not desirable to use BasicEnergyTe, the delegates like BasicSink can also be used
|
||||
* directly, provided they receive the forwards like implemented here.
|
||||
*
|
||||
* <p>Example usage, machine with 10k EU buffer, tier 2, 50 EU/tick, 100 tick process time:
|
||||
* <pre><code>
|
||||
* public class MyMachine extends BasicEnergyTe.Sink implements ITickable {
|
||||
* public MyMachine() {
|
||||
* super(10000, 2);
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void readFromNBT(NBTTagCompound nbt) {
|
||||
* super.readFromNbt(nbt); // important: keep super call
|
||||
*
|
||||
* this.progess = nbt.getInteger("progress");
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
* nbt = super.writeToNBT(nbt); // important: keep super call
|
||||
*
|
||||
* nbt.setInteger("progress", progress);
|
||||
*
|
||||
* return nbt;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void update() {
|
||||
* if (hasWork() && getEnergyBuffer().useEnergy(50) && ++progress >= 100) {
|
||||
* progress = 0;
|
||||
* doWork();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* private int progress;
|
||||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
public class BasicEnergyTe<T extends BasicEnergyTile> extends TileEntity {
|
||||
public static class Sink extends BasicEnergyTe<BasicSink> {
|
||||
public Sink(int capacity, int tier) {
|
||||
energyBuffer = new BasicSink(this, capacity, tier);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Source extends BasicEnergyTe<BasicSource> {
|
||||
public Source(int capacity, int tier) {
|
||||
energyBuffer = new BasicSource(this, capacity, tier);
|
||||
}
|
||||
}
|
||||
|
||||
protected BasicEnergyTe() { }
|
||||
|
||||
public T getEnergyBuffer() {
|
||||
return energyBuffer;
|
||||
}
|
||||
|
||||
// forwards >>
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
energyBuffer.onLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
energyBuffer.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
energyBuffer.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
energyBuffer.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
return energyBuffer.writeToNBT(super.writeToNBT(nbt));
|
||||
}
|
||||
|
||||
// << forwards
|
||||
|
||||
protected T energyBuffer;
|
||||
}
|
||||
Binary file not shown.
@@ -1,309 +0,0 @@
|
||||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.info.ILocatable;
|
||||
import ic2.api.info.Info;
|
||||
import ic2.api.item.ElectricItem;
|
||||
|
||||
/**
|
||||
* Common functionality for BasicSink and BasicSource.
|
||||
*/
|
||||
abstract class BasicEnergyTile implements ILocatable, IEnergyTile {
|
||||
// **********************************
|
||||
// *** Methods for use by the mod ***
|
||||
// **********************************
|
||||
|
||||
/**
|
||||
* Constructor for a new BasicSink delegate.
|
||||
*
|
||||
* @param parent TileEntity represented by this energy sink.
|
||||
* @param capacity Maximum amount of eu to store.
|
||||
* @param tier IC2 tier, 1 = LV, 2 = MV, ...
|
||||
*/
|
||||
protected BasicEnergyTile(TileEntity parent, double capacity) {
|
||||
this((Object) parent, capacity);
|
||||
}
|
||||
|
||||
protected BasicEnergyTile(ILocatable parent, double capacity) {
|
||||
this((Object) parent, capacity);
|
||||
}
|
||||
|
||||
private BasicEnergyTile(Object locationProvider, double capacity) {
|
||||
this.locationProvider = locationProvider;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
protected BasicEnergyTile(World world, BlockPos pos, double capacity) {
|
||||
if (world == null) throw new NullPointerException("null world");
|
||||
if (pos == null) throw new NullPointerException("null pos");
|
||||
|
||||
this.locationProvider = null;
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
// in-world te forwards >>
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's update(), used for creating the energy net link.
|
||||
* Either update or onLoad have to be used.
|
||||
*/
|
||||
public void update() {
|
||||
if (!addedToEnet) onLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the base TileEntity is loaded, used for creating the energy net link.
|
||||
* Either update or onLoad have to be used.
|
||||
*/
|
||||
public void onLoad() {
|
||||
if (!addedToEnet
|
||||
&& !getWorldObj().isRemote
|
||||
&& Info.isIc2Available()) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
|
||||
addedToEnet = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
public void invalidate() {
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
public void onChunkUnload() {
|
||||
if (addedToEnet
|
||||
&& !getWorldObj().isRemote
|
||||
&& Info.isIc2Available()) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
|
||||
addedToEnet = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound data = tag.getCompoundTag(getNbtTagName());
|
||||
energyStored = data.getDouble("energy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
|
||||
*/
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
data.setDouble("energy", energyStored);
|
||||
tag.setTag(getNbtTagName(), data);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
// << in-world te forwards
|
||||
// methods for using this adapter >>
|
||||
|
||||
/**
|
||||
* Get the maximum amount of energy this sink can hold in its buffer.
|
||||
*
|
||||
* @return Capacity in EU.
|
||||
*/
|
||||
public double getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum amount of energy this sink can hold in its buffer.
|
||||
*
|
||||
* @param capacity1 Capacity in EU.
|
||||
*/
|
||||
public void setCapacity(double capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the energy stored in this buffer.
|
||||
*
|
||||
* @return amount in EU, may be above capacity
|
||||
*/
|
||||
public double getEnergyStored() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stored energy to the specified amount.
|
||||
*
|
||||
* This is intended for server -> client synchronization, e.g. to display the stored energy in
|
||||
* a GUI through getEnergyStored().
|
||||
*
|
||||
* @param amount
|
||||
*/
|
||||
public void setEnergyStored(double amount) {
|
||||
energyStored = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the free capacity in this buffer.
|
||||
*
|
||||
* @return amount in EU
|
||||
*/
|
||||
public double getFreeCapacity() {
|
||||
return capacity - energyStored;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some energy to the output buffer.
|
||||
*
|
||||
* @param amount maximum amount of energy to add
|
||||
* @return amount added/used, NOT remaining
|
||||
*/
|
||||
public double addEnergy(double amount) {
|
||||
if (getWorldObj().isRemote) return 0;
|
||||
if (amount > capacity - energyStored) amount = capacity - energyStored;
|
||||
|
||||
energyStored += amount;
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the specified amount of energy is available.
|
||||
*
|
||||
* @param amount in EU
|
||||
* @return true if the amount is available
|
||||
*/
|
||||
public boolean canUseEnergy(double amount) {
|
||||
return energyStored >= amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the specified amount of energy, if available.
|
||||
*
|
||||
* @param amount amount to use
|
||||
* @return true if the amount was available
|
||||
*/
|
||||
public boolean useEnergy(double amount) {
|
||||
if (!canUseEnergy(amount) || getWorldObj().isRemote) return false;
|
||||
|
||||
energyStored -= amount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge the supplied ItemStack from this energy buffer.
|
||||
*
|
||||
* @param stack ItemStack to charge (null is ignored)
|
||||
* @return true if energy was transferred
|
||||
*/
|
||||
public boolean charge(ItemStack stack) {
|
||||
if (stack == null || stack.isEmpty() || !Info.isIc2Available() || getWorldObj().isRemote) return false;
|
||||
|
||||
double amount = ElectricItem.manager.charge(stack, energyStored, Math.max(getSinkTier(), getSourceTier()), false, false);
|
||||
|
||||
energyStored -= amount;
|
||||
|
||||
return amount > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discharge the supplied ItemStack into this energy buffer.
|
||||
*
|
||||
* @param stack ItemStack to discharge (null is ignored)
|
||||
* @param limit Transfer limit, values <= 0 will use the battery's limit
|
||||
* @return true if energy was transferred
|
||||
*/
|
||||
public boolean discharge(ItemStack stack, double limit) {
|
||||
if (stack == null || stack.isEmpty() || !Info.isIc2Available() || getWorldObj().isRemote) return false;
|
||||
|
||||
double amount = capacity - energyStored;
|
||||
if (amount <= 0) return false;
|
||||
|
||||
if (limit > 0 && limit < amount) amount = limit;
|
||||
|
||||
amount = ElectricItem.manager.discharge(stack, amount, Math.max(getSinkTier(), getSourceTier()), limit > 0, true, false);
|
||||
|
||||
energyStored += amount;
|
||||
|
||||
return amount > 0;
|
||||
}
|
||||
|
||||
// << methods for using this adapter
|
||||
|
||||
// ******************************
|
||||
// *** Methods for use by ic2 ***
|
||||
// ******************************
|
||||
|
||||
// ILocatable >>
|
||||
|
||||
@Override
|
||||
public World getWorldObj() {
|
||||
if (world == null) initLocation();
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPosition() {
|
||||
if (pos == null) initLocation();
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
private void initLocation() {
|
||||
if (locationProvider instanceof ILocatable) {
|
||||
ILocatable provider = (ILocatable) locationProvider;
|
||||
world = provider.getWorldObj();
|
||||
pos = provider.getPosition();
|
||||
} else if (locationProvider instanceof TileEntity) {
|
||||
TileEntity provider = (TileEntity) locationProvider;
|
||||
world = provider.getWorld();
|
||||
pos = provider.getPos();
|
||||
} else {
|
||||
throw new IllegalStateException("no/incompatible location provider");
|
||||
}
|
||||
}
|
||||
|
||||
// << ILocatable
|
||||
|
||||
protected abstract String getNbtTagName();
|
||||
|
||||
protected int getSinkTier() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getSourceTier() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private final Object locationProvider;
|
||||
protected World world;
|
||||
protected BlockPos pos;
|
||||
|
||||
protected double capacity;
|
||||
protected double energyStored;
|
||||
protected boolean addedToEnet;
|
||||
}
|
||||
Binary file not shown.
@@ -1,155 +0,0 @@
|
||||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.info.ILocatable;
|
||||
|
||||
/**
|
||||
* BasicSink is a simple delegate to provide an ic2 energy sink.
|
||||
*
|
||||
* <p>It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a
|
||||
* one-time configurable input energy buffer, thus providing a common use case for machines.
|
||||
*
|
||||
* <p>A simpler alternative is to use {@link BasicSinkTe.Sink}, which requires injecting into the
|
||||
* type hierarchy (using it as a super class). BasicSink however can be added to any class without
|
||||
* inheritance, but needs some forwards for keeping its state and registering with the energy net.
|
||||
*
|
||||
* <p>The constraints set by BasicSink like the strict tank-like energy buffering should provide a
|
||||
* more easy to use and stable interface than using IEnergySink directly while aiming for
|
||||
* optimal performance.
|
||||
*
|
||||
* <p>Using BasicSink involves the following steps:<ul>
|
||||
* <li>create a BasicSink instance in your TileEntity, typically in a field
|
||||
* <li>forward onLoad (or update), invalidate, onChunkUnload, readFromNBT and writeToNBT to the BasicSink
|
||||
* instance.
|
||||
* <li>call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available
|
||||
* without consuming the energy.
|
||||
* <li>optionally use getEnergyStored to display the output buffer charge level
|
||||
* <li>optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container)</ul>
|
||||
*
|
||||
* <p>Example implementation code:
|
||||
* <pre><code>
|
||||
* public class SomeTileEntity extends TileEntity {
|
||||
* // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV)
|
||||
* private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1);
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void onLoad() {
|
||||
* ic2EnergySink.onLoad(); // notify the energy sink
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void invalidate() {
|
||||
* ic2EnergySink.invalidate(); // notify the energy sink
|
||||
* ...
|
||||
* super.invalidate(); // this is important for mc!
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void onChunkUnload() {
|
||||
* ic2EnergySink.onChunkUnload(); // notify the energy sink
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void readFromNBT(NBTTagCompound tag) {
|
||||
* super.readFromNBT(tag);
|
||||
*
|
||||
* ic2EnergySink.readFromNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void writeToNBT(NBTTagCompound tag) {
|
||||
* super.writeToNBT(tag);
|
||||
*
|
||||
* ic2EnergySink.writeToNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void update() {
|
||||
* if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick
|
||||
* ... // do something with the energy
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
public class BasicSink extends BasicEnergyTile implements IEnergySink {
|
||||
/**
|
||||
* Constructor for a new BasicSink delegate.
|
||||
*
|
||||
* @param parent TileEntity represented by this energy sink.
|
||||
* @param capacity Maximum amount of eu to store.
|
||||
* @param tier IC2 tier, 1 = LV, 2 = MV, ...
|
||||
*/
|
||||
public BasicSink(TileEntity parent, double capacity, int tier) {
|
||||
super(parent, capacity);
|
||||
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public BasicSink(ILocatable parent, double capacity, int tier) {
|
||||
super(parent, capacity);
|
||||
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public BasicSink(World world, BlockPos pos, double capacity, int tier) {
|
||||
super(world, pos, capacity);
|
||||
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IC2 energy tier for this sink.
|
||||
*
|
||||
* @param tier IC2 Tier.
|
||||
*/
|
||||
public void setSinkTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
// energy net interface >>
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy() {
|
||||
return Math.max(0, capacity - energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
energyStored += amount;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSinkTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
// << energy net interface
|
||||
|
||||
@Override
|
||||
protected String getNbtTagName() {
|
||||
return "IC2BasicSink";
|
||||
}
|
||||
|
||||
protected int tier;
|
||||
}
|
||||
Binary file not shown.
@@ -1,114 +0,0 @@
|
||||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.info.ILocatable;
|
||||
|
||||
/**
|
||||
* Combination of BasicSink and BasicSource, see their respective documentation for details.
|
||||
*
|
||||
* <p>A subclass still has to implement acceptsEnergyFrom and emitsEnergyTo.
|
||||
*/
|
||||
public abstract class BasicSinkSource extends BasicEnergyTile implements IEnergySink, IEnergySource {
|
||||
public BasicSinkSource(TileEntity parent, double capacity, int sinkTier, int sourceTier) {
|
||||
super(parent, capacity);
|
||||
|
||||
this.sinkTier = sinkTier;
|
||||
this.sourceTier = sourceTier;
|
||||
double power = EnergyNet.instance.getPowerFromTier(sourceTier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
}
|
||||
|
||||
public BasicSinkSource(ILocatable parent, double capacity, int sinkTier, int sourceTier) {
|
||||
super(parent, capacity);
|
||||
|
||||
this.sinkTier = sinkTier;
|
||||
this.sourceTier = sourceTier;
|
||||
double power = EnergyNet.instance.getPowerFromTier(sourceTier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
}
|
||||
|
||||
public BasicSinkSource(World world, BlockPos pos, double capacity, int sinkTier, int sourceTier) {
|
||||
super(world, pos, capacity);
|
||||
|
||||
this.sinkTier = sinkTier;
|
||||
this.sourceTier = sourceTier;
|
||||
double power = EnergyNet.instance.getPowerFromTier(sourceTier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IC2 energy tier for this sink.
|
||||
*
|
||||
* @param tier IC2 Tier.
|
||||
*/
|
||||
public void setSinkTier(int tier) {
|
||||
this.sinkTier = tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IC2 energy tier for this source.
|
||||
*
|
||||
* @param tier IC2 Tier.
|
||||
*/
|
||||
public void setSourceTier(int tier) {
|
||||
double power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
|
||||
this.sourceTier = tier;
|
||||
}
|
||||
|
||||
// energy net interface >>
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy() {
|
||||
return Math.max(0, capacity - energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
energyStored += amount;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSinkTier() {
|
||||
return sinkTier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount) {
|
||||
energyStored -= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceTier() {
|
||||
return sourceTier;
|
||||
}
|
||||
|
||||
// << energy net interface
|
||||
|
||||
@Override
|
||||
protected String getNbtTagName() {
|
||||
return "IC2BasicSinkSource";
|
||||
}
|
||||
|
||||
protected int sinkTier;
|
||||
protected int sourceTier;
|
||||
}
|
||||
Binary file not shown.
@@ -1,165 +0,0 @@
|
||||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.info.ILocatable;
|
||||
|
||||
/**
|
||||
* BasicSource is a simple delegate to add an ic2 energy source.
|
||||
*
|
||||
* <p>It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a
|
||||
* one-time configurable output energy buffer, thus providing a common use case for generators.
|
||||
*
|
||||
* <p>A simpler alternative is to use {@link BasicSinkTe.Source}, which requires injecting into the
|
||||
* type hierarchy (using it as a super class). BasicSource however can be added to any class without
|
||||
* inheritance, but needs some forwards for keeping its state and registering with the energy net.
|
||||
*
|
||||
* <p>The constraints set by BasicSource like the strict tank-like energy buffering should provide a
|
||||
* more easy to use and stable interface than using IEnergySource directly while aiming for
|
||||
* optimal performance.
|
||||
*
|
||||
* <p>Using BasicSource involves the following steps:<ul>
|
||||
* <li>create a BasicSource instance in your TileEntity, typically in a field
|
||||
* <li>forward onLoad (or update), invalidate, onChunkUnload, readFromNBT ans writeToNBT to the BasicSource
|
||||
* instance.
|
||||
* <li>call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator
|
||||
* should run
|
||||
* <li>optionally use getEnergyStored to display the output buffer charge level
|
||||
* <li>optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container)</ul>
|
||||
*
|
||||
* <p>Example implementation code:
|
||||
* <pre><code>
|
||||
* public class SomeTileEntity extends TileEntity {
|
||||
* // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV)
|
||||
* private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1);
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void onLoad() {
|
||||
* ic2EnergySource.onLoad(); // notify the energy source
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void invalidate() {
|
||||
* ic2EnergySource.invalidate(); // notify the energy source
|
||||
* ...
|
||||
* super.invalidate(); // this is important for mc!
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void onChunkUnload() {
|
||||
* ic2EnergySource.onChunkUnload(); // notify the energy source
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void readFromNBT(NBTTagCompound tag) {
|
||||
* super.readFromNBT(tag);
|
||||
*
|
||||
* ic2EnergySource.readFromNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void writeToNBT(NBTTagCompound tag) {
|
||||
* super.writeToNBT(tag);
|
||||
*
|
||||
* ic2EnergySource.writeToNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void update() {
|
||||
* ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
public class BasicSource extends BasicEnergyTile implements IEnergySource {
|
||||
/**
|
||||
* Constructor for a new BasicSource delegate.
|
||||
*
|
||||
* @param parent1 Base TileEntity represented by this energy source.
|
||||
* @param capacity1 Maximum amount of eu to store.
|
||||
* @param tier1 IC2 tier, 1 = LV, 2 = MV, ...
|
||||
*/
|
||||
public BasicSource(TileEntity parent, double capacity, int tier) {
|
||||
super(parent, capacity);
|
||||
|
||||
this.tier = tier;
|
||||
double power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
}
|
||||
|
||||
public BasicSource(ILocatable parent, double capacity, int tier) {
|
||||
super(parent, capacity);
|
||||
|
||||
this.tier = tier;
|
||||
double power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
}
|
||||
|
||||
public BasicSource(World world, BlockPos pos, double capacity, int tier) {
|
||||
super(world, pos, capacity);
|
||||
|
||||
this.tier = tier;
|
||||
double power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IC2 energy tier for this source.
|
||||
*
|
||||
* @param tier1 IC2 Tier.
|
||||
*/
|
||||
public void setSourceTier(int tier) {
|
||||
double power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (getCapacity() < power) setCapacity(power);
|
||||
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
// energy net interface >>
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount) {
|
||||
energyStored -= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
// << energy net interface
|
||||
|
||||
@Override
|
||||
protected String getNbtTagName() {
|
||||
return "IC2BasicSource";
|
||||
}
|
||||
|
||||
protected int tier;
|
||||
}
|
||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Represents a slot (or set of slots) that can have electric items in them to be charged
|
||||
*
|
||||
* @author Chocohead
|
||||
*/
|
||||
public interface IChargingSlot {
|
||||
/**
|
||||
* Called when the energy component is ticked to fill the slots
|
||||
*
|
||||
* @param amount The amount of energy available for the slot(s)
|
||||
* @return The amount of energy used charging the items in the slot(s)
|
||||
*/
|
||||
public double charge(double amount);
|
||||
}
|
||||
Binary file not shown.
@@ -1,21 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* Interface, that allows Blocks to be colored and have their connectivity based on that color.
|
||||
* This allows for any Energy Tile to be colored. (Conductors, Sinks, Sources)
|
||||
* @author Aroma1997
|
||||
*/
|
||||
public interface IColoredEnergyTile extends IEnergyTile {
|
||||
|
||||
/**
|
||||
* This is to get a Energy Tile's color for the given side. Mainly used for checking connectivity.
|
||||
* @param side The side you want to get the color from.
|
||||
* @return The color of the Energy Tile at the given side or null, if it's uncolored.
|
||||
*/
|
||||
EnumDyeColor getColor(EnumFacing side);
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1,17 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Represents a slot (or set of slots) that can have electric items in them to be discharged
|
||||
*
|
||||
* @author Chocohead
|
||||
*/
|
||||
public interface IDischargingSlot {
|
||||
/**
|
||||
* Called when the energy component is ticked to empty the slots
|
||||
*
|
||||
* @param space The amount of free space for energy that can be stored
|
||||
* @param ignoreLimit Whether to ignore the discharge limit of the item in the slot(s)
|
||||
* @return The amount of energy discharged from the items in the slot(s)
|
||||
*/
|
||||
public double discharge(double space, boolean ignoreLimit);
|
||||
}
|
||||
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* For internal/multi-block usage only.
|
||||
*
|
||||
* @see IEnergySink
|
||||
* @see IEnergyConductor
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyAcceptor extends IEnergyTile {
|
||||
/**
|
||||
* Determine if this acceptor can accept current from an adjacent emitter in a direction.
|
||||
*
|
||||
* The TileEntity in the emitter parameter is what was originally added to the energy net,
|
||||
* which may be normal in-world TileEntity, a delegate or an IMetaDelegate.
|
||||
*
|
||||
* @param emitter energy emitter, may also be null or an IMetaDelegate
|
||||
* @param side side the energy is being received from
|
||||
*/
|
||||
boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing side);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,53 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this
|
||||
* interface.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter {
|
||||
/**
|
||||
* Energy loss for the conductor in EU per block.
|
||||
*
|
||||
* @return Energy loss
|
||||
*/
|
||||
double getConductionLoss();
|
||||
|
||||
/**
|
||||
* Amount of energy the insulation will handle before shocking nearby players and mobs.
|
||||
*
|
||||
* @return Insulation energy absorption in EU
|
||||
*/
|
||||
double getInsulationEnergyAbsorption();
|
||||
|
||||
/**
|
||||
* Amount of energy the insulation will handle before it is destroyed.
|
||||
* Ensure that this value is greater than the insulation energy absorption + 64.
|
||||
*
|
||||
* @return Insulation-destroying energy in EU
|
||||
*/
|
||||
double getInsulationBreakdownEnergy();
|
||||
|
||||
/**
|
||||
* Amount of energy the conductor will handle before it melts.
|
||||
*
|
||||
* @return Conductor-destroying energy in EU
|
||||
*/
|
||||
double getConductorBreakdownEnergy();
|
||||
|
||||
/**
|
||||
* Remove the conductor's insulation if the insulation breakdown energy was exceeded.
|
||||
*
|
||||
* @see #getInsulationBreakdownEnergy()
|
||||
*/
|
||||
void removeInsulation();
|
||||
|
||||
/**
|
||||
* Remove the conductor if the conductor breakdown energy was exceeded.
|
||||
*
|
||||
* @see #getConductorBreakdownEnergy()
|
||||
*/
|
||||
void removeConductor();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,26 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* For internal/multi-block usage only.
|
||||
*
|
||||
* @see IEnergySource
|
||||
* @see IEnergyConductor
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyEmitter extends IEnergyTile {
|
||||
/**
|
||||
* Determine if this emitter can emit energy to an adjacent receiver.
|
||||
*
|
||||
* The TileEntity in the receiver parameter is what was originally added to the energy net,
|
||||
* which may be normal in-world TileEntity, a delegate or an IMetaDelegate.
|
||||
*
|
||||
* @param receiver receiver, may also be null or an IMetaDelegate
|
||||
* @param side side the energy is to be sent to
|
||||
* @return Whether energy should be emitted
|
||||
*/
|
||||
boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing side);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,45 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* Allows a tile entity (mostly a machine) to receive energy.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergySink extends IEnergyAcceptor {
|
||||
/**
|
||||
* Determine how much energy the sink accepts.
|
||||
*
|
||||
* Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0.
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
*
|
||||
* @return max accepted input in eu
|
||||
*/
|
||||
double getDemandedEnergy();
|
||||
|
||||
/**
|
||||
* Determine the tier of this energy sink.
|
||||
* 1 = LV, 2 = MV, 3 = HV, 4 = EV etc.
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
* @note Return Integer.MAX_VALUE to allow any voltage.
|
||||
*
|
||||
* @return tier of this energy sink
|
||||
*/
|
||||
int getSinkTier();
|
||||
|
||||
/**
|
||||
* Transfer energy to the sink.
|
||||
*
|
||||
* It's highly recommended to accept all energy by letting the internal buffer overflow to
|
||||
* increase the performance and accuracy of the distribution simulation.
|
||||
*
|
||||
* @param directionFrom direction from which the energy comes from
|
||||
* @param amount energy to be transferred
|
||||
* @return Energy not consumed (leftover)
|
||||
*/
|
||||
double injectEnergy(EnumFacing directionFrom, double amount, double voltage);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,40 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Allows a tile entity (mostly a generator) to emit energy.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergySource extends IEnergyEmitter {
|
||||
/**
|
||||
* Maximum energy output provided by the source this tick, typically the stored energy.
|
||||
*
|
||||
* <p>The value will be limited to the source tier's power multiplied with the packet count
|
||||
* (see {@link IMultiEnergySource}, default 1).
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
*
|
||||
* @return Energy offered this tick
|
||||
*/
|
||||
double getOfferedEnergy();
|
||||
|
||||
/**
|
||||
* Draw energy from this source's buffer.
|
||||
*
|
||||
* <p>If the source doesn't have a buffer, this may be a no-op.
|
||||
*
|
||||
* @param amount amount of EU to draw, may be negative
|
||||
*/
|
||||
void drawEnergy(double amount);
|
||||
|
||||
/**
|
||||
* Determine the tier of this energy source.
|
||||
* 1 = LV, 2 = MV, 3 = HV, 4 = EV etc.
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
*
|
||||
* @return tier of this energy source
|
||||
*/
|
||||
int getSourceTier();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,15 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* For internal usage only, base class for all energy tiles.
|
||||
*
|
||||
* @see IEnergySink
|
||||
* @see IEnergySource
|
||||
* @see IEnergyConductor
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyTile {
|
||||
//
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Implement with an {@link IEnergySink} tile entity to change the force of the explosion when overpowered.
|
||||
*/
|
||||
public interface IExplosionPowerOverride {
|
||||
|
||||
/**
|
||||
* Checks if the electric tile should explode. If you return false here,
|
||||
* the explosion will just not happen at all and the block will stay.
|
||||
* This is NOT recommended.
|
||||
* @return Whether the block should explode.
|
||||
*
|
||||
* @note It should not be dependent on the tier of the power injected, consider {@link IOverloadHandler} if necessary.
|
||||
*/
|
||||
boolean shouldExplode();
|
||||
|
||||
/**
|
||||
* The explosion force when too much power is received.
|
||||
* @param tier The tier of power, that was injected into the energy sink, that caused it to explode.
|
||||
* @param defaultPower The default explosion power.
|
||||
* @return The explosion power
|
||||
*/
|
||||
float getExplosionPower(int tier, float defaultPower);
|
||||
}
|
||||
Binary file not shown.
@@ -1,23 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IHeatSource {
|
||||
|
||||
/*
|
||||
* Return max heat transmission peer Tick (only theoretical bandwidth not available amount)
|
||||
*/
|
||||
int maxrequestHeatTick(EnumFacing directionFrom);
|
||||
|
||||
/*
|
||||
* @param requested amount of heat to transfer
|
||||
*
|
||||
* @return transmitted amount of heat
|
||||
*
|
||||
* example: You Request 100 units of heat but the Source have only 50 units left
|
||||
*
|
||||
* requestHeat(100) : return 50 : so 50 units of heat remove from HeatSource
|
||||
*/
|
||||
|
||||
int requestHeat(EnumFacing directionFrom, int requestheat);
|
||||
}
|
||||
Binary file not shown.
@@ -1,22 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IKineticSource {
|
||||
/*
|
||||
* Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount)
|
||||
*/
|
||||
int maxrequestkineticenergyTick(EnumFacing directionFrom);
|
||||
|
||||
/*
|
||||
* @param requested amount of kinetic energy to transfer
|
||||
*
|
||||
* @return transmitted amount of kineticenergy
|
||||
*
|
||||
* example: You Request 100 units of kinetic energy but the Source have only 50 units left
|
||||
*
|
||||
* requestkineticenergy(100) : return 50 : so 50 units of kinetic energy remove from KineticSource
|
||||
*/
|
||||
|
||||
int requestkineticenergy(EnumFacing directionFrom, int requestkineticenergy);
|
||||
}
|
||||
Binary file not shown.
@@ -1,34 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for grouping multi-block structures to a single energy net delegate.
|
||||
*
|
||||
* The energy net uses TileEntity to refer to a specific xyz+world position. If multiple of those
|
||||
* positions should belong to the same functional structure, i.e. they consume or produce energy
|
||||
* only once for the whole multi-block instead of once per every single block, this interface
|
||||
* allows to do so.
|
||||
*
|
||||
* The tile entity implementing IMetaDelegate has to be added/removed to/from the energy net
|
||||
* instead of every single sub-TileEntity. The energy net interaction will be handled by the
|
||||
* IMetaDelegate TileEntity as well.
|
||||
*
|
||||
* The sub tile array TileEntity[] just provides optional connectivity (IEnergyAcceptor,
|
||||
* IEnergyEmitter) and mandatory position (x, y, z, World) data.
|
||||
* If the connectivity data on the sub tile is missing, the meta delegate is queried instead.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IMetaDelegate extends IEnergyTile {
|
||||
/**
|
||||
* Get the sub-Tiles belonging to this Meta Tile.
|
||||
*
|
||||
* @note The list has to be consistent between the EnergyNet Load and Unload events.
|
||||
* @note The list must have at least 1 element.
|
||||
* @note The parent tile implementing IMetaDelegate isn't automatically included.
|
||||
*
|
||||
* @return sub-Tile array
|
||||
*/
|
||||
List<IEnergyTile> getSubTiles();
|
||||
}
|
||||
Binary file not shown.
@@ -1,24 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Allows an {@link IEnergySource} to emit more than one EU packet per tick.
|
||||
* Note: support for this will be dropped in a future version of IC2.
|
||||
* @author Aroma1997
|
||||
*/
|
||||
public interface IMultiEnergySource extends IEnergySource
|
||||
{
|
||||
|
||||
/**
|
||||
* If you want your machine to emit more than one EU packets per tick return true here.
|
||||
* @return if the machine in its current state can emit more than one EU packet per tick.
|
||||
*/
|
||||
public boolean sendMultipleEnergyPackets();
|
||||
|
||||
/**
|
||||
* If {@link #sendMultipleEnergyPackets()} returned true, this will get called.
|
||||
* The value returned by this method will determine the amount of EU packets, this machine can emit.
|
||||
* @return the amount of EU packets, this machine can emit per tick.
|
||||
*/
|
||||
public int getMultipleEnergyPacketAmount();
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1,17 +0,0 @@
|
||||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Complete control for when an {@link IEnergySink} is overloaded.
|
||||
*/
|
||||
public interface IOverloadHandler {
|
||||
|
||||
/**
|
||||
* Called when overloaded. This will override the default explosion.
|
||||
* The default explosion will therefore NOT happen, when you return true here.
|
||||
* If you return false, you can use this as a onExplode hook, but still let the default explosion happen.
|
||||
* @note Will set the block to air and cause an explosion of power 2.5 if false is returned
|
||||
* @param tier The tier of power, that was injected into the energy sink, that caused it to explode.
|
||||
* @return Whether the default explosion should be cancelled.
|
||||
*/
|
||||
boolean onOverload(int tier);
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
--------------------------------
|
||||
-- Energy Network Description --
|
||||
--------------------------------
|
||||
|
||||
There are currently three different types of energy network blocks:
|
||||
- energy sources, e.g. generators or the output side of a storage block/transformer
|
||||
- energy sinks, e.g. machines or the input side of a storage block/transformer
|
||||
- conductors, e.g. cables
|
||||
|
||||
Note that storage blocks or transformers are both sources and sinks.
|
||||
|
||||
All those blocks have to have a tile entity which has to implement the interface corresponding to
|
||||
its function and also post events to the Forge event bus.
|
||||
|
||||
The energy generation, distribution and consumption is strictly limited to the simulating (server)
|
||||
side, use the proper side checks before posting the related events. One possibility is to check for
|
||||
FMLCommonHandler.instance().getEffectiveSide().isClient() being false.
|
||||
|
||||
The energy network works by calculating the energy flow between the sources which offer energy
|
||||
through getOfferedEnergy() and the sinks which request energy through demandedEnergyUnits().
|
||||
Conductors will carry the energy over a distance. Once the energy distribution is calculated, the
|
||||
energy net will update the sources and sinks through drawEnergy() and injectEnergyUnits() respectively.
|
||||
|
||||
|
||||
---------------------------
|
||||
-- Energy Network Events --
|
||||
---------------------------
|
||||
|
||||
The energy network currently requires 2 events to manage its internal representation of the grids:
|
||||
|
||||
-- EnergyTileLoadEvent --
|
||||
|
||||
For all energy network tiles (sources, sinks, conductors) you have to post an EnergyTileLoadEvent.
|
||||
|
||||
The event has to be posted as soon as the implementing tile entity is fully loaded, usually after
|
||||
loading the chunk which contains it or after the user placing the block.
|
||||
|
||||
The energy net implementation will use the event to add it to its energy grid map, taking it into
|
||||
account for further energy transfers.
|
||||
|
||||
You can detect the loading by either using the 1st iteration of update() or by waiting for
|
||||
the next world tick after TileEntity.validate(). The 2nd approach is obviously more sophisticated
|
||||
and requires to use some tick queuing mechanism.
|
||||
|
||||
The event can by posted as following:
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
|
||||
-- EnergyTileUnloadEvent --
|
||||
|
||||
Another event every energy tile has to post is the EnergyTileUnloadEvent.
|
||||
|
||||
The event has to be posted as soon as the implementing tile entity is being unloaded, either by
|
||||
unloading the containing chunk or by destroying the block containing it.
|
||||
|
||||
It's possible to detect the unloading by triggering on both the beginning of
|
||||
TileEntity.invalidate() and the beginning of TileEntity.onChunkUnload().
|
||||
|
||||
It is important that the tile entity is still properly linked to the world while posting the unload
|
||||
event, otherwise the energy net can't find all affected connections.
|
||||
|
||||
|
||||
--------------------------------------
|
||||
-- Participating Block Requirements --
|
||||
--------------------------------------
|
||||
|
||||
The energy net blocks have to do the following to work properly:
|
||||
|
||||
-- energy source --
|
||||
|
||||
An energy source has to post the following events:
|
||||
- EnergyTileLoadEvent on load
|
||||
- EnergyTileUnloadEvent on unload
|
||||
|
||||
Additionally the interface IEnergySource has to be implemented.
|
||||
|
||||
-- energy sink --
|
||||
|
||||
An energy sink has to post the following events:
|
||||
- EnergyTileLoadEvent on load
|
||||
- EnergyTileUnloadEvent on unload
|
||||
|
||||
Additionally the interface IEnergySink has to be implemented.
|
||||
|
||||
-- energy conductor --
|
||||
|
||||
An energy conductor has to post the following events:
|
||||
- EnergyTileLoadEvent on load
|
||||
- EnergyTileUnloadEvent on unload
|
||||
|
||||
Additionally the interface IEnergyConductor has to be implemented.
|
||||
|
||||
-- general ---
|
||||
Optionally, you can implement the interface IColoredEnergyTile, which allows for some basic color-based
|
||||
connectivity. This can be used for IEnergyConductors, but is not limited to them.
|
||||
|
||||
|
||||
------------------------------
|
||||
-- Energy Network Delegates --
|
||||
------------------------------
|
||||
|
||||
A delegate is a separate object which performs tasks for the original object, in this case handling
|
||||
the energy net interaction.
|
||||
|
||||
The TileEntity instances used by the events don't have to be the same as the in-world TileEntity
|
||||
instance for the corresponding position, it can be delegated to a separate TileEntity instance.
|
||||
This separate instance (delegate) needs to have its world and xyz coordinate fields set to match
|
||||
the in-world instance. The delegate implements the energy net interfaces and is added and removed
|
||||
to/from the energy net through EnergyTileLoadEvent and EnergyTileUnloadEvent.
|
||||
|
||||
Separating the interfaces through a delegate allows to isolate the IC2 API usage into separate
|
||||
classes an potentially share common code like an input buffer with battery discharging outside the
|
||||
class hierarchy.
|
||||
It's even possible to use an ic2 energy net delegate alongside an in-world TileEntity which isn't
|
||||
designed to work with ic2 energy at all, like making a furnace electric by receiving energy through
|
||||
a delegate and adding the corresponding fuel amount to the in-world furnace TileEntity.
|
||||
|
||||
Getting the in-world TileEntity for a delegate involves calling World.getBlockTileEntity() with the
|
||||
delegate's world and xyz coordinate information.
|
||||
|
||||
|
||||
------------------
|
||||
-- Multi Blocks --
|
||||
------------------
|
||||
|
||||
Multi blocks are a group of blocks which act as one functional entity.
|
||||
|
||||
The IMetaDelegate interface groups multiple TileEntity instances (=sub tiles) representing the
|
||||
individual blocks to a single Energy Net relevant node. The sub tiles may be normal in-world or
|
||||
delegate TileEntity instances.
|
||||
|
||||
The meta delegate is added to energy net once for the whole multi block structure and implements
|
||||
the energy net interfaces as well. The sub tiles may optionally implement IEnergyEmitter and/or
|
||||
IEnergyAcceptor to specify their connectivity rules independently, otherwise the meta delegate will
|
||||
be queried.
|
||||
|
||||
|
||||
--------------------------------------------------
|
||||
-- How to implement/add your own energy network --
|
||||
--------------------------------------------------
|
||||
|
||||
If you want to create an alternative way of distributing energy, e.g. to have different
|
||||
distribution rules or to use energy networks provided by other mods, you can register to the energy
|
||||
tile events and use the interfaces to handle the energy distribution yourself. It's no longer
|
||||
required to use conversion blocks.
|
||||
|
||||
IC2's EnergyNet itself is built on top of the api events and interfaces, providing their default
|
||||
use case.
|
||||
|
||||
Binary file not shown.
@@ -1,40 +0,0 @@
|
||||
package ic2.api.event;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class ExplosionEvent extends WorldEvent {
|
||||
public ExplosionEvent(World world, Entity entity,
|
||||
Vec3d pos,
|
||||
double power,
|
||||
EntityLivingBase igniter,
|
||||
int radiationRange, double rangeLimit) {
|
||||
super(world);
|
||||
|
||||
this.entity = entity;
|
||||
this.pos = pos;;
|
||||
this.power = power;
|
||||
this.igniter = igniter;
|
||||
this.radiationRange = radiationRange;
|
||||
this.rangeLimit = rangeLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity representing the explosive, may be null.
|
||||
*/
|
||||
public final Entity entity;
|
||||
public final Vec3d pos;
|
||||
public final double power;
|
||||
/**
|
||||
* Entity causing the explosion, may be null.
|
||||
*/
|
||||
public final EntityLivingBase igniter;
|
||||
public final int radiationRange;
|
||||
public final double rangeLimit;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,118 +0,0 @@
|
||||
package ic2.api.event;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
|
||||
/**
|
||||
* A bunch of Events to handle the power of the Mining Laser.
|
||||
*/
|
||||
@Cancelable
|
||||
public class LaserEvent extends WorldEvent {
|
||||
// the Laser Entity
|
||||
public final Entity lasershot;
|
||||
|
||||
// the following variables can be changed and the Laser will adjust to them
|
||||
|
||||
// the Player firing the Laser. If the Laser gets "reflected" the Player could change.
|
||||
public EntityLivingBase owner;
|
||||
// Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range.
|
||||
public float range, power;
|
||||
public int blockBreaks;
|
||||
// Determines whether the laser will explode upon hitting something
|
||||
public boolean explosive, smelt;
|
||||
|
||||
public LaserEvent(World world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt) {
|
||||
super(world);
|
||||
|
||||
this.lasershot = lasershot;
|
||||
this.owner = owner;
|
||||
this.range = range;
|
||||
this.power = power;
|
||||
this.blockBreaks = blockBreaks;
|
||||
this.explosive = explosive;
|
||||
this.smelt = smelt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is getting shot by a Player.
|
||||
*
|
||||
* The Item is the Laser Gun which the "Player" has shot
|
||||
*/
|
||||
public static class LaserShootEvent extends LaserEvent {
|
||||
ItemStack laserItem;
|
||||
|
||||
public LaserShootEvent(World world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt, ItemStack laseritem) {
|
||||
super(world, lasershot, owner, range, power, blockBreaks, explosive, smelt);
|
||||
|
||||
this.laserItem = laseritem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is exploding for some Reason.
|
||||
*
|
||||
* The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired.
|
||||
*/
|
||||
public static class LaserExplodesEvent extends LaserEvent {
|
||||
// explosion strength, even that can be changed!
|
||||
public float explosionPower, explosionDropRate, explosionEntityDamage;
|
||||
|
||||
public LaserExplodesEvent(World world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) {
|
||||
super(world, lasershot, owner, range, power, blockBreaks, explosive, smelt);
|
||||
|
||||
this.explosionPower = explosionpower1;
|
||||
this.explosionDropRate = explosiondroprate1;
|
||||
this.explosionEntityDamage = explosionentitydamage1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is hitting a Block
|
||||
* x, y and z are the Coords of the Block.
|
||||
*
|
||||
* Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass.
|
||||
* Use lasershot.setDead() to remove the Shot entirely.
|
||||
*/
|
||||
public static class LaserHitsBlockEvent extends LaserEvent {
|
||||
// targeted block, even that can be changed!
|
||||
public BlockPos pos;
|
||||
public EnumFacing side;
|
||||
// removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something.
|
||||
public boolean removeBlock, dropBlock;
|
||||
public float dropChance;
|
||||
|
||||
public LaserHitsBlockEvent(World world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive1, boolean smelt1, BlockPos pos, EnumFacing side, float dropChance, boolean removeBlock, boolean dropBlock) {
|
||||
super(world, lasershot, owner, range, power, blockBreaks, explosive1, smelt1);
|
||||
|
||||
this.pos = pos;
|
||||
this.side = side;
|
||||
this.removeBlock = removeBlock;
|
||||
this.dropBlock = dropBlock;
|
||||
this.dropChance = dropChance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is getting at a Living Entity
|
||||
*
|
||||
* Canceling this Event ignores the Entity
|
||||
* Use lasershot.setDead() to remove the Shot entirely.
|
||||
*/
|
||||
public static class LaserHitsEntityEvent extends LaserEvent {
|
||||
// the Entity which the Laser has shot at, even the target can be changed!
|
||||
public Entity hitEntity;
|
||||
|
||||
public LaserHitsEntityEvent(World world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt, Entity hitentity) {
|
||||
super(world, lasershot, owner, range, power, blockBreaks, explosive, smelt);
|
||||
|
||||
this.hitEntity = hitentity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,54 +0,0 @@
|
||||
package ic2.api.event;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class RetextureEvent extends WorldEvent {
|
||||
public RetextureEvent(World world, BlockPos pos, IBlockState state, EnumFacing side, EntityPlayer player,
|
||||
IBlockState refState, String refVariant, EnumFacing refSide, int[] refColorMultipliers) {
|
||||
super(world);
|
||||
|
||||
if (world == null) throw new NullPointerException("null world");
|
||||
if (world.isRemote) throw new IllegalStateException("remote world");
|
||||
if (pos == null) throw new NullPointerException("null pos");
|
||||
if (state == null) throw new NullPointerException("null state");
|
||||
if (side == null) throw new NullPointerException("null side");
|
||||
if (refState == null) throw new NullPointerException("null refState");
|
||||
if (refVariant == null) throw new NullPointerException("null refVariant");
|
||||
if (refSide == null) throw new NullPointerException("null refSide");
|
||||
if (refColorMultipliers == null) throw new NullPointerException("null refColorMultipliers");
|
||||
|
||||
this.pos = pos;
|
||||
this.state = state;
|
||||
this.side = side;
|
||||
this.player = player;
|
||||
this.refState = refState;
|
||||
this.refVariant = refVariant;
|
||||
this.refSide = refSide;
|
||||
this.refColorMultipliers = refColorMultipliers;
|
||||
}
|
||||
|
||||
// target block
|
||||
public final BlockPos pos;
|
||||
public final IBlockState state;
|
||||
public final EnumFacing side;
|
||||
|
||||
// player causing the action, may be null
|
||||
public final EntityPlayer player;
|
||||
|
||||
// referenced block (to grab the texture from)
|
||||
public final IBlockState refState;
|
||||
public final String refVariant;
|
||||
public final EnumFacing refSide;
|
||||
public final int[] refColorMultipliers;
|
||||
|
||||
// set to true to confirm the operation
|
||||
public boolean applied = false;
|
||||
}
|
||||
Binary file not shown.
@@ -1,20 +0,0 @@
|
||||
package ic2.api.event;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import ic2.api.info.ITeBlock;
|
||||
|
||||
/** This event is a notification for an internal event you might will to subscribe to if you're using ITeBlock, hence it is empty.
|
||||
* <p>
|
||||
* For more information such as why this event exists, when it's posted, and how to react to it properly, see {@link ITeBlock}.
|
||||
* </p>
|
||||
*
|
||||
* @see ITeBlock
|
||||
*
|
||||
* @since IC2 2.6.67
|
||||
* @version 1.0
|
||||
*
|
||||
* @author Chocohead
|
||||
*/
|
||||
public final class TeBlockFinalCallEvent extends Event {
|
||||
}
|
||||
Binary file not shown.
@@ -1,27 +0,0 @@
|
||||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IInfoProvider {
|
||||
/**
|
||||
* Determine the energy value for a single item in the supplied stack.
|
||||
* The value is used by most machines in the discharge slot.
|
||||
*
|
||||
* This only applies to basic single use items, others are to be queried
|
||||
* through e.g. ElectricItem.manager.getCharge().
|
||||
*
|
||||
* @param stack ItemStack containing the item to evaluate.
|
||||
* @return energy in EU
|
||||
*/
|
||||
double getEnergyValue(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Determine the fuel value for a single item in the supplied stack.
|
||||
* The information currently applies to Generators and the Iron Furnace.
|
||||
*
|
||||
* @param stack ItemStack containing the item to evaluate.
|
||||
* @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace.
|
||||
* @return fuel value
|
||||
*/
|
||||
int getFuelValue(ItemStack stack, boolean allowLava);
|
||||
}
|
||||
Binary file not shown.
@@ -1,24 +0,0 @@
|
||||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Interface for things, that have a location.
|
||||
* The function names are the way they are, because of obfuscation issues.
|
||||
* See https://github.com/md-5/SpecialSource/issues/12
|
||||
* @author Aroma1997
|
||||
*/
|
||||
public interface ILocatable {
|
||||
|
||||
/**
|
||||
* @return the position of the object.
|
||||
*/
|
||||
BlockPos getPosition();
|
||||
|
||||
/**
|
||||
* @return the world of this object.
|
||||
*/
|
||||
World getWorldObj();
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1,317 +0,0 @@
|
||||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import ic2.api.event.TeBlockFinalCallEvent;
|
||||
import ic2.api.item.ITeBlockSpecialItem;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
/** First of all, yes this class is empty. It's public documentation for the actual internal interface ITeBlock. <strong>Use the internal one not this!</strong>
|
||||
* <p>
|
||||
* You may be asking, why would an internal interface need documenting? Well, the answer is so people can use <code>TileEntityBlock</code>.
|
||||
* That class is the base for all IC2 tile entities, so by being able to use that you're level to IC2.
|
||||
* Many methods are protected in there too, as they're only designed to be called by <code>BlockTileEntity</code> (which is the block all IC2 tile entities will be on),
|
||||
* by being able to extend it means all those methods you can now extend and be confident they will be called correctly.
|
||||
* </p>
|
||||
* <p>
|
||||
* Because it allows effectively level control to IC2 itself, this gives you near total control of your tile entities:
|
||||
* <blockquote>
|
||||
* You can pick whether each of your tile entity items show up in creative, and the order in which they do.<br/>
|
||||
* There is a proper separation between each registered <code>ITeBlock</code> by resource location, rather than everything being inserted into a single <code>enum</code>.
|
||||
* You also receive your own instance of <code>BlockTileEntity</code> and <code>ItemBlockTileEntity</code> rather than having to use IC2's own one.<br/>
|
||||
* All the language keys and blockstate file are in your own assets (which you can, and in fact have to, pick).
|
||||
* You can have custom item models with non-standard model locations.
|
||||
* </blockquote>
|
||||
* The event allows you to properly register your own version of <code>TeBlock</code> in a way that will be as fully supported as is physically possible.
|
||||
* It's not in the actual API itself as it's heavily dependent on internal classes, so you have this instead.
|
||||
* This is also probably the most documented thing in the entire IC2 API. <small>I'm too kind really. ;)</small>
|
||||
* </p>
|
||||
* <hr>
|
||||
* <p>
|
||||
* So that's all well and good, but what you really want is an example of how to do it properly. Good idea, let's go.
|
||||
* <blockquote><pre><code>
|
||||
*import net.minecraftforge.common.MinecraftForge;
|
||||
*import net.minecraftforge.fml.common.Mod;
|
||||
*import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
*import net.minecraftforge.fml.common.event.FMLConstructionEvent;
|
||||
*import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
*import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
*
|
||||
*import ic2.api.event.TeBlockFinalCallEvent;
|
||||
*import ic2.core.block.TeBlockRegistry;
|
||||
*
|
||||
*{@literal @}Mod(modId="ExampleIC2Addon")
|
||||
*public class ExampleIC2Addon {
|
||||
* {@literal @}EventHandler
|
||||
* public void start(FMLConstructionEvent event) {
|
||||
* MinecraftForge.EVENT_BUS.register(this);
|
||||
* }
|
||||
*
|
||||
* {@literal @}SubscribeEvent
|
||||
* public void register(TeBlockFinalCallEvent event) {
|
||||
* TeBlockRegistry.addAll(MyTeBlock.class, MyTeBlock.IDENTITY);
|
||||
*
|
||||
* MinecraftForge.EVENT_BUS.unregister(this);
|
||||
* }
|
||||
*
|
||||
* {@literal @}EventHandler
|
||||
* public void init(FMLInitializationEvent event) {
|
||||
* MyTeBlock.buildDummies();
|
||||
* }
|
||||
*}
|
||||
*
|
||||
*
|
||||
*import net.minecraft.block.material.Material;
|
||||
*import net.minecraft.creativetab.CreativeTabs;
|
||||
*import net.minecraft.item.EnumRarity;
|
||||
*import net.minecraft.item.ItemStack;
|
||||
*import net.minecraft.tileentity.TileEntity;
|
||||
*import net.minecraft.util.EnumFacing;
|
||||
*import net.minecraft.util.ResourceLocation;
|
||||
*
|
||||
*import ic2.core.block.BlockTileEntity;
|
||||
*import ic2.core.block.ITeBlock;
|
||||
*import ic2.core.block.TileEntityBlock;
|
||||
*import ic2.core.item.block.ItemBlockTileEntity;
|
||||
*import ic2.core.ref.TeBlock.DefaultDrop;
|
||||
*import ic2.core.ref.TeBlock.HarvestTool;
|
||||
*import ic2.core.ref.TeBlock.ITePlaceHandler;
|
||||
*import ic2.core.util.Util;
|
||||
*
|
||||
*public enum MyTeBlock implements ITeBlock {
|
||||
* my_machine_name(MyMachineTileEntity.class, 0, false, Util.noFacings, false, HarvestTool.Pickaxe, DefaultDrop.Machine, 5, 10, EnumRarity.UNCOMMON, Material.IRON, false);
|
||||
*
|
||||
* private MyTeBlock(Class<? extends TileEntityBlock> teClass, int ID,
|
||||
* boolean hasActive, Set{@literal <}EnumFacing{@literal >} possibleFacings, boolean canBeWrenched,
|
||||
* HarvestTool tool, DefaultDrop drop,
|
||||
* float hardness, float explosionResistance, EnumRarity rarity, Material material, boolean isTransparent) {
|
||||
* this.teClass = teClass;
|
||||
* this.ID = ID;
|
||||
* this.hasActive = hasActive;
|
||||
* this.possibleFacings = possibleFacings;
|
||||
* this.canBeWrenched = canBeWrenched;
|
||||
* this.tool = tool;
|
||||
* this.drop = drop;
|
||||
* this.hardness = hardness;
|
||||
* this.explosionResistance = explosionResistance;
|
||||
* this.rarity = rarity;
|
||||
* this.material = material;
|
||||
* this.isTransparent = isTransparent;
|
||||
*
|
||||
* TileEntity.addMapping(block.teClass, IDENTITY.getResourceDomain() + ':' + block.getName());
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public boolean hasItem() {
|
||||
* return teClass != null && itemMeta != -1;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public String getName() {
|
||||
* return name();
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public ResourceLocation getIdentifier() {
|
||||
* return IDENTITY;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public Class<? extends TileEntityBlock> getTeClass() {
|
||||
* return teClass;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public boolean hasActive() {
|
||||
* return hasActive;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public int getId() {
|
||||
* return ID;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public float getHardness() {
|
||||
* return hardness;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public HarvestTool getHarvestTool() {
|
||||
* return tool;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public DefaultDrop getDefaultDrop() {
|
||||
* return drop;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public float getExplosionResistance() {
|
||||
* return explosionResistance;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public boolean allowWrenchRotating() {
|
||||
* return canBeWrenched;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public Set{@literal <}EnumFacing{@literal >} getSupportedFacings() {
|
||||
* return possibleFacings;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public EnumRarity getRarity() {
|
||||
* return rarity;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public Material getMaterial() {
|
||||
* return material;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public boolean isTransparent() {
|
||||
* return isTransparent;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public void setPlaceHandler(ITePlaceHandler handler) {
|
||||
* this.placeHandler = handler;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public ITePlaceHandler getPlaceHandler() {
|
||||
* return placeHandler;
|
||||
* }
|
||||
*
|
||||
* public static void buildDummies() {
|
||||
* for (MyTeBlock block : values()) {
|
||||
* //System.out.printf("Building %s (with teClass %s)%n", block.getName(), block.teClass);
|
||||
* if (block.teClass != null) {
|
||||
* try {
|
||||
* block.dummyTe = block.teClass.newInstance();
|
||||
* } catch (Exception e) {
|
||||
* e.printStackTrace();
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public TileEntityBlock getDummyTe() {
|
||||
* return dummyTe;
|
||||
* }
|
||||
*
|
||||
* private final Class<? extends TileEntityBlock> teClass;
|
||||
* private final int ID;
|
||||
* private final boolean hasActive;
|
||||
* private final Set{@literal <}EnumFacing{@literal >} possibleFacings;
|
||||
* private final boolean canBeWrenched;
|
||||
* private final HarvestTool tool;
|
||||
* private final DefaultDrop drop;
|
||||
* private final float hardness;
|
||||
* private final float explosionResistance;
|
||||
* private final EnumRarity rarity;
|
||||
* private final Material material;
|
||||
* private final boolean isTransparent;
|
||||
* private TileEntityBlock dummyTe;
|
||||
* private ITePlaceHandler placeHandler;
|
||||
*
|
||||
* public static final ResourceLocation IDENTITY = new ResourceLocation("ExampleIC2Addon", "machines");
|
||||
*}
|
||||
* </code></pre></blockquote>
|
||||
* And that's it, you now have <code>my_machine_name</code> registered with the <code>MyMachineTileEntity</code> tile entity class,
|
||||
* the language key to translate it's name being ExampleIC2Addon.machines.my_machine_name and
|
||||
* the blockstate being in <code>machines.json</code> file in your mod's assets.
|
||||
* </p>
|
||||
* <hr>
|
||||
* <p>
|
||||
* But hang on, what are all the parameters of our new <code>enum</code> and what does <code>ITeBlock</code> do with them? What are dummy tile entities for?
|
||||
* Don't worry, it's quite simple (once you know it at least).
|
||||
* </p>
|
||||
* <p>
|
||||
* First we'll start on what {@link TeBlockFinalCallEvent} is. It's posted on the {@link MinecraftForge#EVENT_BUS} just before the blocks are built,
|
||||
* after which point any further attempts to register <code>ITeBlock</code>s will fail, as we can't inject them late due to the model generating.
|
||||
* It is best to hook into this to register your <code>ITeBlock</code>s, as it will be guaranteed to be posted at the right time.
|
||||
* <br/><br/>
|
||||
* In terms of <code>ITeBlock</code>, there's quite a bit of information it needs in order to function. We'll go through each parameter (or getter method most cases too) in turn:
|
||||
* <ul>
|
||||
* <li><b>name</b>: The name the new tile entity. This is important as the localisation and resource names depend on it, as well as some network syncing code.</li>
|
||||
* <li><b>teClass</b>: The class of your tile entity, it must extend <code>TileEntityBlock</code> otherwise it would miss critical methods to work.
|
||||
* If extending that is a problem then using <code>ITeBlock</code> isn't what you should be doing.</li>
|
||||
* <li><b>itemMeta</b>: The ID of the new instance. This is utterly critical, as it's the thing used to detect which <code>ITeBlock</code> an item is.
|
||||
* That's very important as the tile entity class is worked out by the ID when a block's being placed in <code>ItemBlockTileEntity</code>.
|
||||
* Changing this will cause everyone's items to change and there is no stopping that if you do.
|
||||
* The ID you pick should start at 0, and go up to {@link Short#MAX_VALUE}.
|
||||
* Use -1 if the tile entity doesn't have an item form (or is placed using an item other than <code>ItemBlockTileEntity</code>).</li>
|
||||
* <li><b>identifier</b>: The resource location associated with the <code>ITeBlock</code>.
|
||||
* The language keys, translations and internal mappings all use this, so it's best to store it as a static final variable and use that.
|
||||
* <li><b>hasActive</b>: If the tile entity has an active state too, which is based off whether <code>TileEntityBlock#getActive()</code> returns <code>true</code> or not.
|
||||
* The models for that will be at name_active, you can check <code>te.json</code> for an example if you wish.</li>
|
||||
* <li><b>supportedFacings</b>: A set of <code>EnumFacing</code>s that the block can face, used for rotating by the wrench for example.
|
||||
* IC2 has some useful constants relating to that in <code>Util</code> (allFacings, horizontalFacings, downSideFacings and noFacings).</li>
|
||||
* <li><b>allowWrenchRotating</b>: Whether the tile entity can be rotated with a wrench (for {@link IWrenchable}).</li>
|
||||
* <li><b>harvestTool</b>: The tool used to harvest the tile entity, currently only None, Pickaxe, Shovel and Axe.
|
||||
* More can be added on request, but support has to be specifically added, so there's no nice way via <code>EnumHelper</code> unfortunately.</li>
|
||||
* <li><b>defaultDrop</b>: The item(s) that will drop when the block is broken using the correct tool. Currently only Self, None, Generator, Machine, and AdvMachine.
|
||||
* Like <code>harvestTool</code>, more can be added upon request.</li>
|
||||
* <li><b>hardness</b>: The hardness the block should have with the tile entity, IC2 normally uses 5.</li>
|
||||
* <li><b>explosionResistance</b>: The explosionResistance the block should have with the tile entity, IC2 normally uses 10.</li>
|
||||
* <li><b>rarity</b>: The <code>EnumRarity</code> that the item will have for the tile entity.</li>
|
||||
* <li><b>material</b>: The {@link Material} that the block representing the tile entity should have. Maximum of 8 different ones per ITeBlock registration.</li>
|
||||
* <li><b>isTransparent</b>: Whether the block should be rendered with {@link BlockRenderLayer#CUTOUT} or {@link BlockRenderLayer#SOLID}
|
||||
* (which controls whether transparency can be in the texture).</li>
|
||||
* <li><b>placeHandler</b>: Custom placement logic, used for things like Reactor Chambers within IC2 itself.
|
||||
* Returning null for this uses the default logic (placing like a normal block).</li>
|
||||
* <li><b>dummyTe</b>: An instance of the tile entity never registered to the world (don't try doing that) used for getting additional information about the Tile Entity.
|
||||
* Mostly an internal thing, only exposed in case your Tile Entity uses a special constructor.</li>
|
||||
* </ul>
|
||||
* <strong>IMPORTANT THINGS TO NOTE</strong>
|
||||
* <dl>
|
||||
* <dt>Getting your instance of <code>BlockTileEntity</code> and <code>ItemBlockTileEntity</code></dt>
|
||||
* <dd>For <code>BlockTileEntity</code>, use {@link TeBlockRegistry#get(ResourceLocation)}.<br/>
|
||||
* For <code>ItemBlockTileEntity</code>, use {@link BlockTileEntity#getItem()}.</dd>
|
||||
* <dt>Using a custom item model for your <code>ITeBlock</code></dt>
|
||||
* <dd>Implement <code>ITeBlockSpecialItem</code> along with <code>ITeBlock</code>, then the item model will be what's provided rather than the block model.</dd>
|
||||
* <dt>The default implementation for adding <code>ITeBlock</code>s to creative</dt>
|
||||
* <dd>The default logic adds all registered <code>ITeBlock</code>s that return true for {@link ic2.core.ref.TeBlock#hasItem()}.</dd>
|
||||
* </dl>
|
||||
* More will be added to this list if questions keep re-occurring, or are about a suitably important topic.
|
||||
* </p>
|
||||
* <hr>
|
||||
* <p>
|
||||
* There, that should be everything you need to utilise <code>ITeBlock</code> to add your own tile entities using IC2's very flexible framework.
|
||||
* I'll be happy to answer any questions you have on it, your best bet is to ask me (Chocohead) on <a href="https://forum.industrial-craft.net">the IC2 forums</a>,
|
||||
* although if you post in the support section other people might be able to help before I see your post.
|
||||
* I'll certainly take suggestions too, this is mostly just based on what IC2 uses/needs, so there might well be things missed that might be useful.
|
||||
* <br/>
|
||||
* <small>Goodness I spent too long on this again...</small>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @see {@link TeBlockFinalCallEvent} for the event you'll need to subscribe to.
|
||||
* @see {@link ic2.core.ref.TeBlock} for how all the IC2 implements {@link ITeBlock}.
|
||||
* @see {@link ic2.core.ref.TeBlock.HarvestTool} for the currently available tools (you'll need this for adding new tile entities).
|
||||
* @see {@link ic2.core.ref.TeBlock.DefaultDrop} for the currently available drops (you'll need this for adding new tile entities too).
|
||||
* @see {@link ic2.core.block.ITeBlock.ITeBlockCreativeRegisterer} for customising what blocks are added to creative past the default implementation
|
||||
* @see {@link ic2.core.ref.TeBlock.ITePlaceHandler} for making your own block placement handler (example in {@link ic2.core.item.ItemHandlers#reactorChamberPlace}).
|
||||
* @see {@link ic2.core.util.Util} for the useful facings you might want for <code>supportedFacings</code>.
|
||||
* @see {@link ic2.core.block.TileEntityBlock} for the base tile entity.
|
||||
* @see {@link ic2.core.block.BlockTileEntity} for the base block (you'll never need to construct this yourself).
|
||||
* @see {@link ic2.core.item.block.ItemBlockTileEntity} for the base item (you shouldn't need to construct this yourself either).
|
||||
* @see {@link ITeBlockSpecialItem} for the interface used to have a custom item location.
|
||||
*
|
||||
*
|
||||
* @since IC2 2.7.14
|
||||
* @version 2.0
|
||||
*
|
||||
* @author Chocohead
|
||||
*/
|
||||
public interface ITeBlock {
|
||||
}
|
||||
Binary file not shown.
@@ -1,39 +0,0 @@
|
||||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
public class Info {
|
||||
public static IInfoProvider itemInfo;
|
||||
public static Object ic2ModInstance;
|
||||
|
||||
/**
|
||||
* Damage Sources used by IC2.
|
||||
* Getting assigned in preload.
|
||||
*/
|
||||
public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION;
|
||||
|
||||
/**
|
||||
* Potions used by IC2.
|
||||
* Getting assigned in preload.
|
||||
*/
|
||||
public static Potion POTION_RADIATION;
|
||||
|
||||
public static boolean isIc2Available() {
|
||||
if (ic2Available != null) return ic2Available;
|
||||
|
||||
boolean loaded = Loader.isModLoaded(MOD_ID);
|
||||
|
||||
if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) {
|
||||
ic2Available = loaded;
|
||||
}
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public static String MOD_ID = "ic2";
|
||||
private static Boolean ic2Available = null;
|
||||
}
|
||||
Binary file not shown.
@@ -1,59 +0,0 @@
|
||||
package ic2.api.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Allows for charging, discharging and using electric items (IElectricItem).
|
||||
*/
|
||||
public final class ElectricItem {
|
||||
/**
|
||||
* IElectricItemManager to use for interacting with IElectricItem ItemStacks.
|
||||
*
|
||||
* This manager will act as a gateway and delegate the tasks to the final implementation
|
||||
* (rawManager or a custom one) as necessary.
|
||||
*/
|
||||
public static IElectricItemManager manager;
|
||||
|
||||
/**
|
||||
* Standard IElectricItemManager implementation, only call it directly from another
|
||||
* IElectricItemManager. Use manager instead.
|
||||
*/
|
||||
public static IElectricItemManager rawManager;
|
||||
|
||||
/**
|
||||
* Register an electric item manager for items not implementing IElectricItem.
|
||||
*
|
||||
* This method is only designed for special purposes, implementing IElectricItem or
|
||||
* ISpecialElectricItem instead of using this is faster.
|
||||
*
|
||||
* Managers used with ISpecialElectricItem shouldn't be registered.
|
||||
*
|
||||
* @param manager Manager to register.
|
||||
*/
|
||||
public static void registerBackupManager(IBackupElectricItemManager manager) {
|
||||
backupManagers.add(manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the electric item manager suitable for the supplied item stack.
|
||||
*
|
||||
* This method is for internal use only.
|
||||
*
|
||||
* @param stack ItemStack to be handled.
|
||||
* @return First suitable electric item manager.
|
||||
*/
|
||||
public static IBackupElectricItemManager getBackupManager(ItemStack stack) {
|
||||
for (IBackupElectricItemManager manager : backupManagers) {
|
||||
if (manager.handles(stack)) return manager;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static final List<IBackupElectricItemManager> backupManagers = new ArrayList<IBackupElectricItemManager>();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,37 +0,0 @@
|
||||
package ic2.api.item;
|
||||
|
||||
public enum HudMode {
|
||||
DISABLED("ic2.hud.disabled"), BASIC("ic2.hud.basic"), EXTENDED("ic2.hud.extended"), ADVANCED("ic2.hud.advanced");
|
||||
|
||||
private HudMode(String key) {
|
||||
translationKey = key;
|
||||
}
|
||||
|
||||
private final String translationKey;
|
||||
|
||||
public boolean shouldDisplay() {
|
||||
return this != DISABLED;
|
||||
}
|
||||
|
||||
public boolean hasTooltip() {
|
||||
return this == EXTENDED || this == ADVANCED;
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
return translationKey;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
public static HudMode getFromID(int ID) {
|
||||
return VALUES[ID % VALUES.length];
|
||||
}
|
||||
|
||||
public static int getMaxMode() {
|
||||
return VALUES.length - 1;
|
||||
}
|
||||
|
||||
private static final HudMode[] VALUES = values();
|
||||
}
|
||||
Binary file not shown.
Loaded 100 of 468 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user