feat: initial port

This commit is contained in:
LordMZTE 2022-11-09 22:15:45 +01:00
parent 50260c3884
commit dffbbd1548
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
553 changed files with 37290 additions and 5 deletions

4
.gitignore vendored
View file

@ -1,3 +1,7 @@
.project
.classpath
bin
.settings
.gradle
.idea
build

16
austri3Fix.md Normal file
View file

@ -0,0 +1,16 @@
- glass button doesn't render in inventory
- tons of missing packets (mostly gui stuff)
- can't apply camouflage texture
- turret UI textures completely fürn oasch
- sounds completely fürn oasch
- unable to mount turret afte dismounting
- turret gui kekt
- no electricity in guis
- EMP tower drops nonsense
- no proper update on multiblock destroy
- condensed explosives doesn't break blocks and explodes instantly
- can push explosive entities
- flying blocks dont properly render
- black hole doesn't suck in blocks
- no missiles??
- remote detonator doesnt work

View file

@ -11,23 +11,43 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {
changing = true
}
}
}
apply plugin: 'forge'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceSets {
api {}
}
version = "1.0"
group= "modgroup"
archivesBaseName = "modid"
group = "universalelectricity"
archivesBaseName = "icbm"
jar {
manifest {
attributes "FMLAT": "icbm_at.cfg"
}
}
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"
}
dependencies {
repositories {
maven { url = "https://maven.tilera.xyz" }
}
dependencies {
implementation "universalelectricity:basiccomponents:1.0.2-dirty:deobf"
implementation "universalelectricity:atomicscience:1.0.1:deobf"
}
processResources

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip

0
gradlew vendored Normal file → Executable file
View file

View file

@ -0,0 +1,17 @@
package atomicscience.api;
import cpw.mods.fml.common.Loader;
import net.minecraftforge.common.config.Configuration;
import java.io.File;
public class AtomicScience {
public static final String MAJOR_VERSION = "0";
public static final String MINOR_VERSION = "6";
public static final String REVISION_VERSION = "2";
public static final String BUILD_VERSION = "117";
public static final String VERSION = "0.6.2";
public static final String NAME = "Atomic Science";
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "AtomicScience.cfg"));
}

View file

@ -0,0 +1,144 @@
package atomicscience.api;
import atomicscience.api.poison.PoisonRadiation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntitySmokeFX;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public class BlockRadioactive extends Block {
public boolean canSpread;
public float radius;
public int amplifier;
public boolean canWalkPoison;
public boolean isRandomlyRadioactive;
private IIcon iconTop;
private IIcon iconBottom;
public BlockRadioactive(Material material) {
super(material);
this.canSpread = true;
this.radius = 5.0F;
this.amplifier = 2;
this.canWalkPoison = true;
this.isRandomlyRadioactive = true;
this.setTickRandomly(true);
this.setHardness(0.2F);
this.setLightLevel(0.1F);
}
public BlockRadioactive() {
this(Material.rock);
}
@Override
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop
: (side == 0 ? this.iconBottom : this.blockIcon);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.blockIcon = iconRegister.registerIcon(
this.getUnlocalizedName().replace("tile.", ""));
this.iconTop = iconRegister.registerIcon(
this.getUnlocalizedName().replace("tile.", "") + "_top");
this.iconBottom = iconRegister.registerIcon(
this.getUnlocalizedName().replace("tile.", "") + "_bottom");
}
@Override
public void onBlockClicked(World world, int x, int y, int z,
EntityPlayer par5EntityPlayer) {
if ((double) world.rand.nextFloat() > 0.8D) {
this.updateTick(world, x, y, z, world.rand);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if (!world.isRemote) {
if (this.isRandomlyRadioactive) {
AxisAlignedBB i = AxisAlignedBB.getBoundingBox(
(double) ((float) x - this.radius), (double) ((float) y - this.radius),
(double) ((float) z - this.radius), (double) ((float) x + this.radius),
(double) ((float) y + this.radius), (double) ((float) z + this.radius));
List<EntityLiving> newX = world.getEntitiesWithinAABB(EntityLiving.class, i);
for (EntityLiving newZ : newX) {
PoisonRadiation.INSTANCE.poisonEntity(
new Vector3((double) x, (double) y, (double) z), newZ,
this.amplifier);
}
}
if (this.canSpread) {
for (int var11 = 0; var11 < 4; ++var11) {
int xOffset = x + rand.nextInt(3) - 1;
int yOffset = y + rand.nextInt(5) - 3;
int zOffset = z + rand.nextInt(3) - 1;
Block block = world.getBlock(xOffset, yOffset, zOffset);
if ((double) rand.nextFloat() > 0.4D &&
(block == Blocks.farmland || block == Blocks.grass)) {
world.setBlock(xOffset, yOffset, zOffset, this);
}
}
if ((double) rand.nextFloat() > 0.85D) {
world.setBlock(x, y, z, Blocks.mycelium);
}
}
}
}
@Override
public void onEntityWalking(World par1World, int x, int y, int z,
Entity par5Entity) {
if (par5Entity instanceof EntityLiving && this.canWalkPoison) {
PoisonRadiation.INSTANCE.poisonEntity(
new Vector3((double) x, (double) y, (double) z),
(EntityLiving) par5Entity);
}
}
@Override
public int quantityDropped(Random par1Random) {
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z,
Random par5Random) {
if (Minecraft.getMinecraft().gameSettings.particleSetting == 0) {
byte radius = 3;
for (int i = 0; i < 2; ++i) {
Vector3 diDian = new Vector3((double) x, (double) y, (double) z);
diDian.x += Math.random() * (double) radius - (double) (radius / 2);
diDian.y += Math.random() * (double) radius - (double) (radius / 2);
diDian.z += Math.random() * (double) radius - (double) (radius / 2);
EntitySmokeFX fx = new EntitySmokeFX(
world, diDian.x, diDian.y, diDian.z, (Math.random() - 0.5D) / 2.0D,
(Math.random() - 0.5D) / 2.0D, (Math.random() - 0.5D) / 2.0D);
fx.setRBGColorF(0.2F, 0.8F, 0.0F);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
}
}
}

View file

@ -0,0 +1,14 @@
package atomicscience.api;
import atomicscience.api.poison.Poison;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface IAntiPoisonArmor {
boolean isProtectedFromPoison(ItemStack var1, EntityLivingBase var2, Poison var3);
void onProtectFromPoison(ItemStack var1, EntityLivingBase var2, Poison var3);
Poison.ArmorType getArmorType();
}

View file

@ -0,0 +1,9 @@
package atomicscience.api;
import atomicscience.api.poison.Poison;
import net.minecraft.world.World;
public interface IAntiPoisonBlock {
boolean isPoisonPrevention(World var1, int var2, int var3, int var4, Poison var5);
}

View file

@ -0,0 +1,8 @@
package atomicscience.api;
import net.minecraft.world.World;
public interface IElectromagnet {
boolean isRunning(World var1, int var2, int var3, int var4);
}

View file

@ -0,0 +1,8 @@
package atomicscience.api;
import atomicscience.api.ITemperature;
public interface IFissileMaterial {
int onFissile(ITemperature var1);
}

View file

@ -0,0 +1,6 @@
package atomicscience.api;
import atomicscience.api.ITemperature;
public interface IHeatSource extends ITemperature {
}

View file

@ -0,0 +1,7 @@
package atomicscience.api;
public interface IReactor {
boolean isOverToxic();
}

View file

@ -0,0 +1,7 @@
package atomicscience.api;
public interface ISteamReceptor {
void onReceiveSteam(int var1);
}

View file

@ -0,0 +1,9 @@
package atomicscience.api;
public interface ITemperature {
float getTemperature();
void setTemperature(float var1);
}

View file

@ -0,0 +1,17 @@
package atomicscience.api;
import net.minecraft.world.World;
public class Plasma {
public static Plasma.IPlasma blockPlasma;
public interface IPlasma {
void spawn(World var1, int var2, int var3, int var4, byte var5);
boolean canPlace(World var1, int var2, int var3, int var4);
}
}

View file

@ -0,0 +1,77 @@
package atomicscience.api.poison;
import atomicscience.api.IAntiPoisonArmor;
import java.util.EnumSet;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import universalelectricity.core.vector.Vector3;
public abstract class Poison {
public static Poison[] list = new Poison[32];
protected String name;
protected EnumSet<Poison.ArmorType> armorRequired;
public Poison(String name, int id) {
this.armorRequired = EnumSet.range(Poison.ArmorType.HELM, Poison.ArmorType.BOOTS);
this.name = name;
if (list == null) {
list = new Poison[32];
}
list[0] = this;
}
public String getName() {
return this.name;
}
public EnumSet<Poison.ArmorType> getArmorRequired() {
return this.armorRequired;
}
public void poisonEntity(Vector3 emitPosition, EntityLivingBase entity,
int amplifier) {
EnumSet<Poison.ArmorType> armorWorn = EnumSet.of(Poison.ArmorType.UNKNOWN);
if (entity instanceof EntityPlayer) {
EntityPlayer entityPlayer = (EntityPlayer) entity;
for (int i = 0; i < entityPlayer.inventory.armorInventory.length; ++i) {
if (entityPlayer.inventory.armorInventory[i] != null &&
entityPlayer.inventory.armorInventory[i].getItem() instanceof IAntiPoisonArmor &&
((IAntiPoisonArmor) entityPlayer.inventory.armorInventory[i]
.getItem())
.isProtectedFromPoison(entityPlayer.inventory.armorInventory[i],
entity, this)) {
((IAntiPoisonArmor) entityPlayer.inventory.armorInventory[i].getItem())
.onProtectFromPoison(entityPlayer.inventory.armorInventory[i],
entity, this);
armorWorn.add(
((IAntiPoisonArmor) entityPlayer.inventory.armorInventory[i]
.getItem())
.getArmorType());
}
}
}
if (!armorWorn.containsAll(this.armorRequired)) {
this.doPoisonEntity(emitPosition, entity, armorWorn, amplifier);
}
}
public void poisonEntity(Vector3 emitPosition, EntityLivingBase entity) {
this.poisonEntity(emitPosition, entity, 0);
}
protected abstract void doPoisonEntity(Vector3 var1, EntityLivingBase var2,
EnumSet<Poison.ArmorType> var3, int var4);
public static enum ArmorType {
HELM,
BODY,
LEGGINGS,
BOOTS,
UNKNOWN;
}
}

View file

@ -0,0 +1,66 @@
package atomicscience.api.poison;
import atomicscience.api.IAntiPoisonBlock;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.CustomDamageSource;
import universalelectricity.prefab.potion.CustomPotionEffect;
public class PoisonRadiation extends Poison {
public static final Poison INSTANCE = new PoisonRadiation("radiation", 0);
public static final CustomDamageSource damageSource = (CustomDamageSource) (new CustomDamageSource("radiation"))
.setDamageBypassesArmor();
public static boolean disabled = false;
public PoisonRadiation(String name, int id) {
super(name, id);
}
@Override
protected void doPoisonEntity(Vector3 emitPosition, EntityLivingBase entity,
EnumSet<Poison.ArmorType> armorWorn,
int amplifier) {
if (!disabled) {
if (emitPosition == null) {
entity.addPotionEffect(
new CustomPotionEffect(PotionRadiation.INSTANCE.getId(),
300 * (amplifier + 1), amplifier, null));
return;
}
if (this.getAntiRadioactiveCount(entity.worldObj, emitPosition,
new Vector3(entity)) <= amplifier) {
entity.addPotionEffect(
new CustomPotionEffect(PotionRadiation.INSTANCE.getId(),
400 * (amplifier + 1), amplifier, null));
}
}
}
public int getAntiRadioactiveCount(World world, Vector3 startingPosition,
Vector3 endingPosition) {
Vector3 delta = Vector3.subtract(endingPosition, startingPosition).normalize();
Vector3 targetPosition = startingPosition.clone();
double totalDistance = startingPosition.distanceTo(endingPosition);
int count = 0;
if (totalDistance > 1.0D) {
for (; targetPosition.distanceTo(endingPosition) <= totalDistance; targetPosition.add(delta)) {
Block block = targetPosition.getBlock(world);
if (block != Blocks.air && block instanceof IAntiPoisonBlock &&
((IAntiPoisonBlock) block)
.isPoisonPrevention(world, targetPosition.intX(),
targetPosition.intY(),
targetPosition.intZ(), this)) {
++count;
}
}
}
return count;
}
}

View file

@ -0,0 +1,38 @@
package atomicscience.api.poison;
import atomicscience.api.AtomicScience;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import universalelectricity.prefab.potion.CustomPotion;
public class PotionRadiation extends CustomPotion {
public static final PotionRadiation INSTANCE;
public PotionRadiation(int id, boolean isBadEffect, int color, String name) {
super(AtomicScience.CONFIGURATION.get("Potion", name + " potion ID", id)
.getInt(id),
isBadEffect, color, name);
this.setIconIndex(6, 0);
}
@Override
public void performEffect(EntityLivingBase entity, int amplifier) {
if ((double) entity.worldObj.rand.nextFloat() > 0.9D - (double) amplifier * 0.08D) {
entity.attackEntityFrom(PoisonRadiation.damageSource, 1);
if (entity instanceof EntityPlayer) {
((EntityPlayer) entity)
.addExhaustion(0.01F * (float) (amplifier + 1));
}
}
}
public boolean isReady(int duration, int amplifier) {
return duration % 10 == 0;
}
static {
AtomicScience.CONFIGURATION.load();
INSTANCE = new PotionRadiation(21, true, 5149489, "radiation");
AtomicScience.CONFIGURATION.save();
}
}

View file

@ -0,0 +1,32 @@
package calclavia.lib;
import java.util.ArrayList;
import java.util.List;
public class Calclavia {
public static final String RESOURCE_DIRECTORY = "/mods/calclavia/";
public static final String TEXTURE_DIRECTORY = "/mods/calclavia/textures/";
public static final String GUI_DIRECTORY = "/mods/calclavia/textures/gui/";
public static final String GUI_COMPONENTS = "/mods/calclavia/textures/gui/gui_components.png";
public static final String GUI_BASE_FILE = "/mods/calclavia/textures/gui/gui_base.png";
public static final String GUI_EMPTY_FILE = "/mods/calclavia/textures/gui/gui_empty.png";
public static List<String> splitStringPerWord(String string, int wordsPerLine) {
String[] words = string.split(" ");
ArrayList<String> lines = new ArrayList<>();
for(int lineCount = 0; (double)lineCount < Math.ceil((double)((float)words.length / (float)wordsPerLine)); ++lineCount) {
String stringInLine = "";
for(int i = lineCount * wordsPerLine; i < Math.min(wordsPerLine + lineCount * wordsPerLine, words.length); ++i) {
stringInLine = stringInLine + words[i] + " ";
}
lines.add(stringInLine.trim());
}
return lines;
}
}

View file

@ -0,0 +1,111 @@
package calclavia.lib;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public class CalculationHelper {
public static void rotateByAngle(Vector3 vector, double yaw) {
double yawRadians = Math.toRadians(yaw);
double x = vector.x;
double z = vector.z;
if(yaw != 0.0D) {
vector.x = x * Math.cos(yawRadians) - z * Math.sin(yawRadians);
vector.z = x * Math.sin(yawRadians) + z * Math.cos(yawRadians);
}
}
public static void rotateByAngle(Vector3 vector, double yaw, double pitch) {
rotateByAngle(vector, yaw, pitch, 0.0D);
}
public static void rotateByAngle(Vector3 vector, double yaw, double pitch, double roll) {
double yawRadians = Math.toRadians(yaw);
double pitchRadians = Math.toRadians(pitch);
double rollRadians = Math.toRadians(roll);
double x = vector.x;
double y = vector.y;
double z = vector.z;
vector.x = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + z * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math.cos(rollRadians)) + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + Math.sin(yawRadians) * Math.sin(rollRadians));
vector.z = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + z * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math.cos(rollRadians)) + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - Math.cos(yawRadians) * Math.sin(rollRadians));
vector.y = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math.cos(pitchRadians) * Math.cos(rollRadians);
}
public static Vector3 getDeltaPositionFromRotation(float rotationYaw, float rotationPitch) {
rotationYaw += 90.0F;
rotationPitch = -rotationPitch;
return new Vector3(Math.cos(Math.toRadians((double)rotationYaw)), Math.sin(Math.toRadians((double)rotationPitch)), Math.sin(Math.toRadians((double)rotationYaw)));
}
public static MovingObjectPosition raytraceEntities(World world, Vector3 startPosition, float rotationYaw, float rotationPitch, boolean collisionFlag, double reachDistance) {
MovingObjectPosition pickedEntity = null;
Vec3 startingPosition = startPosition.toVec3();
Vec3 look = getDeltaPositionFromRotation(rotationYaw, rotationPitch).toVec3();
Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
double playerBorder = 1.1D * reachDistance;
AxisAlignedBB boxToScan = AxisAlignedBB.getBoundingBox(-playerBorder, -playerBorder, -playerBorder, playerBorder, playerBorder, playerBorder);
List entitiesHit = world.getEntitiesWithinAABBExcludingEntity((Entity)null, boxToScan);
double closestEntity = reachDistance;
if(entitiesHit != null && !entitiesHit.isEmpty()) {
Iterator i$ = entitiesHit.iterator();
while(i$.hasNext()) {
Entity entityHit = (Entity)i$.next();
if(entityHit != null && entityHit.canBeCollidedWith() && entityHit.boundingBox != null) {
float border = entityHit.getCollisionBorderSize();
AxisAlignedBB aabb = entityHit.boundingBox.expand((double)border, (double)border, (double)border);
MovingObjectPosition hitMOP = aabb.calculateIntercept(startingPosition, reachPoint);
if(hitMOP != null) {
if(aabb.isVecInside(startingPosition)) {
if(0.0D < closestEntity || closestEntity == 0.0D) {
pickedEntity = new MovingObjectPosition(entityHit);
if(pickedEntity != null) {
pickedEntity.hitVec = hitMOP.hitVec;
closestEntity = 0.0D;
}
}
} else {
double distance = startingPosition.distanceTo(hitMOP.hitVec);
if(distance < closestEntity || closestEntity == 0.0D) {
pickedEntity = new MovingObjectPosition(entityHit);
pickedEntity.hitVec = hitMOP.hitVec;
closestEntity = distance;
}
}
}
}
}
return pickedEntity;
} else {
return null;
}
}
public static MovingObjectPosition raytraceBlocks(World world, Vector3 startPosition, float rotationYaw, float rotationPitch, boolean collisionFlag, double reachDistance) {
Vector3 lookVector = getDeltaPositionFromRotation(rotationYaw, rotationPitch);
Vector3 reachPoint = Vector3.add(startPosition, Vector3.multiply(lookVector, reachDistance));
return world.rayTraceBlocks(startPosition.toVec3(), reachPoint.toVec3(), collisionFlag);
}
public static MovingObjectPosition doCustomRayTrace(World world, Vector3 startPosition, float rotationYaw, float rotationPitch, boolean collisionFlag, double reachDistance) {
MovingObjectPosition pickedBlock = raytraceBlocks(world, startPosition, rotationYaw, rotationPitch, collisionFlag, reachDistance);
MovingObjectPosition pickedEntity = raytraceEntities(world, startPosition, rotationYaw, rotationPitch, collisionFlag, reachDistance);
if(pickedBlock == null) {
return pickedEntity;
} else if(pickedEntity == null) {
return pickedBlock;
} else {
double dBlock = startPosition.distanceTo(new Vector3(pickedBlock.hitVec));
double dEntity = startPosition.distanceTo(new Vector3(pickedEntity.hitVec));
return dEntity < dBlock?pickedEntity:pickedBlock;
}
}
}

View file

@ -0,0 +1,8 @@
package calclavia.lib;
import java.util.HashSet;
public interface IPlayerUsing {
HashSet getPlayersUsing();
}

View file

@ -0,0 +1,7 @@
package calclavia.lib;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IVoltage;
public interface IUniversalEnergyTile extends IConnector, IVoltage {
}

View file

@ -0,0 +1,25 @@
package calclavia.lib;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.tile.TileEntityElectrical;
public class TileEntityUniversalProducer extends TileEntityElectrical {
public ElectricityPack produce(double watts) {
ElectricityPack pack =
new ElectricityPack(watts / this.getVoltage(), this.getVoltage());
ElectricityPack remaining =
ElectricityNetworkHelper.produceFromMultipleSides(this, pack);
return remaining;
}
@Override
public boolean canConnect(ForgeDirection direction) {
return this instanceof IRotatable
? direction.ordinal() == this.getBlockMetadata()
: true;
}
}

View file

@ -0,0 +1,28 @@
package calclavia.lib;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.tile.TileEntityElectricityRunnable;
public abstract class TileEntityUniversalRunnable
extends TileEntityElectricityRunnable implements IUniversalEnergyTile {
@Override
public boolean canConnect(ForgeDirection direction) {
return this instanceof IRotatable
? direction == ForgeDirection.getOrientation(this.getBlockMetadata())
.getOpposite()
: true;
}
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
public void setDirection(World world, int x, int y, int z,
ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 2);
}
}

View file

@ -0,0 +1,28 @@
package calclavia.lib;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.tile.TileEntityElectricityStorage;
public abstract class TileEntityUniversalStorable
extends TileEntityElectricityStorage implements IUniversalEnergyTile {
@Override
public boolean canConnect(ForgeDirection direction) {
return this instanceof IRotatable
? direction == ForgeDirection.getOrientation(this.getBlockMetadata())
.getOpposite()
: true;
}
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
public void setDirection(World world, int x, int y, int z,
ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 2);
}
}

View file

@ -0,0 +1,102 @@
package calclavia.lib;
import cpw.mods.fml.common.FMLLog;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class UniversalRecipes {
public static final String PRIMARY_METAL = "ingotSteel";
public static final String PRIMARY_PLATE = "plateSteel";
public static final String SECONDARY_METAL = "ingotBronze";
public static final String SECONDARY_PLATE = "plateBronze";
public static final String CIRCUIT_T1 = "calclavia:CIRCUIT_T1";
public static final String CIRCUIT_T2 = "calclavia:CIRCUIT_T2";
public static final String CIRCUIT_T3 = "calclavia:CIRCUIT_T3";
public static String ADVANCED_BATTERY = "calclavia:ADVANCED_BATTERY";
public static String BATTERY = "calclavia:BATTERY";
public static String BATTERY_BOX = "calclavia:BATTERY_BOX";
public static final String WRENCH = "calclavia:WRENCH";
public static final String WIRE = "calclavia:WIRE";
public static final String MOTOR = "calclavia:MOTOR";
public static boolean isInit = false;
public static void init() {
if (!isInit) {
// TODO: WTF
// register("calclavia:CIRCUIT_T1", new Object[]{"circuitBasic",
// Items.getItem("electronicCircuit"), new
// ItemStack(Blocks.redstone_torch)}); register("calclavia:CIRCUIT_T2",
// new Object[]{"circuitAdvanced", Items.getItem("advancedCircuit"), new
// ItemStack(Items.repeater)}); register("calclavia:CIRCUIT_T3", new
// Object[]{"circuitElite", Items.getItem("iridiumPlate"), new
// ItemStack(Block.field_94346_cn)}); register(ADVANCED_BATTERY, new
// Object[]{"advancedBattery", Items.getItem("energyCrystal"), "battery",
// new ItemStack(Items.repeater)}); register(BATTERY, new
// Object[]{"battery", Items.getItem("reBattery"), new
// ItemStack(Items.repeater)});
// register(BATTERY_BOX, new Object[]{"batteryBox",
// Items.getItem("batBox"), new ItemStack(Block.field_72105_ah)});
// register("calclavia:WRENCH", new Object[]{"wrench",
// Items.getItem("wrench"), new ItemStack(Item.field_77708_h)});
// register("calclavia:WIRE", new Object[]{"copperWire",
// "copperCableBlock", new ItemStack(Item.field_77767_aC)});
// register("calclavia:MOTOR", new Object[]{"motor",
// Items.getItem("generator"), new ItemStack(Block.field_71963_Z)});
isInit = true;
}
}
public static void register(String name, Object... possiblities) {
Object[] arr$ = possiblities;
int len$ = possiblities.length;
for (int i$ = 0; i$ < len$; ++i$) {
Object possiblity = arr$[i$];
if (possiblity instanceof ItemStack) {
if (registerItemStacksToDictionary(
name, new ItemStack[] {(ItemStack)possiblity})) {
break;
}
} else if (possiblity instanceof String) {
if (registerItemStacksToDictionary(name, (String)possiblity)) {
break;
}
} else {
FMLLog.severe("Universal Recipes: Error Registering " + name,
new Object[0]);
}
}
}
public static boolean registerItemStacksToDictionary(String name,
List itemStacks) {
boolean returnValue = false;
if (itemStacks != null && itemStacks.size() > 0) {
Iterator i$ = itemStacks.iterator();
while (i$.hasNext()) {
ItemStack stack = (ItemStack)i$.next();
if (stack != null) {
OreDictionary.registerOre(name, stack);
returnValue = true;
}
}
}
return returnValue;
}
public static boolean
registerItemStacksToDictionary(String name, ItemStack... itemStacks) {
return registerItemStacksToDictionary(name, Arrays.asList(itemStacks));
}
public static boolean registerItemStacksToDictionary(String name,
String stackName) {
return registerItemStacksToDictionary(
name, (List)OreDictionary.getOres(stackName));
}
}

View file

@ -0,0 +1,96 @@
package calclavia.lib.gui;
import calclavia.lib.IPlayerUsing;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerBase extends Container {
protected int slotCount = 0;
private IInventory inventory;
public ContainerBase(IInventory inventory) {
this.inventory = inventory;
this.slotCount = inventory.getSizeInventory();
}
public void onContainerClosed(EntityPlayer player) {
if(this.inventory instanceof IPlayerUsing) {
((IPlayerUsing)this.inventory).getPlayersUsing().remove(player);
}
}
public void addPlayerInventory(EntityPlayer player) {
if(this.inventory instanceof IPlayerUsing) {
((IPlayerUsing)this.inventory).getPlayersUsing().add(player);
}
int var3;
for(var3 = 0; var3 < 3; ++var3) {
for(int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot(player.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 135 + var3 * 18));
}
}
for(var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(new Slot(player.inventory, var3, 8 + var3 * 18, 193));
}
}
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotID) {
ItemStack var2 = null;
Slot var3 = (Slot)super.inventorySlots.get(slotID);
if(var3 != null && var3.getHasStack()) {
ItemStack itemStack = var3.getStack();
var2 = itemStack.copy();
if(slotID >= this.slotCount) {
boolean didTry = false;
for(int i = 0; i < this.slotCount; ++i) {
if(this.getSlot(i).isItemValid(itemStack)) {
didTry = true;
if(this.mergeItemStack(itemStack, i, i + 1, false)) {
break;
}
}
}
if(!didTry) {
if(slotID < 27 + this.slotCount) {
if(!this.mergeItemStack(itemStack, 27 + this.slotCount, 36 + this.slotCount, false)) {
return null;
}
} else if(slotID >= 27 + this.slotCount && slotID < 36 + this.slotCount && !this.mergeItemStack(itemStack, this.slotCount, 27 + this.slotCount, false)) {
return null;
}
}
} else if(!this.mergeItemStack(itemStack, this.slotCount, 36 + this.slotCount, false)) {
return null;
}
if(itemStack.stackSize == 0) {
var3.putStack((ItemStack)null);
} else {
var3.onSlotChanged();
}
if(itemStack.stackSize == var2.stackSize) {
return null;
}
var3.onPickupFromSlot(par1EntityPlayer, itemStack);
}
return var2;
}
public boolean canInteractWith(EntityPlayer entityplayer) {
return this.inventory.isUseableByPlayer(entityplayer);
}
}

View file

@ -0,0 +1,296 @@
package calclavia.lib.gui;
import calclavia.lib.Calclavia;
import java.util.HashMap;
import java.util.Map.Entry;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector2;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.vector.Region2;
public class GuiContainerBase extends GuiContainer {
//private static final int METER_X = 54;
public static final int METER_HEIGHT = 49;
public static final int METER_WIDTH = 14;
public static final int METER_END = 68;
public String tooltip = "";
protected HashMap<Region2, String> tooltips = new HashMap<>();
protected int containerWidth;
protected int containerHeight;
public GuiContainerBase(Container container) {
super(container);
this.ySize = 217;
}
@Override
public void initGui() {
super.initGui();
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
super.onGuiClosed();
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
for (Entry<Region2, String> entry : this.tooltips.entrySet()) {
if (((Region2)entry.getKey())
.isIn(new Vector2((double)(mouseX - this.guiLeft),
(double)(mouseY - this.guiTop)))) {
this.tooltip = (String)entry.getValue();
break;
}
}
if (this.tooltip != null && this.tooltip != "") {
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop,
(String[])Calclavia.splitStringPerWord(this.tooltip, 5)
.toArray(new String[0]));
}
this.tooltip = "";
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int x, int y) {
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
}
protected void drawBulb(int x, int y, boolean isOn) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (isOn) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 161, 0, 6, 6);
} else {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 161, 4, 6, 6);
}
}
protected void drawSlot(int x, int y, ItemStack itemStack) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 0, 0, 18, 18);
this.drawItemStack(itemStack, this.containerWidth + x,
this.containerHeight + y);
}
protected void drawItemStack(ItemStack itemStack, int x, int y) {
++x;
++y;
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
itemRender.renderItemAndEffectIntoGUI(
this.fontRendererObj, this.mc.renderEngine, itemStack, x, y);
}
protected void drawTextWithTooltip(String textName, String format, int x,
int y, int mouseX, int mouseY) {
this.drawTextWithTooltip(textName, format, x, y, mouseX, mouseY, 4210752);
}
protected void drawTextWithTooltip(String textName, String format, int x,
int y, int mouseX, int mouseY, int color) {
String name = TranslationHelper.getLocal("gui." + textName + ".name");
String text = format.replaceAll("%1", name);
this.fontRendererObj.drawString(text, x, y, color);
String tooltip = TranslationHelper.getLocal("gui." + textName + ".tooltip");
if (tooltip != null && tooltip != "" &&
this.func_146978_c(x, y, (int)((double)text.length() * 4.8D), 12,
mouseX, mouseY)) {
this.tooltip = tooltip;
}
}
protected void drawTextWithTooltip(String textName, int x, int y, int mouseX,
int mouseY) {
this.drawTextWithTooltip(textName, "%1", x, y, mouseX, mouseY);
}
protected void drawSlot(int x, int y, GuiSlotType type, float r, float g,
float b) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_components.png"));
GL11.glColor4f(r, g, b, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 0, 0, 18, 18);
if (type != GuiSlotType.NONE) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 0,
18 * type.ordinal(), 18, 18);
}
}
protected void drawSlot(int x, int y, GuiSlotType type) {
this.drawSlot(x, y, type, 1.0F, 1.0F, 1.0F);
}
protected void drawSlot(int x, int y) {
this.drawSlot(x, y, GuiSlotType.NONE);
}
protected void drawBar(int x, int y, float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_components.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 18, 0, 22, 15);
if (scale > 0.0F) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 18, 15,
22 - (int)(scale * 22.0F), 15);
}
}
protected void drawForce(int x, int y, float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_components.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 0, 107, 11);
if (scale > 0.0F) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 11,
(int)(scale * 107.0F), 11);
}
}
protected void drawElectricity(int x, int y, float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_components.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 0, 107, 11);
if (scale > 0.0F) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 22,
(int)(scale * 107.0F), 11);
}
}
protected void drawMeter(int x, int y, float scale, FluidStack liquidStack) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 40, 0, 14, 49);
this.displayGauge(this.containerWidth + x, this.containerHeight + y, 0, 0,
(int)(48.0F * scale), liquidStack);
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 40, 98, 14, 49);
}
public void drawTooltip(int x, int y, String... toolTips) {
if (!GuiScreen.isShiftKeyDown()) {
GL11.glDisable('\u803a');
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2896);
GL11.glDisable(2929);
if (toolTips != null) {
int var5 = 0;
int var6;
int var7;
for (var6 = 0; var6 < toolTips.length; ++var6) {
var7 = this.fontRendererObj.getStringWidth(toolTips[var6]);
if (var7 > var5) {
var5 = var7;
}
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if (toolTips.length > 1) {
var9 += 2 + (toolTips.length - 1) * 10;
}
if (this.guiTop + var7 + var9 + 6 > this.height) {
var7 = this.height - var9 - this.guiTop - 6;
}
super.zLevel = 300.0F;
int var10 = -267386864;
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3,
var10, var10);
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3,
var7 + var9 + 4, var10, var10);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3,
var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3,
var10, var10);
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4,
var7 + var9 + 3, var10, var10);
int var11 = 1347420415;
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1,
var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3,
var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1,
var11, var11);
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3,
var7 + var9 + 3, var12, var12);
for (int var13 = 0; var13 < toolTips.length; ++var13) {
String var14 = toolTips[var13];
this.fontRendererObj.drawStringWithShadow(var14, var6, var7, -1);
var7 += 10;
}
super.zLevel = 0.0F;
GL11.glEnable(2929);
GL11.glEnable(2896);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable('\u803a');
}
}
}
protected void displayGauge(int j, int k, int line, int col, int squaled,
FluidStack liquid) {
if (liquid != null) {
int start = 0;
IIcon liquidIcon = liquid.getFluid().getIcon();
int x1;
do {
if (squaled > 16) {
x1 = 16;
squaled -= 16;
} else {
x1 = squaled;
squaled = 0;
}
this.drawTexturedModelRectFromIcon(j + col, k + line + 58 - x1 - start,
liquidIcon, 16, 16 - (16 - x1));
start += 16;
} while (x1 != 0 && squaled != 0);
}
}
}

View file

@ -0,0 +1,271 @@
package calclavia.lib.gui;
import calclavia.lib.Calclavia;
import java.util.HashMap;
import java.util.Map.Entry;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector2;
import universalelectricity.prefab.GuiBase;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.vector.Region2;
public class GuiScreenBase extends GuiBase {
// private static final int METER_X = 54;
public static final int METER_HEIGHT = 49;
public static final int METER_WIDTH = 14;
public static final int METER_END = 68;
public String tooltip = "";
protected HashMap<Region2, String> tooltips = new HashMap<>();
protected int containerWidth;
protected int containerHeight;
public GuiScreenBase() { super.ySize = 217; }
@Override
protected void drawForegroundLayer(int mouseX, int mouseY, float var1) {
for (Entry<Region2, String> entry : this.tooltips.entrySet()) {
if (((Region2)entry.getKey())
.isIn(new Vector2((double)(mouseX - this.guiLeft),
(double)(mouseY - this.guiTop)))) {
this.tooltip = (String)entry.getValue();
break;
}
}
if (this.tooltip != null && this.tooltip != "") {
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop,
(String[])Calclavia.splitStringPerWord(this.tooltip, 5)
.toArray(new String[0]));
}
this.tooltip = "";
}
@Override
protected void drawBackgroundLayer(int x, int y, float var1) {
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
}
protected void drawBulb(int x, int y, boolean isOn) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_base.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (isOn) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 161, 0, 6, 6);
} else {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 161, 4, 6, 6);
}
}
protected void drawTextWithTooltip(String textName, String format, int x,
int y, int mouseX, int mouseY) {
this.drawTextWithTooltip(textName, format, x, y, mouseX, mouseY, 4210752);
}
protected void drawTextWithTooltip(String textName, String format, int x,
int y, int mouseX, int mouseY, int color) {
String name = TranslationHelper.getLocal("gui." + textName + ".name");
String text = format.replaceAll("%1", name);
this.fontRendererObj.drawString(text, x, y, color);
String tooltip = TranslationHelper.getLocal("gui." + textName + ".tooltip");
if (tooltip != null && tooltip != "" &&
this.isPointInRegion(x, y, (int)((double)text.length() * 4.8D), 12,
mouseX, mouseY)) {
this.tooltip = tooltip;
}
}
protected boolean isPointInRegion(int par1, int par2, int par3, int par4,
int par5, int par6) {
int k1 = super.guiLeft;
int l1 = super.guiTop;
par5 -= k1;
par6 -= l1;
return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 &&
par6 < par2 + par4 + 1;
}
protected void drawTextWithTooltip(String textName, int x, int y, int mouseX,
int mouseY) {
this.drawTextWithTooltip(textName, "%1", x, y, mouseX, mouseY);
}
protected void drawSlot(int x, int y, GuiSlotType type, float r, float g,
float b) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_empty.png"));
GL11.glColor4f(r, g, b, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 0, 0, 18, 18);
if (type != GuiSlotType.NONE) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 0,
18 * type.ordinal(), 18, 18);
}
}
protected void drawSlot(int x, int y, GuiSlotType type) {
this.drawSlot(x, y, type, 1.0F, 1.0F, 1.0F);
}
protected void drawSlot(int x, int y) {
this.drawSlot(x, y, GuiSlotType.NONE);
}
protected void drawBar(int x, int y, float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_empty.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 18, 0, 22, 15);
if (scale > 0.0F) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 18, 15,
22 - (int)(scale * 22.0F), 15);
}
}
protected void drawForce(int x, int y, float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_empty.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 0, 107, 11);
if (scale > 0.0F) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 11,
(int)(scale * 107.0F), 11);
}
}
protected void drawElectricity(int x, int y, float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_empty.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 0, 107, 11);
if (scale > 0.0F) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 54, 22,
(int)(scale * 107.0F), 11);
}
}
protected void drawMeter(int x, int y, float scale, FluidStack liquidStack) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_empty.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 40, 0, 14, 49);
this.displayGauge(this.containerWidth + x, this.containerHeight + y, 0, 0,
(int)(48.0F * scale), liquidStack);
this.mc.renderEngine.bindTexture(
new ResourceLocation("calclavia", "textures/gui/gui_empty.png"));
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 40, 98, 14, 49);
}
public void drawTooltip(int x, int y, String... toolTips) {
if (!GuiScreen.isShiftKeyDown()) {
GL11.glDisable('\u803a');
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2896);
GL11.glDisable(2929);
if (toolTips != null) {
int var5 = 0;
int var6;
int var7;
for (var6 = 0; var6 < toolTips.length; ++var6) {
var7 = this.fontRendererObj.getStringWidth(toolTips[var6]);
if (var7 > var5) {
var5 = var7;
}
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if (toolTips.length > 1) {
var9 += 2 + (toolTips.length - 1) * 10;
}
if (super.guiTop + var7 + var9 + 6 > this.height) {
var7 = this.height - var9 - super.guiTop - 6;
}
super.zLevel = 300.0F;
int var10 = -267386864;
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3,
var10, var10);
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3,
var7 + var9 + 4, var10, var10);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3,
var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3,
var10, var10);
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4,
var7 + var9 + 3, var10, var10);
int var11 = 1347420415;
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1,
var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3,
var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1,
var11, var11);
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3,
var7 + var9 + 3, var12, var12);
for (int var13 = 0; var13 < toolTips.length; ++var13) {
String var14 = toolTips[var13];
this.fontRendererObj.drawStringWithShadow(var14, var6, var7, -1);
var7 += 10;
}
super.zLevel = 0.0F;
GL11.glEnable(2929);
GL11.glEnable(2896);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable('\u803a');
}
}
}
protected void displayGauge(int j, int k, int line, int col, int squaled,
FluidStack liquid) {
if (liquid != null) {
int start = 0;
IIcon liquidIcon = liquid.getFluid().getIcon();
int x1;
do {
if (squaled > 16) {
x1 = 16;
squaled -= 16;
} else {
x1 = squaled;
squaled = 0;
}
this.drawTexturedModelRectFromIcon(j + col, k + line + 58 - x1 - start,
liquidIcon, 16, 16 - (16 - x1));
start += 16;
} while (x1 != 0 && squaled != 0);
}
}
}

View file

@ -0,0 +1,23 @@
package calclavia.lib.gui;
public enum GuiSlotType {
NONE("NONE", 0),
BATTERY("BATTERY", 1),
LIQUID("LIQUID", 2),
ARR_UP("ARR_UP", 3),
ARR_DOWN("ARR_DOWN", 4),
ARR_LEFT("ARR_LEFT", 5),
ARR_RIGHT("ARR_RIGHT", 6),
ARR_UP_RIGHT("ARR_UP_RIGHT", 7),
ARR_UP_LEFT("ARR_UP_LEFT", 8),
ARR_DOWN_LEFT("ARR_DOWN_LEFT", 9),
ARR_DOWN_RIGHT("ARR_DOWN_RIGHT", 10);
// $FF: synthetic field
private static final GuiSlotType[] $VALUES = new GuiSlotType[]{NONE, BATTERY, LIQUID, ARR_UP, ARR_DOWN, ARR_LEFT, ARR_RIGHT, ARR_UP_RIGHT, ARR_UP_LEFT, ARR_DOWN_LEFT, ARR_DOWN_RIGHT};
private GuiSlotType(String var1, int var2) {}
}

View file

@ -0,0 +1,111 @@
package calclavia.lib.render;
import net.minecraft.block.Block;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import org.lwjgl.opengl.GL11;
public class CalclaviaRenderHelper {
public static void enableBlending() {
GL11.glShadeModel(7425);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
}
public static void disableBlending() {
GL11.glShadeModel(7424);
GL11.glDisable(2848);
GL11.glDisable(2881);
GL11.glDisable(3042);
}
public static void enableLighting() {
RenderHelper.enableStandardItemLighting();
}
public static void disableLighting() {
RenderHelper.disableStandardItemLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
}
public static void renderNormalBlockAsItem(Block block, int metadata, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
block.setBlockBoundsForItemRender();
renderer.setRenderBoundsFromBlock(block);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
public static void renderFloatingText(String text, float x, float y, float z) {
renderFloatingText(text, x, y, z, 16777215);
}
public static void renderFloatingText(String text, float x, float y, float z, int color) {
RenderManager renderManager = RenderManager.instance;
FontRenderer fontRenderer = renderManager.getFontRenderer();
float scale = 0.027F;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
GL11.glPushMatrix();
GL11.glTranslatef(x + 0.0F, y + 2.3F, z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glScalef(-scale, -scale, scale);
GL11.glDisable(2896);
GL11.glDepthMask(false);
GL11.glDisable(2929);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
Tessellator tessellator = Tessellator.instance;
byte yOffset = 0;
GL11.glDisable(3553);
tessellator.startDrawingQuads();
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.5F);
tessellator.addVertex((double)(-stringMiddle - 1), (double)(-1 + yOffset), 0.0D);
tessellator.addVertex((double)(-stringMiddle - 1), (double)(8 + yOffset), 0.0D);
tessellator.addVertex((double)(stringMiddle + 1), (double)(8 + yOffset), 0.0D);
tessellator.addVertex((double)(stringMiddle + 1), (double)(-1 + yOffset), 0.0D);
tessellator.draw();
GL11.glEnable(3553);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
GL11.glEnable(2929);
GL11.glDepthMask(true);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
GL11.glEnable(2896);
GL11.glDisable(3042);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,9 @@
package calclavia.lib.render;
import java.util.HashMap;
import net.minecraft.entity.player.EntityPlayer;
public interface ITagRender {
float addInformation(HashMap var1, EntityPlayer var2);
}

View file

@ -0,0 +1,64 @@
package calclavia.lib.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
@SideOnly(Side.CLIENT)
public abstract class RenderTaggedTile extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z,
float f) {
if (t != null && t instanceof ITagRender &&
this.getPlayer().getDistance((double)t.xCoord, (double)t.yCoord,
(double)t.zCoord) <=
(double)RendererLivingEntity.NAME_TAG_RANGE) {
HashMap tags = new HashMap();
float height = ((ITagRender)t).addInformation(tags, this.getPlayer());
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
if (player.ridingEntity == null) {
MovingObjectPosition objectPosition = player.rayTrace(8.0D, 1.0F);
if (objectPosition != null) {
boolean isLooking = false;
for (int it = 0; (float)it < height; ++it) {
if (objectPosition.blockX == t.xCoord &&
objectPosition.blockY == t.yCoord + it &&
objectPosition.blockZ == t.zCoord) {
isLooking = true;
}
}
if (isLooking) {
Iterator var17 = tags.entrySet().iterator();
for (int i = 0; var17.hasNext(); ++i) {
Entry entry = (Entry)var17.next();
if (entry.getKey() != null) {
CalclaviaRenderHelper.renderFloatingText(
(String)entry.getKey(), (float)x + 0.5F,
(float)y + (float)i * 0.25F - 2.0F + height,
(float)z + 0.5F, ((Integer)entry.getValue()).intValue());
}
}
}
}
}
}
}
public EntityPlayer getPlayer() {
EntityLivingBase entity = this.field_147501_a.field_147551_g;
return entity instanceof EntityPlayer ? (EntityPlayer)entity : null;
}
}

View file

@ -0,0 +1,315 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api;
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount;
import dan200.computercraft.api.media.IMediaProvider;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.permissions.ITurtlePermissionProvider;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import net.minecraft.world.World;
import java.lang.reflect.Method;
/**
* The static entry point to the ComputerCraft API.
* Members in this class must be called after mod_ComputerCraft has been initialised,
* but may be called before it is fully loaded.
*/
public final class ComputerCraftAPI
{
public static boolean isInstalled()
{
findCC();
return computerCraft != null;
}
public static String getInstalledVersion()
{
findCC();
if( computerCraft_getVersion != null )
{
try {
return (String)computerCraft_getVersion.invoke( null );
} catch (Exception e) {
// It failed
}
}
return "";
}
public static String getAPIVersion()
{
return "1.75";
}
/**
* Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number.<br>
* Use in conjuction with createSaveDirMount() to create a unique place for your peripherals or media items to store files.<br>
* @param world The world for which the save dir should be created. This should be the serverside world object.
* @param parentSubPath The folder path within the save directory where the new directory should be created. eg: "computercraft/disk"
* @return The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason.<br>
* eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now available for writing.
* @see #createSaveDirMount(World, String, long)
*/
public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
{
findCC();
if( computerCraft_createUniqueNumberedSaveDir != null )
{
try {
return (Integer)computerCraft_createUniqueNumberedSaveDir.invoke( null, world, parentSubPath );
} catch (Exception e) {
// It failed
}
}
return -1;
}
/**
* Creates a file system mount that maps to a subfolder of the save directory for a given world, and returns it.<br>
* Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a folder from the
* users save directory onto a computers file system.<br>
* @param world The world for which the save dir can be found. This should be the serverside world object.
* @param subPath The folder path within the save directory that the mount should map to. eg: "computer/disk/42".<br>
* Use createUniqueNumberedSaveDir() to create a new numbered folder to use.
* @param capacity The ammount of data that can be stored in the directory before it fills up, in bytes.
* @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
* to mount this on a Computers' file system.
* @see #createUniqueNumberedSaveDir(World, String)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mount(String, dan200.computercraft.api.filesystem.IMount)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see dan200.computercraft.api.filesystem.IMount
* @see IWritableMount
*/
public static IWritableMount createSaveDirMount( World world, String subPath, long capacity )
{
findCC();
if( computerCraft_createSaveDirMount != null )
{
try {
return (IWritableMount)computerCraft_createSaveDirMount.invoke( null, world, subPath, capacity );
} catch (Exception e){
// It failed
}
}
return null;
}
/**
* Creates a file system mount to a resource folder, and returns it.<br>
* Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a resource folder onto a computers file system.<br>
* The files in this mount will be a combination of files in the specified mod jar, and resource packs that contain resources with the same domain and path.<br>
* @param modClass A class in whose jar to look first for the resources to mount. Using your main mod class is recommended. eg: MyMod.class
* @param domain The domain under which to look for resources. eg: "mymod"
* @param subPath The domain under which to look for resources. eg: "mymod/lua/myfiles"
* @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
* to mount this on a Computers' file system.
* @see dan200.computercraft.api.peripheral.IComputerAccess#mount(String, dan200.computercraft.api.filesystem.IMount)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, IWritableMount)
* @see dan200.computercraft.api.filesystem.IMount
*/
public static IMount createResourceMount( Class modClass, String domain, String subPath )
{
findCC();
if( computerCraft_createResourceMount != null )
{
try {
return (IMount)computerCraft_createResourceMount.invoke( null, modClass, domain, subPath );
} catch (Exception e){
// It failed
}
}
return null;
}
/**
* Registers a peripheral handler to convert blocks into IPeripheral implementations.
* @see dan200.computercraft.api.peripheral.IPeripheral
* @see dan200.computercraft.api.peripheral.IPeripheralProvider
*/
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
findCC();
if ( computerCraft_registerPeripheralProvider != null)
{
try {
computerCraft_registerPeripheralProvider.invoke( null, handler );
} catch (Exception e){
// It failed
}
}
}
/**
* Registers a new turtle turtle for use in ComputerCraft. After calling this,
* users should be able to craft Turtles with your new turtle. It is recommended to call
* this during the load() method of your mod.
* @see dan200.computercraft.api.turtle.ITurtleUpgrade
*/
public static void registerTurtleUpgrade( ITurtleUpgrade upgrade )
{
if( upgrade != null )
{
findCC();
if( computerCraft_registerTurtleUpgrade != null )
{
try {
computerCraft_registerTurtleUpgrade.invoke( null, upgrade );
} catch( Exception e ) {
// It failed
}
}
}
}
/**
* Registers a bundled redstone handler to provide bundled redstone output for blocks
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
*/
public static void registerBundledRedstoneProvider( IBundledRedstoneProvider handler )
{
findCC();
if( computerCraft_registerBundledRedstoneProvider != null )
{
try {
computerCraft_registerBundledRedstoneProvider.invoke( null, handler );
} catch (Exception e) {
// It failed
}
}
}
/**
* If there is a Computer or Turtle at a certain position in the world, get it's bundled redstone output.
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
* @return If there is a block capable of emitting bundled redstone at the location, it's signal (0-65535) will be returned.
* If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
*/
public static int getBundledRedstoneOutput( World world, int x, int y, int z, int side )
{
findCC();
if( computerCraft_getDefaultBundledRedstoneOutput != null )
{
try {
return (Integer)computerCraft_getDefaultBundledRedstoneOutput.invoke( null, world, x, y, z, side );
} catch (Exception e){
// It failed
}
}
return -1;
}
/**
* Registers a media handler to provide IMedia implementations for Items
* @see dan200.computercraft.api.media.IMediaProvider
*/
public static void registerMediaProvider( IMediaProvider handler )
{
findCC();
if( computerCraft_registerMediaProvider != null )
{
try {
computerCraft_registerMediaProvider.invoke( null, handler );
} catch (Exception e){
// It failed
}
}
}
/**
* Registers a permission handler to restrict where turtles can move or build
* @see dan200.computercraft.api.permissions.ITurtlePermissionProvider
*/
public static void registerPermissionProvider( ITurtlePermissionProvider handler )
{
findCC();
if( computerCraft_registerPermissionProvider != null )
{
try {
computerCraft_registerPermissionProvider.invoke( null, handler );
} catch (Exception e) {
// It failed
}
}
}
// The functions below here are private, and are used to interface with the non-API ComputerCraft classes.
// Reflection is used here so you can develop your mod without decompiling ComputerCraft and including
// it in your solution, and so your mod won't crash if ComputerCraft is installed.
private static void findCC()
{
if( !ccSearched ) {
try {
computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
computerCraft_getVersion = findCCMethod( "getVersion", new Class[]{
} );
computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
World.class, String.class
} );
computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
World.class, String.class, Long.TYPE
} );
computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
Class.class, String.class, String.class
} );
computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
IPeripheralProvider.class
} );
computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
ITurtleUpgrade.class
} );
computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
IBundledRedstoneProvider.class
} );
computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
} );
computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
IMediaProvider.class
} );
computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class[] {
ITurtlePermissionProvider.class
} );
} catch( Exception e ) {
System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
} finally {
ccSearched = true;
}
}
}
private static Method findCCMethod( String name, Class[] args )
{
try {
if( computerCraft != null )
{
return computerCraft.getMethod( name, args );
}
return null;
} catch( NoSuchMethodException e ) {
System.out.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
return null;
}
}
private static boolean ccSearched = false;
private static Class computerCraft = null;
private static Method computerCraft_getVersion = null;
private static Method computerCraft_createUniqueNumberedSaveDir = null;
private static Method computerCraft_createSaveDirMount = null;
private static Method computerCraft_createResourceMount = null;
private static Method computerCraft_registerPeripheralProvider = null;
private static Method computerCraft_registerTurtleUpgrade = null;
private static Method computerCraft_registerBundledRedstoneProvider = null;
private static Method computerCraft_getDefaultBundledRedstoneOutput = null;
private static Method computerCraft_registerMediaProvider = null;
private static Method computerCraft_registerPermissionProvider = null;
}

View file

@ -0,0 +1,57 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.filesystem;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* Represents a read only part of a virtual filesystem that can be mounted onto a computercraft using IComputerAccess.mount().
* Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount() or ComputerCraftAPI.createResourceMount(), or you're free to implement it yourselves!
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mount(String, IMount)
* @see IWritableMount
*/
public interface IMount
{
/**
* Returns whether a file with a given path exists or not.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return true if the file exists, false otherwise
*/
public boolean exists( String path ) throws IOException;
/**
* Returns whether a file with a given path is a directory or not.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
* @return true if the file exists and is a directory, false otherwise
*/
public boolean isDirectory( String path ) throws IOException;
/**
* Returns the file names of all the files in a directory.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
* @param contents A list of strings. Add all the file names to this list
*/
public void list( String path, List<String> contents ) throws IOException;
/**
* Returns the size of a file with a given path, in bytes
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return the size of the file, in bytes
*/
public long getSize( String path ) throws IOException;
/**
* Opens a file with a given path, and returns an inputstream representing it's contents.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return a stream representing the contents of the file
*/
public InputStream openForRead( String path ) throws IOException;
}

View file

@ -0,0 +1,52 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.filesystem;
import java.io.IOException;
import java.io.OutputStream;
/**
* Represents a part of a virtual filesystem that can be mounted onto a computercraft using IComputerAccess.mount() or IComputerAccess.mountWritable(), that can also be written to.
* Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount(), or you're free to implement it yourselves!
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, dan200.computercraft.api.filesystem.IMount)
* @see dan200.computercraft.api.filesystem.IMount
*/
public interface IWritableMount extends IMount
{
/**
* Creates a directory at a given path inside the virtual file system.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
*/
public void makeDirectory( String path ) throws IOException;
/**
* Deletes a directory at a given path inside the virtual file system.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
*/
public void delete( String path ) throws IOException;
/**
* Opens a file with a given path, and returns an outputstream for writing to it.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return a stream for writing to
*/
public OutputStream openForWrite( String path ) throws IOException;
/**
* Opens a file with a given path, and returns an outputstream for appending to it.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return a stream for writing to
*/
public OutputStream openForAppend( String path ) throws IOException;
/**
* Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
* @return The ammount of free space, in bytes.
*/
public long getRemainingSpace() throws IOException;
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|FileSystem", apiVersion="1.75" )
package dan200.computercraft.api.filesystem;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,58 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An interface passed to peripherals and ILuaObjects' by computers or turtles, providing methods
* that allow the peripheral call to wait for events before returning, just like in lua.
* This is very useful if you need to signal work to be performed on the main thread, and don't want to return
* until the work has been completed.
*/
public interface ILuaContext
{
/**
* Wait for an event to occur on the computercraft, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
* @param filter A specific event to wait for, or null to wait for any event
* @return An object array containing the name of the event that occurred, and any event parameters
* @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
* Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
* @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
*/
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
/**
* The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
* @param filter A specific event to wait for, or null to wait for any event
* @return An object array containing the name of the event that occurred, and any event parameters
* @throws InterruptedException If the user shuts down or reboots the computercraft while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
* @see #pullEvent(String)
*/
public Object[] pullEventRaw( String filter ) throws InterruptedException;
/**
* Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
* @param arguments An object array containing the arguments to pass to coroutine.yield()
* @return An object array containing the return values from coroutine.yield()
* @throws InterruptedException If the user shuts down or reboots the computercraft the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
* @see #pullEvent(String)
*/
public Object[] yield( Object[] arguments ) throws InterruptedException;
/**
* TODO: Document me
* @param task
* @return
*/
public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
/**
* TODO: Document me
* @param task
* @return
*/
public long issueMainThreadTask( ILuaTask task ) throws LuaException;
}

View file

@ -0,0 +1,26 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An interface for representing custom objects returned by IPeripheral.callMethod() calls.
* Return objects implementing this interface to expose objects with methods to lua.
*/
public interface ILuaObject
{
/**
* Get the names of the methods that this object implements. This works the same as IPeripheral.getMethodNames(). See that method for detailed documentation.
* @see dan200.computercraft.api.peripheral.IPeripheral#getMethodNames()
*/
public String[] getMethodNames();
/**
* Called when a user calls one of the methods that this object implements. This works the same as IPeripheral.callMethod(). See that method for detailed documentation.
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod(dan200.computercraft.api.peripheral.IComputerAccess, ILuaContext, int, Object[])
*/
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
}

View file

@ -0,0 +1,12 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
public interface ILuaTask
{
public Object[] execute() throws LuaException;
}

View file

@ -0,0 +1,36 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An exception representing an error in Lua, like that raised by the error() function
*/
public class LuaException extends Exception
{
private final int m_level;
public LuaException()
{
this( "error", 1 );
}
public LuaException( String message )
{
this( message, 1 );
}
public LuaException( String message, int level )
{
super( message );
m_level = level;
}
public int getLevel()
{
return m_level;
}
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Lua", apiVersion="1.75" )
package dan200.computercraft.api.lua;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,59 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.media;
import dan200.computercraft.api.filesystem.IMount;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* Represents an item that can be placed in a disk drive and used by a Computer.
* Implement this interface on your Item class to allow it to be used in the drive.
*/
public interface IMedia
{
/**
* Get a string representing the label of this item. Will be called vi disk.getLabel() in lua.
* @param stack The itemstack to inspect
* @return The label. ie: "Dan's Programs"
*/
public String getLabel( ItemStack stack );
/**
* Set a string representing the label of this item. Will be called vi disk.setLabel() in lua.
* @param stack The itemstack to modify.
* @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified.
*/
public boolean setLabel( ItemStack stack, String label );
/**
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: "Jonathon Coulton - Still Alive"
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioTitle( ItemStack stack );
/**
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioRecordName( ItemStack stack );
/**
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will be mounted onto the filesystem of the computercraft while the media is in the disk drive.
* @param stack The itemstack to inspect.
* @param world The world in which the item and disk drive reside.
* @return The mount, or null if this item does not represent an item with data. If the IMount returned also implements IWritableMount, it will mounted using mountWritable()
* @see dan200.computercraft.api.filesystem.IMount
* @see dan200.computercraft.api.filesystem.IWritableMount
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
*/
public IMount createDataMount( ItemStack stack, World world );
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.media;
import net.minecraft.item.ItemStack;
/**
* This interface is used to provide IMedia implementations for ItemStack
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
*/
public interface IMediaProvider
{
/**
* Produce an IMedia implementation from an ItemStack.
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
* @return an IMedia implementation, or null if the item is not something you wish to handle
*/
public IMedia getMedia( ItemStack stack );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Media", apiVersion="1.75" )
package dan200.computercraft.api.media;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API", apiVersion="1.75" )
package dan200.computercraft.api;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,102 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount;
/**
* The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact
* with computers except via this interface.
*/
public interface IComputerAccess
{
/**
* Mount a mount onto the computers' file system in a read only mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see #unmount(String)
* @see dan200.computercraft.api.filesystem.IMount
*/
public String mount( String desiredLocation, IMount mount );
/**
* TODO: Document me
*/
public String mount( String desiredLocation, IMount mount, String driveName );
/**
* Mount a mount onto the computers' file system in a writable mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mount(String, IMount)
* @see #unmount(String)
* @see IMount
*/
public String mountWritable( String desiredLocation, IWritableMount mount );
/**
* TODO: Document me
*/
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName );
/**
* Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().<br>
* When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to
* access it. All directories mounted by a mount or mountWritable are automatically unmounted when the peripheral
* is attached if they have not been explicitly unmounted.
* @param location The desired location in the computers file system of the directory to unmount.
* This must be the location of a directory previously mounted by mount() or mountWritable(), as
* indicated by their return value.
* @see #mount(String, IMount)
* @see #mountWritable(String, IWritableMount)
*/
public void unmount( String location );
/**
* Returns the numerical ID of this computercraft.<br>
* This is the same number obtained by calling os.getComputerID() or running the "id" program from lua,
* and is guarunteed unique. This number will be positive.
* @return The identifier.
*/
public int getID();
/**
* Causes an event to be raised on this computercraft, which the computercraft can respond to by calling
* os.pullEvent(). This can be used to notify the computercraft when things happen in the world or to
* this peripheral.
* @param event A string identifying the type of event that has occurred, this will be
* returned as the first value from os.pullEvent(). It is recommended that you
* you choose a name that is unique, and recognisable as originating from your
* peripheral. eg: If your peripheral type is "button", a suitable event would be
* "button_pressed".
* @param arguments In addition to a name, you may pass an array of extra arguments to the event, that will
* be supplied as extra return values to os.pullEvent(). Objects in the array will be converted
* to lua data types in the same fashion as the return values of IPeripheral.callMethod().<br>
* You may supply null to indicate that no arguments are to be supplied.
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod
*/
public void queueEvent( String event, Object[] arguments );
/**
* Get a string, unique to the computercraft, by which the computercraft refers to this peripheral.
* For directly attached peripherals this will be "left","right","front","back",etc, but
* for peripherals attached remotely it will be different. It is good practice to supply
* this string when raising events to the computercraft, so that the computercraft knows from
* which peripheral the event came.
* @return A string unique to the computercraft, but not globally.
*/
public String getAttachmentName();
}

View file

@ -0,0 +1,100 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
/**
* The interface that defines a peripheral. This should be implemented by the
* TileEntity of any common that you wish to be interacted with by
* computercraft or turtle.
*/
public interface IPeripheral
{
/**
* Should return a string that uniquely identifies this type of peripheral.
* This can be queried from lua by calling peripheral.getType()
* @return A string identifying the type of peripheral.
*/
public String getType();
/**
* Should return an array of strings that identify the methods that this
* peripheral exposes to Lua. This will be called once before each attachment,
* and should not change when called multiple times.
* @return An array of strings representing method names.
* @see #callMethod
*/
public String[] getMethodNames();
/**
* This is called when a lua program on an attached computercraft calls peripheral.call() with
* one of the methods exposed by getMethodNames().<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param context The context of the currently running lua thread. This can be used to wait for events
* or otherwise yield.
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
* wishes to call. The integer indicates the index into the getMethodNames() table
* that corresponds to the string passed into peripheral.call()
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
* Lua values of type "string" will be represented by Object type String.<br>
* Lua values of type "number" will be represented by Object type Double.<br>
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
* Lua values of any other type will be represented by a null object.<br>
* This array will be empty if no arguments are passed.
* @return An array of objects, representing values you wish to return to the lua program.<br>
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
* All other types will be converted to nil.<br>
* You may return null to indicate no values should be returned.
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
* same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method.
* @see #getMethodNames
*/
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
/**
* Is called when canAttachToSide has returned true, and a computercraft is attaching to the peripheral.
* This will occur when a peripheral is placed next to an active computercraft, when a computercraft is turned on next to a peripheral,
* or when a turtle travels into a square next to a peripheral.
* Between calls to attach() and detach(), the attached computercraft can make method calls on the peripheral using peripheral.call().
* This method can be used to keep track of which computers are attached to the peripheral, or to take action when attachment
* occurs.<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is being attached. Remember that multiple
* computers can be attached to a peripheral at once.
* @see #detach
*/
public void attach( IComputerAccess computer );
/**
* Is called when a computercraft is detaching from the peripheral.
* This will occur when a computercraft shuts down, when the peripheral is removed while attached to computers,
* or when a turtle moves away from a square attached to a peripheral.
* This method can be used to keep track of which computers are attached to the peripheral, or to take action when detachment
* occurs.<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is being detached. Remember that multiple
* computers can be attached to a peripheral at once.
* @see #detach
*/
public void detach( IComputerAccess computer );
/**
* TODO: Document me
*/
public boolean equals( IPeripheral other );
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
import net.minecraft.world.World;
/**
* This interface is used to create peripheral implementations for blocks
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
*/
public interface IPeripheralProvider
{
/**
* Produce an peripheral implementation from a block location.
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
* @return a peripheral, or null if there is not a peripheral here you'd like to handle.
*/
public IPeripheral getPeripheral( World world, int x, int y, int z, int side );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Peripheral", apiVersion="1.75" )
package dan200.computercraft.api.peripheral;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,19 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.permissions;
import net.minecraft.world.World;
/**
* This interface is used to restrict where turtles can move or build
* @see dan200.computercraft.api.ComputerCraftAPI#registerPermissionProvider(ITurtlePermissionProvider)
*/
public interface ITurtlePermissionProvider
{
public boolean isBlockEnterable( World world, int x, int y, int z );
public boolean isBlockEditable( World world, int x, int y, int z );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Permissions", apiVersion="1.75" )
package dan200.computercraft.api.permissions;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.redstone;
import net.minecraft.world.World;
/**
* This interface is used to provide bundled redstone output for blocks
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
*/
public interface IBundledRedstoneProvider
{
/**
* Produce an bundled redstone output from a block location.
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
* @return a number in the range 0-65535 to indicate this block is providing output, or -1 if you do not wish to handle this block
*/
public int getBundledRedstoneOutput( World world, int x, int y, int z, int side );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Redstone", apiVersion="1.75" )
package dan200.computercraft.api.redstone;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,168 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
/**
* The interface passed to turtle by turtles, providing methods that they can call.
* This should not be implemented by your classes. Do not interact with turtles except via this interface and ITurtleUpgrade.
*/
public interface ITurtleAccess
{
/**
* Returns the world in which the turtle resides.
* @return the world in which the turtle resides.
*/
public World getWorld();
/**
* Returns a vector containing the integer co-ordinates at which the turtle resides.
* @return a vector containing the integer co-ordinates at which the turtle resides.
*/
public ChunkCoordinates getPosition();
/**
* TODO: Document me
*/
public boolean teleportTo( World world, int x, int y, int z );
/**
* Returns a vector containing the floating point co-ordinates at which the turtle is rendered.
* This will shift when the turtle is moving.
* @param f The subframe fraction
* @return a vector containing the floating point co-ordinates at which the turtle resides.
*/
public Vec3 getVisualPosition( float f );
/**
* TODO: Document me
*/
public float getVisualYaw( float f );
/**
* Returns the world direction the turtle is currently facing.
* @return the world direction the turtle is currently facing.
*/
public int getDirection();
/**
* TODO: Document me
*/
public void setDirection( int dir );
/**
* TODO: Document me
*/
public int getSelectedSlot();
/**
* TODO: Document me
*/
public void setSelectedSlot( int slot );
/**
* Sets the colour of the turtle, as if the player had dyed it with a dye item.
* @param dyeColour 0-15 to dye the turtle one of the 16 standard minecraft colours, or -1 to remove the dye from the turtle.
*/
public void setDyeColour( int dyeColour );
/**
* Gets the colour the turtle has been dyed.
* @return 0-15 if the turtle has been dyed one of the 16 standard minecraft colours, -1 if the turtle is clean.
*/
public int getDyeColour();
/**
* TODO: Document me
*/
public IInventory getInventory();
/**
* TODO: Document me
*/
public boolean isFuelNeeded();
/**
* TODO: Document me
*/
public int getFuelLevel();
/**
* TODO: Document me
*/
public void setFuelLevel( int fuel );
/**
* TODO: Document me
*/
public int getFuelLimit();
/**
* Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle.
* @return Whether the turtle was able to consume the ammount of fuel specified. Will return false if you supply a number
* greater than the current fuel level of the turtle.
*/
public boolean consumeFuel( int fuel );
/**
* TODO: Document me
*/
public void addFuel( int fuel );
/**
* Adds a custom command to the turtles command queue. Unlike peripheral methods, these custom commands will be executed
* on the main thread, so are guaranteed to be able to access Minecraft objects safely, and will be queued up
* with the turtles standard movement and tool commands. An issued command will return an unique integer, which will
* be supplied as a parameter to a "turtle_response" event issued to the turtle after the command has completed. Look at the
* lua source code for "rom/apis/turtle" for how to build a lua wrapper around this functionality.
* @param command an object which will execute the custom command when its point in the queue is reached
* @return the objects the command returned when executed. you should probably return these to the player
* unchanged if called from a peripheral method.
* @see ITurtleCommand
*/
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws LuaException, InterruptedException;
/**
* TODO: Document me
*/
public void playAnimation( TurtleAnimation animation );
/**
* Returns the turtle on the specified side of the turtle, if there is one.
* @return the turtle on the specified side of the turtle, if there is one.
*/
public ITurtleUpgrade getUpgrade( TurtleSide side );
/**
* TODO: Document me
*/
public void setUpgrade( TurtleSide side, ITurtleUpgrade upgrade );
/**
* Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
* @return the peripheral created by the upgrade on the specified side of the turtle, if there is one.
*/
public IPeripheral getPeripheral( TurtleSide side );
/**
* TODO: Document me
*/
public NBTTagCompound getUpgradeNBTData( TurtleSide side );
/**
* TODO: Document me
*/
public void updateUpgradeNBTData( TurtleSide side );
}

View file

@ -0,0 +1,25 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An interface for objects executing custom turtle commands, used with ITurtleAccess.issueCommand
* @see ITurtleAccess#executeCommand(dan200.computercraft.api.lua.ILuaContext,ITurtleCommand)
*/
public interface ITurtleCommand
{
/**
* Will be called by the turtle on the main thread when it is time to execute the custom command.
* The handler should either perform the work of the command, and return success, or return
* failure with an error message to indicate the command cannot be executed at this time.
* @param turtle access to the turtle for whom the command was issued
* @return TurtleCommandResult.success() or TurtleCommandResult.failure( errorMessage )
* @see ITurtleAccess#executeCommand(dan200.computercraft.api.lua.ILuaContext,ITurtleCommand)
* @see dan200.computercraft.api.turtle.TurtleCommandResult
*/
public TurtleCommandResult execute( ITurtleAccess turtle );
}

View file

@ -0,0 +1,94 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
/**
* The primary interface for defining an turtle for Turtles. A turtle turtle
* can either be a new tool, or a new peripheral.
* @see dan200.computercraft.api.ComputerCraftAPI#registerTurtleUpgrade( dan200.computercraft.api.turtle.ITurtleUpgrade )
*/
public interface ITurtleUpgrade
{
/**
* Gets a unique numerical identifier representing this type of turtle turtle.
* Like Minecraft common and item IDs, you should strive to make this number unique
* among all turtle turtle that have been released for ComputerCraft.
* The ID must be in the range 64 to 255, as the ID is stored as an 8-bit value,
* and 0-64 is reserved for future use by ComputerCraft. The turtle will
* fail registration if an already used ID is specified.
* @see dan200.computercraft.api.ComputerCraftAPI#registerTurtleUpgrade( dan200.computercraft.api.turtle.ITurtleUpgrade )
*/
public int getUpgradeID();
/**
* Return a String to describe this type of turtle in turtle item names.
* Examples of built-in adjectives are "Wireless", "Mining" and "Crafty".
*/
public String getUnlocalisedAdjective();
/**
* Return whether this turtle adds a tool or a peripheral to the turtle.
* Currently, turtle crafting is restricted to one tool & one peripheral per turtle.
* @see TurtleUpgradeType for the differences between the two.
*/
public TurtleUpgradeType getType();
/**
* Return an item stack representing the type of item that a turtle must be crafted
* with to create a turtle which holds this turtle.
* Currently, turtle crafting is restricted to one tool & one peripheral per turtle.
*/
public ItemStack getCraftingItem();
/**
* Will only be called for Peripheral turtle. Creates a peripheral for a turtle
* being placed using this turtle. The peripheral created will be stored
* for the lifetime of the turtle, will have update() called once-per-tick, and will be
* attach'd detach'd and have methods called in the same manner as a Computer peripheral.
*
* @param turtle Access to the turtle that the peripheral is being created for.
* @param side Which side of the turtle (left or right) that the turtle resides on.
* @return The newly created peripheral. You may return null if this turtle is a Tool
* and this method is not expected to be called.
*/
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side );
/**
* Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
* by the turtle, and the tool is required to do some work.
* @param turtle Access to the turtle that the tool resides on.
* @param side Which side of the turtle (left or right) the tool resides on.
* @param verb Which action (dig or attack) the turtle is being called on to perform.
* @param direction Which world direction the action should be performed in, relative to the turtles
* position. This will either be up, down, or the direction the turtle is facing, depending on
* whether dig, digUp or digDown was called.
* @return Whether the turtle was able to perform the action, and hence whether the turtle.dig()
* or turtle.attack() lua method should return true. If true is returned, the tool will perform
* a swinging animation. You may return null if this turtle is a Peripheral
* and this method is not expected to be called.
*/
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction );
/**
* Called to obtain the IIcon to be used when rendering a turtle peripheral. Needs to be a "common"
* type IIcon for now, as there is no way to determine which texture sheet an IIcon is from by the
* IIcon itself.
* @param turtle Access to the turtle that the peripheral resides on.
* @param side Which side of the turtle (left or right) the peripheral resides on.
* @return The IIcon that you wish to be used to render your turtle peripheral.
*/
public IIcon getIcon( ITurtleAccess turtle, TurtleSide side );
/**
* TODO: Document me
*/
public void update( ITurtleAccess turtle, TurtleSide side );
}

View file

@ -0,0 +1,22 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
public enum TurtleAnimation
{
None,
MoveForward,
MoveBack,
MoveUp,
MoveDown,
TurnLeft,
TurnRight,
SwingLeftTool,
SwingRightTool,
Wait,
ShortWait,
}

View file

@ -0,0 +1,73 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
public final class TurtleCommandResult
{
private static final TurtleCommandResult s_success = new TurtleCommandResult( true, null, null );
private static final TurtleCommandResult s_emptyFailure = new TurtleCommandResult( false, null, null );
public static TurtleCommandResult success()
{
return success( null );
}
public static TurtleCommandResult success( Object[] results )
{
if( results == null || results.length == 0 )
{
return s_success;
}
else
{
return new TurtleCommandResult( true, null, results );
}
}
public static TurtleCommandResult failure()
{
return failure( null );
}
public static TurtleCommandResult failure( String errorMessage )
{
if( errorMessage == null )
{
return s_emptyFailure;
}
else
{
return new TurtleCommandResult( false, errorMessage, null );
}
}
private final boolean m_success;
private final String m_errorMessage;
private final Object[] m_results;
private TurtleCommandResult( boolean success, String errorMessage, Object[] results )
{
m_success = success;
m_errorMessage = errorMessage;
m_results = results;
}
public boolean isSuccess()
{
return m_success;
}
public String getErrorMessage()
{
return m_errorMessage;
}
public Object[] getResults()
{
return m_results;
}
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An enum representing the two sides of the turtle that a turtle turtle might reside.
*/
public enum TurtleSide
{
/**
* The turtles left side (where the pickaxe usually is on a Wireless Mining Turtle)
*/
Left,
/**
* The turtles right side (where the modem usually is on a Wireless Mining Turtle)
*/
Right,
}

View file

@ -0,0 +1,27 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An enum representing the two different types of turtle that an ITurtleUpgrade
* implementation can add to a turtle.
* @see ITurtleUpgrade
*/
public enum TurtleUpgradeType
{
/**
* A tool is rendered as an item on the side of the turtle, and responds to the turtle.dig()
* and turtle.attack() methods (Such as pickaxe or sword on Mining and Melee turtles).
*/
Tool,
/**
* A peripheral adds a special peripheral which is attached to the side of the turtle,
* and can be interacted with the peripheral API (Such as the modem on Wireless Turtles).
*/
Peripheral,
}

View file

@ -0,0 +1,26 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An enum representing the two different actions that an ITurtleUpgrade of type
* Tool may be called on to perform by a turtle.
* @see ITurtleUpgrade
* @see ITurtleUpgrade#useTool
*/
public enum TurtleVerb
{
/**
* The turtle called turtle.dig(), turtle.digUp() or turtle.digDown()
*/
Dig,
/**
* The turtle called turtle.attack(), turtle.attackUp() or turtle.attackDown()
*/
Attack,
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Turtle", apiVersion="1.75" )
package dan200.computercraft.api.turtle;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,10 @@
package icbm.api;
import net.minecraft.item.ItemStack;
public interface IAmmunition {
boolean hasAmmunition(ItemStack var1);
boolean useAmmunition(ItemStack var1);
}

View file

@ -0,0 +1,9 @@
package icbm.api;
public interface IBlockFrequency {
int getFrequency();
void setFrequency(int var1);
}

View file

@ -0,0 +1,41 @@
package icbm.api;
import icbm.api.explosion.IExplosive;
import java.lang.reflect.Method;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
public class ICBM {
public static final String NAME = "ICBM";
public static final String VERSION = "1.1.1";
public static final int BLOCK_ID_PREFIX = 3880;
public static final int ITEM_ID_PREFIX = 3900;
public static Class explosionManager;
public static void createExplosion(World worldObj, double x, double y, double z, Entity entity, int explosiveID) {
try {
Method e = explosionManager.getMethod("createExplosion", new Class[]{World.class, Double.class, Double.class, Double.class, Entity.class, Integer.class});
e.invoke((Object)null, new Object[]{worldObj, Double.valueOf(x), Double.valueOf(y), Double.valueOf(z), entity, Integer.valueOf(explosiveID)});
} catch (Exception var10) {
System.out.println("ICBM: Failed to create an ICBM explosion with the ID: " + explosiveID);
var10.printStackTrace();
}
}
public static IExplosive getExplosive(String name) {
if(name != null) {
try {
Method e = explosionManager.getMethod("getExplosiveByName", new Class[]{String.class});
return (IExplosive)e.invoke((Object)null, new Object[]{name});
} catch (Exception var2) {
System.out.println("ICBM: Failed to get explosive with the name: " + name);
var2.printStackTrace();
}
}
return null;
}
}

View file

@ -0,0 +1,11 @@
package icbm.api;
import universalelectricity.prefab.flag.FlagRegistry;
public class ICBMFlags {
public static final String FLAG_BAN_GLOBAL = FlagRegistry.registerFlag("ban_icbm");
public static final String FLAG_BAN_EXPLOSIVE = FlagRegistry.registerFlag("ban_explosive");
public static final String FLAG_BAN_GRENADE = FlagRegistry.registerFlag("ban_grenade");
public static final String FLAG_BAN_MISSILE = FlagRegistry.registerFlag("ban_missile");
public static final String FLAG_BAN_MINECART = FlagRegistry.registerFlag("ban_minecart");
}

View file

@ -0,0 +1,5 @@
package icbm.api;
public interface ICamouflageMaterial {
}

View file

@ -0,0 +1,10 @@
package icbm.api;
import net.minecraft.entity.player.EntityPlayer;
public interface IHackable {
void generateNewKey();
boolean tryForAccess(EntityPlayer var1, String var2);
}

View file

@ -0,0 +1,10 @@
package icbm.api;
import net.minecraft.item.ItemStack;
public interface IItemFrequency {
int getFrequency(ItemStack var1);
void setFrequency(int var1, ItemStack var2);
}

View file

@ -0,0 +1,13 @@
package icbm.api;
import icbm.api.ILauncherController;
import icbm.api.IMissile;
public interface ILauncherContainer {
IMissile getContainingMissile();
void setContainingMissile(IMissile var1);
ILauncherController getController();
}

View file

@ -0,0 +1,28 @@
package icbm.api;
import icbm.api.IBlockFrequency;
import icbm.api.IMissile;
import icbm.api.LauncherType;
import net.minecraft.item.ItemStack;
import universalelectricity.core.block.IElectricityStorage;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor;
public interface ILauncherController extends IElectricityStorage, IRedstoneReceptor, IBlockFrequency {
LauncherType getLauncherType();
void launch();
boolean canLaunch();
String getStatus();
Vector3 getTarget();
void setTarget(Vector3 var1);
void placeMissile(ItemStack var1);
IMissile getMissile();
}

View file

@ -0,0 +1,26 @@
package icbm.api;
import icbm.api.ILauncherContainer;
import icbm.api.explosion.IExplosiveContainer;
import universalelectricity.core.vector.Vector3;
public interface IMissile extends IExplosiveContainer {
void explode();
void setExplode();
void normalExplode();
void setNormalExplode();
void dropMissileAsItem();
int getTicksInAir();
ILauncherContainer getLauncher();
void launch(Vector3 var1);
void launch(Vector3 var1, int var2);
}

View file

@ -0,0 +1,11 @@
package icbm.api;
import icbm.api.IMissile;
import universalelectricity.core.vector.Vector3;
public interface IMissileLockable {
boolean canLock(IMissile var1);
Vector3 getPredictedPosition(int var1);
}

View file

@ -0,0 +1,11 @@
package icbm.api;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface ITracker {
void setTrackingEntity(final ItemStack p0, final Entity p1);
Entity getTrackingEntity(final World p0, final ItemStack p1);
}

View file

@ -0,0 +1,14 @@
package icbm.api;
public enum LauncherType {
TRADITIONAL("TRADITIONAL", 0),
CRUISE("CRUISE", 1);
// $FF: synthetic field
private static final LauncherType[] $VALUES = new LauncherType[]{TRADITIONAL, CRUISE};
private LauncherType(String var1, int var2) {}
}

View file

@ -0,0 +1,110 @@
package icbm.api;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.vector.Region2;
public class RadarRegistry {
private static Set<TileEntity> detectableTileEntities = new HashSet<>();
private static Set<Entity> detectableEntities = new HashSet<>();
public static void register(TileEntity tileEntity) {
if (!detectableTileEntities.contains(tileEntity)) {
detectableTileEntities.add(tileEntity);
}
}
public static void unregister(TileEntity tileEntity) {
if (detectableTileEntities.contains(tileEntity)) {
detectableTileEntities.remove(tileEntity);
}
}
public static void register(Entity entity) {
if (!detectableEntities.contains(entity)) {
detectableEntities.add(entity);
}
}
public static void unregister(Entity entity) {
if (detectableEntities.contains(entity)) {
detectableEntities.remove(entity);
}
}
public static List<TileEntity> getTileEntitiesInArea(Vector2 minVector,
Vector2 maxVector) {
ArrayList<TileEntity> returnArray = new ArrayList<>();
cleanUpArray();
for (TileEntity tileEntity : detectableTileEntities) {
if ((new Region2(minVector, maxVector))
.isIn((new Vector3(tileEntity)).toVector2())) {
returnArray.add(tileEntity);
}
}
return returnArray;
}
public static List<Entity> getEntitiesWithinRadius(Vector2 vector,
int radius) {
cleanUpArray();
ArrayList<Entity> returnArray = new ArrayList<>();
for (Entity entity : detectableEntities) {
if (Vector2.distance(vector, (new Vector3(entity)).toVector2()) <=
(double)radius) {
returnArray.add(entity);
}
}
return returnArray;
}
public static Set<TileEntity> getTileEntities() {
cleanUpArray();
return detectableTileEntities;
}
public static Set<Entity> getEntities() {
cleanUpArray();
return detectableEntities;
}
public static void cleanUpArray() {
try {
Iterator<TileEntity> e = detectableTileEntities.iterator();
while (e.hasNext()) {
TileEntity it2 = e.next();
if (it2 == null) {
e.remove();
} else if (it2.isInvalid()) {
e.remove();
} else if (it2.getWorldObj().getTileEntity(it2.xCoord, it2.yCoord,
it2.zCoord) != it2) {
e.remove();
}
}
Iterator<Entity> it21 = detectableEntities.iterator();
while (it21.hasNext()) {
Entity entity = (Entity)it21.next();
if (entity == null) {
it21.remove();
} else if (entity.isDead) {
it21.remove();
}
}
} catch (Exception var3) {
System.out.println("Failed to clean up radar list properly.");
var3.printStackTrace();
}
}
}

View file

@ -0,0 +1,36 @@
package icbm.api.explosion;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.world.World;
public class ExplosionEvent extends Event {
public final World world;
public final double x;
public final double y;
public final double z;
public IExplosive explosive;
public ExplosionEvent(World world, double x, double y, double z, IExplosive explosive) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.explosive = explosive;
}
public static class PostExplosionEvent extends ExplosionEvent {
public PostExplosionEvent(World world, double x, double y, double z, IExplosive explosive) {
super(world, x, y, z, explosive);
}
}
public static class PreExplosionEvent extends ExplosionEvent {
public PreExplosionEvent(World world, double x, double y, double z, IExplosive explosive) {
super(world, x, y, z, explosive);
}
}
}

View file

@ -0,0 +1,10 @@
package icbm.api.explosion;
import icbm.api.explosion.IExplosive;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public interface IEMPBlock {
void onEMP(World var1, Vector3 var2, IExplosive var3);
}

View file

@ -0,0 +1,11 @@
package icbm.api.explosion;
import icbm.api.explosion.IExplosive;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import universalelectricity.core.item.IItemElectric;
public interface IEMPItem extends IItemElectric {
void onEMP(ItemStack var1, Entity var2, IExplosive var3);
}

View file

@ -0,0 +1,23 @@
package icbm.api.explosion;
public interface IExplosive {
int getID();
String getUnlocalizedName();
String getExplosiveName();
String getGrenadeName();
String getMissileName();
String getMinecartName();
float getRadius();
int getTier();
double getEnergy();
}

View file

@ -0,0 +1,8 @@
package icbm.api.explosion;
import icbm.api.explosion.IExplosive;
public interface IExplosiveContainer {
IExplosive getExplosiveType();
}

View file

@ -0,0 +1,8 @@
package icbm.api.explosion;
import icbm.api.explosion.ExplosionEvent;
public interface IExplosiveIgnore {
boolean canIgnore(ExplosionEvent var1);
}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package icbm.api.sentry;
public interface IAATarget {
void destroyCraft();
int doDamage(final int p0);
boolean canBeTargeted(final Object p0);
}

View file

@ -0,0 +1,38 @@
package icbm.core;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class BSulfurOre extends Block {
public BSulfurOre() {
super(Material.rock);
this.setBlockName("icbm:oreSulfur");
this.setHardness(3.0f);
this.setCreativeTab((CreativeTabs) ICBMTab.INSTANCE);
}
@Override
public void registerBlockIcons(IIconRegister p_149651_1_) {
this.blockIcon = p_149651_1_.registerIcon("icbm:oreSulfur");
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_,
int p_149650_3_) {
return MainBase.itSulfur;
}
@Override
public int quantityDropped(final Random par1Random) {
return 3 + par1Random.nextInt(3);
}
@Override
public int quantityDroppedWithBonus(final int par1, final Random par2Random) {
return this.quantityDropped(par2Random) + par2Random.nextInt(par1 + 1);
}
}

View file

@ -0,0 +1,97 @@
package icbm.core;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.ore.OreGenReplace;
public class GenSulfur extends OreGenReplace {
public GenSulfur(final String name, final String oreDiectionaryName,
final ItemStack stack, final Block replaceID,
final int minGenerateLevel, final int maxGenerateLevel,
final int amountPerChunk, final int amountPerBranch,
final String harvestTool, final int harvestLevel) {
super(name, oreDiectionaryName, stack, replaceID, minGenerateLevel,
maxGenerateLevel, amountPerChunk, amountPerBranch, harvestTool,
harvestLevel);
}
public GenSulfur(final String name, final String oreDiectionaryName,
final ItemStack stack, final Block replaceID,
final int maxGenerateLevel, final int amountPerChunk,
final int amountPerBranch) {
this(name, oreDiectionaryName, stack, replaceID, 0, maxGenerateLevel,
amountPerChunk, amountPerBranch, "pickaxe", 1);
}
@Override
public void generate(final World world, final Random random, final int varX,
final int varZ) {
for (int y = super.minGenerateLevel; y < super.maxGenerateLevel; ++y) {
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
this.generateReplace(world, random, varX + x, y, varZ + z);
}
}
}
}
@Override
public boolean generateReplace(final World world, final Random rand,
final int x, final int y, final int z) {
if (this.nearLava(world, x, y, z)) {
this.placeOre(world, rand, x, y, z);
return true;
}
return false;
}
private void placeOre(final World world, final Random rand, final int x,
final int y, final int z) {
final Vector3 position = new Vector3(x, y, z);
for (int amount = 0; amount < super.amountPerBranch; ++amount) {
final Block block = world.getBlock(x, y, z);
//TODO: WTF
if (block != null /*&&
block.isGenMineableReplaceable(world, x, y, z,
Blocks.stone)*/) {
world.setBlock(x, y, z, super.oreID, super.oreMeta, 2);
}
final ForgeDirection dir = ForgeDirection.values()[rand.nextInt(6)];
position.modifyPositionFromSide(dir);
}
}
private boolean nearLava(final World world, final int x, final int y,
final int z) {
for (int side = 2; side < 6; ++side) {
final Vector3 position = new Vector3(x, y, z);
final ForgeDirection s = ForgeDirection.values()[side];
position.modifyPositionFromSide(s);
if (world.blockExists(position.intX(), position.intY(),
position.intZ())) {
final Block id = world.getBlock(position.intX(), position.intY(),
position.intZ());
if (id == Blocks.lava ||
id == Blocks.flowing_lava) {
return true;
}
}
}
for (int j = 0; j < 4; ++j) {
final Block id2 = world.getBlock(x, y - j, z);
if (id2 == Blocks.lava ||
id2 == Blocks.flowing_lava) {
return true;
}
if (id2 != Blocks.air) {
return false;
}
}
return false;
}
}

View file

@ -0,0 +1,26 @@
package icbm.core;
import java.util.HashMap;
public class HaoMa
{
private static final HashMap<String, Integer> IDS;
public static int getID(final String name, final int defaultID) {
int id = defaultID;
if (HaoMa.IDS.containsKey(name)) {
id = HaoMa.IDS.get(name);
++id;
}
HaoMa.IDS.put(name, id);
return id;
}
public static int getID(final String name) {
return getID(name, 0);
}
static {
IDS = new HashMap<>();
}
}

View file

@ -0,0 +1,31 @@
package icbm.core;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ICBMTab extends CreativeTabs {
public static final ICBMTab INSTANCE;
public static ItemStack itemStack;
public ICBMTab() { super(CreativeTabs.getNextID(), "ICBM"); }
@Override
public Item getTabIconItem() {
if (ICBMTab.itemStack == null) {
return Item.getItemFromBlock(Blocks.tnt);
}
return ICBMTab.itemStack.getItem();
}
public ItemStack getIconItemStack() {
if (ICBMTab.itemStack == null) {
ICBMTab.itemStack = new ItemStack(Blocks.tnt);
}
return ICBMTab.itemStack;
}
static { INSTANCE = new ICBMTab(); }
}

View file

@ -0,0 +1,182 @@
package icbm.core;
import atomicscience.api.poison.PotionRadiation;
import calclavia.lib.UniversalRecipes;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import icbm.core.di.ItICBM;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.flag.CommandFlag;
import universalelectricity.prefab.flag.FlagRegistry;
import universalelectricity.prefab.flag.ModFlag;
import universalelectricity.prefab.flag.NBTFileLoader;
import universalelectricity.prefab.multiblock.BlockMulti;
import universalelectricity.prefab.multiblock.TileEntityMulti;
import universalelectricity.prefab.ore.OreGenBase;
import universalelectricity.prefab.ore.OreGenerator;
public class MainBase {
public static final MainBase INSTANCE;
public static boolean ZAI_KUAI;
public static Block bLiu;
public static BlockMulti bJia;
public static Item itSulfur;
public static Item itDu;
public static OreGenBase liuGenData;
public static final String PREFIX = "icbm:";
public static final String RESOURCE_PATH = "/mods/icbm/";
public static final String TEXTURE_PATH = "/mods/icbm/textures/";
public static final String GUI_PATH = "/mods/icbm/textures/gui/";
public static final String MODEL_PATH = "/mods/icbm/textures/models/";
public static final String SMINE_TEXTURE = "/mods/icbm/textures/models/s-mine.png";
public static final String BLOCK_PATH = "/mods/icbm/textures/blocks/";
public static final String ITEM_PATH = "/mods/icbm/textures/items/";
public static final String YU_YAN_PATH = "/mods/icbm/yuyan/";
public static int DAO_DAN_ZUI_YUAN;
public static final int GUI_XIA_FA_SHE_QI = 1;
public static final int GUI_FA_SHE_SHI_MUO = 2;
public static final int GUI_LEI_DA_TAI = 3;
public static final int GUI_YIN_GAN_QI = 4;
public static final int GUI_SHENG_BUO = 5;
public static final int GUI_DIAN_CI_QI = 6;
public static final int GUI_FA_SHE_DI = 7;
private static boolean isPreInit;
private static boolean isPostInit;
public static final Configuration CONFIGURATION;
public static final Logger LOGGER;
@Mod.EventHandler
public void preInit(final FMLPreInitializationEvent event) {
if (!MainBase.isPreInit) {
MinecraftForge.EVENT_BUS.register((Object) MainBase.INSTANCE);
MainBase.CONFIGURATION.load();
PotionRadiation.INSTANCE.getId();
MainBase.ZAI_KUAI = MainBase.CONFIGURATION.get("general", "Allow Chunk Loading", true)
.getBoolean(true);
MainBase.DAO_DAN_ZUI_YUAN = MainBase.CONFIGURATION
.get("general", "Max Missile Distance", MainBase.DAO_DAN_ZUI_YUAN)
.getInt(MainBase.DAO_DAN_ZUI_YUAN);
MainBase.bLiu = (Block) new BSulfurOre();
MainBase.bJia = new BlockMulti()
.setTextureName("icbm:machine")
.setChannel(this.getChannel());
MainBase.itDu = new ItICBM("poisonPowder");
MainBase.itSulfur = new ItICBM("sulfur");
GameRegistry.registerBlock(MainBase.bLiu, "bLiu");
GameRegistry.registerBlock((Block) MainBase.bJia, "bJia");
MainBase.liuGenData = new GenSulfur("Sulfur Ore", "oreSulfur", new ItemStack(MainBase.bLiu),
Blocks.air, 40, 20, 4)
.enable(MainBase.CONFIGURATION);
MainBase.CONFIGURATION.save();
OreDictionary.registerOre("dustSulfur", MainBase.itSulfur);
OreGenerator.addOre(MainBase.liuGenData);
GameRegistry.registerTileEntity(TileEntityMulti.class, "ICBMMulti");
MainBase.isPreInit = true;
}
}
@Mod.EventHandler
public void postInit(final FMLPostInitializationEvent event) {
if (!MainBase.isPostInit) {
UniversalRecipes.init();
GameRegistry.addSmelting(MainBase.bLiu,
new ItemStack(MainBase.itSulfur, 4), 0.8f);
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(Items.gunpowder, 3),
new Object[] { "@@@", "@?@", "@@@", '@', "dustSulfur", '?',
Items.coal }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(Items.gunpowder, 3),
new Object[] { "@@@", "@?@", "@@@", '@', "dustSulfur", '?',
new ItemStack(Items.coal, 1, 1) }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
Blocks.tnt, new Object[] { "@@@", "@R@", "@@@", '@', Items.gunpowder,
'R', Items.redstone }));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(MainBase.itDu, 3),
new Object[] { Items.spider_eye, Items.rotten_flesh }));
MainBase.isPostInit = true;
}
}
@Mod.EventHandler
public void serverStarting(final FMLServerStartingEvent event) {
FlagRegistry.registerModFlag(
"ModFlags", new ModFlag(NBTFileLoader.loadData("ModFlags")));
final ICommandManager commandManager = FMLCommonHandler.instance()
.getMinecraftServerInstance()
.getCommandManager();
final ServerCommandManager serverCommandManager = (ServerCommandManager) commandManager;
serverCommandManager.registerCommand(
(ICommand) new CommandFlag(FlagRegistry.getModFlag("ModFlags")));
}
@SubscribeEvent
public void worldSave(final WorldEvent.Save evt) {
if (!((WorldEvent) evt).world.isRemote) {
NBTFileLoader.saveData("ModFlags",
FlagRegistry.getModFlag("ModFlags").getNBT());
}
}
public static Vector3 getLook(final float rotationYaw,
final float rotationPitch) {
final float var2 = MathHelper.cos(-rotationYaw * 0.017453292f - 3.1415927f);
final float var3 = MathHelper.sin(-rotationYaw * 0.017453292f - 3.1415927f);
final float var4 = -MathHelper.cos(-rotationPitch * 0.017453292f);
final float var5 = MathHelper.sin(-rotationPitch * 0.017453292f);
return new Vector3(var3 * var4, var5, var2 * var4);
}
public static void setModMetadata(final String id,
final ModMetadata metadata) {
metadata.modId = id;
metadata.name = "ICBM";
metadata.description = "ICBM is a Minecraft Mod that introduces intercontinental ballistic missiles to Minecraft. But the fun doesn't end there! This mod also features many different explosives, missiles and machines classified in three different tiers. If strategic warfare, carefully coordinated airstrikes, messing with matter and general destruction are up your alley, then this mod is for you!";
metadata.url = "http://www.universalelectricity.com/icbm/";
metadata.logoFile = "/icbm_logo.png";
metadata.version = "1.2.1";
metadata.authorList = Arrays.asList("Calclavia");
metadata.credits = "Please visit the website.";
metadata.autogenerated = false;
}
protected String getChannel() {
return null;
}
static {
INSTANCE = new MainBase();
MainBase.DAO_DAN_ZUI_YUAN = 10000;
CONFIGURATION = new Configuration(
new File(Loader.instance().getConfigDir(), "ICBM.cfg"));
LOGGER = Logger.getLogger("ICBM");
}
}

View file

@ -0,0 +1,33 @@
package icbm.core;
public class Pair<T> {
private final T left;
private final T right;
public Pair(final T left, final T right) {
this.left = left;
this.right = right;
}
public T getKey() { return this.left; }
public T getValue() { return this.right; }
@Override
public int hashCode() {
return this.left.hashCode() ^ this.right.hashCode();
}
@Override
public boolean equals(final Object o) {
if (o == null) {
return false;
}
if (!(o instanceof Pair)) {
return false;
}
final Pair<?> pairo = (Pair<?>)o;
return this.left.equals(pairo.getKey()) &&
this.right.equals(pairo.getValue());
}
}

View file

@ -0,0 +1,75 @@
package icbm.core.di;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import icbm.core.ICBMTab;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.implement.IRedstoneProvider;
public abstract class BICBM extends BlockAdvanced {
protected IIcon iconTop;
protected IIcon iconSide;
protected IIcon iconBottom;
protected boolean requireSidedTextures;
public BICBM(final String name, final Material material) {
super(material);
this.requireSidedTextures = false;
this.setBlockName("icbm:" + name);
this.setCreativeTab((CreativeTabs)ICBMTab.INSTANCE);
}
@Override
public int damageDropped(final int metadata) {
return metadata;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
if (this.requireSidedTextures) {
this.iconTop = iconRegister.registerIcon(
this.getUnlocalizedName().replace("tile.", "") + "_top");
this.iconSide = iconRegister.registerIcon(
this.getUnlocalizedName().replace("tile.", "") + "_side");
this.iconBottom = iconRegister.registerIcon(
this.getUnlocalizedName().replace("tile.", "") + "_bottom");
}
}
@Override
public int isProvidingStrongPower(final IBlockAccess par1IBlockAccess,
final int x, final int y, final int z,
final int side) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneProvider) {
return ((IRedstoneProvider)tileEntity)
.isPoweringTo(ForgeDirection.getOrientation(side))
? 15
: 0;
}
return 0;
}
@Override
public int isProvidingWeakPower(final IBlockAccess par1IBlockAccess,
final int x, final int y, final int z,
final int side) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneProvider) {
return ((IRedstoneProvider)tileEntity)
.isIndirectlyPoweringTo(ForgeDirection.getOrientation(side))
? 15
: 0;
}
return 0;
}
}

View file

@ -0,0 +1,13 @@
package icbm.core.di;
import icbm.core.ICBMTab;
import net.minecraft.creativetab.CreativeTabs;
import universalelectricity.core.item.ItemElectric;
public abstract class ItElectricICBM extends ItemElectric {
public ItElectricICBM(final String name) {
super();
this.setUnlocalizedName("icbm:" + name);
this.setCreativeTab((CreativeTabs)ICBMTab.INSTANCE);
}
}

View file

@ -0,0 +1,13 @@
package icbm.core.di;
import icbm.core.ICBMTab;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class ItICBM extends Item {
public ItICBM(final String name) {
super();
this.setUnlocalizedName("icbm:" + name);
this.setCreativeTab((CreativeTabs)ICBMTab.INSTANCE);
}
}

View file

@ -0,0 +1,10 @@
package icbm.core.di;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
@SideOnly(Side.CLIENT)
public abstract class MICBM extends ModelBase {
public void render(final float f5) {}
}

View file

@ -0,0 +1,86 @@
//
// Decompiled by Procyon v0.6.0
//
package icbm.gangshao;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import icbm.gangshao.platform.TPlatform;
import icbm.gangshao.render.BlockRenderingHandler;
import icbm.gangshao.render.FXBeam;
import icbm.gangshao.render.RAATurret;
import icbm.gangshao.render.RESeat;
import icbm.gangshao.render.RGunTurret;
import icbm.gangshao.render.RLaserTurret;
import icbm.gangshao.render.RRailgun;
import icbm.gangshao.shimian.GuiPlatformAccess;
import icbm.gangshao.shimian.GuiPlatformSlots;
import icbm.gangshao.shimian.GuiPlatformTerminal;
import icbm.gangshao.turret.mount.ESeat;
import icbm.gangshao.turret.mount.TRailgunTurret;
import icbm.gangshao.turret.sentries.TAATurret;
import icbm.gangshao.turret.sentries.TLaserTurret;
import icbm.gangshao.turret.sentries.TMachineGunTurret;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public class ClientProxy extends CommonProxy {
@Override
public void preInit() {
super.preInit();
}
@Override
public void init() {
super.init();
ClientRegistry.bindTileEntitySpecialRenderer(
TMachineGunTurret.class, (TileEntitySpecialRenderer) new RGunTurret());
ClientRegistry.bindTileEntitySpecialRenderer(
TAATurret.class, (TileEntitySpecialRenderer) new RAATurret());
ClientRegistry.bindTileEntitySpecialRenderer(
TRailgunTurret.class, (TileEntitySpecialRenderer) new RRailgun());
ClientRegistry.bindTileEntitySpecialRenderer(
TLaserTurret.class, (TileEntitySpecialRenderer) new RLaserTurret());
RenderingRegistry.registerEntityRenderingHandler(ESeat.class,
(Render) new RESeat());
RenderingRegistry.registerBlockHandler(
(ISimpleBlockRenderingHandler) new BlockRenderingHandler());
}
@Override
public Object getClientGuiElement(final int ID, final EntityPlayer player,
final World world, final int x, final int y,
final int z) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 0: {
return new GuiPlatformSlots(player.inventory, (TPlatform) tileEntity);
}
case 1: {
return new GuiPlatformTerminal(player, (TPlatform) tileEntity);
}
case 2: {
return new GuiPlatformAccess(player, (TPlatform) tileEntity);
}
}
}
return null;
}
@Override
public void renderBeam(final World world, final Vector3 position,
final Vector3 target, final float red,
final float green, final float blue, final int age) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect(
(EntityFX) new FXBeam(world, position, target, red, green, blue, age));
}
}

View file

@ -0,0 +1,63 @@
package icbm.gangshao;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import icbm.gangshao.container.ContainerTurretPlatform;
import icbm.gangshao.platform.TPlatform;
import icbm.gangshao.turret.mount.TRailgunTurret;
import icbm.gangshao.turret.sentries.TAATurret;
import icbm.gangshao.turret.sentries.TLaserTurret;
import icbm.gangshao.turret.sentries.TMachineGunTurret;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.TileEntityMulti;
public class CommonProxy implements IGuiHandler {
public static final int GUI_PLATFORM_ID = 0;
public static final int GUI_PLATFORM_TERMINAL_ID = 1;
public static final int GUI_PLATFORM_ACCESS_ID = 2;
public void init() {
GameRegistry.registerTileEntity(TMachineGunTurret.class, "ICBMGunTurret");
GameRegistry.registerTileEntity(TAATurret.class, "ICBMAATurret");
GameRegistry.registerTileEntity(TRailgunTurret.class, "ICBMRailgun");
GameRegistry.registerTileEntity(TLaserTurret.class, "ICBMLeiSheF");
GameRegistry.registerTileEntity(TPlatform.class, "ICBMPlatform");
GameRegistry.registerTileEntity(TileEntityMulti.class, "ICBMMultiblock");
}
public void preInit() {
}
public Object getServerGuiElement(final int ID, final EntityPlayer player,
final World world, final int x, final int y,
final int z) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 0: {
return new ContainerTurretPlatform(player.inventory,
(TPlatform) tileEntity);
}
}
}
return null;
}
public Object getClientGuiElement(final int ID, final EntityPlayer player,
final World world, final int x, final int y,
final int z) {
return null;
}
public void renderTracer(final World world, final Vector3 position,
final Vector3 target) {
}
public void renderBeam(final World world, final Vector3 position,
final Vector3 target, final float red,
final float green, final float blue, final int age) {
}
}

View file

@ -0,0 +1,13 @@
package icbm.gangshao;
import net.minecraft.item.ItemStack;
public interface IAmmunition {
boolean canDrop(final int p0);
ItemStack onDroppedIntoWorld(final ItemStack p0);
ProjectileType getType(final ItemStack p0);
int getDamage();
}

View file

@ -0,0 +1,16 @@
package icbm.gangshao;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
public interface IAutoSentry extends ISentry {
AxisAlignedBB getTargetingBox();
Entity getTarget();
void setTarget(final Entity p0);
boolean isValidTarget(final Entity p0);
double getDetectRange();
}

View file

@ -0,0 +1,230 @@
package icbm.gangshao;
import calclavia.lib.UniversalRecipes;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import icbm.api.ICBMFlags;
import icbm.core.ICBMTab;
import icbm.core.MainBase;
import icbm.gangshao.damage.EntityTileDamagable;
import icbm.gangshao.packet.PacketHandlerTurret;
import icbm.gangshao.packet.PacketTurret;
import icbm.gangshao.platform.BlockTurretPlatform;
import icbm.gangshao.terminal.command.CommandAccess;
import icbm.gangshao.terminal.command.CommandDestroy;
import icbm.gangshao.terminal.command.CommandGet;
import icbm.gangshao.terminal.command.CommandHelp;
import icbm.gangshao.terminal.command.CommandRegistry;
import icbm.gangshao.terminal.command.CommandTarget;
import icbm.gangshao.terminal.command.CommandUser;
import icbm.gangshao.turret.BlockTurret;
import icbm.gangshao.turret.ItemAmmo;
import icbm.gangshao.turret.ItemBlockTurret;
import icbm.gangshao.turret.mount.ESeat;
import icbm.gangshao.turret.upgrades.ItPaoTaiUpgrades;
import net.minecraft.block.Block;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.oredict.ShapedOreRecipe;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.flag.CommandFlag;
import universalelectricity.prefab.flag.FlagRegistry;
import universalelectricity.prefab.flag.ModFlag;
import universalelectricity.prefab.flag.NBTFileLoader;
@Mod(modid = "ICBM|Sentry", name = "ICBM|Sentry", version = "1.2.1", useMetadata = true)
public class ICBMSentry extends MainBase {
public static final String NAME = "ICBM|Sentry";
public static final String CHANNEL = "ICBM";
@SidedProxy(clientSide = "icbm.gangshao.ClientProxy", serverSide = "icbm.gangshao.CommonProxy")
public static CommonProxy proxy;
@Mod.Instance("ICBM|Sentry")
public static ICBMSentry instance;
@Mod.Metadata("ICBM|Sentry")
public static ModMetadata metadata;
public static final int BLOCK_ID_PREFIX = 3517;
public static final int ITEM_ID_PREFIX = 20948;
public static final int ENTITY_ID_PREFIX = 50;
public static Block blockTurret;
public static Block blockPlatform;
public static Item itemAmmo;
public static Item itemUpgrade;
public static ItemStack conventionalBullet;
public static ItemStack railgunBullet;
public static ItemStack antimatterBullet;
public static ItemStack bulletShell;
public static final String FLAG_RAILGUN;
public static SimpleNetworkWrapper channel;
@Mod.EventHandler
@Override
public void preInit(final FMLPreInitializationEvent event) {
super.preInit(event);
NetworkRegistry.INSTANCE.registerGuiHandler((Object) this,
(IGuiHandler) ICBMSentry.proxy);
MinecraftForge.EVENT_BUS.register((Object) this);
MainBase.CONFIGURATION.load();
ICBMSentry.blockTurret = (Block) new BlockTurret();
ICBMSentry.blockPlatform = (Block) new BlockTurretPlatform();
ICBMSentry.itemAmmo = new ItemAmmo();
ICBMSentry.itemUpgrade = new ItPaoTaiUpgrades();
MainBase.CONFIGURATION.save();
ICBMSentry.bulletShell = new ItemStack(ICBMSentry.itemAmmo, 1, 0);
ICBMSentry.conventionalBullet = new ItemStack(ICBMSentry.itemAmmo, 1, 1);
ICBMSentry.railgunBullet = new ItemStack(ICBMSentry.itemAmmo, 1, 2);
ICBMSentry.antimatterBullet = new ItemStack(ICBMSentry.itemAmmo, 1, 3);
GameRegistry.registerBlock(ICBMSentry.blockTurret, ItemBlockTurret.class,
"ICBMTurret");
GameRegistry.registerBlock(ICBMSentry.blockPlatform, "ICBMPlatform");
EntityRegistry.registerGlobalEntityID(
ESeat.class, "ICBMFake", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(ESeat.class, "ICBMFake", 57, (Object) this,
50, 5, true);
EntityRegistry.registerGlobalEntityID(
EntityTileDamagable.class, "ICBMFakeTile",
EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(EntityTileDamagable.class, "ICBMFakeTile",
58, (Object) this, 50, 5, true);
GameRegistry.registerItem(itemAmmo, "icbm:itemAmmo");
GameRegistry.registerItem(itemUpgrade, "icbm:itemUpgrade");
ICBMTab.itemStack = new ItemStack(ICBMSentry.blockTurret);
ICBMSentry.proxy.preInit();
channel = NetworkRegistry.INSTANCE.newSimpleChannel("icbm_sentry");
int pktId = 0;
channel.registerMessage(PacketHandlerTurret.class, PacketTurret.class,
pktId++, Side.CLIENT);
}
@Mod.EventHandler
public void init(final FMLInitializationEvent event) {
MainBase.setModMetadata("ICBM|Sentry", ICBMSentry.metadata);
}
@Mod.EventHandler
@Override
public void postInit(final FMLPostInitializationEvent event) {
super.postInit(event);
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.itemAmmo, 16, 0),
new Object[] { "T", "T", 'T', "ingotTin" }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.itemAmmo, 16, 1),
new Object[] { "SBS", "SGS", "SSS", 'B', Items.iron_ingot, 'G',
Items.gunpowder, 'S', ICBMSentry.bulletShell.copy() }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.itemAmmo, 2, 2),
new Object[] { "D", "B", "B", 'D', Items.diamond, 'B',
ICBMSentry.conventionalBullet }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
ICBMSentry.antimatterBullet,
new Object[] { "A", "B", 'A', "antimatterGram", 'B',
ICBMSentry.railgunBullet }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
ICBMSentry.blockPlatform,
new Object[] { "SPS", "CBC", "SAS", 'P', Blocks.piston, 'A',
UniversalRecipes.BATTERY, 'S', "plateSteel", 'C',
Blocks.chest, 'B', "calclavia:CIRCUIT_T1" }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.blockTurret, 1, 0),
new Object[] { "SSS", "CS ", 'C', "calclavia:CIRCUIT_T1", 'S',
"ingotSteel" }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.blockTurret, 1, 1),
new Object[] { "DDD", "CS ", "GS ", 'D', Items.diamond, 'S',
"plateSteel", 'C', "calclavia:CIRCUIT_T3", 'G',
new ItemStack(ICBMSentry.blockTurret, 1, 0) }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.blockTurret, 1, 2),
new Object[] { "DDS", "CS ", "GS ", 'D', "plateBronze", 'S',
"plateSteel", 'C', "calclavia:CIRCUIT_T2", 'G',
new ItemStack(ICBMSentry.blockTurret, 1, 0) }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.blockTurret, 1, 3),
new Object[] { "DDG", "CS ", "GS ", 'D', "plateBronze", 'S',
"plateSteel", 'C', "calclavia:CIRCUIT_T1", 'D',
Blocks.glass, 'G', Blocks.glass }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.itemUpgrade, 3,
ItPaoTaiUpgrades.TurretUpgradeType.RANGE.ordinal()),
new Object[] { "B", "I", 'B', Items.bow, 'I', Items.iron_ingot }));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ICBMSentry.itemUpgrade, 1,
ItPaoTaiUpgrades.TurretUpgradeType.COLLECTOR.ordinal()),
new Object[] { "BBB", " I ", "BBB", 'B', Items.bucket, 'I',
Items.bowl }));
CommandRegistry.register(new CommandAccess());
CommandRegistry.register(new CommandDestroy());
CommandRegistry.register(new CommandUser());
CommandRegistry.register(new CommandHelp());
CommandRegistry.register(new CommandGet());
CommandRegistry.register(new CommandTarget());
ICBMSentry.proxy.init();
}
public static boolean isProtected(final World world, final Vector3 diDian,
final String banFlag) {
return FlagRegistry.getModFlag("ModFlags") != null &&
(FlagRegistry.getModFlag("ModFlags")
.containsValue(world, ICBMFlags.FLAG_BAN_GLOBAL, "true", diDian) ||
FlagRegistry.getModFlag("ModFlags")
.containsValue(world, banFlag, "true", diDian));
}
@Mod.EventHandler
@Override
public void serverStarting(final FMLServerStartingEvent event) {
FlagRegistry.registerModFlag(
"ModFlags", new ModFlag(NBTFileLoader.loadData("ModFlags")));
final ICommandManager commandManager = FMLCommonHandler.instance()
.getMinecraftServerInstance()
.getCommandManager();
final ServerCommandManager serverCommandManager = (ServerCommandManager) commandManager;
serverCommandManager.registerCommand(
(ICommand) new CommandFlag(FlagRegistry.getModFlag("ModFlags")));
}
@SubscribeEvent
@Override
public void worldSave(final WorldEvent.Save evt) {
if (!((WorldEvent) evt).world.isRemote) {
NBTFileLoader.saveData("ModFlags",
FlagRegistry.getModFlag("ModFlags").getNBT());
}
}
@Override
protected String getChannel() {
return "ICBM";
}
static {
FLAG_RAILGUN = FlagRegistry.registerFlag("ban_railgun");
}
}

Some files were not shown because too many files have changed in this diff Show more