chore: format code

This commit is contained in:
LordMZTE 2023-01-08 16:58:21 +01:00
parent eced15a2f1
commit 2c06c8a55a
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
129 changed files with 9947 additions and 8148 deletions

130
.clang-format Normal file
View File

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

View File

@ -4,29 +4,34 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Calclavia { 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 final String RESOURCE_DIRECTORY = "/mods/calclavia/"; public static List<String> splitStringPerWord(String string, int wordsPerLine) {
public static final String TEXTURE_DIRECTORY = "/mods/calclavia/textures/"; String[] words = string.split(" ");
public static final String GUI_DIRECTORY = "/mods/calclavia/textures/gui/"; ArrayList<String> lines = new ArrayList<>();
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";
for (int lineCount = 0; (double) lineCount
< Math.ceil((double) ((float) words.length / (float) wordsPerLine));
++lineCount) {
String stringInLine = "";
public static List<String> splitStringPerWord(String string, int wordsPerLine) { for (int i = lineCount * wordsPerLine;
String[] words = string.split(" "); i < Math.min(wordsPerLine + lineCount * wordsPerLine, words.length);
ArrayList<String> lines = new ArrayList<>(); ++i) {
stringInLine = stringInLine + words[i] + " ";
}
for(int lineCount = 0; (double)lineCount < Math.ceil((double)((float)words.length / (float)wordsPerLine)); ++lineCount) { lines.add(stringInLine.trim());
String stringInLine = ""; }
for(int i = lineCount * wordsPerLine; i < Math.min(wordsPerLine + lineCount * wordsPerLine, words.length); ++i) { return lines;
stringInLine = stringInLine + words[i] + " "; }
}
lines.add(stringInLine.trim());
}
return lines;
}
} }

View File

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

@ -3,6 +3,5 @@ package calclavia.lib;
import java.util.HashSet; import java.util.HashSet;
public interface IPlayerUsing { public interface IPlayerUsing {
HashSet getPlayersUsing();
HashSet getPlayersUsing();
} }

View File

@ -3,5 +3,4 @@ package calclavia.lib;
import universalelectricity.core.block.IConnector; import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IVoltage; import universalelectricity.core.block.IVoltage;
public interface IUniversalEnergyTile extends IConnector, IVoltage { public interface IUniversalEnergyTile extends IConnector, IVoltage {}
}

View File

@ -7,19 +7,18 @@ import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.tile.TileEntityElectrical; import universalelectricity.prefab.tile.TileEntityElectrical;
public class TileEntityUniversalProducer extends TileEntityElectrical { public class TileEntityUniversalProducer extends TileEntityElectrical {
public ElectricityPack produce(double watts) { public ElectricityPack produce(double watts) {
ElectricityPack pack = ElectricityPack pack
new ElectricityPack(watts / this.getVoltage(), this.getVoltage()); = new ElectricityPack(watts / this.getVoltage(), this.getVoltage());
ElectricityPack remaining = ElectricityPack remaining
ElectricityNetworkHelper.produceFromMultipleSides(this, pack); = ElectricityNetworkHelper.produceFromMultipleSides(this, pack);
return remaining; return remaining;
} }
@Override @Override
public boolean canConnect(ForgeDirection direction) { public boolean canConnect(ForgeDirection direction) {
return this instanceof IRotatable return this instanceof IRotatable ? direction.ordinal() == this.getBlockMetadata()
? direction.ordinal() == this.getBlockMetadata() : true;
: true; }
}
} }

View File

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

View File

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

View File

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

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

View File

@ -1,8 +1,9 @@
package calclavia.lib.gui; package calclavia.lib.gui;
import calclavia.lib.Calclavia;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import calclavia.lib.Calclavia;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
@ -18,279 +19,364 @@ import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.vector.Region2; import universalelectricity.prefab.vector.Region2;
public class GuiContainerBase extends GuiContainer { 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;
//private static final int METER_X = 54; public GuiContainerBase(Container container) {
public static final int METER_HEIGHT = 49; super(container);
public static final int METER_WIDTH = 14; this.ySize = 217;
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 != "") { @Override
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop, public void initGui() {
(String[])Calclavia.splitStringPerWord(this.tooltip, 5) super.initGui();
.toArray(new String[0]));
} }
this.tooltip = ""; @Override
} public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
@Override super.onGuiClosed();
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) { @Override
this.mc.renderEngine.bindTexture( protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
new ResourceLocation("calclavia", "textures/gui/gui_base.png")); for (Entry<Region2, String> entry : this.tooltips.entrySet()) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (((Region2) entry.getKey())
this.drawTexturedModalRect(this.containerWidth + x, .isIn(new Vector2(
this.containerHeight + y, 0, 0, 18, 18); (double) (mouseX - this.guiLeft), (double) (mouseY - this.guiTop)
this.drawItemStack(itemStack, this.containerWidth + x, ))) {
this.containerHeight + y); this.tooltip = (String) entry.getValue();
} break;
}
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; if (this.tooltip != null && this.tooltip != "") {
var7 = y - 12; this.drawTooltip(
int var9 = 8; mouseX - this.guiLeft,
if (toolTips.length > 1) { mouseY - this.guiTop,
var9 += 2 + (toolTips.length - 1) * 10; (String[]) Calclavia.splitStringPerWord(this.tooltip, 5)
.toArray(new String[0])
);
} }
if (this.guiTop + var7 + var9 + 6 > this.height) { this.tooltip = "";
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, @Override
FluidStack liquid) { protected void drawGuiContainerBackgroundLayer(float var1, int x, int y) {
if (liquid != null) { this.containerWidth = (this.width - this.xSize) / 2;
int start = 0; this.containerHeight = (this.height - this.ySize) / 2;
IIcon liquidIcon = liquid.getFluid().getIcon(); 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
);
}
int x1; protected void drawBulb(int x, int y, boolean isOn) {
do { this.mc.renderEngine.bindTexture(
if (squaled > 16) { new ResourceLocation("calclavia", "textures/gui/gui_base.png")
x1 = 16; );
squaled -= 16; 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 { } else {
x1 = squaled; this.drawTexturedModalRect(
squaled = 0; 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);
} }
this.drawTexturedModelRectFromIcon(j + col, k + line + 58 - x1 - start,
liquidIcon, 16, 16 - (16 - x1));
start += 16;
} while (x1 != 0 && squaled != 0);
} }
}
} }

View File

@ -1,8 +1,9 @@
package calclavia.lib.gui; package calclavia.lib.gui;
import calclavia.lib.Calclavia;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import calclavia.lib.Calclavia;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
@ -15,257 +16,342 @@ import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.vector.Region2; import universalelectricity.prefab.vector.Region2;
public class GuiScreenBase extends GuiBase { 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;
// private static final int METER_X = 54; public GuiScreenBase() {
public static final int METER_HEIGHT = 49; super.ySize = 217;
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 != "") { @Override
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop, protected void drawForegroundLayer(int mouseX, int mouseY, float var1) {
(String[])Calclavia.splitStringPerWord(this.tooltip, 5) for (Entry<Region2, String> entry : this.tooltips.entrySet()) {
.toArray(new String[0])); if (((Region2) entry.getKey())
} .isIn(new Vector2(
(double) (mouseX - this.guiLeft), (double) (mouseY - this.guiTop)
this.tooltip = ""; ))) {
} this.tooltip = (String) entry.getValue();
break;
@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; if (this.tooltip != null && this.tooltip != "") {
var7 = y - 12; this.drawTooltip(
int var9 = 8; mouseX - this.guiLeft,
if (toolTips.length > 1) { mouseY - this.guiTop,
var9 += 2 + (toolTips.length - 1) * 10; (String[]) Calclavia.splitStringPerWord(this.tooltip, 5)
.toArray(new String[0])
);
} }
if (super.guiTop + var7 + var9 + 6 > this.height) { this.tooltip = "";
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, @Override
FluidStack liquid) { protected void drawBackgroundLayer(int x, int y, float var1) {
if (liquid != null) { this.containerWidth = (this.width - this.xSize) / 2;
int start = 0; this.containerHeight = (this.height - this.ySize) / 2;
IIcon liquidIcon = liquid.getFluid().getIcon(); 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
);
}
int x1; protected void drawBulb(int x, int y, boolean isOn) {
do { this.mc.renderEngine.bindTexture(
if (squaled > 16) { new ResourceLocation("calclavia", "textures/gui/gui_base.png")
x1 = 16; );
squaled -= 16; 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 { } else {
x1 = squaled; this.drawTexturedModalRect(
squaled = 0; 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);
} }
this.drawTexturedModelRectFromIcon(j + col, k + line + 58 - x1 - start,
liquidIcon, 16, 16 - (16 - x1));
start += 16;
} while (x1 != 0 && squaled != 0);
} }
}
} }

View File

@ -1,23 +1,22 @@
package calclavia.lib.gui; package calclavia.lib.gui;
public enum GuiSlotType { 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 };
NONE("NONE", 0), private GuiSlotType(String var1, int var2) {}
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

@ -10,102 +10,147 @@ import net.minecraft.client.renderer.entity.RenderManager;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class CalclaviaRenderHelper { public class CalclaviaRenderHelper {
public static void enableBlending() {
GL11.glShadeModel(7425);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
}
public static void enableBlending() { public static void disableBlending() {
GL11.glShadeModel(7425); GL11.glShadeModel(7424);
GL11.glEnable(3042); GL11.glDisable(2848);
GL11.glBlendFunc(770, 771); GL11.glDisable(2881);
} GL11.glDisable(3042);
}
public static void disableBlending() { public static void enableLighting() {
GL11.glShadeModel(7424); RenderHelper.enableStandardItemLighting();
GL11.glDisable(2848); }
GL11.glDisable(2881);
GL11.glDisable(3042);
}
public static void enableLighting() { public static void disableLighting() {
RenderHelper.enableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
} OpenGlHelper.setLightmapTextureCoords(
OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F
);
}
public static void disableLighting() { public static void
RenderHelper.disableStandardItemLighting(); renderNormalBlockAsItem(Block block, int metadata, RenderBlocks renderer) {
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F); 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 renderNormalBlockAsItem(Block block, int metadata, RenderBlocks renderer) { public static void renderFloatingText(String text, float x, float y, float z) {
Tessellator tessellator = Tessellator.instance; renderFloatingText(text, x, y, z, 16777215);
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) { public static void
renderFloatingText(text, x, y, z, 16777215); renderFloatingText(String text, float x, float y, float z, int color) {
} RenderManager renderManager = RenderManager.instance;
FontRenderer fontRenderer = renderManager.getFontRenderer();
public static void renderFloatingText(String text, float x, float y, float z, int color) { float scale = 0.027F;
RenderManager renderManager = RenderManager.instance; GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
FontRenderer fontRenderer = renderManager.getFontRenderer(); GL11.glPushMatrix();
float scale = 0.027F; GL11.glTranslatef(x + 0.0F, y + 2.3F, z);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glPushMatrix(); GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(x + 0.0F, y + 2.3F, z); GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glScalef(-scale, -scale, scale);
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glDisable(2896);
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glDepthMask(false);
GL11.glScalef(-scale, -scale, scale); GL11.glDisable(2929);
GL11.glDisable(2896); GL11.glEnable(3042);
GL11.glDepthMask(false); GL11.glBlendFunc(770, 771);
GL11.glDisable(2929); Tessellator tessellator = Tessellator.instance;
GL11.glEnable(3042); byte yOffset = 0;
GL11.glBlendFunc(770, 771); GL11.glDisable(3553);
Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads();
byte yOffset = 0; int stringMiddle = fontRenderer.getStringWidth(text) / 2;
GL11.glDisable(3553); tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.5F);
tessellator.startDrawingQuads(); tessellator.addVertex(
int stringMiddle = fontRenderer.getStringWidth(text) / 2; (double) (-stringMiddle - 1), (double) (-1 + yOffset), 0.0D
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) (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.addVertex((double)(stringMiddle + 1), (double)(-1 + yOffset), 0.0D); tessellator.draw();
tessellator.draw(); GL11.glEnable(3553);
GL11.glEnable(3553); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); fontRenderer.drawString(
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color); text, -fontRenderer.getStringWidth(text) / 2, yOffset, color
GL11.glEnable(2929); );
GL11.glDepthMask(true); GL11.glEnable(2929);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color); GL11.glDepthMask(true);
GL11.glEnable(2896); fontRenderer.drawString(
GL11.glDisable(3042); text, -fontRenderer.getStringWidth(text) / 2, yOffset, color
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); );
GL11.glPopMatrix(); GL11.glEnable(2896);
} GL11.glDisable(3042);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
} }

View File

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

View File

@ -1,10 +1,11 @@
package calclavia.lib.render; package calclavia.lib.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.renderer.entity.RendererLivingEntity;
@ -16,49 +17,51 @@ import net.minecraft.util.MovingObjectPosition;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public abstract class RenderTaggedTile extends TileEntitySpecialRenderer { public abstract class RenderTaggedTile extends TileEntitySpecialRenderer {
@Override @Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) {
float f) { if (t != null && t instanceof ITagRender
if (t != null && t instanceof ITagRender && && this.getPlayer().getDistance(
this.getPlayer().getDistance((double)t.xCoord, (double)t.yCoord, (double) t.xCoord, (double) t.yCoord, (double) t.zCoord
(double)t.zCoord) <= ) <= (double) RendererLivingEntity.NAME_TAG_RANGE) {
(double)RendererLivingEntity.NAME_TAG_RANGE) { HashMap tags = new HashMap();
HashMap tags = new HashMap(); float height = ((ITagRender) t).addInformation(tags, this.getPlayer());
float height = ((ITagRender)t).addInformation(tags, this.getPlayer()); EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; if (player.ridingEntity == null) {
if (player.ridingEntity == null) { MovingObjectPosition objectPosition = player.rayTrace(8.0D, 1.0F);
MovingObjectPosition objectPosition = player.rayTrace(8.0D, 1.0F); if (objectPosition != null) {
if (objectPosition != null) { boolean isLooking = false;
boolean isLooking = false;
for (int it = 0; (float)it < height; ++it) { for (int it = 0; (float) it < height; ++it) {
if (objectPosition.blockX == t.xCoord && if (objectPosition.blockX == t.xCoord
objectPosition.blockY == t.yCoord + it && && objectPosition.blockY == t.yCoord + it
objectPosition.blockZ == t.zCoord) { && objectPosition.blockZ == t.zCoord) {
isLooking = true; 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()
);
}
}
}
}
} }
}
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() { public EntityPlayer getPlayer() {
EntityLivingBase entity = this.field_147501_a.field_147551_g; EntityLivingBase entity = this.field_147501_a.field_147551_g;
return entity instanceof EntityPlayer ? (EntityPlayer)entity : null; return entity instanceof EntityPlayer ? (EntityPlayer) entity : null;
} }
} }

View File

@ -37,103 +37,135 @@ import net.minecraftforge.client.MinecraftForgeClient;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ClientProxy extends CommonProxy { public class ClientProxy extends CommonProxy {
@Override
@Override public void init() {
public void init() { super.init();
super.init(); RenderingRegistry.registerBlockHandler((ISimpleBlockRenderingHandler
RenderingRegistry.registerBlockHandler( ) new RenderBlockHandler());
(ISimpleBlockRenderingHandler) new RenderBlockHandler()); RenderingRegistry.registerBlockHandler((ISimpleBlockRenderingHandler
RenderingRegistry.registerBlockHandler( ) new RenderForceField());
(ISimpleBlockRenderingHandler) new RenderForceField()); MinecraftForgeClient.registerItemRenderer(
MinecraftForgeClient.registerItemRenderer( ModularForceFieldSystem.itemCardID, (IItemRenderer) new RenderIDCard()
ModularForceFieldSystem.itemCardID, (IItemRenderer) new RenderIDCard()); );
ClientRegistry.bindTileEntitySpecialRenderer( ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityFortronCapacitor.class, TileEntityFortronCapacitor.class,
(TileEntitySpecialRenderer) new RenderFortronCapacitor()); (TileEntitySpecialRenderer) new RenderFortronCapacitor()
ClientRegistry.bindTileEntitySpecialRenderer( );
TileEntityCoercionDeriver.class, ClientRegistry.bindTileEntitySpecialRenderer(
(TileEntitySpecialRenderer) new RenderCoercionDeriver()); TileEntityCoercionDeriver.class,
ClientRegistry.bindTileEntitySpecialRenderer( (TileEntitySpecialRenderer) new RenderCoercionDeriver()
TileEntityForceManipulator.class, );
(TileEntitySpecialRenderer) new RenderForceManipulator()); ClientRegistry.bindTileEntitySpecialRenderer(
ClientRegistry.bindTileEntitySpecialRenderer( TileEntityForceManipulator.class,
TileEntityForceFieldProjector.class, (TileEntitySpecialRenderer) new RenderForceManipulator()
(TileEntitySpecialRenderer) new RenderForceFieldProjector()); );
} ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityForceFieldProjector.class,
@Override (TileEntitySpecialRenderer) new RenderForceFieldProjector()
public World getClientWorld() { );
return (World)FMLClientHandler.instance().getClient().theWorld;
}
@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) {
if (tileEntity.getClass() == TileEntityFortronCapacitor.class) {
return new GuiFortronCapacitor(player,
(TileEntityFortronCapacitor)tileEntity);
}
if (tileEntity.getClass() == TileEntityForceFieldProjector.class) {
return new GuiForceFieldProjector(
player, (TileEntityForceFieldProjector)tileEntity);
}
if (tileEntity.getClass() == TileEntityCoercionDeriver.class) {
return new GuiCoercionDeriver(player,
(TileEntityCoercionDeriver)tileEntity);
}
if (tileEntity.getClass() == TileEntityBiometricIdentifier.class) {
return new GuiBiometricIdentifier(
player, (TileEntityBiometricIdentifier)tileEntity);
}
if (tileEntity.getClass() == TileEntityInterdictionMatrix.class) {
return new GuiInterdictionMatrix(
player, (TileEntityInterdictionMatrix)tileEntity);
}
if (tileEntity.getClass() == TileEntityForceManipulator.class) {
return new GuiForceManipulator(player,
(TileEntityForceManipulator)tileEntity);
}
} }
return null;
}
@Override @Override
public boolean isOp(final String username) { public World getClientWorld() {
return false; return (World) FMLClientHandler.instance().getClient().theWorld;
} }
@Override @Override
public void renderBeam(final World world, final Vector3 position, public Object getClientGuiElement(
final Vector3 target, final float red, final int ID,
final float green, final float blue, final int age) { final EntityPlayer player,
FMLClientHandler.instance().getClient().effectRenderer.addEffect( final World world,
(EntityFX) new FXBeam(world, position, target, red, green, blue, age)); final int x,
} final int y,
final int z
) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
if (tileEntity.getClass() == TileEntityFortronCapacitor.class) {
return new GuiFortronCapacitor(
player, (TileEntityFortronCapacitor) tileEntity
);
}
if (tileEntity.getClass() == TileEntityForceFieldProjector.class) {
return new GuiForceFieldProjector(
player, (TileEntityForceFieldProjector) tileEntity
);
}
if (tileEntity.getClass() == TileEntityCoercionDeriver.class) {
return new GuiCoercionDeriver(
player, (TileEntityCoercionDeriver) tileEntity
);
}
if (tileEntity.getClass() == TileEntityBiometricIdentifier.class) {
return new GuiBiometricIdentifier(
player, (TileEntityBiometricIdentifier) tileEntity
);
}
if (tileEntity.getClass() == TileEntityInterdictionMatrix.class) {
return new GuiInterdictionMatrix(
player, (TileEntityInterdictionMatrix) tileEntity
);
}
if (tileEntity.getClass() == TileEntityForceManipulator.class) {
return new GuiForceManipulator(
player, (TileEntityForceManipulator) tileEntity
);
}
}
return null;
}
@Override @Override
public void renderHologram(final World world, final Vector3 position, public boolean isOp(final String username) {
final float red, final float green, return false;
final float blue, final int age, }
final Vector3 targetPosition) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect(
(EntityFX) new FXHologram(world, position, red, green, blue, age)
.setTarget(targetPosition));
}
@Override @Override
public void renderHologramMoving(final World world, final Vector3 position, public void renderBeam(
final float red, final float green, final World world,
final float blue, final int age) { final Vector3 position,
FMLClientHandler.instance().getClient().effectRenderer.addEffect(( final Vector3 target,
EntityFX) new FXHologramMoving(world, position, red, green, blue, age)); 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));
}
@Override @Override
public boolean isSneaking() { public void renderHologram(
EntityPlayer player = Minecraft.getMinecraft().thePlayer; final World world,
return player.isSneaking(); final Vector3 position,
} final float red,
final float green,
final float blue,
final int age,
final Vector3 targetPosition
) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect(
(EntityFX) new FXHologram(world, position, red, green, blue, age)
.setTarget(targetPosition)
);
}
@Override
public void renderHologramMoving(
final World world,
final Vector3 position,
final float red,
final float green,
final float blue,
final int age
) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect((EntityFX
) new FXHologramMoving(world, position, red, green, blue, age));
}
@Override
public boolean isSneaking() {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
return player.isSneaking();
}
} }

View File

@ -21,78 +21,112 @@ import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class CommonProxy implements IGuiHandler { public class CommonProxy implements IGuiHandler {
public void preInit() {} public void preInit() {}
public void init() {} public void init() {}
public Object getClientGuiElement(final int ID, final EntityPlayer player, public Object getClientGuiElement(
final World world, final int x, final int y, final int ID,
final int z) { final EntityPlayer player,
return null; final World world,
} final int x,
final int y,
public Object getServerGuiElement(final int ID, final EntityPlayer player, final int z
final World world, final int x, final int y, ) {
final int z) { return null;
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
if (tileEntity.getClass() == TileEntityFortronCapacitor.class) {
return new ContainerFortronCapacitor(
player, (TileEntityFortronCapacitor)tileEntity);
}
if (tileEntity.getClass() == TileEntityForceFieldProjector.class) {
return new ContainerForceFieldProjector(
player, (TileEntityForceFieldProjector)tileEntity);
}
if (tileEntity.getClass() == TileEntityCoercionDeriver.class) {
return new ContainerCoercionDeriver(
player, (TileEntityCoercionDeriver)tileEntity);
}
if (tileEntity.getClass() == TileEntityBiometricIdentifier.class) {
return new ContainerBiometricIdentifier(
player, (TileEntityBiometricIdentifier)tileEntity);
}
if (tileEntity.getClass() == TileEntityInterdictionMatrix.class) {
return new ContainerInterdictionMatrix(
player, (TileEntityInterdictionMatrix)tileEntity);
}
if (tileEntity.getClass() == TileEntityForceManipulator.class) {
return new ContainerForceManipulator(
player, (TileEntityForceManipulator)tileEntity);
}
} }
return null;
}
public World getClientWorld() { return null; } 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) {
if (tileEntity.getClass() == TileEntityFortronCapacitor.class) {
return new ContainerFortronCapacitor(
player, (TileEntityFortronCapacitor) tileEntity
);
}
if (tileEntity.getClass() == TileEntityForceFieldProjector.class) {
return new ContainerForceFieldProjector(
player, (TileEntityForceFieldProjector) tileEntity
);
}
if (tileEntity.getClass() == TileEntityCoercionDeriver.class) {
return new ContainerCoercionDeriver(
player, (TileEntityCoercionDeriver) tileEntity
);
}
if (tileEntity.getClass() == TileEntityBiometricIdentifier.class) {
return new ContainerBiometricIdentifier(
player, (TileEntityBiometricIdentifier) tileEntity
);
}
if (tileEntity.getClass() == TileEntityInterdictionMatrix.class) {
return new ContainerInterdictionMatrix(
player, (TileEntityInterdictionMatrix) tileEntity
);
}
if (tileEntity.getClass() == TileEntityForceManipulator.class) {
return new ContainerForceManipulator(
player, (TileEntityForceManipulator) tileEntity
);
}
}
return null;
}
public boolean isOp(final String username) { public World getClientWorld() {
final MinecraftServer theServer = return null;
FMLCommonHandler.instance().getMinecraftServerInstance(); }
if (theServer == null)
return false;
for (String op : theServer.getConfigurationManager().func_152606_n()) public boolean isOp(final String username) {
if (username.trim().equalsIgnoreCase(op)) final MinecraftServer theServer
return true; = FMLCommonHandler.instance().getMinecraftServerInstance();
if (theServer == null)
return false;
return false; for (String op : theServer.getConfigurationManager().func_152606_n())
} if (username.trim().equalsIgnoreCase(op))
return true;
public void renderBeam(final World world, final Vector3 position, return false;
final Vector3 target, final float red, }
final float green, final float blue, final int age) {}
public void renderHologram(final World world, final Vector3 position, public void renderBeam(
final float red, final float green, final World world,
final float blue, final int age, final Vector3 position,
final Vector3 targetPosition) {} final Vector3 target,
final float red,
final float green,
final float blue,
final int age
) {}
public void renderHologramMoving(final World world, final Vector3 position, public void renderHologram(
final float red, final float green, final World world,
final float blue, final int age) {} final Vector3 position,
final float red,
final float green,
final float blue,
final int age,
final Vector3 targetPosition
) {}
public boolean isSneaking() { public void renderHologramMoving(
return false; final World world,
} final Vector3 position,
final float red,
final float green,
final float blue,
final int age
) {}
public boolean isSneaking() {
return false;
}
} }

View File

@ -3,7 +3,6 @@ package mffs;
import universalelectricity.core.UniversalElectricity; import universalelectricity.core.UniversalElectricity;
public class ConversionHelper { public class ConversionHelper {
public static double toEU(double joules) { public static double toEU(double joules) {
return joules / UniversalElectricity.UE_IC2_RATIO; return joules / UniversalElectricity.UE_IC2_RATIO;
} }
@ -19,5 +18,4 @@ public class ConversionHelper {
public static double fromRF(int rf) { public static double fromRF(int rf) {
return rf * UniversalElectricity.UE_RF_RATIO; return rf * UniversalElectricity.UE_RF_RATIO;
} }
} }

View File

@ -1,23 +1,25 @@
package mffs; package mffs;
public abstract class DelayedEvent { public abstract class DelayedEvent {
public int ticks; public int ticks;
protected IDelayedEventHandler handler; protected IDelayedEventHandler handler;
public DelayedEvent(final IDelayedEventHandler handler, final int ticks) { public DelayedEvent(final IDelayedEventHandler handler, final int ticks) {
this.ticks = 0; this.ticks = 0;
this.handler = handler; this.handler = handler;
this.ticks = ticks; this.ticks = ticks;
}
protected abstract void onEvent();
public void update() {
--this.ticks;
if (this.ticks <= 0) {
this.onEvent();
} }
}
public int getPriority() { return 0; } protected abstract void onEvent();
public void update() {
--this.ticks;
if (this.ticks <= 0) {
this.onEvent();
}
}
public int getPriority() {
return 0;
}
} }

View File

@ -2,9 +2,8 @@ package mffs;
import java.util.List; import java.util.List;
public interface IDelayedEventHandler public interface IDelayedEventHandler {
{
List<DelayedEvent> getDelayedEvents(); List<DelayedEvent> getDelayedEvents();
List<DelayedEvent> getQuedDelayedEvents(); List<DelayedEvent> getQuedDelayedEvents();
} }

View File

@ -4,20 +4,18 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
public class MFFSCreativeTab extends CreativeTabs { public class MFFSCreativeTab extends CreativeTabs {
public static CreativeTabs INSTANCE; public static CreativeTabs INSTANCE;
public MFFSCreativeTab(final int par1, final String par2Str) { public MFFSCreativeTab(final int par1, final String par2Str) {
super(par1, par2Str); super(par1, par2Str);
} }
@Override @Override
public Item getTabIconItem() { public Item getTabIconItem() {
return Item.getItemFromBlock( return Item.getItemFromBlock(ModularForceFieldSystem.blockForceFieldProjector);
ModularForceFieldSystem.blockForceFieldProjector); }
}
static { static {
MFFSCreativeTab.INSTANCE = MFFSCreativeTab.INSTANCE = new MFFSCreativeTab(CreativeTabs.getNextID(), "MFFS");
new MFFSCreativeTab(CreativeTabs.getNextID(), "MFFS"); }
}
} }

View File

@ -1,11 +1,12 @@
package mffs; package mffs;
import calclavia.lib.CalculationHelper;
import icbm.api.IBlockFrequency;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import calclavia.lib.CalculationHelper;
import icbm.api.IBlockFrequency;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.api.fortron.IFortronFrequency; import mffs.api.fortron.IFortronFrequency;
import mffs.api.modules.IModuleAcceptor; import mffs.api.modules.IModuleAcceptor;
@ -27,344 +28,404 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class MFFSHelper { public class MFFSHelper {
public static void public static void transferFortron(
transferFortron(final IFortronFrequency transferer, final IFortronFrequency transferer,
final Set<IFortronFrequency> frequencyTiles, final Set<IFortronFrequency> frequencyTiles,
final TransferMode transferMode, final int limit) { final TransferMode transferMode,
if (transferer != null && frequencyTiles.size() > 1) { final int limit
int totalFortron = 0; ) {
int totalCapacity = 0; if (transferer != null && frequencyTiles.size() > 1) {
for (final IFortronFrequency machine : frequencyTiles) { int totalFortron = 0;
if (machine != null) { int totalCapacity = 0;
totalFortron += machine.getFortronEnergy(); for (final IFortronFrequency machine : frequencyTiles) {
totalCapacity += machine.getFortronCapacity(); if (machine != null) {
} totalFortron += machine.getFortronEnergy();
} totalCapacity += machine.getFortronCapacity();
if (totalFortron > 0 && totalCapacity > 0) { }
switch (transferMode) { }
case EQUALIZE: { if (totalFortron > 0 && totalCapacity > 0) {
for (final IFortronFrequency machine : frequencyTiles) { switch (transferMode) {
if (machine != null) { case EQUALIZE: {
final double capacityPercentage = for (final IFortronFrequency machine : frequencyTiles) {
machine.getFortronCapacity() / (double)totalCapacity; if (machine != null) {
final int amountToSet = (int)(totalFortron * capacityPercentage); final double capacityPercentage
doTransferFortron(transferer, machine, = machine.getFortronCapacity()
amountToSet - machine.getFortronEnergy(), / (double) totalCapacity;
limit); final int amountToSet
} = (int) (totalFortron * capacityPercentage);
} doTransferFortron(
break; transferer,
} machine,
case DISTRIBUTE: { amountToSet - machine.getFortronEnergy(),
final int amountToSet2 = totalFortron / frequencyTiles.size(); limit
for (final IFortronFrequency machine2 : frequencyTiles) { );
if (machine2 != null) { }
doTransferFortron(transferer, machine2, }
amountToSet2 - machine2.getFortronEnergy(), break;
limit); }
} case DISTRIBUTE: {
} final int amountToSet2 = totalFortron / frequencyTiles.size();
break; for (final IFortronFrequency machine2 : frequencyTiles) {
} if (machine2 != null) {
case DRAIN: { doTransferFortron(
frequencyTiles.remove(transferer); transferer,
for (final IFortronFrequency machine : frequencyTiles) { machine2,
if (machine != null) { amountToSet2 - machine2.getFortronEnergy(),
final double capacityPercentage = limit
machine.getFortronCapacity() / (double)totalCapacity; );
final int amountToSet = (int)(totalFortron * capacityPercentage); }
if (amountToSet - machine.getFortronEnergy() <= 0) { }
continue; break;
} }
doTransferFortron(transferer, machine, case DRAIN: {
amountToSet - machine.getFortronEnergy(), frequencyTiles.remove(transferer);
limit); for (final IFortronFrequency machine : frequencyTiles) {
} if (machine != null) {
} final double capacityPercentage
break; = machine.getFortronCapacity()
} / (double) totalCapacity;
case FILL: { final int amountToSet
if (transferer.getFortronEnergy() < transferer.getFortronCapacity()) { = (int) (totalFortron * capacityPercentage);
frequencyTiles.remove(transferer); if (amountToSet - machine.getFortronEnergy() <= 0) {
final int requiredFortron = continue;
transferer.getFortronCapacity() - transferer.getFortronEnergy(); }
for (final IFortronFrequency machine2 : frequencyTiles) { doTransferFortron(
if (machine2 != null) { transferer,
final int amountToConsume = machine,
Math.min(requiredFortron, machine2.getFortronEnergy()); amountToSet - machine.getFortronEnergy(),
final int amountToSet = limit
-machine2.getFortronEnergy() - amountToConsume; );
if (amountToConsume <= 0) { }
continue; }
break;
}
case FILL: {
if (transferer.getFortronEnergy()
< transferer.getFortronCapacity()) {
frequencyTiles.remove(transferer);
final int requiredFortron = transferer.getFortronCapacity()
- transferer.getFortronEnergy();
for (final IFortronFrequency machine2 : frequencyTiles) {
if (machine2 != null) {
final int amountToConsume = Math.min(
requiredFortron, machine2.getFortronEnergy()
);
final int amountToSet
= -machine2.getFortronEnergy() - amountToConsume;
if (amountToConsume <= 0) {
continue;
}
doTransferFortron(
transferer,
machine2,
amountToSet - machine2.getFortronEnergy(),
limit
);
}
}
break;
}
break;
}
} }
doTransferFortron(transferer, machine2,
amountToSet - machine2.getFortronEnergy(),
limit);
}
} }
break;
}
break;
} }
}
}
} }
}
public static void doTransferFortron(final IFortronFrequency transferer, public static void doTransferFortron(
final IFortronFrequency receiver, final IFortronFrequency transferer,
int joules, final int limit) { final IFortronFrequency receiver,
if (transferer != null && receiver != null) { int joules,
final TileEntity tileEntity = (TileEntity)transferer; final int limit
final World world = tileEntity.getWorldObj(); ) {
boolean isCamo = false; if (transferer != null && receiver != null) {
if (transferer instanceof IModuleAcceptor) { final TileEntity tileEntity = (TileEntity) transferer;
isCamo = final World world = tileEntity.getWorldObj();
(((IModuleAcceptor)transferer) boolean isCamo = false;
.getModuleCount(ModularForceFieldSystem.itemModuleCamouflage, if (transferer instanceof IModuleAcceptor) {
new int[0]) > 0); isCamo
} = (((IModuleAcceptor) transferer)
if (joules > 0) { .getModuleCount(
joules = Math.min(joules, limit); ModularForceFieldSystem.itemModuleCamouflage, new int[0]
int toBeInjected = receiver.provideFortron( )
transferer.requestFortron(joules, false), false); > 0);
toBeInjected = transferer.requestFortron( }
receiver.provideFortron(toBeInjected, true), true); if (joules > 0) {
if (world.isRemote && toBeInjected > 0 && !isCamo) { joules = Math.min(joules, limit);
ModularForceFieldSystem.proxy.renderBeam( int toBeInjected = receiver.provideFortron(
world, Vector3.add(new Vector3(tileEntity), 0.5), transferer.requestFortron(joules, false), false
Vector3.add(new Vector3((TileEntity)receiver), 0.5), 0.6f, 0.6f, );
1.0f, 20); toBeInjected = transferer.requestFortron(
receiver.provideFortron(toBeInjected, true), true
);
if (world.isRemote && toBeInjected > 0 && !isCamo) {
ModularForceFieldSystem.proxy.renderBeam(
world,
Vector3.add(new Vector3(tileEntity), 0.5),
Vector3.add(new Vector3((TileEntity) receiver), 0.5),
0.6f,
0.6f,
1.0f,
20
);
}
} else {
joules = Math.min(Math.abs(joules), limit);
int toBeEjected = transferer.provideFortron(
receiver.requestFortron(joules, false), false
);
toBeEjected = receiver.requestFortron(
transferer.provideFortron(toBeEjected, true), true
);
if (world.isRemote && toBeEjected > 0 && !isCamo) {
ModularForceFieldSystem.proxy.renderBeam(
world,
Vector3.add(new Vector3((TileEntity) receiver), 0.5),
Vector3.add(new Vector3(tileEntity), 0.5),
0.6f,
0.6f,
1.0f,
20
);
}
}
} }
} else {
joules = Math.min(Math.abs(joules), limit);
int toBeEjected = transferer.provideFortron(
receiver.requestFortron(joules, false), false);
toBeEjected = receiver.requestFortron(
transferer.provideFortron(toBeEjected, true), true);
if (world.isRemote && toBeEjected > 0 && !isCamo) {
ModularForceFieldSystem.proxy.renderBeam(
world, Vector3.add(new Vector3((TileEntity)receiver), 0.5),
Vector3.add(new Vector3(tileEntity), 0.5), 0.6f, 0.6f, 1.0f, 20);
}
}
} }
}
public static IInterdictionMatrix public static IInterdictionMatrix
getNearestInterdictionMatrix(final World world, final Vector3 position) { getNearestInterdictionMatrix(final World world, final Vector3 position) {
for (final IBlockFrequency frequencyTile : FrequencyGrid.instance().get()) { for (final IBlockFrequency frequencyTile : FrequencyGrid.instance().get()) {
if (((TileEntity)frequencyTile).getWorldObj() == world && if (((TileEntity) frequencyTile).getWorldObj() == world
frequencyTile instanceof IInterdictionMatrix) { && frequencyTile instanceof IInterdictionMatrix) {
final IInterdictionMatrix interdictionMatrix = final IInterdictionMatrix interdictionMatrix
(IInterdictionMatrix)frequencyTile; = (IInterdictionMatrix) frequencyTile;
if (interdictionMatrix.isActive() && if (interdictionMatrix.isActive()
position.distanceTo(new Vector3((TileEntity)interdictionMatrix)) <= && position.distanceTo(new Vector3((TileEntity) interdictionMatrix))
interdictionMatrix.getActionRange()) { <= interdictionMatrix.getActionRange()) {
return interdictionMatrix; return interdictionMatrix;
}
continue;
}
} }
continue; return null;
}
} }
return null;
}
public static boolean public static boolean isPermittedByInterdictionMatrix(
isPermittedByInterdictionMatrix(final IInterdictionMatrix interdictionMatrix, final IInterdictionMatrix interdictionMatrix,
final String username, final String username,
final Permission... permissions) { final Permission... permissions
if (interdictionMatrix != null && interdictionMatrix.isActive() && ) {
interdictionMatrix.getBiometricIdentifier() != null) { if (interdictionMatrix != null && interdictionMatrix.isActive()
for (final Permission permission : permissions) { && interdictionMatrix.getBiometricIdentifier() != null) {
if (!interdictionMatrix.getBiometricIdentifier().isAccessGranted( for (final Permission permission : permissions) {
username, permission)) { if (!interdictionMatrix.getBiometricIdentifier().isAccessGranted(
return interdictionMatrix.getModuleCount( username, permission
ModularForceFieldSystem.itemModuleInvert, new int[0]) > 0; )) {
return interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleInvert, new int[0]
)
> 0;
}
}
} }
} return interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleInvert, new int[0]
)
<= 0;
} }
return interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleInvert, new int[0]) <= 0;
}
public static List<String> splitStringPerWord(final String string, public static List<String>
final int wordsPerLine) { splitStringPerWord(final String string, final int wordsPerLine) {
final String[] words = string.split(" "); final String[] words = string.split(" ");
final List<String> lines = new ArrayList<>(); final List<String> lines = new ArrayList<>();
for (int lineCount = 0; for (int lineCount = 0;
lineCount < Math.ceil(words.length / (float)wordsPerLine); lineCount < Math.ceil(words.length / (float) wordsPerLine);
++lineCount) { ++lineCount) {
String stringInLine = ""; String stringInLine = "";
for (int i = lineCount * wordsPerLine; for (int i = lineCount * wordsPerLine;
i < Math.min(wordsPerLine + lineCount * wordsPerLine, words.length); i < Math.min(wordsPerLine + lineCount * wordsPerLine, words.length);
++i) { ++i) {
stringInLine = stringInLine + words[i] + " "; stringInLine = stringInLine + words[i] + " ";
} }
lines.add(stringInLine.trim()); lines.add(stringInLine.trim());
}
return lines;
}
public static ItemStack getFirstItemBlock(final TileEntity tileEntity,
final ItemStack itemStack) {
return getFirstItemBlock(tileEntity, itemStack, true);
}
public static ItemStack getFirstItemBlock(final TileEntity tileEntity,
final ItemStack itemStack,
final boolean recur) {
if (tileEntity instanceof IProjector) {
for (final int i : ((IProjector)tileEntity).getModuleSlots()) {
final ItemStack checkStack =
getFirstItemBlock(i, (IInventory)tileEntity, itemStack);
if (checkStack != null) {
return checkStack;
} }
} return lines;
} else if (tileEntity instanceof IInventory) {
final IInventory inventory = (IInventory)tileEntity;
for (int j = 0; j < inventory.getSizeInventory(); ++j) {
final ItemStack checkStack2 =
getFirstItemBlock(j, inventory, itemStack);
if (checkStack2 != null) {
return checkStack2;
}
}
} }
if (recur) {
for (int k = 0; k < 6; ++k) { public static ItemStack
final ForgeDirection direction = ForgeDirection.getOrientation(k); getFirstItemBlock(final TileEntity tileEntity, final ItemStack itemStack) {
final Vector3 vector = new Vector3(tileEntity); return getFirstItemBlock(tileEntity, itemStack, true);
vector.modifyPositionFromSide(direction); }
final TileEntity checkTile =
vector.getTileEntity((IBlockAccess)tileEntity.getWorldObj()); public static ItemStack getFirstItemBlock(
if (checkTile != null) { final TileEntity tileEntity, final ItemStack itemStack, final boolean recur
final ItemStack checkStack = ) {
getFirstItemBlock(checkTile, itemStack, false); if (tileEntity instanceof IProjector) {
if (checkStack != null) { for (final int i : ((IProjector) tileEntity).getModuleSlots()) {
final ItemStack checkStack
= getFirstItemBlock(i, (IInventory) tileEntity, itemStack);
if (checkStack != null) {
return checkStack;
}
}
} else if (tileEntity instanceof IInventory) {
final IInventory inventory = (IInventory) tileEntity;
for (int j = 0; j < inventory.getSizeInventory(); ++j) {
final ItemStack checkStack2 = getFirstItemBlock(j, inventory, itemStack);
if (checkStack2 != null) {
return checkStack2;
}
}
}
if (recur) {
for (int k = 0; k < 6; ++k) {
final ForgeDirection direction = ForgeDirection.getOrientation(k);
final Vector3 vector = new Vector3(tileEntity);
vector.modifyPositionFromSide(direction);
final TileEntity checkTile
= vector.getTileEntity((IBlockAccess) tileEntity.getWorldObj());
if (checkTile != null) {
final ItemStack checkStack
= getFirstItemBlock(checkTile, itemStack, false);
if (checkStack != null) {
return checkStack;
}
}
}
}
return null;
}
public static ItemStack getFirstItemBlock(
final int i, final IInventory inventory, final ItemStack itemStack
) {
final ItemStack checkStack = inventory.getStackInSlot(i);
if (checkStack != null && checkStack.getItem() instanceof ItemBlock
&& (itemStack == null || checkStack.isItemEqual(itemStack))) {
return checkStack; return checkStack;
}
} }
} return null;
} }
return null;
}
public static ItemStack getFirstItemBlock(final int i, public static Block getFilterBlock(final ItemStack itemStack) {
final IInventory inventory, if (itemStack != null && itemStack.getItem() instanceof ItemBlock) {
final ItemStack itemStack) { final Block block = Block.getBlockFromItem(itemStack.getItem());
final ItemStack checkStack = inventory.getStackInSlot(i); if (block.renderAsNormalBlock()) {
if (checkStack != null && checkStack.getItem() instanceof ItemBlock && return block;
(itemStack == null || checkStack.isItemEqual(itemStack))) { }
return checkStack;
}
return null;
}
public static Block getFilterBlock(final ItemStack itemStack) {
if (itemStack != null && itemStack.getItem() instanceof ItemBlock) {
final Block block = Block.getBlockFromItem(itemStack.getItem());
if (block.renderAsNormalBlock()) {
return block;
}
}
return null;
}
public static ItemStack getCamoBlock(final IProjector projector,
final Vector3 position) {
if (projector != null && !((TileEntity)projector).getWorldObj().isRemote &&
projector != null &&
projector.getModuleCount(ModularForceFieldSystem.itemModuleCamouflage,
new int[0]) > 0) {
if (projector.getMode() instanceof ItemModeCustom) {
final HashMap<Vector3, int[]> fieldMap =
((ItemModeCustom)projector.getMode())
.getFieldBlockMap(projector, projector.getModeStack());
if (fieldMap != null) {
final Vector3 fieldCenter = new Vector3((TileEntity)projector)
.add(projector.getTranslation());
final Vector3 relativePosition =
position.clone().subtract(fieldCenter);
CalculationHelper.rotateByAngle(relativePosition,
-projector.getRotationYaw(),
-projector.getRotationPitch());
final int[] blockInfo = fieldMap.get(relativePosition.round());
if (blockInfo != null && blockInfo[0] > 0) {
return new ItemStack(Block.getBlockById(blockInfo[0]), 1,
blockInfo[1]);
}
} }
} return null;
for (final int i : projector.getModuleSlots()) { }
final ItemStack checkStack = projector.getStackInSlot(i);
final Block block = getFilterBlock(checkStack); public static ItemStack
if (block != null) { getCamoBlock(final IProjector projector, final Vector3 position) {
return checkStack; if (projector != null && !((TileEntity) projector).getWorldObj().isRemote
&& projector != null
&& projector.getModuleCount(
ModularForceFieldSystem.itemModuleCamouflage, new int[0]
) > 0) {
if (projector.getMode() instanceof ItemModeCustom) {
final HashMap<Vector3, int[]> fieldMap
= ((ItemModeCustom) projector.getMode())
.getFieldBlockMap(projector, projector.getModeStack());
if (fieldMap != null) {
final Vector3 fieldCenter = new Vector3((TileEntity) projector)
.add(projector.getTranslation());
final Vector3 relativePosition
= position.clone().subtract(fieldCenter);
CalculationHelper.rotateByAngle(
relativePosition,
-projector.getRotationYaw(),
-projector.getRotationPitch()
);
final int[] blockInfo = fieldMap.get(relativePosition.round());
if (blockInfo != null && blockInfo[0] > 0) {
return new ItemStack(
Block.getBlockById(blockInfo[0]), 1, blockInfo[1]
);
}
}
}
for (final int i : projector.getModuleSlots()) {
final ItemStack checkStack = projector.getStackInSlot(i);
final Block block = getFilterBlock(checkStack);
if (block != null) {
return checkStack;
}
}
} }
} return null;
} }
return null;
}
public static NBTTagCompound getNBTTagCompound(final ItemStack itemStack) { public static NBTTagCompound getNBTTagCompound(final ItemStack itemStack) {
if (itemStack != null) { if (itemStack != null) {
if (itemStack.getTagCompound() == null) { if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound()); itemStack.setTagCompound(new NBTTagCompound());
} }
return itemStack.getTagCompound(); return itemStack.getTagCompound();
}
return null;
} }
return null;
}
public static boolean hasPermission(final World world, final Vector3 position, public static boolean hasPermission(
final Permission permission, final World world,
final EntityPlayer player) { final Vector3 position,
final IInterdictionMatrix interdictionMatrix = final Permission permission,
getNearestInterdictionMatrix(world, position); final EntityPlayer player
return interdictionMatrix == null || ) {
isPermittedByInterdictionMatrix(interdictionMatrix, final IInterdictionMatrix interdictionMatrix
player.getDisplayName(), permission); = getNearestInterdictionMatrix(world, position);
} return interdictionMatrix == null
|| isPermittedByInterdictionMatrix(
public static boolean hasPermission(final World world, final Vector3 position, interdictionMatrix, player.getDisplayName(), permission
final PlayerInteractEvent.Action action, );
final EntityPlayer player) {
final IInterdictionMatrix interdictionMatrix =
getNearestInterdictionMatrix(world, position);
return interdictionMatrix == null ||
hasPermission(world, position, interdictionMatrix, action, player);
}
public static boolean
hasPermission(final World world, final Vector3 position,
final IInterdictionMatrix interdictionMatrix,
final PlayerInteractEvent.Action action,
final EntityPlayer player) {
boolean hasPermission = true;
if (action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK &&
position.getTileEntity((IBlockAccess)world) != null &&
interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleBlockAccess, new int[0]) > 0) {
hasPermission = false;
if (isPermittedByInterdictionMatrix(interdictionMatrix,
player.getDisplayName(),
Permission.BLOCK_ACCESS)) {
hasPermission = true;
}
} }
if (hasPermission &&
interdictionMatrix.getModuleCount( public static boolean hasPermission(
ModularForceFieldSystem.itemModuleBlockAlter, new int[0]) > 0 && final World world,
(player.getCurrentEquippedItem() != null || final Vector3 position,
action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) { final PlayerInteractEvent.Action action,
hasPermission = false; final EntityPlayer player
if (isPermittedByInterdictionMatrix(interdictionMatrix, ) {
player.getDisplayName(), final IInterdictionMatrix interdictionMatrix
Permission.BLOCK_ALTER)) { = getNearestInterdictionMatrix(world, position);
hasPermission = true; return interdictionMatrix == null
} || hasPermission(world, position, interdictionMatrix, action, player);
}
public static boolean hasPermission(
final World world,
final Vector3 position,
final IInterdictionMatrix interdictionMatrix,
final PlayerInteractEvent.Action action,
final EntityPlayer player
) {
boolean hasPermission = true;
if (action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
&& position.getTileEntity((IBlockAccess) world) != null
&& interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleBlockAccess, new int[0]
) > 0) {
hasPermission = false;
if (isPermittedByInterdictionMatrix(
interdictionMatrix, player.getDisplayName(), Permission.BLOCK_ACCESS
)) {
hasPermission = true;
}
}
if (hasPermission
&& interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleBlockAlter, new int[0]
) > 0
&& (player.getCurrentEquippedItem() != null
|| action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) {
hasPermission = false;
if (isPermittedByInterdictionMatrix(
interdictionMatrix, player.getDisplayName(), Permission.BLOCK_ALTER
)) {
hasPermission = true;
}
}
return hasPermission;
} }
return hasPermission;
}
} }

View File

@ -8,60 +8,71 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ManipulatorHelper { public class ManipulatorHelper {
public static void setBlockSneaky(final World world, final Vector3 position, public static void setBlockSneaky(
final Block id, final int metadata, final World world,
final TileEntity tileEntity) { final Vector3 position,
final Chunk chunk = world.getChunkFromChunkCoords(position.intX() >> 4, final Block id,
position.intZ() >> 4); final int metadata,
final Vector3 chunkPosition = new Vector3( final TileEntity tileEntity
position.intX() & 0xF, position.intY() & 0xF, position.intZ() & 0xF); ) {
final int heightMapIndex = chunkPosition.intZ() << 4 | chunkPosition.intX(); final Chunk chunk
if (position.intY() >= chunk.precipitationHeightMap[heightMapIndex] - 1) { = world.getChunkFromChunkCoords(position.intX() >> 4, position.intZ() >> 4);
chunk.precipitationHeightMap[heightMapIndex] = -999; final Vector3 chunkPosition = new Vector3(
} position.intX() & 0xF, position.intY() & 0xF, position.intZ() & 0xF
final int heightMapValue = chunk.heightMap[heightMapIndex]; );
world.removeTileEntity(position.intX(), position.intY(), position.intZ()); final int heightMapIndex = chunkPosition.intZ() << 4 | chunkPosition.intX();
ExtendedBlockStorage extendedBlockStorage = if (position.intY() >= chunk.precipitationHeightMap[heightMapIndex] - 1) {
chunk.getBlockStorageArray()[position.intY() >> 4]; chunk.precipitationHeightMap[heightMapIndex] = -999;
if (extendedBlockStorage == null) {
extendedBlockStorage = new ExtendedBlockStorage(position.intY() >> 4 << 4,
!world.provider.hasNoSky);
chunk.getBlockStorageArray()[position.intY() >> 4] = extendedBlockStorage;
}
extendedBlockStorage.func_150818_a(
chunkPosition.intX(), chunkPosition.intY(), chunkPosition.intZ(), id);
extendedBlockStorage.setExtBlockMetadata(chunkPosition.intX(),
chunkPosition.intY(),
chunkPosition.intZ(), metadata);
if (position.intY() >= heightMapValue) {
chunk.generateSkylightMap();
} else {
if (chunk.func_150808_b(chunkPosition.intX(), position.intY(),
chunkPosition.intZ()) > 0) {
if (position.intY() >= heightMapValue) {
relightBlock(chunk,
Vector3.add(chunkPosition, new Vector3(0.0, 1.0, 0.0)));
} }
} else if (position.intY() == heightMapValue - 1) { final int heightMapValue = chunk.heightMap[heightMapIndex];
relightBlock(chunk, chunkPosition); world.removeTileEntity(position.intX(), position.intY(), position.intZ());
} ExtendedBlockStorage extendedBlockStorage
propagateSkylightOcclusion(chunk, chunkPosition); = chunk.getBlockStorageArray()[position.intY() >> 4];
if (extendedBlockStorage == null) {
extendedBlockStorage = new ExtendedBlockStorage(
position.intY() >> 4 << 4, !world.provider.hasNoSky
);
chunk.getBlockStorageArray()[position.intY() >> 4] = extendedBlockStorage;
}
extendedBlockStorage.func_150818_a(
chunkPosition.intX(), chunkPosition.intY(), chunkPosition.intZ(), id
);
extendedBlockStorage.setExtBlockMetadata(
chunkPosition.intX(), chunkPosition.intY(), chunkPosition.intZ(), metadata
);
if (position.intY() >= heightMapValue) {
chunk.generateSkylightMap();
} else {
if (chunk.func_150808_b(
chunkPosition.intX(), position.intY(), chunkPosition.intZ()
)
> 0) {
if (position.intY() >= heightMapValue) {
relightBlock(
chunk, Vector3.add(chunkPosition, new Vector3(0.0, 1.0, 0.0))
);
}
} else if (position.intY() == heightMapValue - 1) {
relightBlock(chunk, chunkPosition);
}
propagateSkylightOcclusion(chunk, chunkPosition);
}
chunk.isModified = true;
world.func_147451_t(position.intX(), position.intY(), position.intZ());
if (tileEntity != null) {
world.setTileEntity(
position.intX(), position.intY(), position.intZ(), tileEntity
);
}
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
} }
chunk.isModified = true;
world.func_147451_t(position.intX(), position.intY(), position.intZ()); public static void relightBlock(final Chunk chunk, final Vector3 position) {
if (tileEntity != null) { chunk.relightBlock(position.intX(), position.intY(), position.intZ());
world.setTileEntity(position.intX(), position.intY(), position.intZ(),
tileEntity);
} }
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
}
public static void relightBlock(final Chunk chunk, final Vector3 position) { public static void
chunk.relightBlock(position.intX(), position.intY(), position.intZ()); propagateSkylightOcclusion(final Chunk chunk, final Vector3 position) {
} chunk.propagateSkylightOcclusion(position.intX(), position.intZ());
}
public static void propagateSkylightOcclusion(final Chunk chunk,
final Vector3 position) {
chunk.propagateSkylightOcclusion(position.intX(), position.intZ());
}
} }

View File

@ -1,5 +1,8 @@
package mffs; package mffs;
import java.util.Arrays;
import java.util.logging.Logger;
import calclavia.lib.UniversalRecipes; import calclavia.lib.UniversalRecipes;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
@ -14,8 +17,6 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import java.util.Arrays;
import java.util.logging.Logger;
import mffs.base.BlockBase; import mffs.base.BlockBase;
import mffs.base.BlockMachine; import mffs.base.BlockMachine;
import mffs.base.ItemBase; import mffs.base.ItemBase;
@ -74,279 +75,290 @@ import net.minecraftforge.fluids.FluidRegistry;
import universalelectricity.prefab.CustomDamageSource; import universalelectricity.prefab.CustomDamageSource;
import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.TranslationHelper;
@Mod(modid = "MFFS", name = "Modular Force Field System", version = ModularForceFieldSystem.VERSION, @Mod(
useMetadata = true, dependencies = "required-after:basiccomponents;after:IC2") modid = "MFFS",
name = "Modular Force Field System",
version = ModularForceFieldSystem.VERSION,
useMetadata = true,
dependencies = "required-after:basiccomponents;after:IC2"
)
public class ModularForceFieldSystem { public class ModularForceFieldSystem {
public static final String CHANNEL = "MFFS"; public static final String CHANNEL = "MFFS";
public static final String ID = "MFFS"; public static final String ID = "MFFS";
public static final String NAME = "Modular Force Field System"; public static final String NAME = "Modular Force Field System";
public static final String PREFIX = "mffs:"; public static final String PREFIX = "mffs:";
public static final String VERSION = "{VERSION}"; public static final String VERSION = "{VERSION}";
@Mod.Instance("MFFS") public static ModularForceFieldSystem instance; @Mod.Instance("MFFS")
@Mod.Metadata("MFFS") public static ModMetadata metadata; public static ModularForceFieldSystem instance;
@SidedProxy(clientSide = "mffs.ClientProxy", serverSide = "mffs.CommonProxy") @Mod.Metadata("MFFS")
public static CommonProxy proxy; public static ModMetadata metadata;
public static final Logger LOGGER; @SidedProxy(clientSide = "mffs.ClientProxy", serverSide = "mffs.CommonProxy")
public static final String RESOURCE_DIRECTORY = "/mods/mffs/"; public static CommonProxy proxy;
public static final String LANGUAGE_DIRECTORY = "/mods/mffs/languages/"; public static final Logger LOGGER;
public static final String TEXTURE_DIRECTORY = "/mods/mffs/textures/"; public static final String RESOURCE_DIRECTORY = "/mods/mffs/";
public static final String BLOCK_DIRECTORY = "/mods/mffs/textures/blocks/"; public static final String LANGUAGE_DIRECTORY = "/mods/mffs/languages/";
public static final String ITEM_DIRECTORY = "/mods/mffs/textures/items/"; public static final String TEXTURE_DIRECTORY = "/mods/mffs/textures/";
public static final String MODEL_DIRECTORY = "/mods/mffs/textures/models/"; public static final String BLOCK_DIRECTORY = "/mods/mffs/textures/blocks/";
public static final String GUI_DIRECTORY = "/mods/mffs/textures/gui/"; public static final String ITEM_DIRECTORY = "/mods/mffs/textures/items/";
public static final String GUI_BASE_DIRECTORY = public static final String MODEL_DIRECTORY = "/mods/mffs/textures/models/";
"/mods/mffs/textures/gui/gui_base.png"; public static final String GUI_DIRECTORY = "/mods/mffs/textures/gui/";
public static final String GUI_COMPONENTS = public static final String GUI_BASE_DIRECTORY
"/mods/mffs/textures/gui/gui_components.png"; = "/mods/mffs/textures/gui/gui_base.png";
public static final String GUI_BUTTON = public static final String GUI_COMPONENTS
"/mods/mffs/textures/gui/gui_button.png"; = "/mods/mffs/textures/gui/gui_components.png";
public static BlockMachine blockCoercionDeriver; public static final String GUI_BUTTON = "/mods/mffs/textures/gui/gui_button.png";
public static BlockMachine blockFortronCapacitor; public static BlockMachine blockCoercionDeriver;
public static BlockMachine blockForceFieldProjector; public static BlockMachine blockFortronCapacitor;
public static BlockMachine blockBiometricIdentifier; public static BlockMachine blockForceFieldProjector;
public static BlockMachine blockInterdictionMatrix; public static BlockMachine blockBiometricIdentifier;
public static BlockMachine blockForceManipulator; public static BlockMachine blockInterdictionMatrix;
public static BlockBase blockForceField; public static BlockMachine blockForceManipulator;
public static Item itemRemoteController; public static BlockBase blockForceField;
public static Item itemFocusMatrix; public static Item itemRemoteController;
public static ItemCard itemCardBlank; public static Item itemFocusMatrix;
public static ItemCard itemCardInfinite; public static ItemCard itemCardBlank;
public static ItemCard itemCardFrequency; public static ItemCard itemCardInfinite;
public static ItemCard itemCardID; public static ItemCard itemCardFrequency;
public static ItemCard itemCardLink; public static ItemCard itemCardID;
public static ItemMode itemModeCube; public static ItemCard itemCardLink;
public static ItemMode itemModeSphere; public static ItemMode itemModeCube;
public static ItemMode itemModeTube; public static ItemMode itemModeSphere;
public static ItemMode itemModeCylinder; public static ItemMode itemModeTube;
public static ItemMode itemModePyramid; public static ItemMode itemModeCylinder;
public static ItemMode itemModeCustom; public static ItemMode itemModePyramid;
public static ItemModule itemModuleSpeed; public static ItemMode itemModeCustom;
public static ItemModule itemModuleCapacity; public static ItemModule itemModuleSpeed;
public static ItemModule itemModuleTranslate; public static ItemModule itemModuleCapacity;
public static ItemModule itemModuleScale; public static ItemModule itemModuleTranslate;
public static ItemModule itemModuleRotate; public static ItemModule itemModuleScale;
public static ItemModule itemModuleCollection; public static ItemModule itemModuleRotate;
public static ItemModule itemModuleInvert; public static ItemModule itemModuleCollection;
public static ItemModule itemModuleSilence; public static ItemModule itemModuleInvert;
public static ItemModule itemModuleFusion; public static ItemModule itemModuleSilence;
public static ItemModule itemModuleManipulator; public static ItemModule itemModuleFusion;
public static ItemModule itemModuleCamouflage; public static ItemModule itemModuleManipulator;
public static ItemModule itemModuleDisintegration; public static ItemModule itemModuleCamouflage;
public static ItemModule itemModuleShock; public static ItemModule itemModuleDisintegration;
public static ItemModule itemModuleGlow; public static ItemModule itemModuleShock;
public static ItemModule itemModuleSponge; public static ItemModule itemModuleGlow;
public static ItemModule itemModuleStablize; public static ItemModule itemModuleSponge;
public static ItemModule itemModuleAntiHostile; public static ItemModule itemModuleStablize;
public static ItemModule itemModuleAntiFriendly; public static ItemModule itemModuleAntiHostile;
public static ItemModule itemModuleAntiPersonnel; public static ItemModule itemModuleAntiFriendly;
public static ItemModule itemModuleConfiscate; public static ItemModule itemModuleAntiPersonnel;
public static ItemModule itemModuleWarn; public static ItemModule itemModuleConfiscate;
public static ItemModule itemModuleBlockAccess; public static ItemModule itemModuleWarn;
public static ItemModule itemModuleBlockAlter; public static ItemModule itemModuleBlockAccess;
public static ItemModule itemModuleAntiSpawn; public static ItemModule itemModuleBlockAlter;
public static DamageSource damagefieldShock; public static ItemModule itemModuleAntiSpawn;
public static DamageSource damagefieldShock;
public static SimpleNetworkWrapper channel; public static SimpleNetworkWrapper channel;
@EventHandler @EventHandler
public void preInit(final FMLPreInitializationEvent event) { public void preInit(final FMLPreInitializationEvent event) {
NetworkRegistry.INSTANCE.registerGuiHandler( NetworkRegistry.INSTANCE.registerGuiHandler(
(Object)this, (IGuiHandler)ModularForceFieldSystem.proxy); (Object) this, (IGuiHandler) ModularForceFieldSystem.proxy
MinecraftForge.EVENT_BUS.register((Object) new SubscribeEventHandler()); );
Settings.load(); MinecraftForge.EVENT_BUS.register((Object) new SubscribeEventHandler());
Settings.CONFIGURATION.load(); Settings.load();
ModularForceFieldSystem.blockForceField = new BlockForceField(); Settings.CONFIGURATION.load();
ModularForceFieldSystem.blockCoercionDeriver = new BlockCoercionDeriver(); ModularForceFieldSystem.blockForceField = new BlockForceField();
ModularForceFieldSystem.blockFortronCapacitor = new BlockFortronCapacitor(); ModularForceFieldSystem.blockCoercionDeriver = new BlockCoercionDeriver();
ModularForceFieldSystem.blockForceFieldProjector = ModularForceFieldSystem.blockFortronCapacitor = new BlockFortronCapacitor();
new BlockForceFieldProjector(); ModularForceFieldSystem.blockForceFieldProjector = new BlockForceFieldProjector();
ModularForceFieldSystem.blockBiometricIdentifier = ModularForceFieldSystem.blockBiometricIdentifier = new BlockBiometricIdentifier();
new BlockBiometricIdentifier(); ModularForceFieldSystem.blockInterdictionMatrix = new BlockInterdictionMatrix();
ModularForceFieldSystem.blockInterdictionMatrix = ModularForceFieldSystem.blockForceManipulator = new BlockForceManipulator();
new BlockInterdictionMatrix(); ModularForceFieldSystem.itemRemoteController = new ItemRemoteController();
ModularForceFieldSystem.blockForceManipulator = new BlockForceManipulator(); ModularForceFieldSystem.itemFocusMatrix = new ItemBase("focusMatrix");
ModularForceFieldSystem.itemRemoteController = new ItemRemoteController(); ModularForceFieldSystem.itemModeCube = new ItemModeCube(Settings.getNextItemID());
ModularForceFieldSystem.itemFocusMatrix = new ItemBase("focusMatrix"); ModularForceFieldSystem.itemModeSphere
ModularForceFieldSystem.itemModeCube = = new ItemModeSphere(Settings.getNextItemID());
new ItemModeCube(Settings.getNextItemID()); ModularForceFieldSystem.itemModeTube = new ItemModeTube();
ModularForceFieldSystem.itemModeSphere = ModularForceFieldSystem.itemModePyramid = new ItemModePyramid();
new ItemModeSphere(Settings.getNextItemID()); ModularForceFieldSystem.itemModeCylinder = new ItemModeCylinder();
ModularForceFieldSystem.itemModeTube = new ItemModeTube(); ModularForceFieldSystem.itemModeCustom = new ItemModeCustom();
ModularForceFieldSystem.itemModePyramid = new ItemModePyramid(); ModularForceFieldSystem.itemModuleTranslate
ModularForceFieldSystem.itemModeCylinder = new ItemModeCylinder(); = new ItemModule("moduleTranslate").setCost(1.6f);
ModularForceFieldSystem.itemModeCustom = new ItemModeCustom(); ModularForceFieldSystem.itemModuleScale
ModularForceFieldSystem.itemModuleTranslate = = new ItemModule("moduleScale").setCost(1.2f);
new ItemModule("moduleTranslate").setCost(1.6f); ModularForceFieldSystem.itemModuleRotate
ModularForceFieldSystem.itemModuleScale = = new ItemModule("moduleRotate").setCost(0.1f);
new ItemModule("moduleScale").setCost(1.2f); ModularForceFieldSystem.itemModuleSpeed
ModularForceFieldSystem.itemModuleRotate = = new ItemModule("moduleSpeed").setCost(1.0f);
new ItemModule("moduleRotate").setCost(0.1f); ModularForceFieldSystem.itemModuleCapacity
ModularForceFieldSystem.itemModuleSpeed = = new ItemModule("moduleCapacity").setCost(0.5f);
new ItemModule("moduleSpeed").setCost(1.0f); ModularForceFieldSystem.itemModuleFusion = new ItemModuleFusion();
ModularForceFieldSystem.itemModuleCapacity = ModularForceFieldSystem.itemModuleManipulator = new ItemModuleManipulator();
new ItemModule("moduleCapacity").setCost(0.5f); ModularForceFieldSystem.itemModuleCamouflage
ModularForceFieldSystem.itemModuleFusion = new ItemModuleFusion(); = new ItemModule("moduleCamouflage").setCost(1.5f).setMaxStackSize(1);
ModularForceFieldSystem.itemModuleManipulator = new ItemModuleManipulator(); ModularForceFieldSystem.itemModuleDisintegration = new ItemModuleDisintegration();
ModularForceFieldSystem.itemModuleCamouflage = ModularForceFieldSystem.itemModuleShock = new ItemModuleShock();
new ItemModule("moduleCamouflage").setCost(1.5f).setMaxStackSize(1); ModularForceFieldSystem.itemModuleGlow = new ItemModule("moduleGlow");
ModularForceFieldSystem.itemModuleDisintegration = ModularForceFieldSystem.itemModuleSponge = new ItemModuleSponge();
new ItemModuleDisintegration(); ModularForceFieldSystem.itemModuleStablize = new ItemModuleStablize();
ModularForceFieldSystem.itemModuleShock = new ItemModuleShock(); ModularForceFieldSystem.itemModuleAntiFriendly = new ItemModuleAntiFriendly();
ModularForceFieldSystem.itemModuleGlow = new ItemModule("moduleGlow"); ModularForceFieldSystem.itemModuleAntiHostile = new ItemModuleAntiHostile();
ModularForceFieldSystem.itemModuleSponge = new ItemModuleSponge(); ModularForceFieldSystem.itemModuleAntiPersonnel = new ItemModuleAntiPersonnel();
ModularForceFieldSystem.itemModuleStablize = new ItemModuleStablize(); ModularForceFieldSystem.itemModuleConfiscate = new ItemModuleConfiscate();
ModularForceFieldSystem.itemModuleAntiFriendly = ModularForceFieldSystem.itemModuleWarn = new ItemModuleWarn();
new ItemModuleAntiFriendly(); ModularForceFieldSystem.itemModuleBlockAccess
ModularForceFieldSystem.itemModuleAntiHostile = new ItemModuleAntiHostile(); = new ItemModuleInterdictionMatrix("moduleBlockAccess").setCost(10.0f);
ModularForceFieldSystem.itemModuleAntiPersonnel = ModularForceFieldSystem.itemModuleBlockAlter
new ItemModuleAntiPersonnel(); = new ItemModuleInterdictionMatrix("moduleBlockAlter").setCost(15.0f);
ModularForceFieldSystem.itemModuleConfiscate = new ItemModuleConfiscate(); ModularForceFieldSystem.itemModuleAntiSpawn
ModularForceFieldSystem.itemModuleWarn = new ItemModuleWarn(); = new ItemModuleInterdictionMatrix("moduleAntiSpawn").setCost(10.0f);
ModularForceFieldSystem.itemModuleBlockAccess = ModularForceFieldSystem.itemCardBlank = new ItemCard("cardBlank");
new ItemModuleInterdictionMatrix("moduleBlockAccess").setCost(10.0f); ModularForceFieldSystem.itemCardFrequency = new ItemCardFrequency();
ModularForceFieldSystem.itemModuleBlockAlter = ModularForceFieldSystem.itemCardLink = new ItemCardLink();
new ItemModuleInterdictionMatrix("moduleBlockAlter").setCost(15.0f); ModularForceFieldSystem.itemCardID = new ItemCardID();
ModularForceFieldSystem.itemModuleAntiSpawn = ModularForceFieldSystem.itemCardInfinite = new ItemCardInfinite();
new ItemModuleInterdictionMatrix("moduleAntiSpawn").setCost(10.0f); FortronHelper.FLUID_FORTRON = new Fluid("fortron");
ModularForceFieldSystem.itemCardBlank = new ItemCard("cardBlank"); ModularForceFieldSystem.itemModuleCollection
ModularForceFieldSystem.itemCardFrequency = new ItemCardFrequency(); = new ItemModule("moduleCollection").setMaxStackSize(1).setCost(15.0f);
ModularForceFieldSystem.itemCardLink = new ItemCardLink(); ModularForceFieldSystem.itemModuleInvert
ModularForceFieldSystem.itemCardID = new ItemCardID(); = new ItemModule("moduleInvert").setMaxStackSize(1).setCost(15.0f);
ModularForceFieldSystem.itemCardInfinite = new ItemCardInfinite(); ModularForceFieldSystem.itemModuleSilence
FortronHelper.FLUID_FORTRON = new Fluid("fortron"); = new ItemModule("moduleSilence").setMaxStackSize(1).setCost(1.0f);
ModularForceFieldSystem.itemModuleCollection = Settings.CONFIGURATION.save();
new ItemModule("moduleCollection").setMaxStackSize(1).setCost(15.0f); GameRegistry.registerBlock(
ModularForceFieldSystem.itemModuleInvert = (Block) ModularForceFieldSystem.blockForceField, "blockForceField"
new ItemModule("moduleInvert").setMaxStackSize(1).setCost(15.0f); );
ModularForceFieldSystem.itemModuleSilence = GameRegistry.registerBlock(
new ItemModule("moduleSilence").setMaxStackSize(1).setCost(1.0f); (Block) ModularForceFieldSystem.blockCoercionDeriver,
Settings.CONFIGURATION.save();
GameRegistry.registerBlock((Block)ModularForceFieldSystem.blockForceField,
"blockForceField");
GameRegistry.registerBlock(
(Block)ModularForceFieldSystem.blockCoercionDeriver,
"blockCoercionDeriver"); "blockCoercionDeriver"
GameRegistry.registerBlock( );
(Block)ModularForceFieldSystem.blockFortronCapacitor, GameRegistry.registerBlock(
"blockFortronCapacitor"); (Block) ModularForceFieldSystem.blockFortronCapacitor, "blockFortronCapacitor"
GameRegistry.registerBlock( );
(Block)ModularForceFieldSystem.blockForceFieldProjector, GameRegistry.registerBlock(
"blockForceFieldProjector"); (Block) ModularForceFieldSystem.blockForceFieldProjector,
GameRegistry.registerBlock( "blockForceFieldProjector"
(Block)ModularForceFieldSystem.blockBiometricIdentifier, );
"blockBiometricIdentifier"); GameRegistry.registerBlock(
GameRegistry.registerBlock( (Block) ModularForceFieldSystem.blockBiometricIdentifier,
(Block)ModularForceFieldSystem.blockInterdictionMatrix, "blockBiometricIdentifier"
"blockInterdictionMatrix"); );
GameRegistry.registerBlock( GameRegistry.registerBlock(
(Block)ModularForceFieldSystem.blockForceManipulator, (Block) ModularForceFieldSystem.blockInterdictionMatrix,
"blockForceManipulator" "blockInterdictionMatrix"
);
GameRegistry.registerBlock(
(Block) ModularForceFieldSystem.blockForceManipulator, "blockForceManipulator"
); );
GameRegistry.registerTileEntity(TileEntityForceField.class, GameRegistry.registerTileEntity(TileEntityForceField.class, "tileForceField");
"tileForceField"); GameRegistry.registerTileEntity(
GameRegistry.registerTileEntity(TileEntityCoercionDeriver.class, TileEntityCoercionDeriver.class, "tileCoercionDeriver"
"tileCoercionDeriver"); );
GameRegistry.registerTileEntity(TileEntityFortronCapacitor.class, GameRegistry.registerTileEntity(
"tileFortronCapacitor"); TileEntityFortronCapacitor.class, "tileFortronCapacitor"
GameRegistry.registerTileEntity(TileEntityForceFieldProjector.class, );
"tileForceFieldProjector"); GameRegistry.registerTileEntity(
GameRegistry.registerTileEntity(TileEntityBiometricIdentifier.class, TileEntityForceFieldProjector.class, "tileForceFieldProjector"
"tileBiometricIdentifier"); );
GameRegistry.registerTileEntity(TileEntityInterdictionMatrix.class, GameRegistry.registerTileEntity(
"tileInterdictionMatrix"); TileEntityBiometricIdentifier.class, "tileBiometricIdentifier"
GameRegistry.registerTileEntity(TileEntityForceManipulator.class, );
"tileForceManipulator"); GameRegistry.registerTileEntity(
TileEntityInterdictionMatrix.class, "tileInterdictionMatrix"
);
GameRegistry.registerTileEntity(
TileEntityForceManipulator.class, "tileForceManipulator"
);
ModularForceFieldSystem.proxy.preInit(); ModularForceFieldSystem.proxy.preInit();
FluidRegistry.registerFluid(FortronHelper.FLUID_FORTRON); FluidRegistry.registerFluid(FortronHelper.FLUID_FORTRON);
GameRegistry.registerItem(itemRemoteController, "itemRemoteController"); GameRegistry.registerItem(itemRemoteController, "itemRemoteController");
GameRegistry.registerItem(itemFocusMatrix, "itemFocusMatix"); GameRegistry.registerItem(itemFocusMatrix, "itemFocusMatix");
GameRegistry.registerItem(itemCardBlank, "itemCardBlank"); GameRegistry.registerItem(itemCardBlank, "itemCardBlank");
GameRegistry.registerItem(itemCardInfinite, "itemCardInfinite"); GameRegistry.registerItem(itemCardInfinite, "itemCardInfinite");
GameRegistry.registerItem(itemCardFrequency, "itemCardFrequency"); GameRegistry.registerItem(itemCardFrequency, "itemCardFrequency");
GameRegistry.registerItem(itemCardID, "itemCardID"); GameRegistry.registerItem(itemCardID, "itemCardID");
GameRegistry.registerItem(itemCardLink, "itemCardLink"); GameRegistry.registerItem(itemCardLink, "itemCardLink");
GameRegistry.registerItem(itemModeCube, "itemModeCube"); GameRegistry.registerItem(itemModeCube, "itemModeCube");
GameRegistry.registerItem(itemModeSphere, "itemModeSphere"); GameRegistry.registerItem(itemModeSphere, "itemModeSphere");
GameRegistry.registerItem(itemModeTube, "itemModeTube"); GameRegistry.registerItem(itemModeTube, "itemModeTube");
GameRegistry.registerItem(itemModeCylinder, "itemModeCylinder"); GameRegistry.registerItem(itemModeCylinder, "itemModeCylinder");
GameRegistry.registerItem(itemModePyramid, "itemModePyramid"); GameRegistry.registerItem(itemModePyramid, "itemModePyramid");
GameRegistry.registerItem(itemModeCustom, "itemModeCustom"); GameRegistry.registerItem(itemModeCustom, "itemModeCustom");
GameRegistry.registerItem(itemModuleSpeed, "itemModuleSpeed"); GameRegistry.registerItem(itemModuleSpeed, "itemModuleSpeed");
GameRegistry.registerItem(itemModuleCapacity, "itemModuleCapacity"); GameRegistry.registerItem(itemModuleCapacity, "itemModuleCapacity");
GameRegistry.registerItem(itemModuleTranslate, "itemModuleTranslate"); GameRegistry.registerItem(itemModuleTranslate, "itemModuleTranslate");
GameRegistry.registerItem(itemModuleScale, "itemModuleScale"); GameRegistry.registerItem(itemModuleScale, "itemModuleScale");
GameRegistry.registerItem(itemModuleRotate, "itemModuleRotate"); GameRegistry.registerItem(itemModuleRotate, "itemModuleRotate");
GameRegistry.registerItem(itemModuleCollection, "itemModuleCollection"); GameRegistry.registerItem(itemModuleCollection, "itemModuleCollection");
GameRegistry.registerItem(itemModuleInvert, "itemModuleInvert"); GameRegistry.registerItem(itemModuleInvert, "itemModuleInvert");
GameRegistry.registerItem(itemModuleSilence, "itemModuleSilence"); GameRegistry.registerItem(itemModuleSilence, "itemModuleSilence");
GameRegistry.registerItem(itemModuleFusion, "itemModuleFusion"); GameRegistry.registerItem(itemModuleFusion, "itemModuleFusion");
GameRegistry.registerItem(itemModuleManipulator, "itemModuleManipulator"); GameRegistry.registerItem(itemModuleManipulator, "itemModuleManipulator");
GameRegistry.registerItem(itemModuleCamouflage, "itemModuleCamouflage"); GameRegistry.registerItem(itemModuleCamouflage, "itemModuleCamouflage");
GameRegistry.registerItem(itemModuleDisintegration, GameRegistry.registerItem(itemModuleDisintegration, "itemModuleDisintegration");
"itemModuleDisintegration"); GameRegistry.registerItem(itemModuleShock, "itemModuleShock");
GameRegistry.registerItem(itemModuleShock, "itemModuleShock"); GameRegistry.registerItem(itemModuleGlow, "itemModuleGlow");
GameRegistry.registerItem(itemModuleGlow, "itemModuleGlow"); GameRegistry.registerItem(itemModuleSponge, "itemModuleSponge");
GameRegistry.registerItem(itemModuleSponge, "itemModuleSponge"); GameRegistry.registerItem(itemModuleStablize, "itemModuleStablize");
GameRegistry.registerItem(itemModuleStablize, "itemModuleStablize"); GameRegistry.registerItem(itemModuleAntiHostile, "itemModuleAntiHostile");
GameRegistry.registerItem(itemModuleAntiHostile, "itemModuleAntiHostile"); GameRegistry.registerItem(itemModuleAntiFriendly, "itemModuleAntiFriendly");
GameRegistry.registerItem(itemModuleAntiFriendly, "itemModuleAntiFriendly"); GameRegistry.registerItem(itemModuleAntiPersonnel, "itemModuleAntiPersonnel");
GameRegistry.registerItem(itemModuleAntiPersonnel, GameRegistry.registerItem(itemModuleConfiscate, "itemModuleConfiscate");
"itemModuleAntiPersonnel"); GameRegistry.registerItem(itemModuleWarn, "itemModuleWarn");
GameRegistry.registerItem(itemModuleConfiscate, "itemModuleConfiscate"); GameRegistry.registerItem(itemModuleBlockAccess, "itemModuleBlockAccess");
GameRegistry.registerItem(itemModuleWarn, "itemModuleWarn"); GameRegistry.registerItem(itemModuleBlockAlter, "itemModuleBlockAlter");
GameRegistry.registerItem(itemModuleBlockAccess, "itemModuleBlockAccess"); GameRegistry.registerItem(itemModuleAntiSpawn, "itemModuleAntiSpawn");
GameRegistry.registerItem(itemModuleBlockAlter, "itemModuleBlockAlter");
GameRegistry.registerItem(itemModuleAntiSpawn, "itemModuleAntiSpawn");
channel = channel = NetworkRegistry.INSTANCE.newSimpleChannel("mffs");
NetworkRegistry.INSTANCE.newSimpleChannel("mffs");
int pkgDiscriminator = 0;
channel.registerMessage(PacketTileHandler.class, PacketTile.class,
pkgDiscriminator++, Side.SERVER);
channel.registerMessage(PacketFxsHandler.class, PacketFxs.class,
pkgDiscriminator++, Side.CLIENT);
}
@EventHandler int pkgDiscriminator = 0;
public void load(final FMLInitializationEvent evt) { channel.registerMessage(
ModularForceFieldSystem.LOGGER.fine( PacketTileHandler.class, PacketTile.class, pkgDiscriminator++, Side.SERVER
"Language(s) Loaded: " + );
TranslationHelper.loadLanguages( channel.registerMessage(
"/assets/mffs/lang/", new String[] {"en_US", "zh_CN", "de_DE"})); PacketFxsHandler.class, PacketFxs.class, pkgDiscriminator++, Side.CLIENT
ModularForceFieldSystem.metadata.modId = "MFFS"; );
ModularForceFieldSystem.metadata.name = "Modular Force Field System"; }
ModularForceFieldSystem.metadata.description =
"Modular Force Field System is a mod that adds force fields, high tech machinery and defensive measures to Minecraft.";
ModularForceFieldSystem.metadata.url =
"http://www.universalelectricity.com/mffs/";
ModularForceFieldSystem.metadata.logoFile = "mffs_logo.png";
ModularForceFieldSystem.metadata.version = VERSION;
ModularForceFieldSystem.metadata.authorList = Arrays.asList("Calclavia", "LordMZTE", "tilera");
ModularForceFieldSystem.metadata.credits = "Please visit the website.";
ModularForceFieldSystem.metadata.autogenerated = false;
}
@EventHandler @EventHandler
public void postInit(final FMLPostInitializationEvent evt) { public void load(final FMLInitializationEvent evt) {
UniversalRecipes.init(); ModularForceFieldSystem.LOGGER.fine(
Recipes.registerRecipes(); "Language(s) Loaded: "
ModularForceFieldSystem.proxy.init(); + TranslationHelper.loadLanguages(
} "/assets/mffs/lang/", new String[] { "en_US", "zh_CN", "de_DE" }
)
);
ModularForceFieldSystem.metadata.modId = "MFFS";
ModularForceFieldSystem.metadata.name = "Modular Force Field System";
ModularForceFieldSystem.metadata.description
= "Modular Force Field System is a mod that adds force fields, high tech machinery and defensive measures to Minecraft.";
ModularForceFieldSystem.metadata.url
= "http://www.universalelectricity.com/mffs/";
ModularForceFieldSystem.metadata.logoFile = "mffs_logo.png";
ModularForceFieldSystem.metadata.version = VERSION;
ModularForceFieldSystem.metadata.authorList
= Arrays.asList("Calclavia", "LordMZTE", "tilera");
ModularForceFieldSystem.metadata.credits = "Please visit the website.";
ModularForceFieldSystem.metadata.autogenerated = false;
}
@EventHandler @EventHandler
public void serverStarting(final FMLServerStartingEvent evt) { public void postInit(final FMLPostInitializationEvent evt) {
FrequencyGrid.reinitiate(); UniversalRecipes.init();
} Recipes.registerRecipes();
ModularForceFieldSystem.proxy.init();
}
static { @EventHandler
LOGGER = Logger.getLogger("Modular Force Field System"); public void serverStarting(final FMLServerStartingEvent evt) {
ModularForceFieldSystem.damagefieldShock = FrequencyGrid.reinitiate();
new CustomDamageSource("fieldShock").setDamageBypassesArmor(); }
}
static {
LOGGER = Logger.getLogger("Modular Force Field System");
ModularForceFieldSystem.damagefieldShock
= new CustomDamageSource("fieldShock").setDamageBypassesArmor();
}
} }

View File

@ -9,323 +9,324 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class Recipes { public class Recipes {
public static void registerRecipes() { public static void registerRecipes() {
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemFocusMatrix, 9) .output(ModularForceFieldSystem.itemFocusMatrix, 9)
.pattern("RMR", "MDM", "RMR") .pattern("RMR", "MDM", "RMR")
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.ingredient('D', Items.diamond) .ingredient('D', Items.diamond)
.ingredient('R', Items.redstone) .ingredient('R', Items.redstone)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemRemoteController) .output(ModularForceFieldSystem.itemRemoteController)
.pattern("WWW", "MCM", "MCM") .pattern("WWW", "MCM", "MCM")
.ingredient('W', BasicComponents.blockCopperWire) .ingredient('W', BasicComponents.blockCopperWire)
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.ingredient('C', BasicComponents.itemBattery) .ingredient('C', BasicComponents.itemBattery)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.blockCoercionDeriver) .output(ModularForceFieldSystem.blockCoercionDeriver)
.pattern("M M", "MFM", "MCM") .pattern("M M", "MFM", "MCM")
.ingredient('C', BasicComponents.itemBattery) .ingredient('C', BasicComponents.itemBattery)
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.blockFortronCapacitor) .output(ModularForceFieldSystem.blockFortronCapacitor)
.pattern("MFM", "FCF", "MFM") .pattern("MFM", "FCF", "MFM")
.ingredient('C', BasicComponents.itemBattery) .ingredient('C', BasicComponents.itemBattery)
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.blockForceFieldProjector) .output(ModularForceFieldSystem.blockForceFieldProjector)
.pattern(" D ", "FFF", "MCM") .pattern(" D ", "FFF", "MCM")
.ingredient('D', Items.diamond) .ingredient('D', Items.diamond)
.ingredient('C', BasicComponents.itemBattery) .ingredient('C', BasicComponents.itemBattery)
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.blockBiometricIdentifier) .output(ModularForceFieldSystem.blockBiometricIdentifier)
.pattern("FMF", "MCM", "FMF") .pattern("FMF", "MCM", "FMF")
.ingredient('C', ModularForceFieldSystem.itemCardBlank) .ingredient('C', ModularForceFieldSystem.itemCardBlank)
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.blockInterdictionMatrix) .output(ModularForceFieldSystem.blockInterdictionMatrix)
.pattern("SSS", "FFF", "FEF") .pattern("SSS", "FFF", "FEF")
.ingredient('S', ModularForceFieldSystem.itemModuleShock) .ingredient('S', ModularForceFieldSystem.itemModuleShock)
.ingredient('E', Blocks.ender_chest) .ingredient('E', Blocks.ender_chest)
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.blockForceManipulator) .output(ModularForceFieldSystem.blockForceManipulator)
.pattern("F F", "FMF", "F F") .pattern("F F", "FMF", "F F")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('M', BasicComponents.itemMotor) .ingredient('M', BasicComponents.itemMotor)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemCardBlank) .output(ModularForceFieldSystem.itemCardBlank)
.pattern("PPP", "PMP", "PPP") .pattern("PPP", "PMP", "PPP")
.ingredient('M', "ingotSteel") .ingredient('M', "ingotSteel")
.ingredient('P', Items.paper) .ingredient('P', Items.paper)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemCardLink) .output(ModularForceFieldSystem.itemCardLink)
.pattern("BWB") .pattern("BWB")
.ingredient('B', ModularForceFieldSystem.itemCardBlank) .ingredient('B', ModularForceFieldSystem.itemCardBlank)
.ingredient('W', BasicComponents.blockCopperWire) .ingredient('W', BasicComponents.blockCopperWire)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemCardLink) .output(ModularForceFieldSystem.itemCardLink)
.pattern("WBW") .pattern("WBW")
.ingredient('B', ModularForceFieldSystem.itemCardFrequency) .ingredient('B', ModularForceFieldSystem.itemCardFrequency)
.ingredient('W', BasicComponents.blockCopperWire) .ingredient('W', BasicComponents.blockCopperWire)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemCardID) .output(ModularForceFieldSystem.itemCardID)
.pattern("RBR") .pattern("RBR")
.ingredient('B', ModularForceFieldSystem.itemCardBlank) .ingredient('B', ModularForceFieldSystem.itemCardBlank)
.ingredient('R', Items.redstone) .ingredient('R', Items.redstone)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModeSphere) .output(ModularForceFieldSystem.itemModeSphere)
.pattern(" F ", "FFF", " F ") .pattern(" F ", "FFF", " F ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModeCube) .output(ModularForceFieldSystem.itemModeCube)
.pattern("FFF", "FFF", "FFF") .pattern("FFF", "FFF", "FFF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModeTube) .output(ModularForceFieldSystem.itemModeTube)
.pattern("FFF", " ", "FFF") .pattern("FFF", " ", "FFF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModePyramid) .output(ModularForceFieldSystem.itemModePyramid)
.pattern("F ", "FF ", "FFF") .pattern("F ", "FF ", "FFF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModeCylinder) .output(ModularForceFieldSystem.itemModeCylinder)
.pattern("S", "S", "S") .pattern("S", "S", "S")
.ingredient('S', ModularForceFieldSystem.itemModeSphere) .ingredient('S', ModularForceFieldSystem.itemModeSphere)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModeCustom) .output(ModularForceFieldSystem.itemModeCustom)
.pattern(" C ", "TFP", " S ") .pattern(" C ", "TFP", " S ")
.ingredient('S', ModularForceFieldSystem.itemModeSphere) .ingredient('S', ModularForceFieldSystem.itemModeSphere)
.ingredient('C', ModularForceFieldSystem.itemModeCube) .ingredient('C', ModularForceFieldSystem.itemModeCube)
.ingredient('T', ModularForceFieldSystem.itemModeTube) .ingredient('T', ModularForceFieldSystem.itemModeTube)
.ingredient('P', ModularForceFieldSystem.itemModePyramid) .ingredient('P', ModularForceFieldSystem.itemModePyramid)
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapelessOreRecipeAdapter()) new RecipeBuilder(new ShapelessOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModeCustom) .output(ModularForceFieldSystem.itemModeCustom)
.ingredient(ModularForceFieldSystem.itemModeCustom) .ingredient(ModularForceFieldSystem.itemModeCustom)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleSpeed) .output(ModularForceFieldSystem.itemModuleSpeed)
.pattern("FFF", "RRR", "FFF") .pattern("FFF", "RRR", "FFF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('R', Items.redstone) .ingredient('R', Items.redstone)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleCapacity) .output(ModularForceFieldSystem.itemModuleCapacity)
.pattern("FCF") .pattern("FCF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('C', BasicComponents.itemBattery) .ingredient('C', BasicComponents.itemBattery)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleShock) .output(ModularForceFieldSystem.itemModuleShock)
.pattern("FWF") .pattern("FWF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('W', BasicComponents.blockCopperWire) .ingredient('W', BasicComponents.blockCopperWire)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleSponge) .output(ModularForceFieldSystem.itemModuleSponge)
.pattern("BBB", "BFB", "BBB") .pattern("BBB", "BFB", "BBB")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('B', Items.water_bucket) .ingredient('B', Items.water_bucket)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleDisintegration) .output(ModularForceFieldSystem.itemModuleDisintegration)
.pattern(" W ", "FBF", " W ") .pattern(" W ", "FBF", " W ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('W', BasicComponents.blockCopperWire) .ingredient('W', BasicComponents.blockCopperWire)
.ingredient('B', BasicComponents.itemBattery) .ingredient('B', BasicComponents.itemBattery)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleManipulator) .output(ModularForceFieldSystem.itemModuleManipulator)
.pattern("F", " ", "F") .pattern("F", " ", "F")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleCamouflage) .output(ModularForceFieldSystem.itemModuleCamouflage)
.pattern("WFW", "FWF", "WFW") .pattern("WFW", "FWF", "WFW")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('W', new ItemStack(Blocks.wool, 1, 32767)) .ingredient('W', new ItemStack(Blocks.wool, 1, 32767))
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleFusion) .output(ModularForceFieldSystem.itemModuleFusion)
.pattern("FJF") .pattern("FJF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('J', ModularForceFieldSystem.itemModuleShock) .ingredient('J', ModularForceFieldSystem.itemModuleShock)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleScale, 2) .output(ModularForceFieldSystem.itemModuleScale, 2)
.pattern("FRF") .pattern("FRF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient( .ingredient(
'R', 'R',
Items.redstone) // this is a guess, R isnt defined in the original Items.redstone
.register(); ) // this is a guess, R isnt defined in the original
.register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleTranslate, 2) .output(ModularForceFieldSystem.itemModuleTranslate, 2)
.pattern("FSF") .pattern("FSF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('S', ModularForceFieldSystem.itemModuleScale) .ingredient('S', ModularForceFieldSystem.itemModuleScale)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleRotate) .output(ModularForceFieldSystem.itemModuleRotate)
.pattern("F ", " F ", " F") .pattern("F ", " F ", " F")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleGlow) .output(ModularForceFieldSystem.itemModuleGlow)
.pattern("GGG", "GFG", "GGG") .pattern("GGG", "GFG", "GGG")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('G', Blocks.glowstone) .ingredient('G', Blocks.glowstone)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleStablize) .output(ModularForceFieldSystem.itemModuleStablize)
.pattern("FDF", "PSA", "FDF") .pattern("FDF", "PSA", "FDF")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('P', Items.diamond_pickaxe) .ingredient('P', Items.diamond_pickaxe)
.ingredient('S', Items.diamond_shovel) .ingredient('S', Items.diamond_shovel)
.ingredient('A', Items.diamond_axe) .ingredient('A', Items.diamond_axe)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleCollection) .output(ModularForceFieldSystem.itemModuleCollection)
.pattern("F F", " H ", "F F") .pattern("F F", " H ", "F F")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('H', Blocks.hopper) .ingredient('H', Blocks.hopper)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleInvert) .output(ModularForceFieldSystem.itemModuleInvert)
.pattern("L", "F", "L") .pattern("L", "F", "L")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('L', Blocks.lapis_block) .ingredient('L', Blocks.lapis_block)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleSilence) .output(ModularForceFieldSystem.itemModuleSilence)
.pattern(" N ", "NFN", " N ") .pattern(" N ", "NFN", " N ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('N', Blocks.noteblock) .ingredient('N', Blocks.noteblock)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleAntiHostile) .output(ModularForceFieldSystem.itemModuleAntiHostile)
.pattern(" R ", "GFB", " S ") .pattern(" R ", "GFB", " S ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('G', Items.gunpowder) .ingredient('G', Items.gunpowder)
.ingredient('R', Items.rotten_flesh) .ingredient('R', Items.rotten_flesh)
.ingredient('B', Items.bone) .ingredient('B', Items.bone)
.ingredient('S', Items.ghast_tear) .ingredient('S', Items.ghast_tear)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleAntiFriendly) .output(ModularForceFieldSystem.itemModuleAntiFriendly)
.pattern(" R ", "GFB", " S ") .pattern(" R ", "GFB", " S ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('G', Items.cooked_porkchop) .ingredient('G', Items.cooked_porkchop)
.ingredient('R', new ItemStack(Blocks.wool, 1, 32767)) .ingredient('R', new ItemStack(Blocks.wool, 1, 32767))
.ingredient('B', Items.leather) .ingredient('B', Items.leather)
.ingredient('S', Items.slime_ball) .ingredient('S', Items.slime_ball)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleAntiPersonnel) .output(ModularForceFieldSystem.itemModuleAntiPersonnel)
.pattern("BFG") .pattern("BFG")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('B', ModularForceFieldSystem.itemModuleAntiHostile) .ingredient('B', ModularForceFieldSystem.itemModuleAntiHostile)
.ingredient('G', ModularForceFieldSystem.itemModuleAntiFriendly) .ingredient('G', ModularForceFieldSystem.itemModuleAntiFriendly)
.register(); .register();
// TODO: config option for confiscate module // TODO: config option for confiscate module
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleConfiscate) .output(ModularForceFieldSystem.itemModuleConfiscate)
.pattern("PEP", "EFE", "PEP") .pattern("PEP", "EFE", "PEP")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('E', Items.ender_eye) .ingredient('E', Items.ender_eye)
.ingredient('P', Items.ender_pearl) .ingredient('P', Items.ender_pearl)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleWarn) .output(ModularForceFieldSystem.itemModuleWarn)
.pattern("NFN") .pattern("NFN")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('N', Blocks.noteblock) .ingredient('N', Blocks.noteblock)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleBlockAccess) .output(ModularForceFieldSystem.itemModuleBlockAccess)
.pattern(" C ", "BFB", " C ") .pattern(" C ", "BFB", " C ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('B', Blocks.iron_block) .ingredient('B', Blocks.iron_block)
.ingredient('C', Blocks.chest) .ingredient('C', Blocks.chest)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleBlockAlter) .output(ModularForceFieldSystem.itemModuleBlockAlter)
.pattern(" G ", "GFG", " G ") .pattern(" G ", "GFG", " G ")
.ingredient('F', ModularForceFieldSystem.itemFocusMatrix) .ingredient('F', ModularForceFieldSystem.itemFocusMatrix)
.ingredient('G', Blocks.gold_block) .ingredient('G', Blocks.gold_block)
.register(); .register();
new RecipeBuilder(new ShapedOreRecipeAdapter()) new RecipeBuilder(new ShapedOreRecipeAdapter())
.output(ModularForceFieldSystem.itemModuleAntiSpawn) .output(ModularForceFieldSystem.itemModuleAntiSpawn)
.pattern(" H ", "G G", " H ") .pattern(" H ", "G G", " H ")
.ingredient('H', ModularForceFieldSystem.itemModuleAntiHostile) .ingredient('H', ModularForceFieldSystem.itemModuleAntiHostile)
.ingredient('G', ModularForceFieldSystem.itemModuleAntiFriendly) .ingredient('G', ModularForceFieldSystem.itemModuleAntiFriendly)
.register(); .register();
} }
} }

View File

@ -1,7 +1,8 @@
package mffs; package mffs;
import cpw.mods.fml.common.Loader;
import java.io.File; import java.io.File;
import cpw.mods.fml.common.Loader;
import mffs.api.Blacklist; import mffs.api.Blacklist;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -9,168 +10,179 @@ import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
public class Settings { public class Settings {
public static final Configuration CONFIGURATION; public static final Configuration CONFIGURATION;
public static final int BLOCK_ID_PREFIX = 1680; public static final int BLOCK_ID_PREFIX = 1680;
public static final int ITEM_ID_PREFIX = 11130; public static final int ITEM_ID_PREFIX = 11130;
private static int NEXT_BLOCK_ID; private static int NEXT_BLOCK_ID;
private static int NEXT_ITEM_ID; private static int NEXT_ITEM_ID;
public static int MAX_FORCE_FIELDS_PER_TICK; public static int MAX_FORCE_FIELDS_PER_TICK;
public static int MAX_FORCE_FIELD_SCALE; public static int MAX_FORCE_FIELD_SCALE;
public static boolean INTERACT_CREATIVE; public static boolean INTERACT_CREATIVE;
public static boolean LOAD_CHUNKS; public static boolean LOAD_CHUNKS;
public static boolean OP_OVERRIDE; public static boolean OP_OVERRIDE;
public static boolean USE_CACHE; public static boolean USE_CACHE;
public static boolean ENABLE_ELECTRICITY; public static boolean ENABLE_ELECTRICITY;
public static boolean CONSERVE_PACKETS; public static boolean CONSERVE_PACKETS;
public static boolean HIGH_GRAPHICS; public static boolean HIGH_GRAPHICS;
public static int INTERDICTION_MURDER_ENERGY; public static int INTERDICTION_MURDER_ENERGY;
public static final int MAX_FREQUENCY_DIGITS = 6; public static final int MAX_FREQUENCY_DIGITS = 6;
public static boolean ENABLE_MANIPULATOR; public static boolean ENABLE_MANIPULATOR;
public static int getNextBlockID() { return ++Settings.NEXT_BLOCK_ID; } public static int getNextBlockID() {
return ++Settings.NEXT_BLOCK_ID;
public static int getNextItemID() { return ++Settings.NEXT_ITEM_ID; }
public static void load() {
Settings.CONFIGURATION.load();
Settings.ENABLE_MANIPULATOR =
Settings.CONFIGURATION
.get("general", "Enable Force Manipulator",
Settings.ENABLE_MANIPULATOR)
.getBoolean(Settings.ENABLE_MANIPULATOR);
final Property propFieldScale = Settings.CONFIGURATION.get(
"general", "Max Force Field Scale", Settings.MAX_FORCE_FIELD_SCALE);
Settings.MAX_FORCE_FIELD_SCALE =
propFieldScale.getInt(Settings.MAX_FORCE_FIELD_SCALE);
final Property propInterdiction = Settings.CONFIGURATION.get(
"general", "Interdiction Murder Fortron Consumption",
Settings.INTERDICTION_MURDER_ENERGY);
Settings.INTERDICTION_MURDER_ENERGY =
propInterdiction.getInt(Settings.INTERDICTION_MURDER_ENERGY);
final Property propCreative = Settings.CONFIGURATION.get(
"general", "Effect Creative Players", Settings.INTERACT_CREATIVE);
propCreative.comment =
"Should the interdiction matrix interact with creative players?.";
Settings.INTERACT_CREATIVE =
propCreative.getBoolean(Settings.INTERACT_CREATIVE);
final Property propChunkLoading = Settings.CONFIGURATION.get(
"general", "Load Chunks", Settings.LOAD_CHUNKS);
propChunkLoading.comment =
"Set this to false to turn off the MFFS Chunkloading capabilities.";
Settings.LOAD_CHUNKS = propChunkLoading.getBoolean(Settings.LOAD_CHUNKS);
final Property propOpOverride = Settings.CONFIGURATION.get(
"general", "Op Override", Settings.OP_OVERRIDE);
propOpOverride.comment =
"Allow the operator(s) to override security measures created by MFFS?";
Settings.OP_OVERRIDE = propOpOverride.getBoolean(Settings.OP_OVERRIDE);
final Property propUseCache =
Settings.CONFIGURATION.get("general", "Use Cache", Settings.USE_CACHE);
propUseCache.comment =
"Cache allows temporary data saving to decrease calculations required.";
Settings.USE_CACHE = propUseCache.getBoolean(Settings.USE_CACHE);
final Property maxFFGenPerTick =
Settings.CONFIGURATION.get("general", "Field Calculation Per Tick",
Settings.MAX_FORCE_FIELDS_PER_TICK);
maxFFGenPerTick.comment =
"How many force field blocks can be generated per tick? Less reduces lag.";
Settings.MAX_FORCE_FIELDS_PER_TICK =
maxFFGenPerTick.getInt(Settings.MAX_FORCE_FIELDS_PER_TICK);
final Property useElectricity = Settings.CONFIGURATION.get(
"general", "Require Electricity?", Settings.ENABLE_ELECTRICITY);
useElectricity.comment =
"Turning this to false will make MFFS run without electricity or energy systems required. Great for vanilla!";
Settings.ENABLE_ELECTRICITY =
useElectricity.getBoolean(Settings.ENABLE_ELECTRICITY);
final Property conservePackets = Settings.CONFIGURATION.get(
"general", "Conserve Packets?", Settings.CONSERVE_PACKETS);
conservePackets.comment =
"Turning this to false will enable better client side packet and updates but in the cost of more packets sent.";
Settings.CONSERVE_PACKETS =
conservePackets.getBoolean(Settings.CONSERVE_PACKETS);
final Property highGraphics = Settings.CONFIGURATION.get(
"general", "High Graphics", Settings.HIGH_GRAPHICS);
highGraphics.comment =
"Turning this to false will reduce rendering and client side packet graphical packets.";
Settings.CONSERVE_PACKETS = highGraphics.getBoolean(Settings.HIGH_GRAPHICS);
final Property forceManipulatorBlacklist = Settings.CONFIGURATION.get(
"general", "Force Manipulator Blacklist", "");
highGraphics.comment =
"Put a list of block IDs to be not-moved by the force manipulator. Separate by commas, no space.";
final String blackListString = forceManipulatorBlacklist.getString();
if (blackListString != null) {
for (final String blockIDString : blackListString.split(",")) {
Block b = Block.getBlockFromName(blockIDString);
if (b == null) {
ModularForceFieldSystem.LOGGER.severe(
"Invalid block blacklist ID \'" + blockIDString + "\'!");
continue;
}
Blacklist.forceManipulationBlacklist.add(b);
}
} }
final Property blacklist1 = public static int getNextItemID() {
Settings.CONFIGURATION.get("general", "Stabilization Blacklist", ""); return ++Settings.NEXT_ITEM_ID;
final String blackListString2 = blacklist1.getString(); }
if (blackListString2 != null) {
for (final String blockIDString2 : blackListString2.split(",")) { public static void load() {
Block b = Block.getBlockFromName(blockIDString2); Settings.CONFIGURATION.load();
if (b == null) { Settings.ENABLE_MANIPULATOR
ModularForceFieldSystem.LOGGER.severe( = Settings.CONFIGURATION
"Invalid block blacklist ID \'" + blockIDString2 + "\'!"); .get("general", "Enable Force Manipulator", Settings.ENABLE_MANIPULATOR)
continue; .getBoolean(Settings.ENABLE_MANIPULATOR);
final Property propFieldScale = Settings.CONFIGURATION.get(
"general", "Max Force Field Scale", Settings.MAX_FORCE_FIELD_SCALE
);
Settings.MAX_FORCE_FIELD_SCALE
= propFieldScale.getInt(Settings.MAX_FORCE_FIELD_SCALE);
final Property propInterdiction = Settings.CONFIGURATION.get(
"general",
"Interdiction Murder Fortron Consumption",
Settings.INTERDICTION_MURDER_ENERGY
);
Settings.INTERDICTION_MURDER_ENERGY
= propInterdiction.getInt(Settings.INTERDICTION_MURDER_ENERGY);
final Property propCreative = Settings.CONFIGURATION.get(
"general", "Effect Creative Players", Settings.INTERACT_CREATIVE
);
propCreative.comment
= "Should the interdiction matrix interact with creative players?.";
Settings.INTERACT_CREATIVE = propCreative.getBoolean(Settings.INTERACT_CREATIVE);
final Property propChunkLoading
= Settings.CONFIGURATION.get("general", "Load Chunks", Settings.LOAD_CHUNKS);
propChunkLoading.comment
= "Set this to false to turn off the MFFS Chunkloading capabilities.";
Settings.LOAD_CHUNKS = propChunkLoading.getBoolean(Settings.LOAD_CHUNKS);
final Property propOpOverride
= Settings.CONFIGURATION.get("general", "Op Override", Settings.OP_OVERRIDE);
propOpOverride.comment
= "Allow the operator(s) to override security measures created by MFFS?";
Settings.OP_OVERRIDE = propOpOverride.getBoolean(Settings.OP_OVERRIDE);
final Property propUseCache
= Settings.CONFIGURATION.get("general", "Use Cache", Settings.USE_CACHE);
propUseCache.comment
= "Cache allows temporary data saving to decrease calculations required.";
Settings.USE_CACHE = propUseCache.getBoolean(Settings.USE_CACHE);
final Property maxFFGenPerTick = Settings.CONFIGURATION.get(
"general", "Field Calculation Per Tick", Settings.MAX_FORCE_FIELDS_PER_TICK
);
maxFFGenPerTick.comment
= "How many force field blocks can be generated per tick? Less reduces lag.";
Settings.MAX_FORCE_FIELDS_PER_TICK
= maxFFGenPerTick.getInt(Settings.MAX_FORCE_FIELDS_PER_TICK);
final Property useElectricity = Settings.CONFIGURATION.get(
"general", "Require Electricity?", Settings.ENABLE_ELECTRICITY
);
useElectricity.comment
= "Turning this to false will make MFFS run without electricity or energy systems required. Great for vanilla!";
Settings.ENABLE_ELECTRICITY
= useElectricity.getBoolean(Settings.ENABLE_ELECTRICITY);
final Property conservePackets = Settings.CONFIGURATION.get(
"general", "Conserve Packets?", Settings.CONSERVE_PACKETS
);
conservePackets.comment
= "Turning this to false will enable better client side packet and updates but in the cost of more packets sent.";
Settings.CONSERVE_PACKETS = conservePackets.getBoolean(Settings.CONSERVE_PACKETS);
final Property highGraphics = Settings.CONFIGURATION.get(
"general", "High Graphics", Settings.HIGH_GRAPHICS
);
highGraphics.comment
= "Turning this to false will reduce rendering and client side packet graphical packets.";
Settings.CONSERVE_PACKETS = highGraphics.getBoolean(Settings.HIGH_GRAPHICS);
final Property forceManipulatorBlacklist
= Settings.CONFIGURATION.get("general", "Force Manipulator Blacklist", "");
highGraphics.comment
= "Put a list of block IDs to be not-moved by the force manipulator. Separate by commas, no space.";
final String blackListString = forceManipulatorBlacklist.getString();
if (blackListString != null) {
for (final String blockIDString : blackListString.split(",")) {
Block b = Block.getBlockFromName(blockIDString);
if (b == null) {
ModularForceFieldSystem.LOGGER.severe(
"Invalid block blacklist ID \'" + blockIDString + "\'!"
);
continue;
}
Blacklist.forceManipulationBlacklist.add(b);
}
} }
Blacklist.stabilizationBlacklist.add(b); final Property blacklist1
} = Settings.CONFIGURATION.get("general", "Stabilization Blacklist", "");
} final String blackListString2 = blacklist1.getString();
final Property blacklist2 = if (blackListString2 != null) {
Settings.CONFIGURATION.get("general", "Disintegration Blacklist", ""); for (final String blockIDString2 : blackListString2.split(",")) {
final String blackListString3 = blacklist2.getString(); Block b = Block.getBlockFromName(blockIDString2);
if (blackListString3 != null) { if (b == null) {
for (final String blockIDString3 : blackListString3.split(",")) { ModularForceFieldSystem.LOGGER.severe(
if (blockIDString3 != null && !blockIDString3.isEmpty()) { "Invalid block blacklist ID \'" + blockIDString2 + "\'!"
Block b = Block.getBlockFromName(blockIDString3); );
if (b == null) { continue;
ModularForceFieldSystem.LOGGER.severe( }
"Invalid block blacklist ID \'" + blockIDString3 + "\'!");
continue;
}
Blacklist.disintegrationBlacklist.add(b); Blacklist.stabilizationBlacklist.add(b);
}
} }
} final Property blacklist2
} = Settings.CONFIGURATION.get("general", "Disintegration Blacklist", "");
Blacklist.stabilizationBlacklist.add(Blocks.water); final String blackListString3 = blacklist2.getString();
Blacklist.stabilizationBlacklist.add(Blocks.flowing_water); if (blackListString3 != null) {
Blacklist.stabilizationBlacklist.add(Blocks.lava); for (final String blockIDString3 : blackListString3.split(",")) {
Blacklist.stabilizationBlacklist.add(Blocks.flowing_lava); if (blockIDString3 != null && !blockIDString3.isEmpty()) {
Blacklist.disintegrationBlacklist.add(Blocks.water); Block b = Block.getBlockFromName(blockIDString3);
Blacklist.disintegrationBlacklist.add(Blocks.flowing_water); if (b == null) {
Blacklist.disintegrationBlacklist.add(Blocks.lava); ModularForceFieldSystem.LOGGER.severe(
Blacklist.stabilizationBlacklist.add(Blocks.flowing_lava); "Invalid block blacklist ID \'" + blockIDString3 + "\'!"
Blacklist.forceManipulationBlacklist.add(Blocks.bedrock); );
Blacklist.forceManipulationBlacklist.add( continue;
ModularForceFieldSystem.blockForceField); }
Settings.CONFIGURATION.save();
}
static { Blacklist.disintegrationBlacklist.add(b);
CONFIGURATION = new Configuration(new File( }
Loader.instance().getConfigDir(), "Modular Force Field System.cfg")); }
Settings.NEXT_BLOCK_ID = 1680; }
Settings.NEXT_ITEM_ID = 11130; Blacklist.stabilizationBlacklist.add(Blocks.water);
Settings.MAX_FORCE_FIELDS_PER_TICK = 1000; Blacklist.stabilizationBlacklist.add(Blocks.flowing_water);
Settings.MAX_FORCE_FIELD_SCALE = 200; Blacklist.stabilizationBlacklist.add(Blocks.lava);
Settings.INTERACT_CREATIVE = true; Blacklist.stabilizationBlacklist.add(Blocks.flowing_lava);
Settings.LOAD_CHUNKS = true; Blacklist.disintegrationBlacklist.add(Blocks.water);
Settings.OP_OVERRIDE = true; Blacklist.disintegrationBlacklist.add(Blocks.flowing_water);
Settings.USE_CACHE = true; Blacklist.disintegrationBlacklist.add(Blocks.lava);
Settings.ENABLE_ELECTRICITY = true; Blacklist.stabilizationBlacklist.add(Blocks.flowing_lava);
Settings.CONSERVE_PACKETS = true; Blacklist.forceManipulationBlacklist.add(Blocks.bedrock);
Settings.HIGH_GRAPHICS = true; Blacklist.forceManipulationBlacklist.add(ModularForceFieldSystem.blockForceField);
Settings.INTERDICTION_MURDER_ENERGY = 0; Settings.CONFIGURATION.save();
Settings.ENABLE_MANIPULATOR = true; }
}
static {
CONFIGURATION = new Configuration(
new File(Loader.instance().getConfigDir(), "Modular Force Field System.cfg")
);
Settings.NEXT_BLOCK_ID = 1680;
Settings.NEXT_ITEM_ID = 11130;
Settings.MAX_FORCE_FIELDS_PER_TICK = 1000;
Settings.MAX_FORCE_FIELD_SCALE = 200;
Settings.INTERACT_CREATIVE = true;
Settings.LOAD_CHUNKS = true;
Settings.OP_OVERRIDE = true;
Settings.USE_CACHE = true;
Settings.ENABLE_ELECTRICITY = true;
Settings.CONSERVE_PACKETS = true;
Settings.HIGH_GRAPHICS = true;
Settings.INTERDICTION_MURDER_ENERGY = 0;
Settings.ENABLE_MANIPULATOR = true;
}
} }

View File

@ -18,69 +18,79 @@ import net.minecraftforge.fluids.FluidRegistry;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class SubscribeEventHandler { public class SubscribeEventHandler {
@SubscribeEvent @SubscribeEvent
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void textureHook(final TextureStitchEvent.Pre event) { public void textureHook(final TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 1) { if (event.map.getTextureType() == 1) {
FluidRegistry.getFluid("fortron").setIcons( FluidRegistry.getFluid("fortron").setIcons(
event.map.registerIcon("mffs:fortron")); event.map.registerIcon("mffs:fortron")
} );
}
@SubscribeEvent
public void playerInteractEvent(final PlayerInteractEvent evt) {
if (evt.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK ||
evt.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
if (evt.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK &&
((Entity)((PlayerEvent)evt).entityPlayer)
.worldObj.getBlock(evt.x, evt.y, evt.z) ==
ModularForceFieldSystem.blockForceField) {
evt.setCanceled(true);
return;
}
if (((PlayerEvent)evt).entityPlayer.capabilities.isCreativeMode) {
return;
}
final Vector3 position = new Vector3(evt.x, evt.y, evt.z);
final IInterdictionMatrix interdictionMatrix =
MFFSHelper.getNearestInterdictionMatrix(
((Entity)((PlayerEvent)evt).entityPlayer).worldObj, position);
if (interdictionMatrix != null) {
final Block block = position.getBlock(
(IBlockAccess)((Entity)((PlayerEvent)evt).entityPlayer).worldObj);
if (ModularForceFieldSystem.blockBiometricIdentifier == block &&
MFFSHelper.isPermittedByInterdictionMatrix(
interdictionMatrix,
((PlayerEvent)evt).entityPlayer.getDisplayName(),
Permission.SECURITY_CENTER_CONFIGURE)) {
return;
} }
final boolean hasPermission = MFFSHelper.hasPermission(
((Entity)((PlayerEvent)evt).entityPlayer).worldObj,
new Vector3(evt.x, evt.y, evt.z), interdictionMatrix, evt.action,
((PlayerEvent)evt).entityPlayer);
if (!hasPermission) {
((PlayerEvent)evt)
.entityPlayer.addChatMessage(new ChatComponentText(
"[" +
ModularForceFieldSystem.blockInterdictionMatrix
.getLocalizedName() +
"] You have no permission to do that!"));
evt.setCanceled(true);
}
}
} }
}
@SubscribeEvent @SubscribeEvent
public void livingSpawnEvent(final LivingSpawnEvent evt) { public void playerInteractEvent(final PlayerInteractEvent evt) {
final IInterdictionMatrix interdictionMatrix = if (evt.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
MFFSHelper.getNearestInterdictionMatrix( || evt.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
evt.world, new Vector3((Entity)evt.entityLiving)); if (evt.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK
if (interdictionMatrix != null && && ((Entity) ((PlayerEvent) evt).entityPlayer)
interdictionMatrix.getModuleCount( .worldObj.getBlock(evt.x, evt.y, evt.z)
ModularForceFieldSystem.itemModuleAntiSpawn, new int[0]) > 0) { == ModularForceFieldSystem.blockForceField) {
evt.setResult(Result.DENY); evt.setCanceled(true);
return;
}
if (((PlayerEvent) evt).entityPlayer.capabilities.isCreativeMode) {
return;
}
final Vector3 position = new Vector3(evt.x, evt.y, evt.z);
final IInterdictionMatrix interdictionMatrix
= MFFSHelper.getNearestInterdictionMatrix(
((Entity) ((PlayerEvent) evt).entityPlayer).worldObj, position
);
if (interdictionMatrix != null) {
final Block block = position.getBlock(
(IBlockAccess) ((Entity) ((PlayerEvent) evt).entityPlayer).worldObj
);
if (ModularForceFieldSystem.blockBiometricIdentifier == block
&& MFFSHelper.isPermittedByInterdictionMatrix(
interdictionMatrix,
((PlayerEvent) evt).entityPlayer.getDisplayName(),
Permission.SECURITY_CENTER_CONFIGURE
)) {
return;
}
final boolean hasPermission = MFFSHelper.hasPermission(
((Entity) ((PlayerEvent) evt).entityPlayer).worldObj,
new Vector3(evt.x, evt.y, evt.z),
interdictionMatrix,
evt.action,
((PlayerEvent) evt).entityPlayer
);
if (!hasPermission) {
((PlayerEvent) evt)
.entityPlayer.addChatMessage(new ChatComponentText(
"["
+ ModularForceFieldSystem.blockInterdictionMatrix
.getLocalizedName()
+ "] You have no permission to do that!"
));
evt.setCanceled(true);
}
}
}
}
@SubscribeEvent
public void livingSpawnEvent(final LivingSpawnEvent evt) {
final IInterdictionMatrix interdictionMatrix
= MFFSHelper.getNearestInterdictionMatrix(
evt.world, new Vector3((Entity) evt.entityLiving)
);
if (interdictionMatrix != null
&& interdictionMatrix.getModuleCount(
ModularForceFieldSystem.itemModuleAntiSpawn, new int[0]
) > 0) {
evt.setResult(Result.DENY);
}
} }
}
} }

View File

@ -1,16 +1,17 @@
package mffs; package mffs;
public enum TransferMode { public enum TransferMode {
EQUALIZE, EQUALIZE,
DISTRIBUTE, DISTRIBUTE,
DRAIN, DRAIN,
FILL; FILL;
public TransferMode toggle() { public TransferMode toggle() {
int newOrdinal = this.ordinal() + 1; int newOrdinal = this.ordinal() + 1;
if (newOrdinal >= values().length) { if (newOrdinal >= values().length) {
newOrdinal = 0; newOrdinal = 0;
}
return values()[newOrdinal];
} }
return values()[newOrdinal];
}
} }

View File

@ -20,8 +20,7 @@ import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockRotatable; import universalelectricity.prefab.block.BlockRotatable;
import universalelectricity.prefab.implement.IRedstoneReceptor; import universalelectricity.prefab.implement.IRedstoneReceptor;
public abstract class BlockMachine public abstract class BlockMachine extends BlockRotatable implements ICamouflageMaterial {
extends BlockRotatable implements ICamouflageMaterial {
public BlockMachine(final String name) { public BlockMachine(final String name) {
super(UniversalElectricity.machine); super(UniversalElectricity.machine);
this.setBlockName("mffs:" + name); this.setBlockName("mffs:" + name);
@ -32,68 +31,95 @@ public abstract class BlockMachine
} }
@Override @Override
public boolean onMachineActivated(final World world, final int x, final int y, final int z, public boolean onMachineActivated(
final EntityPlayer entityPlayer, final int side, final World world,
final float hitX, final float hitY, final float hitZ) { final int x,
final int y,
final int z,
final EntityPlayer entityPlayer,
final int side,
final float hitX,
final float hitY,
final float hitZ
) {
if (!world.isRemote) { if (!world.isRemote) {
if (entityPlayer.getCurrentEquippedItem() != null && if (entityPlayer.getCurrentEquippedItem() != null
entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCardLink) { && entityPlayer.getCurrentEquippedItem().getItem()
instanceof ItemCardLink) {
return false; return false;
} }
entityPlayer.openGui((Object) ModularForceFieldSystem.instance, 0, world, entityPlayer.openGui(
x, y, z); (Object) ModularForceFieldSystem.instance, 0, world, x, y, z
);
} }
return true; return true;
} }
@Override @Override
public boolean onSneakMachineActivated(final World world, final int x, public boolean onSneakMachineActivated(
final int y, final int z, final World world,
final EntityPlayer entityPlayer, final int x,
final int side, final float hitX, final int y,
final float hitY, final float hitZ) { final int z,
return this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, final EntityPlayer entityPlayer,
hitZ); final int side,
final float hitX,
final float hitY,
final float hitZ
) {
return this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
} }
@Override @Override
public boolean onSneakUseWrench(final World world, final int x, final int y, public boolean onSneakUseWrench(
final int z, final EntityPlayer entityPlayer, final World world,
final int side, final float hitX, final int x,
final float hitY, final float hitZ) { final int y,
final int z,
final EntityPlayer entityPlayer,
final int side,
final float hitX,
final float hitY,
final float hitZ
) {
if (!world.isRemote) { if (!world.isRemote) {
final TileEntity tileEntity = world.getTileEntity(x, y, z); final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof IBiometricIdentifierLink) { if (tileEntity instanceof IBiometricIdentifierLink) {
if (((IBiometricIdentifierLink) tileEntity).getBiometricIdentifier() == null) { if (((IBiometricIdentifierLink) tileEntity).getBiometricIdentifier()
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), == null) {
0); this.dropBlockAsItem(
world, x, y, z, world.getBlockMetadata(x, y, z), 0
);
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
return true; return true;
} }
if (((IBiometricIdentifierLink) tileEntity) if (((IBiometricIdentifierLink) tileEntity)
.getBiometricIdentifier() .getBiometricIdentifier()
.isAccessGranted(entityPlayer.getDisplayName(), .isAccessGranted(
Permission.SECURITY_CENTER_CONFIGURE)) { entityPlayer.getDisplayName(),
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), Permission.SECURITY_CENTER_CONFIGURE
0); )) {
this.dropBlockAsItem(
world, x, y, z, world.getBlockMetadata(x, y, z), 0
);
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
return true; return true;
} }
entityPlayer.addChatMessage(new ChatComponentText( entityPlayer.addChatMessage(new ChatComponentText(
"[" + "["
ModularForceFieldSystem.blockBiometricIdentifier + ModularForceFieldSystem.blockBiometricIdentifier.getLocalizedName()
.getLocalizedName() + "]"
+ + " Cannot remove machine! Access denied!"
"]" ));
+ " Cannot remove machine! Access denied!"));
} }
} }
return false; return false;
} }
@Override @Override
public void onNeighborBlockChange(final World world, final int x, final int y, public void onNeighborBlockChange(
final int z, final Block block) { final World world, final int x, final int y, final int z, final Block block
) {
if (!world.isRemote) { if (!world.isRemote) {
final TileEntity tileEntity = world.getTileEntity(x, y, z); final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneReceptor) { if (tileEntity instanceof IRedstoneReceptor) {
@ -107,10 +133,16 @@ public abstract class BlockMachine
} }
@Override @Override
public float getExplosionResistance(final Entity entity, final World world, public float getExplosionResistance(
final int i, final int j, final int k, final Entity entity,
final double d, final double d1, final World world,
final double d2) { final int i,
final int j,
final int k,
final double d,
final double d1,
final double d2
) {
return 100.0f; return 100.0f;
} }

View File

@ -7,89 +7,92 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class ContainerBase extends Container { public class ContainerBase extends Container {
protected int slotCount; protected int slotCount;
private IInventory inventory; private IInventory inventory;
public ContainerBase(final IInventory inventory) { public ContainerBase(final IInventory inventory) {
this.slotCount = 0; this.slotCount = 0;
this.inventory = inventory; this.inventory = inventory;
this.slotCount = inventory.getSizeInventory(); this.slotCount = inventory.getSizeInventory();
} }
@Override @Override
public void onContainerClosed(final EntityPlayer player) { public void onContainerClosed(final EntityPlayer player) {
if (this.inventory instanceof TileEntityBase) { if (this.inventory instanceof TileEntityBase) {
((TileEntityBase)this.inventory).playersUsing.remove(player); ((TileEntityBase) this.inventory).playersUsing.remove(player);
}
}
public void addPlayerInventory(final EntityPlayer player) {
if (this.inventory instanceof TileEntityBase) {
((TileEntityBase)this.inventory).playersUsing.add(player);
}
for (int var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory)player.inventory,
var4 + var3 * 9 + 9, 8 + var4 * 18,
135 + var3 * 18));
}
}
for (int var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(
new Slot((IInventory)player.inventory, var3, 8 + var3 * 18, 193));
}
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer,
final int slotID) {
ItemStack var2 = null;
final Slot var3 = (Slot)super.inventorySlots.get(slotID);
if (var3 != null && var3.getHasStack()) {
final 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;
}
@Override public void addPlayerInventory(final EntityPlayer player) {
public boolean canInteractWith(final EntityPlayer entityplayer) { if (this.inventory instanceof TileEntityBase) {
return this.inventory.isUseableByPlayer(entityplayer); ((TileEntityBase) this.inventory).playersUsing.add(player);
} }
for (int var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot(
(IInventory) player.inventory,
var4 + var3 * 9 + 9,
8 + var4 * 18,
135 + var3 * 18
));
}
}
for (int var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(
new Slot((IInventory) player.inventory, var3, 8 + var3 * 18, 193)
);
}
}
@Override
public ItemStack
transferStackInSlot(final EntityPlayer par1EntityPlayer, final int slotID) {
ItemStack var2 = null;
final Slot var3 = (Slot) super.inventorySlots.get(slotID);
if (var3 != null && var3.getHasStack()) {
final 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;
}
@Override
public boolean canInteractWith(final EntityPlayer entityplayer) {
return this.inventory.isUseableByPlayer(entityplayer);
}
} }

View File

@ -1,8 +1,9 @@
package mffs.base; package mffs.base;
import icbm.api.IBlockFrequency;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import icbm.api.IBlockFrequency;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.IBiometricIdentifierLink; import mffs.api.IBiometricIdentifierLink;
@ -26,337 +27,447 @@ import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.vector.Region2; import universalelectricity.prefab.vector.Region2;
public class GuiBase extends GuiContainer { public class GuiBase extends GuiContainer {
public static final int METER_HEIGHT = 49; public static final int METER_HEIGHT = 49;
public static final int METER_WIDTH = 14; public static final int METER_WIDTH = 14;
public static final int METER_END = 68; public static final int METER_END = 68;
protected GuiTextField textFieldFrequency; protected GuiTextField textFieldFrequency;
protected Vector2 textFieldPos; protected Vector2 textFieldPos;
public String tooltip; public String tooltip;
protected int containerWidth; protected int containerWidth;
protected int containerHeight; protected int containerHeight;
protected IBlockFrequency frequencyTile; protected IBlockFrequency frequencyTile;
protected HashMap<Region2, String> tooltips; protected HashMap<Region2, String> tooltips;
public GuiBase(final Container container) { public GuiBase(final Container container) {
super(container); super(container);
this.textFieldPos = new Vector2(); this.textFieldPos = new Vector2();
this.tooltip = ""; this.tooltip = "";
this.tooltips = new HashMap<>(); this.tooltips = new HashMap<>();
this.ySize = 217; this.ySize = 217;
}
public GuiBase(final Container container,
final IBlockFrequency frequencyTile) {
this(container);
this.frequencyTile = frequencyTile;
}
@Override
public void initGui() {
super.initGui();
this.buttonList.clear();
this.buttonList.add(new GuiIcon(
0, this.width / 2 - 82, this.height / 2 - 104,
new ItemStack(Blocks.torch), new ItemStack(Blocks.redstone_torch)));
Keyboard.enableRepeatEvents(true);
if (this.frequencyTile != null) {
(this.textFieldFrequency =
new GuiTextField(this.fontRendererObj, this.textFieldPos.intX(),
this.textFieldPos.intY(), 50, 12))
.setMaxStringLength(6);
this.textFieldFrequency.setText(this.frequencyTile.getFrequency() + "");
} }
}
@Override public GuiBase(final Container container, final IBlockFrequency frequencyTile) {
public void onGuiClosed() { this(container);
Keyboard.enableRepeatEvents(false); this.frequencyTile = frequencyTile;
super.onGuiClosed();
}
@Override
protected void keyTyped(final char par1, final int par2) {
super.keyTyped(par1, par2);
if (this.textFieldFrequency != null) {
this.textFieldFrequency.textboxKeyTyped(par1, par2);
try {
final int newFrequency =
Math.max(0, Integer.parseInt(this.textFieldFrequency.getText()));
this.frequencyTile.setFrequency(newFrequency);
this.textFieldFrequency.setText(this.frequencyTile.getFrequency() + "");
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("frequency", this.frequencyTile.getFrequency());
ModularForceFieldSystem.channel.sendToServer(
new PacketTile(PacketTile.Type.FREQUENCY,
new Vector3((TileEntity)this.frequencyTile), nbt));
} catch (final NumberFormatException ex) {
}
} }
}
@Override @Override
protected void actionPerformed(final GuiButton guiButton) { public void initGui() {
super.actionPerformed(guiButton); super.initGui();
if (this.frequencyTile != null && guiButton.id == 0) { this.buttonList.clear();
ModularForceFieldSystem.channel.sendToServer(new PacketTile( this.buttonList.add(new GuiIcon(
PacketTile.Type.TOGGLE_ACTIVATION, 0,
new Vector3((TileEntity)this.frequencyTile), new NBTTagCompound())); this.width / 2 - 82,
} this.height / 2 - 104,
} new ItemStack(Blocks.torch),
new ItemStack(Blocks.redstone_torch)
@Override ));
public void updateScreen() { Keyboard.enableRepeatEvents(true);
super.updateScreen(); if (this.frequencyTile != null) {
if (this.textFieldFrequency != null && (this.textFieldFrequency = new GuiTextField(
!this.textFieldFrequency.isFocused()) { this.fontRendererObj,
this.textFieldFrequency.setText(this.frequencyTile.getFrequency() + ""); this.textFieldPos.intX(),
} this.textFieldPos.intY(),
if (this.frequencyTile instanceof TileEntityBase && 50,
this.buttonList.size() > 0 && this.buttonList.get(0) != null) { 12
((GuiIcon)this.buttonList.get(0)) ))
.setIndex(((TileEntityBase)this.frequencyTile).isActive() ? 1 : 0); .setMaxStringLength(6);
} this.textFieldFrequency.setText(this.frequencyTile.getFrequency() + "");
}
@Override
protected void mouseClicked(final int x, final int y, final int par3) {
super.mouseClicked(x, y, par3);
if (this.textFieldFrequency != null) {
this.textFieldFrequency.mouseClicked(x - this.containerWidth,
y - this.containerHeight, par3);
}
}
@Override
protected void drawGuiContainerForegroundLayer(final int mouseX,
final int mouseY) {
if (this.textFieldFrequency != null &&
this.func_146978_c(this.textFieldPos.intX(), this.textFieldPos.intY(),
this.textFieldFrequency.getWidth(), 12, mouseX,
mouseY)) {
this.tooltip = TranslationHelper.getLocal("gui.frequency.tooltip");
}
for (final Map.Entry<Region2, String> entry : this.tooltips.entrySet()) {
if (entry.getKey().isIn(
new Vector2(mouseX - this.guiLeft, mouseY - this.guiTop))) {
this.tooltip = entry.getValue();
break;
}
}
if (this.tooltip != null && this.tooltip != "") {
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop,
MFFSHelper.splitStringPerWord(this.tooltip, 5)
.toArray(new String[] {}));
}
this.tooltip = "";
}
@Override
protected void drawGuiContainerBackgroundLayer(final float var1, final int x,
final int y) {
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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);
if (this.frequencyTile instanceof IBiometricIdentifierLink) {
this.drawBulb(167, 4,
((IBiometricIdentifierLink)this.frequencyTile)
.getBiometricIdentifier() != null);
}
}
protected void drawBulb(final int x, final int y, final boolean isOn) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/gui/gui_components.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(final int x, final int y, final ItemStack itemStack) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/gui/gui_components.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(final ItemStack itemStack, int x, int y) {
++x;
++y;
GL11.glTranslatef(0.0f, 0.0f, 32.0f);
GuiBase.itemRender.renderItemAndEffectIntoGUI(
this.fontRendererObj, this.mc.renderEngine, itemStack, x, y);
}
protected void drawTextWithTooltip(final String textName, final String format,
final int x, final int y, final int mouseX,
final int mouseY) {
this.drawTextWithTooltip(textName, format, x, y, mouseX, mouseY, 4210752);
}
protected void drawTextWithTooltip(final String textName, final String format,
final int x, final int y, final int mouseX,
final int mouseY, final int color) {
final String name = TranslationHelper.getLocal("gui." + textName + ".name");
final String text = format.replaceAll("%1", name);
this.fontRendererObj.drawString(text, x, y, color);
final String tooltip =
TranslationHelper.getLocal("gui." + textName + ".tooltip");
if (tooltip != null && tooltip != "" &&
this.func_146978_c(x, y, (int)(text.length() * 4.8), 12, mouseX,
mouseY)) {
this.tooltip = tooltip;
}
}
protected void drawTextWithTooltip(final String textName, final int x,
final int y, final int mouseX,
final int mouseY) {
this.drawTextWithTooltip(textName, "%1", x, y, mouseX, mouseY);
}
protected void drawSlot(final int x, final int y, final SlotType type,
final float r, final float g, final float b) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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 != SlotType.NONE) {
this.drawTexturedModalRect(this.containerWidth + x,
this.containerHeight + y, 0,
18 * type.ordinal(), 18, 18);
}
}
protected void drawSlot(final int x, final int y, final SlotType type) {
this.drawSlot(x, y, type, 1.0f, 1.0f, 1.0f);
}
protected void drawSlot(final int x, final int y) {
this.drawSlot(x, y, SlotType.NONE);
}
protected void drawBar(final int x, final int y, final float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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(final int x, final int y, final float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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(final int x, final int y, final float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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);
}
}
public void drawTooltip(final int x, final int y, final String... toolTips) {
if (!GuiScreen.isShiftKeyDown()) {
GL11.glDisable(32826);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2896);
GL11.glDisable(2929);
if (toolTips != null) {
int var5 = 0;
for (int var6 = 0; var6 < toolTips.length; ++var6) {
final int var7 = this.fontRendererObj.getStringWidth(toolTips[var6]);
if (var7 > var5) {
var5 = var7;
}
} }
int var6 = x + 12;
int var7 = y - 12;
int var8 = 8;
if (toolTips.length > 1) {
var8 += 2 + (toolTips.length - 1) * 10;
}
if (this.guiTop + var7 + var8 + 6 > this.height) {
var7 = this.height - var8 - this.guiTop - 6;
}
zLevel = 300.0f;
final int var9 = -267386864;
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3,
var9, var9);
this.drawGradientRect(var6 - 3, var7 + var8 + 3, var6 + var5 + 3,
var7 + var8 + 4, var9, var9);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3,
var7 + var8 + 3, var9, var9);
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var8 + 3,
var9, var9);
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4,
var7 + var8 + 3, var9, var9);
final int var10 = 1347420415;
final int var11 = (var10 & 0xFEFEFE) >> 1 | (var10 & 0xFF000000);
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1,
var7 + var8 + 3 - 1, var10, var11);
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3,
var7 + var8 + 3 - 1, var10, var11);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1,
var10, var10);
this.drawGradientRect(var6 - 3, var7 + var8 + 2, var6 + var5 + 3,
var7 + var8 + 3, var11, var11);
for (int var12 = 0; var12 < toolTips.length; ++var12) {
final String var13 = toolTips[var12];
this.fontRendererObj.drawStringWithShadow(var13, var6, var7, -1);
var7 += 10;
}
this.zLevel = 0.0f;
GL11.glEnable(2929);
GL11.glEnable(2896);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
}
} }
}
public enum SlotType { @Override
NONE, public void onGuiClosed() {
BATTERY, Keyboard.enableRepeatEvents(false);
LIQUID, super.onGuiClosed();
ARR_UP, }
ARR_DOWN,
ARR_LEFT, @Override
ARR_RIGHT, protected void keyTyped(final char par1, final int par2) {
ARR_UP_RIGHT, super.keyTyped(par1, par2);
ARR_UP_LEFT, if (this.textFieldFrequency != null) {
ARR_DOWN_LEFT, this.textFieldFrequency.textboxKeyTyped(par1, par2);
ARR_DOWN_RIGHT; try {
} final int newFrequency
= Math.max(0, Integer.parseInt(this.textFieldFrequency.getText()));
this.frequencyTile.setFrequency(newFrequency);
this.textFieldFrequency.setText(this.frequencyTile.getFrequency() + "");
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("frequency", this.frequencyTile.getFrequency());
ModularForceFieldSystem.channel.sendToServer(new PacketTile(
PacketTile.Type.FREQUENCY,
new Vector3((TileEntity) this.frequencyTile),
nbt
));
} catch (final NumberFormatException ex) {}
}
}
@Override
protected void actionPerformed(final GuiButton guiButton) {
super.actionPerformed(guiButton);
if (this.frequencyTile != null && guiButton.id == 0) {
ModularForceFieldSystem.channel.sendToServer(new PacketTile(
PacketTile.Type.TOGGLE_ACTIVATION,
new Vector3((TileEntity) this.frequencyTile),
new NBTTagCompound()
));
}
}
@Override
public void updateScreen() {
super.updateScreen();
if (this.textFieldFrequency != null && !this.textFieldFrequency.isFocused()) {
this.textFieldFrequency.setText(this.frequencyTile.getFrequency() + "");
}
if (this.frequencyTile instanceof TileEntityBase && this.buttonList.size() > 0
&& this.buttonList.get(0) != null) {
((GuiIcon) this.buttonList.get(0))
.setIndex(((TileEntityBase) this.frequencyTile).isActive() ? 1 : 0);
}
}
@Override
protected void mouseClicked(final int x, final int y, final int par3) {
super.mouseClicked(x, y, par3);
if (this.textFieldFrequency != null) {
this.textFieldFrequency.mouseClicked(
x - this.containerWidth, y - this.containerHeight, par3
);
}
}
@Override
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
if (this.textFieldFrequency != null
&& this.func_146978_c(
this.textFieldPos.intX(),
this.textFieldPos.intY(),
this.textFieldFrequency.getWidth(),
12,
mouseX,
mouseY
)) {
this.tooltip = TranslationHelper.getLocal("gui.frequency.tooltip");
}
for (final Map.Entry<Region2, String> entry : this.tooltips.entrySet()) {
if (entry.getKey().isIn(
new Vector2(mouseX - this.guiLeft, mouseY - this.guiTop)
)) {
this.tooltip = entry.getValue();
break;
}
}
if (this.tooltip != null && this.tooltip != "") {
this.drawTooltip(
mouseX - this.guiLeft,
mouseY - this.guiTop,
MFFSHelper.splitStringPerWord(this.tooltip, 5).toArray(new String[] {})
);
}
this.tooltip = "";
}
@Override
protected void
drawGuiContainerBackgroundLayer(final float var1, final int x, final int y) {
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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
);
if (this.frequencyTile instanceof IBiometricIdentifierLink) {
this.drawBulb(
167,
4,
((IBiometricIdentifierLink) this.frequencyTile).getBiometricIdentifier()
!= null
);
}
}
protected void drawBulb(final int x, final int y, final boolean isOn) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/gui/gui_components.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(final int x, final int y, final ItemStack itemStack) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/gui/gui_components.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(final ItemStack itemStack, int x, int y) {
++x;
++y;
GL11.glTranslatef(0.0f, 0.0f, 32.0f);
GuiBase.itemRender.renderItemAndEffectIntoGUI(
this.fontRendererObj, this.mc.renderEngine, itemStack, x, y
);
}
protected void drawTextWithTooltip(
final String textName,
final String format,
final int x,
final int y,
final int mouseX,
final int mouseY
) {
this.drawTextWithTooltip(textName, format, x, y, mouseX, mouseY, 4210752);
}
protected void drawTextWithTooltip(
final String textName,
final String format,
final int x,
final int y,
final int mouseX,
final int mouseY,
final int color
) {
final String name = TranslationHelper.getLocal("gui." + textName + ".name");
final String text = format.replaceAll("%1", name);
this.fontRendererObj.drawString(text, x, y, color);
final String tooltip = TranslationHelper.getLocal("gui." + textName + ".tooltip");
if (tooltip != null && tooltip != ""
&& this.func_146978_c(
x, y, (int) (text.length() * 4.8), 12, mouseX, mouseY
)) {
this.tooltip = tooltip;
}
}
protected void drawTextWithTooltip(
final String textName,
final int x,
final int y,
final int mouseX,
final int mouseY
) {
this.drawTextWithTooltip(textName, "%1", x, y, mouseX, mouseY);
}
protected void drawSlot(
final int x,
final int y,
final SlotType type,
final float r,
final float g,
final float b
) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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 != SlotType.NONE) {
this.drawTexturedModalRect(
this.containerWidth + x,
this.containerHeight + y,
0,
18 * type.ordinal(),
18,
18
);
}
}
protected void drawSlot(final int x, final int y, final SlotType type) {
this.drawSlot(x, y, type, 1.0f, 1.0f, 1.0f);
}
protected void drawSlot(final int x, final int y) {
this.drawSlot(x, y, SlotType.NONE);
}
protected void drawBar(final int x, final int y, final float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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(final int x, final int y, final float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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(final int x, final int y, final float scale) {
this.mc.renderEngine.bindTexture(
new ResourceLocation("mffs", "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
);
}
}
public void drawTooltip(final int x, final int y, final String... toolTips) {
if (!GuiScreen.isShiftKeyDown()) {
GL11.glDisable(32826);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2896);
GL11.glDisable(2929);
if (toolTips != null) {
int var5 = 0;
for (int var6 = 0; var6 < toolTips.length; ++var6) {
final int var7 = this.fontRendererObj.getStringWidth(toolTips[var6]);
if (var7 > var5) {
var5 = var7;
}
}
int var6 = x + 12;
int var7 = y - 12;
int var8 = 8;
if (toolTips.length > 1) {
var8 += 2 + (toolTips.length - 1) * 10;
}
if (this.guiTop + var7 + var8 + 6 > this.height) {
var7 = this.height - var8 - this.guiTop - 6;
}
zLevel = 300.0f;
final int var9 = -267386864;
this.drawGradientRect(
var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var9, var9
);
this.drawGradientRect(
var6 - 3,
var7 + var8 + 3,
var6 + var5 + 3,
var7 + var8 + 4,
var9,
var9
);
this.drawGradientRect(
var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var8 + 3, var9, var9
);
this.drawGradientRect(
var6 - 4, var7 - 3, var6 - 3, var7 + var8 + 3, var9, var9
);
this.drawGradientRect(
var6 + var5 + 3,
var7 - 3,
var6 + var5 + 4,
var7 + var8 + 3,
var9,
var9
);
final int var10 = 1347420415;
final int var11 = (var10 & 0xFEFEFE) >> 1 | (var10 & 0xFF000000);
this.drawGradientRect(
var6 - 3,
var7 - 3 + 1,
var6 - 3 + 1,
var7 + var8 + 3 - 1,
var10,
var11
);
this.drawGradientRect(
var6 + var5 + 2,
var7 - 3 + 1,
var6 + var5 + 3,
var7 + var8 + 3 - 1,
var10,
var11
);
this.drawGradientRect(
var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var10, var10
);
this.drawGradientRect(
var6 - 3,
var7 + var8 + 2,
var6 + var5 + 3,
var7 + var8 + 3,
var11,
var11
);
for (int var12 = 0; var12 < toolTips.length; ++var12) {
final String var13 = toolTips[var12];
this.fontRendererObj.drawStringWithShadow(var13, var6, var7, -1);
var7 += 10;
}
this.zLevel = 0.0f;
GL11.glEnable(2929);
GL11.glEnable(2896);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
}
}
}
public enum SlotType {
NONE,
BATTERY,
LIQUID,
ARR_UP,
ARR_DOWN,
ARR_LEFT,
ARR_RIGHT,
ARR_UP_RIGHT,
ARR_UP_LEFT,
ARR_DOWN_LEFT,
ARR_DOWN_RIGHT;
}
} }

View File

@ -1,6 +1,7 @@
package mffs.base; package mffs.base;
import java.util.List; import java.util.List;
import mffs.MFFSCreativeTab; import mffs.MFFSCreativeTab;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -9,22 +10,25 @@ import net.minecraft.item.ItemStack;
import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.TranslationHelper;
public class ItemBase extends Item { public class ItemBase extends Item {
public ItemBase(final String name) { public ItemBase(final String name) {
super(); super();
this.setUnlocalizedName("mffs:" + name); this.setUnlocalizedName("mffs:" + name);
this.setCreativeTab(MFFSCreativeTab.INSTANCE); this.setCreativeTab(MFFSCreativeTab.INSTANCE);
this.setNoRepair(); this.setNoRepair();
this.iconString = "mffs:" + name; this.iconString = "mffs:" + name;
} }
@Override @Override
public void addInformation(final ItemStack itemStack, public void addInformation(
final EntityPlayer player, final List info, final ItemStack itemStack,
final boolean b) { final EntityPlayer player,
final String tooltip = final List info,
TranslationHelper.getLocal(this.getUnlocalizedName() + ".tooltip"); final boolean b
if (tooltip != null && tooltip.length() > 0) { ) {
info.addAll(MFFSHelper.splitStringPerWord(tooltip, 5)); final String tooltip
= TranslationHelper.getLocal(this.getUnlocalizedName() + ".tooltip");
if (tooltip != null && tooltip.length() > 0) {
info.addAll(MFFSHelper.splitStringPerWord(tooltip, 5));
}
} }
}
} }

View File

@ -1,12 +1,13 @@
package mffs.base; package mffs.base;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.ByteBufOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
@ -29,7 +30,8 @@ public class PacketFxs implements IMessage {
NBTTagCompound nbt = null; NBTTagCompound nbt = null;
try { try {
nbt = CompressedStreamTools.read( nbt = CompressedStreamTools.read(
new DataInputStream(new ByteBufInputStream(buf))); new DataInputStream(new ByteBufInputStream(buf))
);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -47,7 +49,8 @@ public class PacketFxs implements IMessage {
try { try {
CompressedStreamTools.write( CompressedStreamTools.write(
nbt, new DataOutputStream(new ByteBufOutputStream(buf))); nbt, new DataOutputStream(new ByteBufOutputStream(buf))
);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -10,7 +10,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
public class PacketFxsHandler implements IMessageHandler<PacketFxs, IMessage> { public class PacketFxsHandler implements IMessageHandler<PacketFxs, IMessage> {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IMessage onMessage(PacketFxs message, MessageContext ctx) { public IMessage onMessage(PacketFxs message, MessageContext ctx) {

View File

@ -1,65 +1,68 @@
package mffs.base; package mffs.base;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.ByteBufOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class PacketTile implements IMessage { public class PacketTile implements IMessage {
Type type; Type type;
Vector3 pos; Vector3 pos;
NBTTagCompound data; NBTTagCompound data;
public PacketTile(Type type, Vector3 pos, NBTTagCompound data) { public PacketTile(Type type, Vector3 pos, NBTTagCompound data) {
this.type = type; this.type = type;
this.pos = pos; this.pos = pos;
this.data = data; this.data = data;
}
public PacketTile() {}
@Override
public void fromBytes(ByteBuf buf) {
try {
NBTTagCompound nbt = CompressedStreamTools.read(
new DataInputStream(new ByteBufInputStream(buf)));
this.type = Type.values()[nbt.getInteger("type")];
this.pos = Vector3.readFromNBT(nbt);
this.data = nbt.getCompoundTag("data");
} catch (IOException e) {
e.printStackTrace();
} }
}
@Override public PacketTile() {}
public void toBytes(ByteBuf buf) {
try {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("type", this.type.ordinal()); @Override
this.pos.writeToNBT(nbt); public void fromBytes(ByteBuf buf) {
nbt.setTag("data", this.data); try {
NBTTagCompound nbt = CompressedStreamTools.read(
new DataInputStream(new ByteBufInputStream(buf))
);
CompressedStreamTools.write( this.type = Type.values()[nbt.getInteger("type")];
nbt, new DataOutputStream(new ByteBufOutputStream(buf))); this.pos = Vector3.readFromNBT(nbt);
} catch (IOException e) { this.data = nbt.getCompoundTag("data");
e.printStackTrace(); } catch (IOException e) {
e.printStackTrace();
}
} }
}
public enum Type { @Override
NONE, public void toBytes(ByteBuf buf) {
FREQUENCY, try {
TOGGLE_ACTIVATION, NBTTagCompound nbt = new NBTTagCompound();
TOGGLE_MODE,
INVENTORY, nbt.setInteger("type", this.type.ordinal());
STRING, this.pos.writeToNBT(nbt);
} nbt.setTag("data", this.data);
CompressedStreamTools.write(
nbt, new DataOutputStream(new ByteBufOutputStream(buf))
);
} catch (IOException e) {
e.printStackTrace();
}
}
public enum Type {
NONE,
FREQUENCY,
TOGGLE_ACTIVATION,
TOGGLE_MODE,
INVENTORY,
STRING,
}
} }

View File

@ -6,19 +6,18 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
public class PacketTileHandler public class PacketTileHandler implements IMessageHandler<PacketTile, IMessage> {
implements IMessageHandler<PacketTile, IMessage> { @Override
@Override public IMessage onMessage(PacketTile arg0, MessageContext arg1) {
public IMessage onMessage(PacketTile arg0, MessageContext arg1) { World w = arg1.getServerHandler().playerEntity.worldObj;
World w = arg1.getServerHandler().playerEntity.worldObj;
TileEntity te = arg0.pos.getTileEntity(w); TileEntity te = arg0.pos.getTileEntity(w);
if (!(te instanceof TileEntityBase)) if (!(te instanceof TileEntityBase))
return null; return null;
((TileEntityBase)te).onReceivePacket(arg0.type, arg0.data); ((TileEntityBase) te).onReceivePacket(arg0.type, arg0.data);
return null; return null;
} }
} }

View File

@ -1,11 +1,11 @@
package mffs.base; package mffs.base;
import dan200.computercraft.api.peripheral.IPeripheral;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
import mffs.api.IActivatable; import mffs.api.IActivatable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -22,112 +22,118 @@ import universalelectricity.prefab.tile.TileEntityDisableable;
public abstract class TileEntityBase extends TileEntityDisableable public abstract class TileEntityBase extends TileEntityDisableable
implements IRotatable, IRedstoneReceptor, IActivatable, IPeripheral { implements IRotatable, IRedstoneReceptor, IActivatable, IPeripheral {
public boolean isActive; public boolean isActive;
public boolean isRedstoneActive; public boolean isRedstoneActive;
public final List<EntityPlayer> playersUsing; public final List<EntityPlayer> playersUsing;
public float animation; public float animation;
public TileEntityBase() { public TileEntityBase() {
this.isActive = false; this.isActive = false;
this.isRedstoneActive = false; this.isRedstoneActive = false;
this.playersUsing = new ArrayList<>(); this.playersUsing = new ArrayList<>();
this.animation = 0.0f; this.animation = 0.0f;
}
@Override
public void updateEntity() {
super.updateEntity();
if (super.ticks % 4L == 0L && this.playersUsing.size() > 0) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
} }
}
@Override @Override
public Packet getDescriptionPacket() { public void updateEntity() {
NBTTagCompound nbt = new NBTTagCompound(); super.updateEntity();
if (super.ticks % 4L == 0L && this.playersUsing.size() > 0) {
nbt.setBoolean("isActive", this.isActive); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord,
this.getBlockMetadata(), nbt);
}
@Override
public void onDataPacket(NetworkManager arg0,
S35PacketUpdateTileEntity arg1) {
NBTTagCompound nbt = arg1.func_148857_g();
this.isActive = nbt.getBoolean("isActive");
}
@SideOnly(Side.CLIENT)
public void onFxsPacket(NBTTagCompound data) {}
public void onReceivePacket(final PacketTile.Type type,
final NBTTagCompound data) {
if (type == PacketTile.Type.TOGGLE_ACTIVATION) {
this.isRedstoneActive = !this.isRedstoneActive;
this.setActive(this.isRedstoneActive);
} }
}
public boolean isPoweredByRedstone() { @Override
return this.worldObj.isBlockIndirectlyGettingPowered( public Packet getDescriptionPacket() {
this.xCoord, this.yCoord, this.zCoord); NBTTagCompound nbt = new NBTTagCompound();
}
@Override nbt.setBoolean("isActive", this.isActive);
public void readFromNBT(final NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.isActive = nbt.getBoolean("isActive");
this.isRedstoneActive = nbt.getBoolean("isRedstoneActive");
}
@Override return new S35PacketUpdateTileEntity(
public void writeToNBT(final NBTTagCompound nbttagcompound) { this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
super.writeToNBT(nbttagcompound); );
nbttagcompound.setBoolean("isActive", this.isActive);
nbttagcompound.setBoolean("isRedstoneActive", this.isRedstoneActive);
}
@Override
public boolean isActive() {
return this.isActive;
}
@Override
public void setActive(final boolean flag) {
this.isActive = flag;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
@Override
public ForgeDirection getDirection(final IBlockAccess world, final int x,
final int y, final int z) {
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
@Override
public void setDirection(final World world, final int x, final int y,
final int z, final ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
}
@Override
public void onPowerOn() {
this.setActive(true);
}
@Override
public void onPowerOff() {
if (!this.isRedstoneActive && !this.worldObj.isRemote) {
this.setActive(false);
} }
}
@Override @Override
public boolean equals(IPeripheral other) { public void onDataPacket(NetworkManager arg0, S35PacketUpdateTileEntity arg1) {
return this == other; NBTTagCompound nbt = arg1.func_148857_g();
}
this.isActive = nbt.getBoolean("isActive");
}
@SideOnly(Side.CLIENT)
public void onFxsPacket(NBTTagCompound data) {}
public void onReceivePacket(final PacketTile.Type type, final NBTTagCompound data) {
if (type == PacketTile.Type.TOGGLE_ACTIVATION) {
this.isRedstoneActive = !this.isRedstoneActive;
this.setActive(this.isRedstoneActive);
}
}
public boolean isPoweredByRedstone() {
return this.worldObj.isBlockIndirectlyGettingPowered(
this.xCoord, this.yCoord, this.zCoord
);
}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.isActive = nbt.getBoolean("isActive");
this.isRedstoneActive = nbt.getBoolean("isRedstoneActive");
}
@Override
public void writeToNBT(final NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setBoolean("isActive", this.isActive);
nbttagcompound.setBoolean("isRedstoneActive", this.isRedstoneActive);
}
@Override
public boolean isActive() {
return this.isActive;
}
@Override
public void setActive(final boolean flag) {
this.isActive = flag;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
@Override
public ForgeDirection
getDirection(final IBlockAccess world, final int x, final int y, final int z) {
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
@Override
public void setDirection(
final World world,
final int x,
final int y,
final int z,
final ForgeDirection facingDirection
) {
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3
);
}
@Override
public void onPowerOn() {
this.setActive(true);
}
@Override
public void onPowerOff() {
if (!this.isRedstoneActive && !this.worldObj.isRemote) {
this.setActive(false);
}
}
@Override
public boolean equals(IPeripheral other) {
return this == other;
}
} }

View File

@ -24,148 +24,155 @@ import universalelectricity.core.vector.Vector3;
public abstract class TileEntityFortron extends TileEntityFrequency public abstract class TileEntityFortron extends TileEntityFrequency
implements IFluidHandler, IFortronFrequency, ISpecialForceManipulation { implements IFluidHandler, IFortronFrequency, ISpecialForceManipulation {
protected FluidTank fortronTank; protected FluidTank fortronTank;
private boolean markSendFortron; private boolean markSendFortron;
public TileEntityFortron() { public TileEntityFortron() {
this.fortronTank = new FluidTank(FortronHelper.FLUID_FORTRON, 0, 1000); this.fortronTank = new FluidTank(FortronHelper.FLUID_FORTRON, 0, 1000);
this.markSendFortron = true; this.markSendFortron = true;
}
@Override
public void updateEntity() {
super.updateEntity();
if (!Settings.CONSERVE_PACKETS && super.ticks % 60L == 0L) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
} }
}
@Override @Override
public void invalidate() { public void updateEntity() {
if (this.markSendFortron) { super.updateEntity();
MFFSHelper.transferFortron( if (!Settings.CONSERVE_PACKETS && super.ticks % 60L == 0L) {
this, this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
FrequencyGrid.instance().getFortronTiles( }
this.worldObj, new Vector3(this), 100, this.getFrequency()),
TransferMode.DRAIN, Integer.MAX_VALUE);
} }
super.invalidate();
}
@Override @Override
public Packet getDescriptionPacket() { public void invalidate() {
NBTTagCompound nbt = new NBTTagCompound(); if (this.markSendFortron) {
MFFSHelper.transferFortron(
nbt.setInteger("fortron", this.fortronTank.getFluidAmount()); this,
nbt.setBoolean("isActive", this.isActive()); FrequencyGrid.instance().getFortronTiles(
this.worldObj, new Vector3(this), 100, this.getFrequency()
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, ),
this.getBlockMetadata(), nbt); TransferMode.DRAIN,
} Integer.MAX_VALUE
);
@Override }
public void onDataPacket(NetworkManager arg0, super.invalidate();
S35PacketUpdateTileEntity arg1) {
NBTTagCompound nbt = arg1.func_148857_g();
this.fortronTank.setFluid(
new FluidStack(FortronHelper.FLUID_FORTRON, nbt.getInteger("fortron")));
this.isActive = nbt.getBoolean("isActive");
}
@Override
public boolean preMove(final int x, final int y, final int z) {
return true;
}
@Override
public void move(final int x, final int y, final int z) {
this.markSendFortron = false;
}
@Override
public void postMove() {}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.fortronTank.setFluid(
FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("fortron")));
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
if (this.fortronTank.getFluid() != null) {
final NBTTagCompound fortronCompound = new NBTTagCompound();
this.fortronTank.getFluid().writeToNBT(fortronCompound);
nbt.setTag("fortron", (NBTBase)fortronCompound);
} }
}
@Override @Override
public int fill(final ForgeDirection from, final FluidStack resource, public Packet getDescriptionPacket() {
final boolean doFill) { NBTTagCompound nbt = new NBTTagCompound();
if (resource.getFluid() == FortronHelper.FLUID_FORTRON) {
return this.fortronTank.fill(resource, doFill); nbt.setInteger("fortron", this.fortronTank.getFluidAmount());
nbt.setBoolean("isActive", this.isActive());
return new S35PacketUpdateTileEntity(
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
);
} }
return 0;
}
@Override @Override
public boolean canFill(ForgeDirection arg0, Fluid arg1) { public void onDataPacket(NetworkManager arg0, S35PacketUpdateTileEntity arg1) {
return arg1 == FortronHelper.FLUID_FORTRON && NBTTagCompound nbt = arg1.func_148857_g();
this.fortronTank.getFluidAmount() < this.fortronTank.getCapacity();
}
@Override this.fortronTank.setFluid(
public FluidStack drain(final ForgeDirection from, final int maxDrain, new FluidStack(FortronHelper.FLUID_FORTRON, nbt.getInteger("fortron"))
final boolean doDrain) { );
return this.fortronTank.drain(maxDrain, doDrain); this.isActive = nbt.getBoolean("isActive");
} }
@Override @Override
public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { public boolean preMove(final int x, final int y, final int z) {
if (arg1.getFluid() != FortronHelper.FLUID_FORTRON) return true;
return null; }
return this.fortronTank.drain(arg1.amount, arg2); @Override
} public void move(final int x, final int y, final int z) {
this.markSendFortron = false;
@Override }
public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
return arg1 == FortronHelper.FLUID_FORTRON && @Override
this.fortronTank.getFluidAmount() > 0; public void postMove() {}
}
@Override
@Override public void readFromNBT(final NBTTagCompound nbt) {
public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { super.readFromNBT(nbt);
return new FluidTankInfo[] {new FluidTankInfo(this.fortronTank)}; this.fortronTank.setFluid(
} FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("fortron"))
);
public void setFortronEnergy(final int joules) { }
this.fortronTank.setFluid(FortronHelper.getFortron(joules));
} @Override
public void writeToNBT(final NBTTagCompound nbt) {
public int getFortronEnergy() { super.writeToNBT(nbt);
return FortronHelper.getAmount(this.fortronTank); if (this.fortronTank.getFluid() != null) {
} final NBTTagCompound fortronCompound = new NBTTagCompound();
this.fortronTank.getFluid().writeToNBT(fortronCompound);
public int getFortronCapacity() { return this.fortronTank.getCapacity(); } nbt.setTag("fortron", (NBTBase) fortronCompound);
}
public int requestFortron(final int amount, final boolean doUse) { }
return FortronHelper.getAmount(this.fortronTank.drain(amount, doUse));
} @Override
public int
public int provideFortron(final int joules, final boolean doUse) { fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
return this.fortronTank.fill(FortronHelper.getFortron(joules), doUse); if (resource.getFluid() == FortronHelper.FLUID_FORTRON) {
} return this.fortronTank.fill(resource, doFill);
}
public ItemStack getCard() { return 0;
final ItemStack itemStack = this.getStackInSlot(0); }
if (itemStack != null && itemStack.getItem() instanceof ICard) {
return itemStack; @Override
public boolean canFill(ForgeDirection arg0, Fluid arg1) {
return arg1 == FortronHelper.FLUID_FORTRON
&& this.fortronTank.getFluidAmount() < this.fortronTank.getCapacity();
}
@Override
public FluidStack
drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) {
return this.fortronTank.drain(maxDrain, doDrain);
}
@Override
public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
if (arg1.getFluid() != FortronHelper.FLUID_FORTRON)
return null;
return this.fortronTank.drain(arg1.amount, arg2);
}
@Override
public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
return arg1 == FortronHelper.FLUID_FORTRON
&& this.fortronTank.getFluidAmount() > 0;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
return new FluidTankInfo[] { new FluidTankInfo(this.fortronTank) };
}
public void setFortronEnergy(final int joules) {
this.fortronTank.setFluid(FortronHelper.getFortron(joules));
}
public int getFortronEnergy() {
return FortronHelper.getAmount(this.fortronTank);
}
public int getFortronCapacity() {
return this.fortronTank.getCapacity();
}
public int requestFortron(final int amount, final boolean doUse) {
return FortronHelper.getAmount(this.fortronTank.drain(amount, doUse));
}
public int provideFortron(final int joules, final boolean doUse) {
return this.fortronTank.fill(FortronHelper.getFortron(joules), doUse);
}
public ItemStack getCard() {
final ItemStack itemStack = this.getStackInSlot(0);
if (itemStack != null && itemStack.getItem() instanceof ICard) {
return itemStack;
}
return null;
} }
return null;
}
} }

View File

@ -1,8 +1,9 @@
package mffs.base; package mffs.base;
import icbm.api.IBlockFrequency;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import icbm.api.IBlockFrequency;
import mffs.api.IBiometricIdentifierLink; import mffs.api.IBiometricIdentifierLink;
import mffs.api.card.ICardLink; import mffs.api.card.ICardLink;
import mffs.api.security.IBiometricIdentifier; import mffs.api.security.IBiometricIdentifier;
@ -13,83 +14,82 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public abstract class TileEntityFrequency extends TileEntityInventory public abstract class TileEntityFrequency
implements IBlockFrequency, IBiometricIdentifierLink { extends TileEntityInventory implements IBlockFrequency, IBiometricIdentifierLink {
private int frequency; private int frequency;
@Override @Override
public void initiate() { public void initiate() {
FrequencyGrid.instance().register(this); FrequencyGrid.instance().register(this);
super.initiate(); super.initiate();
}
@Override
public void invalidate() {
FrequencyGrid.instance().unregister(this);
super.invalidate();
}
@Override
public void onReceivePacket(final PacketTile.Type type,
final NBTTagCompound data) {
super.onReceivePacket(type, data);
if (type == PacketTile.Type.FREQUENCY) {
this.setFrequency(data.getInteger("frequency"));
} }
}
@Override @Override
public void readFromNBT(final NBTTagCompound nbt) { public void invalidate() {
super.readFromNBT(nbt); FrequencyGrid.instance().unregister(this);
this.setFrequency(nbt.getInteger("frequency")); super.invalidate();
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("frequency", this.getFrequency());
}
@Override
public int getFrequency() {
return this.frequency;
}
@Override
public void setFrequency(final int frequency) {
this.frequency = frequency;
}
@Override
public IBiometricIdentifier getBiometricIdentifier() {
if (this.getBiometricIdentifiers().size() > 0) {
return (IBiometricIdentifier)this.getBiometricIdentifiers().toArray()[0];
} }
return null;
}
@Override @Override
public Set<IBiometricIdentifier> getBiometricIdentifiers() { public void onReceivePacket(final PacketTile.Type type, final NBTTagCompound data) {
final Set<IBiometricIdentifier> list = new HashSet<>(); super.onReceivePacket(type, data);
for (final ItemStack itemStack : this.getCards()) { if (type == PacketTile.Type.FREQUENCY) {
if (itemStack != null && itemStack.getItem() instanceof ICardLink) { this.setFrequency(data.getInteger("frequency"));
final Vector3 linkedPosition =
((ICardLink)itemStack.getItem()).getLink(itemStack);
final TileEntity tileEntity =
linkedPosition.getTileEntity((IBlockAccess)this.worldObj);
if (linkedPosition == null ||
!(tileEntity instanceof IBiometricIdentifier)) {
continue;
} }
list.add((IBiometricIdentifier)tileEntity);
}
} }
for (final IBlockFrequency tileEntity2 :
FrequencyGrid.instance().get(this.getFrequency())) { @Override
if (tileEntity2 instanceof IBiometricIdentifier) { public void readFromNBT(final NBTTagCompound nbt) {
list.add((IBiometricIdentifier)tileEntity2); super.readFromNBT(nbt);
} this.setFrequency(nbt.getInteger("frequency"));
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("frequency", this.getFrequency());
}
@Override
public int getFrequency() {
return this.frequency;
}
@Override
public void setFrequency(final int frequency) {
this.frequency = frequency;
}
@Override
public IBiometricIdentifier getBiometricIdentifier() {
if (this.getBiometricIdentifiers().size() > 0) {
return (IBiometricIdentifier) this.getBiometricIdentifiers().toArray()[0];
}
return null;
}
@Override
public Set<IBiometricIdentifier> getBiometricIdentifiers() {
final Set<IBiometricIdentifier> list = new HashSet<>();
for (final ItemStack itemStack : this.getCards()) {
if (itemStack != null && itemStack.getItem() instanceof ICardLink) {
final Vector3 linkedPosition
= ((ICardLink) itemStack.getItem()).getLink(itemStack);
final TileEntity tileEntity
= linkedPosition.getTileEntity((IBlockAccess) this.worldObj);
if (linkedPosition == null
|| !(tileEntity instanceof IBiometricIdentifier)) {
continue;
}
list.add((IBiometricIdentifier) tileEntity);
}
}
for (final IBlockFrequency tileEntity2 :
FrequencyGrid.instance().get(this.getFrequency())) {
if (tileEntity2 instanceof IBiometricIdentifier) {
list.add((IBiometricIdentifier) tileEntity2);
}
}
return list;
} }
return list;
}
} }

View File

@ -1,10 +1,11 @@
package mffs.base; package mffs.base;
import java.util.HashSet;
import java.util.Set;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -24,8 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.TileEntityMulti; import universalelectricity.prefab.multiblock.TileEntityMulti;
public abstract class TileEntityInventory public abstract class TileEntityInventory extends TileEntityBase implements IInventory {
extends TileEntityBase implements IInventory {
protected ItemStack[] inventory; protected ItemStack[] inventory;
public TileEntityInventory() { public TileEntityInventory() {
@ -49,12 +49,13 @@ public abstract class TileEntityInventory
this.writeToNBT(nbt); this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt); return new S35PacketUpdateTileEntity(
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
);
} }
@Override @Override
public void onDataPacket(NetworkManager arg0, public void onDataPacket(NetworkManager arg0, S35PacketUpdateTileEntity arg1) {
S35PacketUpdateTileEntity arg1) {
NBTTagCompound nbt = arg1.func_148857_g(); NBTTagCompound nbt = arg1.func_148857_g();
this.readFromNBT(nbt); this.readFromNBT(nbt);
@ -87,8 +88,7 @@ public abstract class TileEntityInventory
@Override @Override
public void setInventorySlotContents(final int i, final ItemStack itemstack) { public void setInventorySlotContents(final int i, final ItemStack itemstack) {
this.inventory[i] = itemstack; this.inventory[i] = itemstack;
if (itemstack != null && if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
itemstack.stackSize > this.getInventoryStackLimit()) {
itemstack.stackSize = this.getInventoryStackLimit(); itemstack.stackSize = this.getInventoryStackLimit();
} }
} }
@ -111,12 +111,10 @@ public abstract class TileEntityInventory
} }
@Override @Override
public void openInventory() { public void openInventory() {}
}
@Override @Override
public void closeInventory() { public void closeInventory() {}
}
@Override @Override
public boolean isUseableByPlayer(final EntityPlayer entityplayer) { public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
@ -139,15 +137,14 @@ public abstract class TileEntityInventory
} }
@Override @Override
public boolean isItemValidForSlot(final int slotID, public boolean isItemValidForSlot(final int slotID, final ItemStack itemStack) {
final ItemStack itemStack) {
return true; return true;
} }
public boolean canIncreaseStack(final int slotID, final ItemStack itemStack) { public boolean canIncreaseStack(final int slotID, final ItemStack itemStack) {
return this.getStackInSlot(slotID) == null || return this.getStackInSlot(slotID) == null
(this.getStackInSlot(slotID).stackSize + 1 <= 64 && || (this.getStackInSlot(slotID).stackSize + 1 <= 64
this.getStackInSlot(slotID).isItemEqual(itemStack)); && this.getStackInSlot(slotID).isItemEqual(itemStack));
} }
public void incrStackSize(final int slot, final ItemStack itemStack) { public void incrStackSize(final int slot, final ItemStack itemStack) {
@ -165,37 +162,47 @@ public abstract class TileEntityInventory
return cards; return cards;
} }
public ItemStack tryPlaceInPosition(ItemStack itemStack, public ItemStack tryPlaceInPosition(
final Vector3 position, ItemStack itemStack, final Vector3 position, final ForgeDirection dir
final ForgeDirection dir) { ) {
final TileEntity tileEntity = position.getTileEntity((IBlockAccess) this.worldObj); final TileEntity tileEntity
= position.getTileEntity((IBlockAccess) this.worldObj);
final ForgeDirection direction = dir.getOpposite(); final ForgeDirection direction = dir.getOpposite();
if (tileEntity != null && itemStack != null) { if (tileEntity != null && itemStack != null) {
if (tileEntity instanceof TileEntityMulti) { if (tileEntity instanceof TileEntityMulti) {
final Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition; final Vector3 mainBlockPosition
if (mainBlockPosition != null && = ((TileEntityMulti) tileEntity).mainBlockPosition;
!(mainBlockPosition.getTileEntity((IBlockAccess) this.worldObj) instanceof TileEntityMulti)) { if (mainBlockPosition != null
return this.tryPlaceInPosition(itemStack, mainBlockPosition, && !(
direction); mainBlockPosition.getTileEntity((IBlockAccess) this.worldObj)
instanceof TileEntityMulti
)) {
return this.tryPlaceInPosition(
itemStack, mainBlockPosition, direction
);
} }
} else if (tileEntity instanceof TileEntityChest) { } else if (tileEntity instanceof TileEntityChest) {
final TileEntityChest[] chests = { (TileEntityChest) tileEntity, null }; final TileEntityChest[] chests = { (TileEntityChest) tileEntity, null };
for (int i = 2; i < 6; ++i) { for (int i = 2; i < 6; ++i) {
final ForgeDirection searchDirection = ForgeDirection.getOrientation(i); final ForgeDirection searchDirection
= ForgeDirection.getOrientation(i);
final Vector3 searchPosition = position.clone(); final Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection); searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity((IBlockAccess) this.worldObj) != null && if (searchPosition.getTileEntity((IBlockAccess) this.worldObj) != null
searchPosition.getTileEntity((IBlockAccess) this.worldObj) && searchPosition.getTileEntity((IBlockAccess) this.worldObj)
.getClass() == chests[0].getClass()) { .getClass()
chests[1] = (TileEntityChest) searchPosition.getTileEntity( == chests[0].getClass()) {
(IBlockAccess) this.worldObj); chests[1] = (TileEntityChest
) searchPosition.getTileEntity((IBlockAccess) this.worldObj);
break; break;
} }
} }
for (final TileEntityChest chest : chests) { for (final TileEntityChest chest : chests) {
if (chest != null) { if (chest != null) {
for (int j = 0; j < chest.getSizeInventory(); ++j) { for (int j = 0; j < chest.getSizeInventory(); ++j) {
itemStack = this.addStackToInventory(j, (IInventory) chest, itemStack); itemStack = this.addStackToInventory(
j, (IInventory) chest, itemStack
);
if (itemStack == null) { if (itemStack == null) {
return null; return null;
} }
@ -204,12 +211,15 @@ public abstract class TileEntityInventory
} }
} else if (tileEntity instanceof ISidedInventory) { } else if (tileEntity instanceof ISidedInventory) {
final ISidedInventory inventory = (ISidedInventory) tileEntity; final ISidedInventory inventory = (ISidedInventory) tileEntity;
final int[] slots = inventory.getAccessibleSlotsFromSide(direction.ordinal()); final int[] slots
= inventory.getAccessibleSlotsFromSide(direction.ordinal());
for (int k = 0; k < slots.length; ++k) { for (int k = 0; k < slots.length; ++k) {
if (inventory.canInsertItem(slots[k], itemStack, if (inventory.canInsertItem(
direction.ordinal())) { slots[k], itemStack, direction.ordinal()
)) {
itemStack = this.addStackToInventory( itemStack = this.addStackToInventory(
slots[k], (IInventory) inventory, itemStack); slots[k], (IInventory) inventory, itemStack
);
} }
if (itemStack == null) { if (itemStack == null) {
return null; return null;
@ -231,9 +241,9 @@ public abstract class TileEntityInventory
return itemStack; return itemStack;
} }
public ItemStack addStackToInventory(final int slotIndex, public ItemStack addStackToInventory(
final IInventory inventory, final int slotIndex, final IInventory inventory, final ItemStack itemStack
final ItemStack itemStack) { ) {
if (inventory.getSizeInventory() > slotIndex) { if (inventory.getSizeInventory() > slotIndex) {
ItemStack stackInInventory = inventory.getStackInSlot(slotIndex); ItemStack stackInInventory = inventory.getStackInSlot(slotIndex);
if (stackInInventory == null) { if (stackInInventory == null) {
@ -242,17 +252,21 @@ public abstract class TileEntityInventory
return itemStack; return itemStack;
} }
return null; return null;
} else if (stackInInventory.isItemEqual(itemStack) && } else if (stackInInventory.isItemEqual(itemStack) && stackInInventory.isStackable()) {
stackInInventory.isStackable()) {
stackInInventory = stackInInventory.copy(); stackInInventory = stackInInventory.copy();
final int stackLim = Math.min(inventory.getInventoryStackLimit(), final int stackLim = Math.min(
itemStack.getMaxStackSize()); inventory.getInventoryStackLimit(), itemStack.getMaxStackSize()
);
final int rejectedAmount = Math.max( final int rejectedAmount = Math.max(
stackInInventory.stackSize + itemStack.stackSize - stackLim, 0); stackInInventory.stackSize + itemStack.stackSize - stackLim, 0
stackInInventory.stackSize = Math.min(Math.max(stackInInventory.stackSize + itemStack.stackSize - );
rejectedAmount, stackInInventory.stackSize = Math.min(
0), Math.max(
inventory.getInventoryStackLimit()); stackInInventory.stackSize + itemStack.stackSize - rejectedAmount,
0
),
inventory.getInventoryStackLimit()
);
itemStack.stackSize = rejectedAmount; itemStack.stackSize = rejectedAmount;
inventory.setInventorySlotContents(slotIndex, stackInInventory); inventory.setInventorySlotContents(slotIndex, stackInInventory);
} }
@ -268,14 +282,20 @@ public abstract class TileEntityInventory
for (final ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { for (final ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (itemStack != null) { if (itemStack != null) {
itemStack = this.tryPlaceInPosition( itemStack = this.tryPlaceInPosition(
itemStack, new Vector3(this).modifyPositionFromSide(direction), itemStack,
direction); new Vector3(this).modifyPositionFromSide(direction),
direction
);
} }
} }
if (itemStack != null) { if (itemStack != null) {
this.worldObj.spawnEntityInWorld((Entity) new EntityItem( this.worldObj.spawnEntityInWorld((Entity) new EntityItem(
this.worldObj, this.xCoord + 0.5, (double) (this.yCoord + 1), this.worldObj,
this.zCoord + 0.5, itemStack)); this.xCoord + 0.5,
(double) (this.yCoord + 1),
this.zCoord + 0.5,
itemStack
));
} }
} }
return false; return false;
@ -287,7 +307,8 @@ public abstract class TileEntityInventory
final NBTTagList nbtTagList = nbttagcompound.getTagList("Items", 10); final NBTTagList nbtTagList = nbttagcompound.getTagList("Items", 10);
this.inventory = new ItemStack[this.getSizeInventory()]; this.inventory = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbtTagList.tagCount(); ++i) { for (int i = 0; i < nbtTagList.tagCount(); ++i) {
final NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbtTagList.getCompoundTagAt(i); final NBTTagCompound nbttagcompound2
= (NBTTagCompound) nbtTagList.getCompoundTagAt(i);
final byte byte0 = nbttagcompound2.getByte("Slot"); final byte byte0 = nbttagcompound2.getByte("Slot");
if (byte0 >= 0 && byte0 < this.inventory.length) { if (byte0 >= 0 && byte0 < this.inventory.length) {
this.inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound2); this.inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound2);
@ -321,9 +342,9 @@ public abstract class TileEntityInventory
} }
@Override @Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, public Object[] callMethod(
int method, Object[] arguments) IComputerAccess computer, ILuaContext context, int method, Object[] arguments
throws LuaException, InterruptedException { ) throws LuaException, InterruptedException {
switch (method) { switch (method) {
case 0: { case 0: {
return new Object[] { this.isActive() }; return new Object[] { this.isActive() };
@ -338,12 +359,9 @@ public abstract class TileEntityInventory
} }
} }
@Override
public void attach(final IComputerAccess computer) {}
@Override @Override
public void attach(final IComputerAccess computer) { public void detach(final IComputerAccess computer) {}
}
@Override
public void detach(final IComputerAccess computer) {
}
} }

View File

@ -14,7 +14,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public abstract class TileEntityModuleAcceptor public abstract class TileEntityModuleAcceptor
extends TileEntityFortron implements IModuleAcceptor, ICache { extends TileEntityFortron implements IModuleAcceptor, ICache {
public final HashMap<String, Object> cache; public final HashMap<String, Object> cache;
public int startModuleIndex; public int startModuleIndex;
public int endModuleIndex; public int endModuleIndex;
@ -33,11 +33,11 @@ public abstract class TileEntityModuleAcceptor
public void initiate() { public void initiate() {
super.initiate(); super.initiate();
super.fortronTank.setCapacity( super.fortronTank.setCapacity(
(this.getModuleCount(ModularForceFieldSystem.itemModuleCapacity, (this.getModuleCount(ModularForceFieldSystem.itemModuleCapacity, new int[0])
new int[0]) * * this.capacityBoost
this.capacityBoost + + this.capacityBase)
this.capacityBase) * * 1000
1000); );
} }
public void consumeCost() { public void consumeCost() {
@ -49,8 +49,8 @@ public abstract class TileEntityModuleAcceptor
@Override @Override
public ItemStack getModule(final IModule module) { public ItemStack getModule(final IModule module) {
final String cacheID = "getModule_" + module.hashCode(); final String cacheID = "getModule_" + module.hashCode();
if (Settings.USE_CACHE && this.cache.containsKey(cacheID) && if (Settings.USE_CACHE && this.cache.containsKey(cacheID)
this.cache.get(cacheID) instanceof ItemStack) { && this.cache.get(cacheID) instanceof ItemStack) {
return (ItemStack) this.cache.get(cacheID); return (ItemStack) this.cache.get(cacheID);
} }
final ItemStack returnStack = new ItemStack((Item) module, 0); final ItemStack returnStack = new ItemStack((Item) module, 0);
@ -74,14 +74,14 @@ public abstract class TileEntityModuleAcceptor
if (slots != null) { if (slots != null) {
cacheID = cacheID + "_" + Arrays.hashCode(slots); cacheID = cacheID + "_" + Arrays.hashCode(slots);
} }
if (Settings.USE_CACHE && this.cache.containsKey(cacheID) && if (Settings.USE_CACHE && this.cache.containsKey(cacheID)
this.cache.get(cacheID) instanceof Integer) { && this.cache.get(cacheID) instanceof Integer) {
return (int) this.cache.get(cacheID); return (int) this.cache.get(cacheID);
} }
if (slots != null && slots.length > 0) { if (slots != null && slots.length > 0) {
for (final int slotID : slots) { for (final int slotID : slots) {
if (this.getStackInSlot(slotID) != null && if (this.getStackInSlot(slotID) != null
this.getStackInSlot(slotID).getItem() == module) { && this.getStackInSlot(slotID).getItem() == module) {
count += this.getStackInSlot(slotID).stackSize; count += this.getStackInSlot(slotID).stackSize;
} }
} }
@ -105,13 +105,14 @@ public abstract class TileEntityModuleAcceptor
if (slots != null) { if (slots != null) {
cacheID += Arrays.hashCode(slots); cacheID += Arrays.hashCode(slots);
} }
if (Settings.USE_CACHE && this.cache.containsKey(cacheID) && if (Settings.USE_CACHE && this.cache.containsKey(cacheID)
this.cache.get(cacheID) instanceof Set<?>) { && this.cache.get(cacheID) instanceof Set<?>) {
return (Set<ItemStack>) this.cache.get(cacheID); return (Set<ItemStack>) this.cache.get(cacheID);
} }
final Set<ItemStack> modules = new HashSet<>(); final Set<ItemStack> modules = new HashSet<>();
if (slots == null || slots.length <= 0) { if (slots == null || slots.length <= 0) {
for (int slotID = this.startModuleIndex; slotID <= this.endModuleIndex; ++slotID) { for (int slotID = this.startModuleIndex; slotID <= this.endModuleIndex;
++slotID) {
final ItemStack itemStack = this.getStackInSlot(slotID); final ItemStack itemStack = this.getStackInSlot(slotID);
if (itemStack != null && itemStack.getItem() instanceof IModule) { if (itemStack != null && itemStack.getItem() instanceof IModule) {
modules.add(itemStack); modules.add(itemStack);
@ -137,13 +138,14 @@ public abstract class TileEntityModuleAcceptor
if (slots != null) { if (slots != null) {
cacheID += Arrays.hashCode(slots); cacheID += Arrays.hashCode(slots);
} }
if (Settings.USE_CACHE && this.cache.containsKey(cacheID) && if (Settings.USE_CACHE && this.cache.containsKey(cacheID)
this.cache.get(cacheID) instanceof Set) { && this.cache.get(cacheID) instanceof Set) {
return (Set<IModule>) this.cache.get(cacheID); return (Set<IModule>) this.cache.get(cacheID);
} }
final Set<IModule> modules = new HashSet<>(); final Set<IModule> modules = new HashSet<>();
if (slots == null || slots.length <= 0) { if (slots == null || slots.length <= 0) {
for (int slotID = this.startModuleIndex; slotID <= this.endModuleIndex; ++slotID) { for (int slotID = this.startModuleIndex; slotID <= this.endModuleIndex;
++slotID) {
final ItemStack itemStack = this.getStackInSlot(slotID); final ItemStack itemStack = this.getStackInSlot(slotID);
if (itemStack != null && itemStack.getItem() instanceof IModule) { if (itemStack != null && itemStack.getItem() instanceof IModule) {
modules.add((IModule) itemStack.getItem()); modules.add((IModule) itemStack.getItem());
@ -166,15 +168,15 @@ public abstract class TileEntityModuleAcceptor
@Override @Override
public int getFortronCost() { public int getFortronCost() {
final String cacheID = "getFortronCost"; final String cacheID = "getFortronCost";
if (Settings.USE_CACHE && this.cache.containsKey(cacheID) && if (Settings.USE_CACHE && this.cache.containsKey(cacheID)
this.cache.get(cacheID) instanceof Integer) { && this.cache.get(cacheID) instanceof Integer) {
return (int) this.cache.get(cacheID); return (int) this.cache.get(cacheID);
} }
float cost = 0.0f; float cost = 0.0f;
for (final ItemStack itemStack : this.getModuleStacks(new int[0])) { for (final ItemStack itemStack : this.getModuleStacks(new int[0])) {
if (itemStack != null) { if (itemStack != null) {
cost += itemStack.stackSize * cost += itemStack.stackSize
((IModule) itemStack.getItem()).getFortronCost(this.getAmplifier()); * ((IModule) itemStack.getItem()).getFortronCost(this.getAmplifier());
} }
} }
final int result = Math.round(cost); final int result = Math.round(cost);
@ -192,11 +194,11 @@ public abstract class TileEntityModuleAcceptor
public void markDirty() { public void markDirty() {
super.markDirty(); super.markDirty();
super.fortronTank.setCapacity( super.fortronTank.setCapacity(
(this.getModuleCount(ModularForceFieldSystem.itemModuleCapacity, (this.getModuleCount(ModularForceFieldSystem.itemModuleCapacity, new int[0])
new int[0]) * * this.capacityBoost
this.capacityBoost + + this.capacityBase)
this.capacityBase) * * 1000
1000); );
this.clearCache(); this.clearCache();
} }

View File

@ -1,16 +1,15 @@
package mffs.base; package mffs.base;
import cpw.mods.fml.common.Optional; import java.util.EnumSet;
import calclavia.lib.IUniversalEnergyTile; import calclavia.lib.IUniversalEnergyTile;
import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.common.Optional;
import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySink;
import mffs.ConversionHelper; import mffs.ConversionHelper;
import mffs.tileentity.TileEntityCoercionDeriver; import mffs.tileentity.TileEntityCoercionDeriver;
import java.util.EnumSet;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -20,143 +19,162 @@ import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
@Optional.Interface(modid = "IC2", iface = "ic2.api.energy.tile.IEnergySink") @Optional.Interface(modid = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
public abstract class TileEntityUniversalEnergy public abstract class TileEntityUniversalEnergy extends TileEntityModuleAcceptor
extends TileEntityModuleAcceptor implements IUniversalEnergyTile, IEnergyReceiver, IEnergySink { implements IUniversalEnergyTile, IEnergyReceiver, IEnergySink {
public double prevWatts; public double prevWatts;
public double wattsReceived; public double wattsReceived;
public TileEntityUniversalEnergy() { this.wattsReceived = 0.0; } public TileEntityUniversalEnergy() {
this.wattsReceived = 0.0;
@Optional.Method(modid = "IC2")
@Override
public void initiate() {
super.initiate();
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
}
@Optional.Method(modid = "IC2")
@Override
public void invalidate() {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
super.invalidate();
}
@Override
public void updateEntity() {
super.updateEntity();
this.prevWatts = this.wattsReceived;
if (!this.worldObj.isRemote) {
if (!this.isDisabled()) {
final ElectricityPack electricityPack =
ElectricityNetworkHelper.consumeFromMultipleSides(
this, this.getConsumingSides(), this.getRequest());
this.onReceive(electricityPack);
} else {
ElectricityNetworkHelper.consumeFromMultipleSides(
this, new ElectricityPack());
}
} }
}
protected EnumSet<ForgeDirection> getConsumingSides() { @Optional.Method(modid = "IC2")
return ElectricityNetworkHelper.getDirections(this); @Override
} public void initiate() {
super.initiate();
public ElectricityPack getRequest() { return new ElectricityPack(); } MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
public void onReceive(final ElectricityPack electricityPack) {
if (UniversalElectricity.isVoltageSensitive &&
electricityPack.voltage > this.getVoltage()) {
return;
} }
this.wattsReceived = Math.min(
this.wattsReceived + electricityPack.getWatts(), this.getWattBuffer());
}
public double getWattBuffer() { return this.getRequest().getWatts() * 2.0; } @Optional.Method(modid = "IC2")
@Override
@Override public void invalidate() {
public double getVoltage() { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
return 120.0; super.invalidate();
}
public ElectricityPack produce(double watts) {
ElectricityPack pack =
new ElectricityPack(watts / this.getVoltage(), this.getVoltage());
ElectricityPack remaining =
ElectricityNetworkHelper.produceFromMultipleSides(this, pack);
return remaining;
}
public int produceRF(int amount) {
int available = amount;
for(ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj);
if (te instanceof IEnergyReceiver) {
IEnergyReceiver receiver = (IEnergyReceiver) te;
if (!receiver.canConnectEnergy(dir.getOpposite())) continue;
available -= receiver.receiveEnergy(dir.getOpposite(), (available), false);
}
} }
return amount - available;
}
@Override @Override
public boolean canConnectEnergy(ForgeDirection side) { public void updateEntity() {
return canConnect(side); super.updateEntity();
} this.prevWatts = this.wattsReceived;
if (!this.worldObj.isRemote) {
@Override if (!this.isDisabled()) {
public int receiveEnergy(ForgeDirection side, int energy, boolean simulate) { final ElectricityPack electricityPack
if (!canConnect(side)) return 0; = ElectricityNetworkHelper.consumeFromMultipleSides(
double toReceive = ConversionHelper.fromRF(energy); this, this.getConsumingSides(), this.getRequest()
double free = getWattBuffer() - wattsReceived; );
double toInject = Math.min(toReceive, free); this.onReceive(electricityPack);
if (!simulate) { } else {
wattsReceived += toInject; ElectricityNetworkHelper.consumeFromMultipleSides(
this, new ElectricityPack()
);
}
}
} }
return (int) Math.ceil(toInject / UniversalElectricity.UE_RF_RATIO);
}
@Override protected EnumSet<ForgeDirection> getConsumingSides() {
public int getEnergyStored(ForgeDirection var1) { return ElectricityNetworkHelper.getDirections(this);
return ConversionHelper.toRF(getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO);
}
@Override
public int getMaxEnergyStored(ForgeDirection var1) {
return ConversionHelper.toRF(getFortronCapacity() * TileEntityCoercionDeriver.FORTRON_UE_RATIO);
}
@Optional.Method(modid = "IC2")
@Override
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
return getConsumingSides().contains(direction);
}
@Optional.Method(modid = "IC2")
@Override
public double getDemandedEnergy() {
return ConversionHelper.toEU(this.getRequest().getWatts());
}
@Optional.Method(modid = "IC2")
@Override
public int getSinkTier() {
return 2;
}
@Optional.Method(modid = "IC2")
@Override
public double injectEnergy(ForgeDirection direction, double i, double voltage) {
double givenElectricity = ConversionHelper.fromEU(i);
double rejects = 0.0;
if (givenElectricity > this.getWattBuffer()) {
rejects = givenElectricity - this.getRequest().getWatts();
} }
this.onReceive(new ElectricityPack(givenElectricity / this.getVoltage(), this.getVoltage()));
return ConversionHelper.toEU(rejects);
}
public ElectricityPack getRequest() {
return new ElectricityPack();
}
public void onReceive(final ElectricityPack electricityPack) {
if (UniversalElectricity.isVoltageSensitive
&& electricityPack.voltage > this.getVoltage()) {
return;
}
this.wattsReceived = Math.min(
this.wattsReceived + electricityPack.getWatts(), this.getWattBuffer()
);
}
public double getWattBuffer() {
return this.getRequest().getWatts() * 2.0;
}
@Override
public double getVoltage() {
return 120.0;
}
public ElectricityPack produce(double watts) {
ElectricityPack pack
= new ElectricityPack(watts / this.getVoltage(), this.getVoltage());
ElectricityPack remaining
= ElectricityNetworkHelper.produceFromMultipleSides(this, pack);
return remaining;
}
public int produceRF(int amount) {
int available = amount;
for (ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(
this.worldObj
);
if (te instanceof IEnergyReceiver) {
IEnergyReceiver receiver = (IEnergyReceiver) te;
if (!receiver.canConnectEnergy(dir.getOpposite()))
continue;
available
-= receiver.receiveEnergy(dir.getOpposite(), (available), false);
}
}
return amount - available;
}
@Override
public boolean canConnectEnergy(ForgeDirection side) {
return canConnect(side);
}
@Override
public int receiveEnergy(ForgeDirection side, int energy, boolean simulate) {
if (!canConnect(side))
return 0;
double toReceive = ConversionHelper.fromRF(energy);
double free = getWattBuffer() - wattsReceived;
double toInject = Math.min(toReceive, free);
if (!simulate) {
wattsReceived += toInject;
}
return (int) Math.ceil(toInject / UniversalElectricity.UE_RF_RATIO);
}
@Override
public int getEnergyStored(ForgeDirection var1) {
return ConversionHelper.toRF(
getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO
);
}
@Override
public int getMaxEnergyStored(ForgeDirection var1) {
return ConversionHelper.toRF(
getFortronCapacity() * TileEntityCoercionDeriver.FORTRON_UE_RATIO
);
}
@Optional.Method(modid = "IC2")
@Override
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
return getConsumingSides().contains(direction);
}
@Optional.Method(modid = "IC2")
@Override
public double getDemandedEnergy() {
return ConversionHelper.toEU(this.getRequest().getWatts());
}
@Optional.Method(modid = "IC2")
@Override
public int getSinkTier() {
return 2;
}
@Optional.Method(modid = "IC2")
@Override
public double injectEnergy(ForgeDirection direction, double i, double voltage) {
double givenElectricity = ConversionHelper.fromEU(i);
double rejects = 0.0;
if (givenElectricity > this.getWattBuffer()) {
rejects = givenElectricity - this.getRequest().getWatts();
}
this.onReceive(
new ElectricityPack(givenElectricity / this.getVoltage(), this.getVoltage())
);
return ConversionHelper.toEU(rejects);
}
} }

View File

@ -1,10 +1,11 @@
package mffs.block; package mffs.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.IForceFieldBlock; import mffs.api.IForceFieldBlock;
import mffs.api.IProjector; import mffs.api.IProjector;
@ -41,289 +42,340 @@ import universalelectricity.prefab.CustomDamageSource;
public class BlockForceField public class BlockForceField
extends BlockBase implements IForceFieldBlock, IPartialSealableBlock { extends BlockBase implements IForceFieldBlock, IPartialSealableBlock {
public BlockForceField() { public BlockForceField() {
super("forceField", Material.glass); super("forceField", Material.glass);
this.setBlockUnbreakable(); this.setBlockUnbreakable();
this.setResistance(999.0f); this.setResistance(999.0f);
this.setCreativeTab((CreativeTabs)null); this.setCreativeTab((CreativeTabs) null);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
protected boolean canSilkHarvest() {
return false;
}
@Override
public int quantityDropped(final Random random) {
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType() {
return RenderForceField.ID;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(final IBlockAccess par1IBlockAccess,
final int par2, final int par3,
final int par4, final int par5) {
final Block i1 = par1IBlockAccess.getBlock(par2, par3, par4);
return i1 != this &&
super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
}
@Override
public void onBlockClicked(final World world, final int x, final int y,
final int z, final EntityPlayer entityPlayer) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField &&
((TileEntityForceField)tileEntity).getProjector() != null) {
for (final ItemStack moduleStack :
((TileEntityForceField)tileEntity)
.getProjector()
.getModuleStacks(((TileEntityForceField)tileEntity)
.getProjector()
.getModuleSlots())) {
if (((IModule)moduleStack.getItem())
.onCollideWithForceField(world, x, y, z, (Entity)entityPlayer,
moduleStack)) {
return;
}
}
} }
}
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(final World world, public boolean isOpaqueCube() {
final int x, final int y, return false;
final int z) {
if (world.isRemote) {
if (ModularForceFieldSystem.proxy.isSneaking()) {
return null;
}
} }
if (this.getProjector((IBlockAccess)world, x, y, z) != null && !world.isRemote) {
final IBiometricIdentifier BiometricIdentifier =
this.getProjector((IBlockAccess)world, x, y, z)
.getBiometricIdentifier();
final List entities = world.getEntitiesWithinAABB(
EntityPlayer.class, AxisAlignedBB.getBoundingBox(
(double)(x), (double)y, (double)(z),
(double)(x + 1), y + 1, (double)(z + 1)));
for (final EntityPlayer entityPlayer : (List<EntityPlayer>)entities) {
if (entityPlayer != null && entityPlayer.isSneaking()) {
if (entityPlayer.capabilities.isCreativeMode) {
return null;
}
if (BiometricIdentifier != null &&
BiometricIdentifier.isAccessGranted(
entityPlayer.getDisplayName(), Permission.FORCE_FIELD_WARP)) {
return null;
}
continue;
}
}
}
final float f = 0.0625f;
return AxisAlignedBB.getBoundingBox(
(double)(x + f), (double)(y + f), (double)(z + f), (double)(x + 1 - f),
(double)(y + 1 - f), (double)(z + 1 - f));
}
@Override @Override
public void onEntityCollidedWithBlock(final World world, final int x, public boolean renderAsNormalBlock() {
final int y, final int z, return false;
final Entity entity) { }
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField && @Override
this.getProjector((IBlockAccess)world, x, y, z) != null) { protected boolean canSilkHarvest() {
for (final ItemStack moduleStack : return false;
((TileEntityForceField)tileEntity) }
.getProjector()
.getModuleStacks(((TileEntityForceField)tileEntity) @Override
.getProjector() public int quantityDropped(final Random random) {
.getModuleSlots())) { return 0;
if (((IModule)moduleStack.getItem()) }
.onCollideWithForceField(world, x, y, z, entity, moduleStack)) {
return; @Override
} @SideOnly(Side.CLIENT)
} public int getRenderBlockPass() {
final IBiometricIdentifier biometricIdentifier = return 1;
this.getProjector((IBlockAccess)world, x, y, z) }
.getBiometricIdentifier();
if (new Vector3(entity).distanceTo(new Vector3(x, y, z).add(0.4)) < 0.5 && @Override
entity instanceof EntityLiving && !world.isRemote) { @SideOnly(Side.CLIENT)
((EntityLiving)entity) public int getRenderType() {
.addPotionEffect(new PotionEffect(Potion.confusion.id, 80, 3)); return RenderForceField.ID;
((EntityLiving)entity) }
.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 1));
boolean hasPermission = false; @Override
final List entities = world.getEntitiesWithinAABB( @SideOnly(Side.CLIENT)
EntityPlayer.class, AxisAlignedBB.getBoundingBox( public boolean shouldSideBeRendered(
(double)x, (double)y, (double)z, final IBlockAccess par1IBlockAccess,
(double)(x + 1), y + 0.9, (double)(z + 1))); final int par2,
for (final EntityPlayer entityPlayer : (List<EntityPlayer>)entities) { final int par3,
if (entityPlayer != null && entityPlayer.isSneaking()) { final int par4,
if (entityPlayer.capabilities.isCreativeMode) { final int par5
hasPermission = true; ) {
break; final Block i1 = par1IBlockAccess.getBlock(par2, par3, par4);
return i1 != this
&& super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
}
@Override
public void onBlockClicked(
final World world,
final int x,
final int y,
final int z,
final EntityPlayer entityPlayer
) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField
&& ((TileEntityForceField) tileEntity).getProjector() != null) {
for (final ItemStack moduleStack :
((TileEntityForceField) tileEntity)
.getProjector()
.getModuleStacks(((TileEntityForceField) tileEntity)
.getProjector()
.getModuleSlots())) {
if (((IModule) moduleStack.getItem())
.onCollideWithForceField(
world, x, y, z, (Entity) entityPlayer, moduleStack
)) {
return;
}
} }
if (biometricIdentifier == null ||
!biometricIdentifier.isAccessGranted(
entityPlayer.getDisplayName(),
Permission.FORCE_FIELD_WARP)) {
continue;
}
hasPermission = true;
}
} }
if (!hasPermission) {
entity.attackEntityFrom(
(DamageSource)CustomDamageSource.electrocution,
Integer.MAX_VALUE);
}
}
} }
}
@Override @Override
public IIcon getIcon(final IBlockAccess iBlockAccess, final int x, public AxisAlignedBB getCollisionBoundingBoxFromPool(
final int y, final int z, final int side) { final World world, final int x, final int y, final int z
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z); ) {
if (tileEntity instanceof TileEntityForceField) { if (world.isRemote) {
final ItemStack checkStack = ((TileEntityForceField)tileEntity).camoStack; if (ModularForceFieldSystem.proxy.isSneaking()) {
if (checkStack != null) { return null;
}
}
if (this.getProjector((IBlockAccess) world, x, y, z) != null && !world.isRemote) {
final IBiometricIdentifier BiometricIdentifier
= this.getProjector((IBlockAccess) world, x, y, z)
.getBiometricIdentifier();
final List entities = world.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getBoundingBox(
(double) (x),
(double) y,
(double) (z),
(double) (x + 1),
y + 1,
(double) (z + 1)
)
);
for (final EntityPlayer entityPlayer : (List<EntityPlayer>) entities) {
if (entityPlayer != null && entityPlayer.isSneaking()) {
if (entityPlayer.capabilities.isCreativeMode) {
return null;
}
if (BiometricIdentifier != null
&& BiometricIdentifier.isAccessGranted(
entityPlayer.getDisplayName(), Permission.FORCE_FIELD_WARP
)) {
return null;
}
continue;
}
}
}
final float f = 0.0625f;
return AxisAlignedBB.getBoundingBox(
(double) (x + f),
(double) (y + f),
(double) (z + f),
(double) (x + 1 - f),
(double) (y + 1 - f),
(double) (z + 1 - f)
);
}
@Override
public void onEntityCollidedWithBlock(
final World world, final int x, final int y, final int z, final Entity entity
) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField
&& this.getProjector((IBlockAccess) world, x, y, z) != null) {
for (final ItemStack moduleStack :
((TileEntityForceField) tileEntity)
.getProjector()
.getModuleStacks(((TileEntityForceField) tileEntity)
.getProjector()
.getModuleSlots())) {
if (((IModule) moduleStack.getItem())
.onCollideWithForceField(world, x, y, z, entity, moduleStack)) {
return;
}
}
final IBiometricIdentifier biometricIdentifier
= this.getProjector((IBlockAccess) world, x, y, z)
.getBiometricIdentifier();
if (new Vector3(entity).distanceTo(new Vector3(x, y, z).add(0.4)) < 0.5
&& entity instanceof EntityLiving && !world.isRemote) {
((EntityLiving) entity)
.addPotionEffect(new PotionEffect(Potion.confusion.id, 80, 3));
((EntityLiving) entity)
.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 1));
boolean hasPermission = false;
final List entities = world.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
y + 0.9,
(double) (z + 1)
)
);
for (final EntityPlayer entityPlayer : (List<EntityPlayer>) entities) {
if (entityPlayer != null && entityPlayer.isSneaking()) {
if (entityPlayer.capabilities.isCreativeMode) {
hasPermission = true;
break;
}
if (biometricIdentifier == null
|| !biometricIdentifier.isAccessGranted(
entityPlayer.getDisplayName(), Permission.FORCE_FIELD_WARP
)) {
continue;
}
hasPermission = true;
}
}
if (!hasPermission) {
entity.attackEntityFrom(
(DamageSource) CustomDamageSource.electrocution, Integer.MAX_VALUE
);
}
}
}
}
@Override
public IIcon getIcon(
final IBlockAccess iBlockAccess,
final int x,
final int y,
final int z,
final int side
) {
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField) {
final ItemStack checkStack = ((TileEntityForceField) tileEntity).camoStack;
if (checkStack != null) {
try {
final Block block = Block.getBlockFromItem(checkStack.getItem());
final Integer[] allowedRenderTypes
= { 0, 1, 4, 31, 20, 39, 5, 13, 23,
6, 8, 7, 12, 29, 30, 14, 16, 17 };
if (Arrays.asList(allowedRenderTypes)
.contains(block.getRenderType())) {
final IIcon icon
= block.getIcon(side, checkStack.getItemDamage());
if (icon != null) {
return icon;
}
}
} catch (final Exception e) {
e.printStackTrace();
}
}
}
return this.getIcon(side, iBlockAccess.getBlockMetadata(x, y, z));
}
@Override
public int colorMultiplier(
final IBlockAccess iBlockAccess, final int x, final int y, final int z
) {
try { try {
final Block block = Block.getBlockFromItem(checkStack.getItem()); final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
final Integer[] allowedRenderTypes = { if (tileEntity instanceof TileEntityForceField) {
0, 1, 4, 31, 20, 39, 5, 13, 23, 6, 8, 7, 12, 29, 30, 14, 16, 17}; final ItemStack checkStack
if (Arrays.asList(allowedRenderTypes) = ((TileEntityForceField) tileEntity).camoStack;
.contains(block.getRenderType())) { if (checkStack != null) {
final IIcon icon = block.getIcon(side, checkStack.getItemDamage()); try {
if (icon != null) { return Block.getBlockFromItem(checkStack.getItem())
return icon; .colorMultiplier(iBlockAccess, x, y, x);
} catch (final Exception e) {
e.printStackTrace();
}
}
}
} catch (final Exception e2) {
e2.printStackTrace();
}
return super.colorMultiplier(iBlockAccess, x, y, z);
}
@Override
public int getLightValue(
final IBlockAccess iBlockAccess, final int x, final int y, final int z
) {
try {
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField) {
final IProjector zhuYao
= ((TileEntityForceField) tileEntity).getProjectorSafe();
if (zhuYao instanceof IProjector) {
return (int
) (Math.min(
zhuYao.getModuleCount(
ModularForceFieldSystem.itemModuleGlow, new int[0]
),
64
)
/ 64.0f * 15.0f);
}
} }
}
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace();
}
}
}
return this.getIcon(side, iBlockAccess.getBlockMetadata(x, y, z));
}
@Override
public int colorMultiplier(final IBlockAccess iBlockAccess, final int x,
final int y, final int z) {
try {
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField) {
final ItemStack checkStack =
((TileEntityForceField)tileEntity).camoStack;
if (checkStack != null) {
try {
return Block.getBlockFromItem(checkStack.getItem())
.colorMultiplier(iBlockAccess, x, y, x);
} catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
}
} }
} return 0;
} catch (final Exception e2) {
e2.printStackTrace();
} }
return super.colorMultiplier(iBlockAccess, x, y, z);
}
@Override @Override
public int getLightValue(final IBlockAccess iBlockAccess, final int x, public float getExplosionResistance(
final int y, final int z) { final Entity entity,
try { final World world,
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z); final int x,
if (tileEntity instanceof TileEntityForceField) { final int y,
final IProjector zhuYao = final int z,
((TileEntityForceField)tileEntity).getProjectorSafe(); final double d,
if (zhuYao instanceof IProjector) { final double d1,
return (int)(Math.min(zhuYao.getModuleCount( final double d2
ModularForceFieldSystem.itemModuleGlow, ) {
new int[0]), return 2.1474836E9f;
64) / }
64.0f * 15.0f);
@Override
public TileEntity createNewTileEntity(final World world, int meta) {
return new TileEntityForceField();
}
@Override
public void weakenForceField(
final World world, final int x, final int y, final int z, final int joules
) {
final IProjector projector = this.getProjector((IBlockAccess) world, x, y, z);
if (projector != null) {
((IFortronStorage) projector).provideFortron(joules, true);
} }
} world.setBlock(x, y, z, Blocks.air, 0, 3);
} catch (final Exception e) {
e.printStackTrace();
} }
return 0;
}
@Override @Override
public float getExplosionResistance(final Entity entity, final World world, public ItemStack getPickBlock(
final int x, final int y, final int z, final MovingObjectPosition target,
final double d, final double d1, final World world,
final double d2) { final int x,
return 2.1474836E9f; final int y,
} final int z
) {
@Override return null;
public TileEntity createNewTileEntity(final World world, int meta) {
return new TileEntityForceField();
}
@Override
public void weakenForceField(final World world, final int x, final int y,
final int z, final int joules) {
final IProjector projector =
this.getProjector((IBlockAccess)world, x, y, z);
if (projector != null) {
((IFortronStorage)projector).provideFortron(joules, true);
} }
world.setBlock(x, y, z, Blocks.air, 0, 3);
}
@Override @Override
public ItemStack getPickBlock(final MovingObjectPosition target, public IProjector
final World world, final int x, final int y, getProjector(final IBlockAccess iBlockAccess, final int x, final int y, final int z) {
final int z) { final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
return null; if (tileEntity instanceof TileEntityForceField) {
} return ((TileEntityForceField) tileEntity).getProjector();
}
@Override return null;
public IProjector getProjector(final IBlockAccess iBlockAccess, final int x,
final int y, final int z) {
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceField) {
return ((TileEntityForceField)tileEntity).getProjector();
} }
return null;
}
@Override @Override
public boolean isSealed(World world, int x, int y, int z, public boolean isSealed(World world, int x, int y, int z, ForgeDirection direction) {
ForgeDirection direction) { return true;
return true; }
}
@Override @Override
public void registerBlockIcons(IIconRegister p_149651_1_) { public void registerBlockIcons(IIconRegister p_149651_1_) {
this.blockIcon = p_149651_1_.registerIcon("mffs:forceField"); this.blockIcon = p_149651_1_.registerIcon("mffs:forceField");
} }
} }

View File

@ -19,20 +19,31 @@ public class BlockForceFieldProjector extends BlockMachine {
} }
@Override @Override
public boolean onMachineActivated(final World world, final int i, final int j, final int k, public boolean onMachineActivated(
final EntityPlayer entityplayer, final int par6, final World world,
final float par7, final float par8, final float par9) { final int i,
final TileEntityForceFieldProjector tileentity = (TileEntityForceFieldProjector) world.getTileEntity(i, j, k); final int j,
return !tileentity.isDisabled() && final int k,
super.onMachineActivated(world, i, j, k, entityplayer, par6, par7, par8, final EntityPlayer entityplayer,
par9); final int par6,
final float par7,
final float par8,
final float par9
) {
final TileEntityForceFieldProjector tileentity
= (TileEntityForceFieldProjector) world.getTileEntity(i, j, k);
return !tileentity.isDisabled()
&& super.onMachineActivated(
world, i, j, k, entityplayer, par6, par7, par8, par9
);
} }
public int getLightValue(final IBlockAccess iBlockAccess, final int x, public int getLightValue(
final int y, final int z) { final IBlockAccess iBlockAccess, final int x, final int y, final int z
) {
final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z); final TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityForceFieldProjector && if (tileEntity instanceof TileEntityForceFieldProjector
((TileEntityForceFieldProjector) tileEntity).getMode() != null) { && ((TileEntityForceFieldProjector) tileEntity).getMode() != null) {
return 10; return 10;
} }
return super.getLightValue(iBlockAccess, x, y, z); return super.getLightValue(iBlockAccess, x, y, z);

View File

@ -16,12 +16,17 @@ public class BlockForceManipulator extends BlockMachine {
super("manipulator"); super("manipulator");
} }
public static int determineOrientation(final World world, final int x, public static int determineOrientation(
final int y, final int z, final World world,
final EntityPlayer entityPlayer) { final int x,
if (MathHelper.abs((float) ((Entity) entityPlayer).posX - x) < 2.0f && final int y,
MathHelper.abs((float) ((Entity) entityPlayer).posZ - z) < 2.0f) { final int z,
final double var5 = ((Entity) entityPlayer).posY + 1.82 - ((Entity) entityPlayer).yOffset; final EntityPlayer entityPlayer
) {
if (MathHelper.abs((float) ((Entity) entityPlayer).posX - x) < 2.0f
&& MathHelper.abs((float) ((Entity) entityPlayer).posZ - z) < 2.0f) {
final double var5
= ((Entity) entityPlayer).posY + 1.82 - ((Entity) entityPlayer).yOffset;
if (var5 - y > 2.0) { if (var5 - y > 2.0) {
return 1; return 1;
} }
@ -30,36 +35,52 @@ public class BlockForceManipulator extends BlockMachine {
} }
} }
final int var6 = MathHelper.floor_double( final int var6 = MathHelper.floor_double(
((Entity) entityPlayer).rotationYaw * 4.0f / 360.0f + 0.5) & ((Entity) entityPlayer).rotationYaw * 4.0f / 360.0f + 0.5
0x3; )
& 0x3;
return (var6 == 0) return (var6 == 0)
? 2 ? 2
: ((var6 == 1) ? 5 : ((var6 == 2) ? 3 : ((var6 == 3) ? 4 : 0))); : ((var6 == 1) ? 5 : ((var6 == 2) ? 3 : ((var6 == 3) ? 4 : 0)));
} }
@Override @Override
public void onBlockPlacedBy(final World world, final int x, final int y, public void onBlockPlacedBy(
final int z, final World world,
final EntityLivingBase par5EntityLiving, final int x,
final ItemStack stack) { final int y,
final int z,
final EntityLivingBase par5EntityLiving,
final ItemStack stack
) {
final int metadata = determineOrientation( final int metadata = determineOrientation(
world, x, y, z, world,
(EntityPlayer) par5EntityLiving); // TODO: ClassCastException? x,
y,
z,
(EntityPlayer) par5EntityLiving
); // TODO: ClassCastException?
world.setBlockMetadataWithNotify(x, y, z, metadata, 2); world.setBlockMetadataWithNotify(x, y, z, metadata, 2);
} }
@Override @Override
public boolean onUseWrench(final World world, final int x, final int y, public boolean onUseWrench(
final int z, final EntityPlayer par5EntityPlayer, final World world,
final int side, final float hitX, final float hitY, final int x,
final float hitZ) { final int y,
final int z,
final EntityPlayer par5EntityPlayer,
final int side,
final float hitX,
final float hitY,
final float hitZ
) {
final int mask = 7; final int mask = 7;
final int rotMeta = world.getBlockMetadata(x, y, z); final int rotMeta = world.getBlockMetadata(x, y, z);
final int masked = rotMeta & ~mask; final int masked = rotMeta & ~mask;
final ForgeDirection orientation = ForgeDirection.getOrientation(rotMeta & mask); final ForgeDirection orientation = ForgeDirection.getOrientation(rotMeta & mask);
final ForgeDirection rotated = orientation.getRotation(ForgeDirection.getOrientation(side)); final ForgeDirection rotated
world.setBlockMetadataWithNotify(x, y, z, = orientation.getRotation(ForgeDirection.getOrientation(side));
(rotated.ordinal() & mask) | masked, 3); world.setBlockMetadataWithNotify(x, y, z, (rotated.ordinal() & mask) | masked, 3);
return true; return true;
} }

View File

@ -17,11 +17,16 @@ public abstract class BlockMachineBlock extends BlockMachine {
} }
@Override @Override
public IIcon getIcon(final IBlockAccess par1IBlockAccess, final int x, public IIcon getIcon(
final int y, final int z, final int side) { final IBlockAccess par1IBlockAccess,
final int x,
final int y,
final int z,
final int side
) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z); final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityBase && if (tileEntity instanceof TileEntityBase
((TileEntityBase) tileEntity).isActive()) { && ((TileEntityBase) tileEntity).isActive()) {
if (side == 0 || side == 1) { if (side == 0 || side == 1) {
return this.blockIconTopOn; return this.blockIconTopOn;
} }
@ -36,14 +41,14 @@ public abstract class BlockMachineBlock extends BlockMachine {
@Override @Override
public void registerBlockIcons(final IIconRegister reg) { public void registerBlockIcons(final IIconRegister reg) {
this.blockIcon = reg.registerIcon( this.blockIcon = reg.registerIcon(this.getUnlocalizedName().replace("tile.", ""));
this.getUnlocalizedName().replace("tile.", "")); this.blockIconTop
this.blockIconTop = reg.registerIcon( = reg.registerIcon(this.getUnlocalizedName().replace("tile.", "") + "_top");
this.getUnlocalizedName().replace("tile.", "") + "_top"); this.blockIconOn
this.blockIconOn = reg.registerIcon( = reg.registerIcon(this.getUnlocalizedName().replace("tile.", "") + "_on");
this.getUnlocalizedName().replace("tile.", "") + "_on");
this.blockIconTopOn = reg.registerIcon( this.blockIconTopOn = reg.registerIcon(
this.getUnlocalizedName().replace("tile.", "") + "_top_on"); this.getUnlocalizedName().replace("tile.", "") + "_top_on"
);
} }
@Override @Override

View File

@ -9,15 +9,16 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
public class ContainerBiometricIdentifier extends ContainerBase { public class ContainerBiometricIdentifier extends ContainerBase {
public ContainerBiometricIdentifier(final EntityPlayer player, public ContainerBiometricIdentifier(
final TileEntityBiometricIdentifier tileentity) { final EntityPlayer player, final TileEntityBiometricIdentifier tileentity
) {
super((IInventory) tileentity); super((IInventory) tileentity);
this.addSlotToContainer((Slot) new SlotActive(tileentity, 0, 88, 91)); this.addSlotToContainer((Slot) new SlotActive(tileentity, 0, 88, 91));
this.addSlotToContainer((Slot) new SlotBase(tileentity, 1, 8, 46)); this.addSlotToContainer((Slot) new SlotBase(tileentity, 1, 8, 46));
this.addSlotToContainer((Slot) new SlotActive(tileentity, 2, 8, 91)); this.addSlotToContainer((Slot) new SlotActive(tileentity, 2, 8, 91));
for (int var4 = 0; var4 < 9; ++var4) { for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer( this.addSlotToContainer((Slot
(Slot) new SlotActive(tileentity, 3 + var4, 8 + var4 * 18, 111)); ) new SlotActive(tileentity, 3 + var4, 8 + var4 * 18, 111));
} }
this.addSlotToContainer((Slot) new SlotBase(tileentity, 12, 8, 66)); this.addSlotToContainer((Slot) new SlotBase(tileentity, 12, 8, 66));
this.addPlayerInventory(player); this.addPlayerInventory(player);

View File

@ -9,8 +9,9 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
public class ContainerCoercionDeriver extends ContainerBase { public class ContainerCoercionDeriver extends ContainerBase {
public ContainerCoercionDeriver(final EntityPlayer player, public ContainerCoercionDeriver(
final TileEntityCoercionDeriver tileEntity) { final EntityPlayer player, final TileEntityCoercionDeriver tileEntity
) {
super((IInventory) tileEntity); super((IInventory) tileEntity);
this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 9, 41)); this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 9, 41));
this.addSlotToContainer((Slot) new SlotBase(tileEntity, 1, 9, 83)); this.addSlotToContainer((Slot) new SlotBase(tileEntity, 1, 9, 83));

View File

@ -9,8 +9,9 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
public class ContainerForceFieldProjector extends ContainerBase { public class ContainerForceFieldProjector extends ContainerBase {
public ContainerForceFieldProjector(final EntityPlayer player, public ContainerForceFieldProjector(
final TileEntityForceFieldProjector tileEntity) { final EntityPlayer player, final TileEntityForceFieldProjector tileEntity
) {
super((IInventory) tileEntity); super((IInventory) tileEntity);
this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 10, 89)); this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 10, 89));
this.addSlotToContainer((Slot) new SlotCard(tileEntity, 1, 28, 89)); this.addSlotToContainer((Slot) new SlotCard(tileEntity, 1, 28, 89));
@ -18,18 +19,18 @@ public class ContainerForceFieldProjector extends ContainerBase {
int i = 3; int i = 3;
for (int xSlot = 0; xSlot < 4; ++xSlot) { for (int xSlot = 0; xSlot < 4; ++xSlot) {
for (int ySlot = 0; ySlot < 4; ++ySlot) { for (int ySlot = 0; ySlot < 4; ++ySlot) {
if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2) && if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2)
(xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) { && (xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) {
this.addSlotToContainer((Slot) new SlotBase( this.addSlotToContainer((Slot
tileEntity, i, 91 + 18 * xSlot, 18 + 18 * ySlot)); ) new SlotBase(tileEntity, i, 91 + 18 * xSlot, 18 + 18 * ySlot));
++i; ++i;
} }
} }
} }
for (int xSlot = 0; xSlot < 3; ++xSlot) { for (int xSlot = 0; xSlot < 3; ++xSlot) {
for (int ySlot = 0; ySlot < 2; ++ySlot) { for (int ySlot = 0; ySlot < 2; ++ySlot) {
this.addSlotToContainer((Slot) new SlotBase( this.addSlotToContainer((Slot
tileEntity, i, 19 + 18 * xSlot, 36 + 18 * ySlot)); ) new SlotBase(tileEntity, i, 19 + 18 * xSlot, 36 + 18 * ySlot));
++i; ++i;
} }
} }

View File

@ -10,7 +10,8 @@ import net.minecraft.inventory.Slot;
public class ContainerForceManipulator extends ContainerBase { public class ContainerForceManipulator extends ContainerBase {
public ContainerForceManipulator( public ContainerForceManipulator(
final EntityPlayer player, final TileEntityForceManipulator tileEntity) { final EntityPlayer player, final TileEntityForceManipulator tileEntity
) {
super((IInventory) tileEntity); super((IInventory) tileEntity);
this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 73, 91)); this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 73, 91));
this.addSlotToContainer((Slot) new SlotCard(tileEntity, 1, 91, 91)); this.addSlotToContainer((Slot) new SlotCard(tileEntity, 1, 91, 91));
@ -18,18 +19,18 @@ public class ContainerForceManipulator extends ContainerBase {
int i = 3; int i = 3;
for (int xSlot = 0; xSlot < 4; ++xSlot) { for (int xSlot = 0; xSlot < 4; ++xSlot) {
for (int ySlot = 0; ySlot < 4; ++ySlot) { for (int ySlot = 0; ySlot < 4; ++ySlot) {
if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2) && if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2)
(xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) { && (xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) {
this.addSlotToContainer((Slot) new SlotBase( this.addSlotToContainer((Slot
tileEntity, i, 91 + 18 * xSlot, 18 + 18 * ySlot)); ) new SlotBase(tileEntity, i, 91 + 18 * xSlot, 18 + 18 * ySlot));
++i; ++i;
} }
} }
} }
for (int xSlot = 0; xSlot < 3; ++xSlot) { for (int xSlot = 0; xSlot < 3; ++xSlot) {
for (int ySlot = 0; ySlot < 2; ++ySlot) { for (int ySlot = 0; ySlot < 2; ++ySlot) {
this.addSlotToContainer((Slot) new SlotBase( this.addSlotToContainer((Slot
tileEntity, i, 31 + 18 * xSlot, 19 + 18 * ySlot)); ) new SlotBase(tileEntity, i, 31 + 18 * xSlot, 19 + 18 * ySlot));
++i; ++i;
} }
} }

View File

@ -12,7 +12,8 @@ public class ContainerFortronCapacitor extends ContainerBase {
private TileEntityFortronCapacitor tileEntity; private TileEntityFortronCapacitor tileEntity;
public ContainerFortronCapacitor( public ContainerFortronCapacitor(
final EntityPlayer player, final TileEntityFortronCapacitor tileEntity) { final EntityPlayer player, final TileEntityFortronCapacitor tileEntity
) {
super((IInventory) tileEntity); super((IInventory) tileEntity);
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
this.addSlotToContainer((Slot) new SlotCard(this.tileEntity, 0, 9, 74)); this.addSlotToContainer((Slot) new SlotCard(this.tileEntity, 0, 9, 74));

View File

@ -9,20 +9,22 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
public class ContainerInterdictionMatrix extends ContainerBase { public class ContainerInterdictionMatrix extends ContainerBase {
public ContainerInterdictionMatrix(final EntityPlayer player, public ContainerInterdictionMatrix(
final TileEntityInterdictionMatrix tileEntity) { final EntityPlayer player, final TileEntityInterdictionMatrix tileEntity
) {
super((IInventory) tileEntity); super((IInventory) tileEntity);
this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 87, 89)); this.addSlotToContainer((Slot) new SlotCard(tileEntity, 0, 87, 89));
this.addSlotToContainer((Slot) new SlotBase(tileEntity, 1, 69, 89)); this.addSlotToContainer((Slot) new SlotBase(tileEntity, 1, 69, 89));
for (int var3 = 0; var3 < 2; ++var3) { for (int var3 = 0; var3 < 2; ++var3) {
for (int var4 = 0; var4 < 4; ++var4) { for (int var4 = 0; var4 < 4; ++var4) {
this.addSlotToContainer((Slot) new SlotBase( this.addSlotToContainer((Slot) new SlotBase(
tileEntity, var4 + var3 * 4 + 2, 99 + var4 * 18, 31 + var3 * 18)); tileEntity, var4 + var3 * 4 + 2, 99 + var4 * 18, 31 + var3 * 18
));
} }
} }
for (int var5 = 0; var5 < 9; ++var5) { for (int var5 = 0; var5 < 9; ++var5) {
this.addSlotToContainer( this.addSlotToContainer((Slot
(Slot) new SlotBase(tileEntity, var5 + 8 + 2, 9 + var5 * 18, 69)); ) new SlotBase(tileEntity, var5 + 8 + 2, 9 + var5 * 18, 69));
} }
this.addPlayerInventory(player); this.addPlayerInventory(player);
} }

View File

@ -13,9 +13,13 @@ public class BlockDropDelayedEvent extends DelayedEvent {
protected World world; protected World world;
protected Vector3 position; protected Vector3 position;
public BlockDropDelayedEvent(final IDelayedEventHandler handler, public BlockDropDelayedEvent(
final int ticks, final Block block, final IDelayedEventHandler handler,
final World world, final Vector3 position) { final int ticks,
final Block block,
final World world,
final Vector3 position
) {
super(handler, ticks); super(handler, ticks);
this.block = block; this.block = block;
this.world = world; this.world = world;
@ -26,9 +30,13 @@ public class BlockDropDelayedEvent extends DelayedEvent {
protected void onEvent() { protected void onEvent() {
if (this.position.getBlock((IBlockAccess) this.world) == this.block) { if (this.position.getBlock((IBlockAccess) this.world) == this.block) {
this.block.dropBlockAsItem( this.block.dropBlockAsItem(
this.world, this.position.intX(), this.position.intY(), this.world,
this.position.intZ(), this.position.intX(),
this.position.getBlockMetadata((IBlockAccess) this.world), 0); this.position.intY(),
this.position.intZ(),
this.position.getBlockMetadata((IBlockAccess) this.world),
0
);
this.position.setBlock(this.world, Blocks.air); this.position.setBlock(this.world, Blocks.air);
} }
} }

View File

@ -1,6 +1,7 @@
package mffs.event; package mffs.event;
import java.util.ArrayList; import java.util.ArrayList;
import mffs.IDelayedEventHandler; import mffs.IDelayedEventHandler;
import mffs.base.TileEntityInventory; import mffs.base.TileEntityInventory;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -13,11 +14,14 @@ import universalelectricity.core.vector.Vector3;
public class BlockInventoryDropDelayedEvent extends BlockDropDelayedEvent { public class BlockInventoryDropDelayedEvent extends BlockDropDelayedEvent {
private TileEntityInventory projector; private TileEntityInventory projector;
public BlockInventoryDropDelayedEvent(final IDelayedEventHandler handler, public BlockInventoryDropDelayedEvent(
final int ticks, final Block block, final IDelayedEventHandler handler,
final World world, final int ticks,
final Vector3 position, final Block block,
final TileEntityInventory projector) { final World world,
final Vector3 position,
final TileEntityInventory projector
) {
super(handler, ticks, block, world, position); super(handler, ticks, block, world, position);
this.projector = projector; this.projector = projector;
} }
@ -26,9 +30,13 @@ public class BlockInventoryDropDelayedEvent extends BlockDropDelayedEvent {
protected void onEvent() { protected void onEvent() {
if (super.position.getBlock((IBlockAccess) super.world) == super.block) { if (super.position.getBlock((IBlockAccess) super.world) == super.block) {
final ArrayList<ItemStack> itemStacks = super.block.getDrops( final ArrayList<ItemStack> itemStacks = super.block.getDrops(
super.world, super.position.intX(), super.position.intY(), super.world,
super.position.intZ(), super.position.intX(),
super.position.getBlockMetadata((IBlockAccess) super.world), 0); super.position.intY(),
super.position.intZ(),
super.position.getBlockMetadata((IBlockAccess) super.world),
0
);
for (final ItemStack itemStack : itemStacks) { for (final ItemStack itemStack : itemStacks) {
this.projector.mergeIntoInventory(itemStack); this.projector.mergeIntoInventory(itemStack);
} }

View File

@ -14,9 +14,12 @@ public class BlockNotifyDelayedEvent extends DelayedEvent {
private World world; private World world;
private Vector3 position; private Vector3 position;
public BlockNotifyDelayedEvent(final IDelayedEventHandler handler, public BlockNotifyDelayedEvent(
final int ticks, final World world, final IDelayedEventHandler handler,
final Vector3 position) { final int ticks,
final World world,
final Vector3 position
) {
super(handler, ticks); super(handler, ticks);
this.world = world; this.world = world;
this.position = position; this.position = position;
@ -26,21 +29,29 @@ public class BlockNotifyDelayedEvent extends DelayedEvent {
protected void onEvent() { protected void onEvent() {
if (!this.world.isRemote) { if (!this.world.isRemote) {
this.world.notifyBlocksOfNeighborChange( this.world.notifyBlocksOfNeighborChange(
this.position.intX(), this.position.intY(), this.position.intZ(), this.position.intX(),
this.position.getBlock((IBlockAccess) this.world)); this.position.intY(),
final TileEntity newTile = this.position.getTileEntity((IBlockAccess) this.world); this.position.intZ(),
this.position.getBlock((IBlockAccess) this.world)
);
final TileEntity newTile
= this.position.getTileEntity((IBlockAccess) this.world);
if (newTile != null) { if (newTile != null) {
if (newTile instanceof ISpecialForceManipulation) { if (newTile instanceof ISpecialForceManipulation) {
((ISpecialForceManipulation) newTile).postMove(); ((ISpecialForceManipulation) newTile).postMove();
} }
if (Loader.isModLoaded("BuildCraft|Factory")) { if (Loader.isModLoaded("BuildCraft|Factory")) {
try { try {
final Class clazz = Class.forName("buildcraft.factory.TileQuarry"); final Class clazz
= Class.forName("buildcraft.factory.TileQuarry");
if (clazz == newTile.getClass()) { if (clazz == newTile.getClass()) {
// TODO: W T F AAAAAAAAAAAAA // TODO: W T F AAAAAAAAAAAAA
ReflectionHelper.setPrivateValue(clazz, (Object) newTile, ReflectionHelper.setPrivateValue(
(Object) true, clazz,
new String[] { "isAlive" }); (Object) newTile,
(Object) true,
new String[] { "isAlive" }
);
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -19,13 +19,17 @@ public class BlockPostMoveDelayedEvent extends DelayedEvent {
private TileEntity tileEntity; private TileEntity tileEntity;
private NBTTagCompound tileData; private NBTTagCompound tileData;
public BlockPostMoveDelayedEvent(final IDelayedEventHandler handler, public BlockPostMoveDelayedEvent(
final int ticks, final World world, final IDelayedEventHandler handler,
final Vector3 originalPosition, final int ticks,
final Vector3 newPosition, final Block blockID, final World world,
final int blockMetadata, final Vector3 originalPosition,
final TileEntity tileEntity, final Vector3 newPosition,
final NBTTagCompound tileData) { final Block blockID,
final int blockMetadata,
final TileEntity tileEntity,
final NBTTagCompound tileData
) {
super(handler, ticks); super(handler, ticks);
this.blockID = Blocks.air; this.blockID = Blocks.air;
this.blockMetadata = 0; this.blockMetadata = 0;
@ -44,17 +48,27 @@ public class BlockPostMoveDelayedEvent extends DelayedEvent {
try { try {
if (this.tileEntity != null && this.tileData != null) { if (this.tileEntity != null && this.tileData != null) {
ManipulatorHelper.setBlockSneaky( ManipulatorHelper.setBlockSneaky(
this.world, this.newPosition, this.blockID, this.blockMetadata, this.world,
TileEntity.createAndLoadEntity(this.tileData)); this.newPosition,
this.blockID,
this.blockMetadata,
TileEntity.createAndLoadEntity(this.tileData)
);
} else { } else {
ManipulatorHelper.setBlockSneaky(this.world, this.newPosition, ManipulatorHelper.setBlockSneaky(
this.blockID, this.blockMetadata, this.world,
null); this.newPosition,
this.blockID,
this.blockMetadata,
null
);
} }
super.handler.getQuedDelayedEvents().add(new BlockNotifyDelayedEvent( super.handler.getQuedDelayedEvents().add(new BlockNotifyDelayedEvent(
super.handler, 0, this.world, this.originalPosition)); super.handler, 0, this.world, this.originalPosition
));
super.handler.getQuedDelayedEvents().add(new BlockNotifyDelayedEvent( super.handler.getQuedDelayedEvents().add(new BlockNotifyDelayedEvent(
super.handler, 0, this.world, this.newPosition)); super.handler, 0, this.world, this.newPosition
));
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -17,10 +17,13 @@ public class BlockPreMoveDelayedEvent extends DelayedEvent {
private Vector3 position; private Vector3 position;
private Vector3 newPosition; private Vector3 newPosition;
public BlockPreMoveDelayedEvent(final IDelayedEventHandler handler, public BlockPreMoveDelayedEvent(
final int ticks, final World world, final IDelayedEventHandler handler,
final Vector3 position, final int ticks,
final Vector3 newPosition) { final World world,
final Vector3 position,
final Vector3 newPosition
) {
super(handler, ticks); super(handler, ticks);
this.world = world; this.world = world;
this.position = position; this.position = position;
@ -30,23 +33,37 @@ public class BlockPreMoveDelayedEvent extends DelayedEvent {
@Override @Override
protected void onEvent() { protected void onEvent() {
if (!this.world.isRemote) { if (!this.world.isRemote) {
final TileEntity tileEntity = this.position.getTileEntity((IBlockAccess) this.world); final TileEntity tileEntity
= this.position.getTileEntity((IBlockAccess) this.world);
if (tileEntity instanceof ISpecialForceManipulation) { if (tileEntity instanceof ISpecialForceManipulation) {
((ISpecialForceManipulation) tileEntity) ((ISpecialForceManipulation) tileEntity)
.move(this.newPosition.intX(), this.newPosition.intY(), .move(
this.newPosition.intZ()); this.newPosition.intX(),
this.newPosition.intY(),
this.newPosition.intZ()
);
} }
final Block blockID = this.position.getBlock((IBlockAccess) this.world); final Block blockID = this.position.getBlock((IBlockAccess) this.world);
final int blockMetadata = this.position.getBlockMetadata((IBlockAccess) this.world); final int blockMetadata
= this.position.getBlockMetadata((IBlockAccess) this.world);
final NBTTagCompound tileData = new NBTTagCompound(); final NBTTagCompound tileData = new NBTTagCompound();
if (tileEntity != null) { if (tileEntity != null) {
tileEntity.writeToNBT(tileData); tileEntity.writeToNBT(tileData);
} }
ManipulatorHelper.setBlockSneaky(this.world, this.position, Blocks.air, 0, ManipulatorHelper.setBlockSneaky(
null); this.world, this.position, Blocks.air, 0, null
);
super.handler.getQuedDelayedEvents().add(new BlockPostMoveDelayedEvent( super.handler.getQuedDelayedEvents().add(new BlockPostMoveDelayedEvent(
super.handler, 0, this.world, this.position, this.newPosition, super.handler,
blockID, blockMetadata, tileEntity, tileData)); 0,
this.world,
this.position,
this.newPosition,
blockID,
blockMetadata,
tileEntity,
tileData
));
} }
} }
} }

View File

@ -4,21 +4,20 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
public class FortronHelper public class FortronHelper {
{
public static Fluid FLUID_FORTRON; public static Fluid FLUID_FORTRON;
public static FluidStack getFortron(final int amount) { public static FluidStack getFortron(final int amount) {
return new FluidStack(FLUID_FORTRON, amount); return new FluidStack(FLUID_FORTRON, amount);
} }
public static int getAmount(final FluidStack fluidStack) { public static int getAmount(final FluidStack fluidStack) {
if (fluidStack != null) { if (fluidStack != null) {
return fluidStack.amount; return fluidStack.amount;
} }
return 0; return 0;
} }
public static int getAmount(final FluidTank fortronTank) { public static int getAmount(final FluidTank fortronTank) {
if (fortronTank != null) { if (fortronTank != null) {
return fortronTank.getFluidAmount(); return fortronTank.getFluidAmount();

View File

@ -1,11 +1,12 @@
package mffs.fortron; package mffs.fortron;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import icbm.api.IBlockFrequency; import icbm.api.IBlockFrequency;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mffs.api.fortron.IFortronFrequency; import mffs.api.fortron.IFortronFrequency;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -31,7 +32,7 @@ public class FrequencyGrid {
it.remove(); it.remove();
} else { } else {
if (!new Vector3((TileEntity) frequency) if (!new Vector3((TileEntity) frequency)
.equals(new Vector3((TileEntity) tileEntity))) { .equals(new Vector3((TileEntity) tileEntity))) {
continue; continue;
} }
it.remove(); it.remove();
@ -55,8 +56,8 @@ public class FrequencyGrid {
public Set<IBlockFrequency> get(final int frequency) { public Set<IBlockFrequency> get(final int frequency) {
final Set<IBlockFrequency> set = new HashSet<>(); final Set<IBlockFrequency> set = new HashSet<>();
for (final IBlockFrequency tile : this.get()) { for (final IBlockFrequency tile : this.get()) {
if (tile != null && !((TileEntity) tile).isInvalid() && if (tile != null && !((TileEntity) tile).isInvalid()
tile.getFrequency() == frequency) { && tile.getFrequency() == frequency) {
set.add(tile); set.add(tile);
} }
} }
@ -73,10 +74,14 @@ public class FrequencyGrid {
} else if (((TileEntity) frequency).isInvalid()) { } else if (((TileEntity) frequency).isInvalid()) {
it.remove(); it.remove();
} else { } else {
if (((TileEntity) frequency).getWorldObj().getTileEntity( if (((TileEntity) frequency)
((TileEntity) frequency).xCoord, .getWorldObj()
((TileEntity) frequency).yCoord, .getTileEntity(
((TileEntity) frequency).zCoord) == (TileEntity) frequency) { ((TileEntity) frequency).xCoord,
((TileEntity) frequency).yCoord,
((TileEntity) frequency).zCoord
)
== (TileEntity) frequency) {
continue; continue;
} }
it.remove(); it.remove();
@ -87,25 +92,29 @@ public class FrequencyGrid {
} }
} }
public Set<IBlockFrequency> get(final World world, final Vector3 position, final int radius, public Set<IBlockFrequency>
final int frequency) { get(final World world, final Vector3 position, final int radius, final int frequency
) {
final Set set = new HashSet(); final Set set = new HashSet();
for (final IBlockFrequency tileEntity : this.get(frequency)) { for (final IBlockFrequency tileEntity : this.get(frequency)) {
if (((TileEntity) tileEntity).getWorldObj() == world && if (((TileEntity) tileEntity).getWorldObj() == world
Vector3.distance(new Vector3((TileEntity) tileEntity), position) <= radius) { && Vector3.distance(new Vector3((TileEntity) tileEntity), position)
<= radius) {
set.add(tileEntity); set.add(tileEntity);
} }
} }
return set; return set;
} }
public Set<IFortronFrequency> getFortronTiles(final World world, final Vector3 position, public Set<IFortronFrequency> getFortronTiles(
final int radius, final int frequency) { final World world, final Vector3 position, final int radius, final int frequency
) {
final Set set = new HashSet(); final Set set = new HashSet();
for (final IBlockFrequency tileEntity : this.get(frequency)) { for (final IBlockFrequency tileEntity : this.get(frequency)) {
if (((TileEntity) tileEntity).getWorldObj() == world && if (((TileEntity) tileEntity).getWorldObj() == world
tileEntity instanceof IFortronFrequency && && tileEntity instanceof IFortronFrequency
Vector3.distance(new Vector3((TileEntity) tileEntity), position) <= radius) { && Vector3.distance(new Vector3((TileEntity) tileEntity), position)
<= radius) {
set.add(tileEntity); set.add(tileEntity);
} }
} }

View File

@ -19,8 +19,9 @@ public class GuiBiometricIdentifier extends GuiBase {
private TileEntityBiometricIdentifier tileEntity; private TileEntityBiometricIdentifier tileEntity;
private GuiTextField textFieldUsername; private GuiTextField textFieldUsername;
public GuiBiometricIdentifier(final EntityPlayer player, public GuiBiometricIdentifier(
final TileEntityBiometricIdentifier tileEntity) { final EntityPlayer player, final TileEntityBiometricIdentifier tileEntity
) {
super(new ContainerBiometricIdentifier(player, tileEntity), tileEntity); super(new ContainerBiometricIdentifier(player, tileEntity), tileEntity);
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
tileEntity.canUpdate(); tileEntity.canUpdate();
@ -31,15 +32,19 @@ public class GuiBiometricIdentifier extends GuiBase {
super.textFieldPos = new Vector2(109.0, 92.0); super.textFieldPos = new Vector2(109.0, 92.0);
super.initGui(); super.initGui();
(this.textFieldUsername = new GuiTextField(this.fontRendererObj, 52, 18, 90, 12)) (this.textFieldUsername = new GuiTextField(this.fontRendererObj, 52, 18, 90, 12))
.setMaxStringLength(30); .setMaxStringLength(30);
int x = 0; int x = 0;
int y = 0; int y = 0;
for (int i = 0; i < Permission.getPermissions().length; ++i) { for (int i = 0; i < Permission.getPermissions().length; ++i) {
++x; ++x;
this.buttonList.add(new GuiButtonPress( this.buttonList.add(new GuiButtonPress(
i + 1, this.width / 2 - 50 + 20 * x, this.height / 2 - 75 + 20 * y, i + 1,
new Vector2(18.0, 18 * i), this, this.width / 2 - 50 + 20 * x,
Permission.getPermissions()[i].name)); this.height / 2 - 75 + 20 * y,
new Vector2(18.0, 18 * i),
this,
Permission.getPermissions()[i].name
));
if (i % 3 == 0 && i != 0) { if (i % 3 == 0 && i != 0) {
x = 0; x = 0;
++y; ++y;
@ -50,27 +55,32 @@ public class GuiBiometricIdentifier extends GuiBase {
@Override @Override
protected void drawGuiContainerForegroundLayer(final int x, final int y) { protected void drawGuiContainerForegroundLayer(final int x, final int y) {
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
this.tileEntity.getInventoryName(), this.tileEntity.getInventoryName(),
this.xSize / 2 - this.fontRendererObj.getStringWidth( this.xSize / 2
this.tileEntity.getInventoryName()) / - this.fontRendererObj.getStringWidth(this.tileEntity.getInventoryName())
2, / 2,
6, 4210752); 6,
4210752
);
this.drawTextWithTooltip("rights", "%1", 8, 32, x, y, 0); this.drawTextWithTooltip("rights", "%1", 8, 32, x, y, 0);
try { try {
if (this.tileEntity.getManipulatingCard() != null) { if (this.tileEntity.getManipulatingCard() != null) {
final ICardIdentification idCard = (ICardIdentification) this.tileEntity.getManipulatingCard() final ICardIdentification idCard
.getItem(); = (ICardIdentification) this.tileEntity.getManipulatingCard().getItem(
);
this.textFieldUsername.drawTextBox(); this.textFieldUsername.drawTextBox();
if (idCard.getUsername(this.tileEntity.getManipulatingCard()) != null) { if (idCard.getUsername(this.tileEntity.getManipulatingCard()) != null) {
for (int i = 0; i < this.buttonList.size(); ++i) { for (int i = 0; i < this.buttonList.size(); ++i) {
if (this.buttonList.get(i) instanceof GuiButtonPress) { if (this.buttonList.get(i) instanceof GuiButtonPress) {
final GuiButtonPress button = (GuiButtonPress) this.buttonList.get(i); final GuiButtonPress button
= (GuiButtonPress) this.buttonList.get(i);
button.visible = true; button.visible = true;
final int permissionID = i - 1; final int permissionID = i - 1;
if (Permission.getPermission(permissionID) != null) { if (Permission.getPermission(permissionID) != null) {
if (idCard.hasPermission( if (idCard.hasPermission(
this.tileEntity.getManipulatingCard(), this.tileEntity.getManipulatingCard(),
Permission.getPermission(permissionID))) { Permission.getPermission(permissionID)
)) {
button.stuck = true; button.stuck = true;
} else { } else {
button.stuck = false; button.stuck = false;
@ -90,27 +100,30 @@ public class GuiBiometricIdentifier extends GuiBase {
e.printStackTrace(); e.printStackTrace();
} }
super.textFieldFrequency.drawTextBox(); super.textFieldFrequency.drawTextBox();
this.drawTextWithTooltip("master", 28, this.drawTextWithTooltip(
90 + this.fontRendererObj.FONT_HEIGHT / 2, x, y); "master", 28, 90 + this.fontRendererObj.FONT_HEIGHT / 2, x, y
);
super.drawGuiContainerForegroundLayer(x, y); super.drawGuiContainerForegroundLayer(x, y);
} }
@Override @Override
public void updateScreen() { public void updateScreen() {
super.updateScreen(); super.updateScreen();
if (!this.textFieldUsername.isFocused() && if (!this.textFieldUsername.isFocused()
this.tileEntity.getManipulatingCard() != null) { && this.tileEntity.getManipulatingCard() != null) {
final ICardIdentification idCard = (ICardIdentification) this.tileEntity.getManipulatingCard().getItem(); final ICardIdentification idCard
= (ICardIdentification) this.tileEntity.getManipulatingCard().getItem();
if (idCard.getUsername(this.tileEntity.getManipulatingCard()) != null) { if (idCard.getUsername(this.tileEntity.getManipulatingCard()) != null) {
this.textFieldUsername.setText( this.textFieldUsername.setText(
idCard.getUsername(this.tileEntity.getManipulatingCard())); idCard.getUsername(this.tileEntity.getManipulatingCard())
);
} }
} }
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float f, final int x, protected void
final int y) { drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
super.drawGuiContainerBackgroundLayer(f, x, y); super.drawGuiContainerBackgroundLayer(f, x, y);
this.drawSlot(87, 90); this.drawSlot(87, 90);
this.drawSlot(7, 45); this.drawSlot(7, 45);
@ -129,15 +142,17 @@ public class GuiBiometricIdentifier extends GuiBase {
this.textFieldUsername.textboxKeyTyped(par1, par2); this.textFieldUsername.textboxKeyTyped(par1, par2);
NBTTagCompound nbt = new NBTTagCompound(); NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("username", this.textFieldUsername.getText()); nbt.setString("username", this.textFieldUsername.getText());
ModularForceFieldSystem.channel.sendToServer(new PacketTile( ModularForceFieldSystem.channel.sendToServer(
PacketTile.Type.STRING, new Vector3(this.tileEntity), nbt)); new PacketTile(PacketTile.Type.STRING, new Vector3(this.tileEntity), nbt)
);
} }
@Override @Override
protected void mouseClicked(final int x, final int y, final int par3) { protected void mouseClicked(final int x, final int y, final int par3) {
super.mouseClicked(x, y, par3); super.mouseClicked(x, y, par3);
this.textFieldUsername.mouseClicked(x - super.containerWidth, this.textFieldUsername.mouseClicked(
y - super.containerHeight, par3); x - super.containerWidth, y - super.containerHeight, par3
);
} }
@Override @Override
@ -146,7 +161,9 @@ public class GuiBiometricIdentifier extends GuiBase {
if (guiButton.id > 0) { if (guiButton.id > 0) {
NBTTagCompound nbt = new NBTTagCompound(); NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("buttonId", guiButton.id - 1); nbt.setInteger("buttonId", guiButton.id - 1);
ModularForceFieldSystem.channel.sendToServer(new PacketTile(PacketTile.Type.TOGGLE_MODE, new Vector3(this.tileEntity), nbt)); ModularForceFieldSystem.channel.sendToServer(new PacketTile(
PacketTile.Type.TOGGLE_MODE, new Vector3(this.tileEntity), nbt
));
} }
} }
} }

View File

@ -9,16 +9,17 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.vector.Vector2; import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class GuiCoercionDeriver extends GuiBase { public class GuiCoercionDeriver extends GuiBase {
private TileEntityCoercionDeriver tileEntity; private TileEntityCoercionDeriver tileEntity;
public GuiCoercionDeriver(final EntityPlayer player, public GuiCoercionDeriver(
final TileEntityCoercionDeriver tileentity) { final EntityPlayer player, final TileEntityCoercionDeriver tileentity
) {
super(new ContainerCoercionDeriver(player, tileentity), tileentity); super(new ContainerCoercionDeriver(player, tileentity), tileentity);
this.tileEntity = tileentity; this.tileEntity = tileentity;
} }
@ -27,18 +28,21 @@ public class GuiCoercionDeriver extends GuiBase {
public void initGui() { public void initGui() {
super.textFieldPos = new Vector2(30.0, 43.0); super.textFieldPos = new Vector2(30.0, 43.0);
super.initGui(); super.initGui();
this.buttonList.add(new GuiButton(1, this.width / 2 - 10, this.buttonList.add(
this.height / 2 - 28, 58, 20, "Derive")); new GuiButton(1, this.width / 2 - 10, this.height / 2 - 28, 58, 20, "Derive")
);
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(final int x, final int y) { protected void drawGuiContainerForegroundLayer(final int x, final int y) {
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
this.tileEntity.getInventoryName(), this.tileEntity.getInventoryName(),
this.xSize / 2 - this.fontRendererObj.getStringWidth( this.xSize / 2
this.tileEntity.getInventoryName()) / - this.fontRendererObj.getStringWidth(this.tileEntity.getInventoryName())
2, / 2,
6, 4210752); 6,
4210752
);
this.drawTextWithTooltip("frequency", "%1:", 8, 30, x, y); this.drawTextWithTooltip("frequency", "%1:", 8, 30, x, y);
super.textFieldFrequency.drawTextBox(); super.textFieldFrequency.drawTextBox();
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -53,38 +57,58 @@ public class GuiCoercionDeriver extends GuiBase {
} }
} }
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
1000.0 * UniversalElectricity.UE_RF_RATIO + " RF/s", 85, 30, 4210752); 1000.0 * UniversalElectricity.UE_RF_RATIO + " RF/s", 85, 30, 4210752
);
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
1000.0 * UniversalElectricity.UE_IC2_RATIO + " EU/s", 85, 40, 4210752); 1000.0 * UniversalElectricity.UE_IC2_RATIO + " EU/s", 85, 40, 4210752
);
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
UnitDisplay.getDisplayShort( UnitDisplay.getDisplayShort(1000.0, UnitDisplay.Unit.WATT), 85, 50, 4210752
1000.0, UnitDisplay.Unit.WATT), );
85, 50, 4210752);
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
UnitDisplay.getDisplayShort( UnitDisplay.getDisplayShort(
this.tileEntity.getVoltage(), this.tileEntity.getVoltage(), UnitDisplay.Unit.VOLTAGE
UnitDisplay.Unit.VOLTAGE), ),
85, 60, 4210752); 85,
60,
4210752
);
this.drawTextWithTooltip( this.drawTextWithTooltip(
"progress", "%1: " + (this.tileEntity.isActive() ? "Running" : "Idle"), "progress",
8, 70, x, y); "%1: " + (this.tileEntity.isActive() ? "Running" : "Idle"),
this.drawTextWithTooltip("fortron", 8,
"%1: " + 70,
UnitDisplay.getDisplayShort( x,
this.tileEntity.getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, y
UnitDisplay.Unit.JOULES), );
8, 105, x, y); this.drawTextWithTooltip(
"fortron",
"%1: "
+ UnitDisplay.getDisplayShort(
this.tileEntity.getFortronEnergy()
* TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES
),
8,
105,
x,
y
);
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
"§2+" + UnitDisplay.getDisplayShort( "§2+"
this.tileEntity.getProductionRate() * 20, + UnitDisplay.getDisplayShort(
UnitDisplay.Unit.JOULES), this.tileEntity.getProductionRate() * 20, UnitDisplay.Unit.JOULES
120, 117, 4210752); ),
120,
117,
4210752
);
super.drawGuiContainerForegroundLayer(x, y); super.drawGuiContainerForegroundLayer(x, y);
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float f, final int x, protected void
final int y) { drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
super.drawGuiContainerBackgroundLayer(f, x, y); super.drawGuiContainerBackgroundLayer(f, x, y);
this.drawSlot(153, 46); this.drawSlot(153, 46);
this.drawSlot(153, 66); this.drawSlot(153, 66);
@ -93,18 +117,23 @@ public class GuiCoercionDeriver extends GuiBase {
this.drawSlot(8, 82, SlotType.BATTERY); this.drawSlot(8, 82, SlotType.BATTERY);
this.drawSlot(28, 82); this.drawSlot(28, 82);
this.drawBar(50, 84, 1.0f); this.drawBar(50, 84, 1.0f);
this.drawForce(8, 115, this.drawForce(
this.tileEntity.getFortronEnergy() / 8,
(float) this.tileEntity.getFortronCapacity()); 115,
this.tileEntity.getFortronEnergy()
/ (float) this.tileEntity.getFortronCapacity()
);
} }
@Override @Override
protected void actionPerformed(final GuiButton guibutton) { protected void actionPerformed(final GuiButton guibutton) {
super.actionPerformed(guibutton); super.actionPerformed(guibutton);
if (guibutton.id == 1) { if (guibutton.id == 1) {
ModularForceFieldSystem.channel.sendToServer( ModularForceFieldSystem.channel.sendToServer(new PacketTile(
new PacketTile(PacketTile.Type.TOGGLE_MODE, PacketTile.Type.TOGGLE_MODE,
new Vector3(this.tileEntity), new NBTTagCompound())); new Vector3(this.tileEntity),
new NBTTagCompound()
));
} }
} }
} }

View File

@ -12,140 +12,178 @@ import universalelectricity.core.vector.Vector2;
import universalelectricity.prefab.vector.Region2; import universalelectricity.prefab.vector.Region2;
public class GuiForceFieldProjector extends GuiBase { public class GuiForceFieldProjector extends GuiBase {
private TileEntityForceFieldProjector tileEntity; private TileEntityForceFieldProjector tileEntity;
public GuiForceFieldProjector(final EntityPlayer player, public GuiForceFieldProjector(
final TileEntityForceFieldProjector final EntityPlayer player, final TileEntityForceFieldProjector tileEntity
tileEntity) { ) {
super(new ContainerForceFieldProjector(player, tileEntity), tileEntity); super(new ContainerForceFieldProjector(player, tileEntity), tileEntity);
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
} }
@Override @Override
public void initGui() { public void initGui() {
super.textFieldPos = new Vector2(48.0, 91.0); super.textFieldPos = new Vector2(48.0, 91.0);
super.initGui(); super.initGui();
super.tooltips.put(new Region2(new Vector2(117.0, 44.0), super.tooltips.put(
new Vector2(117.0, 44.0).add(18.0)), new Region2(new Vector2(117.0, 44.0), new Vector2(117.0, 44.0).add(18.0)),
"Mode"); "Mode"
super.tooltips.put( );
new Region2(new Vector2(90.0, 17.0), new Vector2(90.0, 17.0).add(18.0)), super.tooltips.put(
"Up"); new Region2(new Vector2(90.0, 17.0), new Vector2(90.0, 17.0).add(18.0)), "Up"
super.tooltips.put(new Region2(new Vector2(144.0, 17.0), );
new Vector2(144.0, 17.0).add(18.0)), super.tooltips.put(
"Up"); new Region2(new Vector2(144.0, 17.0), new Vector2(144.0, 17.0).add(18.0)),
super.tooltips.put( "Up"
new Region2(new Vector2(90.0, 71.0), new Vector2(90.0, 71.0).add(18.0)), );
"Down"); super.tooltips.put(
super.tooltips.put(new Region2(new Vector2(144.0, 71.0), new Region2(new Vector2(90.0, 71.0), new Vector2(90.0, 71.0).add(18.0)),
new Vector2(144.0, 71.0).add(18.0)), "Down"
"Down"); );
super.tooltips.put(new Region2(new Vector2(108.0, 17.0), super.tooltips.put(
new Vector2(108.0, 17.0).add(18.0)), new Region2(new Vector2(144.0, 71.0), new Vector2(144.0, 71.0).add(18.0)),
"Front"); "Down"
super.tooltips.put(new Region2(new Vector2(126.0, 17.0), );
new Vector2(126.0, 17.0).add(18.0)), super.tooltips.put(
"Front"); new Region2(new Vector2(108.0, 17.0), new Vector2(108.0, 17.0).add(18.0)),
super.tooltips.put(new Region2(new Vector2(108.0, 71.0), "Front"
new Vector2(108.0, 71.0).add(18.0)), );
"Back"); super.tooltips.put(
super.tooltips.put(new Region2(new Vector2(126.0, 71.0), new Region2(new Vector2(126.0, 17.0), new Vector2(126.0, 17.0).add(18.0)),
new Vector2(126.0, 71.0).add(18.0)), "Front"
"Back"); );
super.tooltips.put(new Region2(new Vector2(90.0, 35.0), super.tooltips.put(
new Vector2(108.0, 35.0).add(18.0)), new Region2(new Vector2(108.0, 71.0), new Vector2(108.0, 71.0).add(18.0)),
"Left"); "Back"
super.tooltips.put(new Region2(new Vector2(90.0, 53.0), );
new Vector2(108.0, 53.0).add(18.0)), super.tooltips.put(
"Left"); new Region2(new Vector2(126.0, 71.0), new Vector2(126.0, 71.0).add(18.0)),
super.tooltips.put(new Region2(new Vector2(144.0, 35.0), "Back"
new Vector2(144.0, 35.0).add(18.0)), );
"Right"); super.tooltips.put(
super.tooltips.put(new Region2(new Vector2(144.0, 53.0), new Region2(new Vector2(90.0, 35.0), new Vector2(108.0, 35.0).add(18.0)),
new Vector2(144.0, 53.0).add(18.0)), "Left"
"Right"); );
} super.tooltips.put(
new Region2(new Vector2(90.0, 53.0), new Vector2(108.0, 53.0).add(18.0)),
"Left"
);
super.tooltips.put(
new Region2(new Vector2(144.0, 35.0), new Vector2(144.0, 35.0).add(18.0)),
"Right"
);
super.tooltips.put(
new Region2(new Vector2(144.0, 53.0), new Vector2(144.0, 53.0).add(18.0)),
"Right"
);
}
@Override @Override
protected void drawGuiContainerForegroundLayer(final int x, final int y) { protected void drawGuiContainerForegroundLayer(final int x, final int y) {
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
this.tileEntity.getInventoryName(), this.tileEntity.getInventoryName(),
this.xSize / 2 - this.fontRendererObj.getStringWidth( this.xSize / 2
this.tileEntity.getInventoryName()) / - this.fontRendererObj.getStringWidth(this.tileEntity.getInventoryName())
2, / 2,
6, 4210752); 6,
GL11.glPushMatrix(); 4210752
GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); );
this.fontRendererObj.drawString( GL11.glPushMatrix();
this.tileEntity GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
.getDirection((IBlockAccess)this.tileEntity.getWorldObj(), this.fontRendererObj.drawString(
this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity
this.tileEntity.zCoord) .getDirection(
.name(), (IBlockAccess) this.tileEntity.getWorldObj(),
-63, 8, 4210752); this.tileEntity.xCoord,
GL11.glPopMatrix(); this.tileEntity.yCoord,
this.drawTextWithTooltip("matrix", 32, 20, x, y); this.tileEntity.zCoord
this.drawTextWithTooltip("frequency", "%1:", 8, 76, x, y); )
super.textFieldFrequency.drawTextBox(); .name(),
this.drawTextWithTooltip("fortron", -63,
"%1: " + 8,
UnitDisplay.getDisplayShort( 4210752
this.tileEntity.getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, );
UnitDisplay.Unit.JOULES) + GL11.glPopMatrix();
"/" + this.drawTextWithTooltip("matrix", 32, 20, x, y);
UnitDisplay.getDisplayShort( this.drawTextWithTooltip("frequency", "%1:", 8, 76, x, y);
this.tileEntity.getFortronCapacity() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, super.textFieldFrequency.drawTextBox();
UnitDisplay.Unit.JOULES), this.drawTextWithTooltip(
8, 110, x, y); "fortron",
this.fontRendererObj.drawString( "%1: "
"§4-" + UnitDisplay.getDisplayShort( + UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCost() * 20, this.tileEntity.getFortronEnergy()
UnitDisplay.Unit.JOULES), * TileEntityCoercionDeriver.FORTRON_UE_RATIO,
120, 121, 4210752); UnitDisplay.Unit.JOULES
super.drawGuiContainerForegroundLayer(x, y); )
} + "/"
+ UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCapacity()
* TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES
),
8,
110,
x,
y
);
this.fontRendererObj.drawString(
"§4-"
+ UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCost() * 20, UnitDisplay.Unit.JOULES
),
120,
121,
4210752
);
super.drawGuiContainerForegroundLayer(x, y);
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float f, final int x, protected void
final int y) { drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
super.drawGuiContainerBackgroundLayer(f, x, y); super.drawGuiContainerBackgroundLayer(f, x, y);
this.drawSlot(9, 88); this.drawSlot(9, 88);
this.drawSlot(27, 88); this.drawSlot(27, 88);
this.drawSlot(117, 44, SlotType.NONE, 1.0f, 0.4f, 0.4f); this.drawSlot(117, 44, SlotType.NONE, 1.0f, 0.4f, 0.4f);
for (int xSlot = 0; xSlot < 4; ++xSlot) { for (int xSlot = 0; xSlot < 4; ++xSlot) {
for (int ySlot = 0; ySlot < 4; ++ySlot) { for (int ySlot = 0; ySlot < 4; ++ySlot) {
if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2) && if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2)
(xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) { && (xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) {
SlotType type = SlotType.NONE; SlotType type = SlotType.NONE;
if (xSlot == 0 && ySlot == 0) { if (xSlot == 0 && ySlot == 0) {
type = SlotType.ARR_UP_LEFT; type = SlotType.ARR_UP_LEFT;
} else if (xSlot == 0 && ySlot == 3) { } else if (xSlot == 0 && ySlot == 3) {
type = SlotType.ARR_DOWN_LEFT; type = SlotType.ARR_DOWN_LEFT;
} else if (xSlot == 3 && ySlot == 0) { } else if (xSlot == 3 && ySlot == 0) {
type = SlotType.ARR_UP_RIGHT; type = SlotType.ARR_UP_RIGHT;
} else if (xSlot == 3 && ySlot == 3) { } else if (xSlot == 3 && ySlot == 3) {
type = SlotType.ARR_DOWN_RIGHT; type = SlotType.ARR_DOWN_RIGHT;
} else if (ySlot == 0) { } else if (ySlot == 0) {
type = SlotType.ARR_UP; type = SlotType.ARR_UP;
} else if (ySlot == 3) { } else if (ySlot == 3) {
type = SlotType.ARR_DOWN; type = SlotType.ARR_DOWN;
} else if (xSlot == 0) { } else if (xSlot == 0) {
type = SlotType.ARR_LEFT; type = SlotType.ARR_LEFT;
} else if (xSlot == 3) { } else if (xSlot == 3) {
type = SlotType.ARR_RIGHT; type = SlotType.ARR_RIGHT;
} }
this.drawSlot(90 + 18 * xSlot, 17 + 18 * ySlot, type); this.drawSlot(90 + 18 * xSlot, 17 + 18 * ySlot, type);
}
}
} }
} for (int xSlot = 0; xSlot < 3; ++xSlot) {
for (int ySlot = 0; ySlot < 2; ++ySlot) {
this.drawSlot(18 + 18 * xSlot, 35 + 18 * ySlot);
}
}
this.drawForce(
8,
120,
Math.min(
this.tileEntity.getFortronEnergy()
/ (float) this.tileEntity.getFortronCapacity(),
1.0f
)
);
} }
for (int xSlot = 0; xSlot < 3; ++xSlot) {
for (int ySlot = 0; ySlot < 2; ++ySlot) {
this.drawSlot(18 + 18 * xSlot, 35 + 18 * ySlot);
}
}
this.drawForce(8, 120,
Math.min(this.tileEntity.getFortronEnergy() /
(float)this.tileEntity.getFortronCapacity(),
1.0f));
}
} }

View File

@ -23,8 +23,9 @@ import universalelectricity.prefab.vector.Region2;
public class GuiForceManipulator extends GuiBase { public class GuiForceManipulator extends GuiBase {
private TileEntityForceManipulator tileEntity; private TileEntityForceManipulator tileEntity;
public GuiForceManipulator(final EntityPlayer player, public GuiForceManipulator(
final TileEntityForceManipulator tileEntity) { final EntityPlayer player, final TileEntityForceManipulator tileEntity
) {
super(new ContainerForceManipulator(player, tileEntity), tileEntity); super(new ContainerForceManipulator(player, tileEntity), tileEntity);
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
} }
@ -33,98 +34,141 @@ public class GuiForceManipulator extends GuiBase {
public void initGui() { public void initGui() {
super.textFieldPos = new Vector2(111.0, 93.0); super.textFieldPos = new Vector2(111.0, 93.0);
super.initGui(); super.initGui();
this.buttonList.add(new GuiButton(1, this.width / 2 - 60,
this.height / 2 - 22, 40, 20, "Reset"));
this.buttonList.add( this.buttonList.add(
new GuiIcon(2, this.width / 2 - 82, this.height / 2 - 82, new GuiButton(1, this.width / 2 - 60, this.height / 2 - 22, 40, 20, "Reset")
new ItemStack[] { null, new ItemStack(Items.redstone), );
new ItemStack(Blocks.redstone_block) })); this.buttonList.add(new GuiIcon(
this.buttonList.add( 2,
new GuiIcon(3, this.width / 2 - 82, this.height / 2 - 60, this.width / 2 - 82,
new ItemStack[] { null, new ItemStack(Blocks.anvil) })); this.height / 2 - 82,
super.tooltips.put(new Region2(new Vector2(117.0, 44.0), new ItemStack[] { null,
new Vector2(117.0, 44.0).add(18.0)), new ItemStack(Items.redstone),
"Mode"); new ItemStack(Blocks.redstone_block) }
));
this.buttonList.add(new GuiIcon(
3,
this.width / 2 - 82,
this.height / 2 - 60,
new ItemStack[] { null, new ItemStack(Blocks.anvil) }
));
super.tooltips.put( super.tooltips.put(
new Region2(new Vector2(90.0, 17.0), new Vector2(90.0, 17.0).add(18.0)), new Region2(new Vector2(117.0, 44.0), new Vector2(117.0, 44.0).add(18.0)),
"Up"); "Mode"
super.tooltips.put(new Region2(new Vector2(144.0, 17.0), );
new Vector2(144.0, 17.0).add(18.0)),
"Up");
super.tooltips.put( super.tooltips.put(
new Region2(new Vector2(90.0, 71.0), new Vector2(90.0, 71.0).add(18.0)), new Region2(new Vector2(90.0, 17.0), new Vector2(90.0, 17.0).add(18.0)), "Up"
"Down"); );
super.tooltips.put(new Region2(new Vector2(144.0, 71.0), super.tooltips.put(
new Vector2(144.0, 71.0).add(18.0)), new Region2(new Vector2(144.0, 17.0), new Vector2(144.0, 17.0).add(18.0)),
"Down"); "Up"
super.tooltips.put(new Region2(new Vector2(108.0, 17.0), );
new Vector2(108.0, 17.0).add(18.0)), super.tooltips.put(
"Front"); new Region2(new Vector2(90.0, 71.0), new Vector2(90.0, 71.0).add(18.0)),
super.tooltips.put(new Region2(new Vector2(126.0, 17.0), "Down"
new Vector2(126.0, 17.0).add(18.0)), );
"Front"); super.tooltips.put(
super.tooltips.put(new Region2(new Vector2(108.0, 71.0), new Region2(new Vector2(144.0, 71.0), new Vector2(144.0, 71.0).add(18.0)),
new Vector2(108.0, 71.0).add(18.0)), "Down"
"Back"); );
super.tooltips.put(new Region2(new Vector2(126.0, 71.0), super.tooltips.put(
new Vector2(126.0, 71.0).add(18.0)), new Region2(new Vector2(108.0, 17.0), new Vector2(108.0, 17.0).add(18.0)),
"Back"); "Front"
super.tooltips.put(new Region2(new Vector2(90.0, 35.0), );
new Vector2(108.0, 35.0).add(18.0)), super.tooltips.put(
"Left"); new Region2(new Vector2(126.0, 17.0), new Vector2(126.0, 17.0).add(18.0)),
super.tooltips.put(new Region2(new Vector2(90.0, 53.0), "Front"
new Vector2(108.0, 53.0).add(18.0)), );
"Left"); super.tooltips.put(
super.tooltips.put(new Region2(new Vector2(144.0, 35.0), new Region2(new Vector2(108.0, 71.0), new Vector2(108.0, 71.0).add(18.0)),
new Vector2(144.0, 35.0).add(18.0)), "Back"
"Right"); );
super.tooltips.put(new Region2(new Vector2(144.0, 53.0), super.tooltips.put(
new Vector2(144.0, 53.0).add(18.0)), new Region2(new Vector2(126.0, 71.0), new Vector2(126.0, 71.0).add(18.0)),
"Right"); "Back"
);
super.tooltips.put(
new Region2(new Vector2(90.0, 35.0), new Vector2(108.0, 35.0).add(18.0)),
"Left"
);
super.tooltips.put(
new Region2(new Vector2(90.0, 53.0), new Vector2(108.0, 53.0).add(18.0)),
"Left"
);
super.tooltips.put(
new Region2(new Vector2(144.0, 35.0), new Vector2(144.0, 35.0).add(18.0)),
"Right"
);
super.tooltips.put(
new Region2(new Vector2(144.0, 53.0), new Vector2(144.0, 53.0).add(18.0)),
"Right"
);
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(final int x, final int y) { protected void drawGuiContainerForegroundLayer(final int x, final int y) {
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
this.tileEntity.getInventoryName(), this.tileEntity.getInventoryName(),
this.xSize / 2 - this.fontRendererObj.getStringWidth( this.xSize / 2
this.tileEntity.getInventoryName()) / - this.fontRendererObj.getStringWidth(this.tileEntity.getInventoryName())
2, / 2,
6, 4210752); 6,
4210752
);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
this.tileEntity this.tileEntity
.getDirection((IBlockAccess) this.tileEntity.getWorldObj(), .getDirection(
this.tileEntity.xCoord, this.tileEntity.yCoord, (IBlockAccess) this.tileEntity.getWorldObj(),
this.tileEntity.zCoord) this.tileEntity.xCoord,
.name(), this.tileEntity.yCoord,
-100, 10, 4210752); this.tileEntity.zCoord
)
.name(),
-100,
10,
4210752
);
GL11.glPopMatrix(); GL11.glPopMatrix();
this.fontRendererObj.drawString("Anchor:", 30, 60, 4210752); this.fontRendererObj.drawString("Anchor:", 30, 60, 4210752);
if (this.tileEntity.anchor != null) { if (this.tileEntity.anchor != null) {
this.fontRendererObj.drawString(this.tileEntity.anchor.intX() + ", " + this.fontRendererObj.drawString(
this.tileEntity.anchor.intY() + ", " + this.tileEntity.anchor.intX() + ", " + this.tileEntity.anchor.intY()
this.tileEntity.anchor.intZ(), + ", " + this.tileEntity.anchor.intZ(),
30, 72, 4210752); 30,
72,
4210752
);
} }
super.textFieldFrequency.drawTextBox(); super.textFieldFrequency.drawTextBox();
this.drawTextWithTooltip("fortron", this.drawTextWithTooltip(
"%1: " + "fortron",
UnitDisplay.getDisplayShort( "%1: "
this.tileEntity.getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, + UnitDisplay.getDisplayShort(
UnitDisplay.Unit.JOULES) this.tileEntity.getFortronEnergy()
+ * TileEntityCoercionDeriver.FORTRON_UE_RATIO,
"/" + UnitDisplay.Unit.JOULES
UnitDisplay.getDisplayShort( )
this.tileEntity.getFortronCapacity() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, + "/"
UnitDisplay.Unit.JOULES), + UnitDisplay.getDisplayShort(
8, 110, x, y); this.tileEntity.getFortronCapacity()
* TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES
),
8,
110,
x,
y
);
this.fontRendererObj.drawString( this.fontRendererObj.drawString(
"§4-" + UnitDisplay.getDisplayShort( "§4-"
this.tileEntity.getFortronCost(), + UnitDisplay.getDisplayShort(
UnitDisplay.Unit.JOULES), this.tileEntity.getFortronCost(), UnitDisplay.Unit.JOULES
120, 121, 4210752); ),
120,
121,
4210752
);
super.drawGuiContainerForegroundLayer(x, y); super.drawGuiContainerForegroundLayer(x, y);
} }
@ -132,21 +176,20 @@ public class GuiForceManipulator extends GuiBase {
public void updateScreen() { public void updateScreen() {
super.updateScreen(); super.updateScreen();
((GuiIcon) this.buttonList.get(2)).setIndex(this.tileEntity.displayMode); ((GuiIcon) this.buttonList.get(2)).setIndex(this.tileEntity.displayMode);
((GuiIcon) this.buttonList.get(3)) ((GuiIcon) this.buttonList.get(3)).setIndex(this.tileEntity.doAnchor ? 1 : 0);
.setIndex(this.tileEntity.doAnchor ? 1 : 0);
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float f, final int x, protected void
final int y) { drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
super.drawGuiContainerBackgroundLayer(f, x, y); super.drawGuiContainerBackgroundLayer(f, x, y);
this.drawSlot(72, 90); this.drawSlot(72, 90);
this.drawSlot(90, 90); this.drawSlot(90, 90);
this.drawSlot(117, 44, SlotType.NONE, 1.0f, 0.4f, 0.4f); this.drawSlot(117, 44, SlotType.NONE, 1.0f, 0.4f, 0.4f);
for (int xSlot = 0; xSlot < 4; ++xSlot) { for (int xSlot = 0; xSlot < 4; ++xSlot) {
for (int ySlot = 0; ySlot < 4; ++ySlot) { for (int ySlot = 0; ySlot < 4; ++ySlot) {
if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2) && if ((xSlot != 1 || ySlot != 1) && (xSlot != 2 || ySlot != 2)
(xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) { && (xSlot != 1 || ySlot != 2) && (xSlot != 2 || ySlot != 1)) {
SlotType type = SlotType.NONE; SlotType type = SlotType.NONE;
if (xSlot == 0 && ySlot == 0) { if (xSlot == 0 && ySlot == 0) {
type = SlotType.ARR_UP_LEFT; type = SlotType.ARR_UP_LEFT;
@ -174,10 +217,15 @@ public class GuiForceManipulator extends GuiBase {
this.drawSlot(30 + 18 * xSlot, 18 + 18 * ySlot); this.drawSlot(30 + 18 * xSlot, 18 + 18 * ySlot);
} }
} }
this.drawForce(8, 120, this.drawForce(
Math.min(this.tileEntity.getFortronEnergy() / 8,
(float) this.tileEntity.getFortronCapacity(), 120,
1.0f)); Math.min(
this.tileEntity.getFortronEnergy()
/ (float) this.tileEntity.getFortronCapacity(),
1.0f
)
);
} }
@Override @Override
@ -189,7 +237,8 @@ public class GuiForceManipulator extends GuiBase {
if (guiButton.id == 1 || guiButton.id == 2 || guiButton.id == 3) { if (guiButton.id == 1 || guiButton.id == 2 || guiButton.id == 3) {
ModularForceFieldSystem.channel.sendToServer(new PacketTile( ModularForceFieldSystem.channel.sendToServer(new PacketTile(
PacketTile.Type.TOGGLE_MODE, new Vector3(this.tileEntity), nbt)); PacketTile.Type.TOGGLE_MODE, new Vector3(this.tileEntity), nbt
));
} }
} }
} }

View File

@ -16,82 +16,110 @@ import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class GuiFortronCapacitor extends GuiBase { public class GuiFortronCapacitor extends GuiBase {
private TileEntityFortronCapacitor tileEntity; private TileEntityFortronCapacitor tileEntity;
public GuiFortronCapacitor(final EntityPlayer player, public GuiFortronCapacitor(
final TileEntityFortronCapacitor tileentity) { final EntityPlayer player, final TileEntityFortronCapacitor tileentity
super(new ContainerFortronCapacitor(player, tileentity), tileentity); ) {
this.tileEntity = tileentity; super(new ContainerFortronCapacitor(player, tileentity), tileentity);
} this.tileEntity = tileentity;
}
@Override
public void initGui() { @Override
super.textFieldPos = new Vector2(50.0, 76.0); public void initGui() {
super.initGui(); super.textFieldPos = new Vector2(50.0, 76.0);
this.buttonList.add(new GuiButtonPressTransferMode( super.initGui();
1, this.width / 2 + 15, this.height / 2 - 37, this, this.tileEntity)); this.buttonList.add(new GuiButtonPressTransferMode(
} 1, this.width / 2 + 15, this.height / 2 - 37, this, this.tileEntity
));
@Override }
protected void drawGuiContainerForegroundLayer(final int x, final int y) {
this.fontRendererObj.drawString( @Override
this.tileEntity.getInventoryName(), protected void drawGuiContainerForegroundLayer(final int x, final int y) {
this.xSize / 2 - this.fontRendererObj.getStringWidth( this.fontRendererObj.drawString(
this.tileEntity.getInventoryName()) / this.tileEntity.getInventoryName(),
2, this.xSize / 2
6, 4210752); - this.fontRendererObj.getStringWidth(this.tileEntity.getInventoryName())
GL11.glPushMatrix(); / 2,
GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); 6,
this.drawTextWithTooltip("upgrade", -95, 140, x, y); 4210752
GL11.glPopMatrix(); );
this.drawTextWithTooltip("linkedDevice", GL11.glPushMatrix();
"%1: " + this.tileEntity.getLinkedDevices().size(), GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
8, 28, x, y); this.drawTextWithTooltip("upgrade", -95, 140, x, y);
this.drawTextWithTooltip("transmissionRate", GL11.glPopMatrix();
"%1: " + this.drawTextWithTooltip(
UnitDisplay.getDisplayShort( "linkedDevice",
this.tileEntity.getTransmissionRate(), "%1: " + this.tileEntity.getLinkedDevices().size(),
UnitDisplay.Unit.JOULES), 8,
8, 40, x, y); 28,
this.drawTextWithTooltip( x,
"range", "%1: " + this.tileEntity.getTransmissionRange(), 8, 52, x, y); y
this.drawTextWithTooltip("frequency", "%1:", 8, 63, x, y); );
super.textFieldFrequency.drawTextBox(); this.drawTextWithTooltip(
this.drawTextWithTooltip("fortron", "%1:", 8, 95, x, y); "transmissionRate",
this.fontRendererObj.drawString( "%1: "
UnitDisplay.getDisplayShort( + UnitDisplay.getDisplayShort(
this.tileEntity.getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, this.tileEntity.getTransmissionRate(), UnitDisplay.Unit.JOULES
UnitDisplay.Unit.JOULES) + ),
"/" + 8,
UnitDisplay.getDisplayShort( 40,
this.tileEntity.getFortronCapacity() * TileEntityCoercionDeriver.FORTRON_UE_RATIO, x,
UnitDisplay.Unit.JOULES), y
8, 105, 4210752); );
super.drawGuiContainerForegroundLayer(x, y); this.drawTextWithTooltip(
} "range", "%1: " + this.tileEntity.getTransmissionRange(), 8, 52, x, y
);
@Override this.drawTextWithTooltip("frequency", "%1:", 8, 63, x, y);
protected void drawGuiContainerBackgroundLayer(final float f, final int x, super.textFieldFrequency.drawTextBox();
final int y) { this.drawTextWithTooltip("fortron", "%1:", 8, 95, x, y);
super.drawGuiContainerBackgroundLayer(f, x, y); this.fontRendererObj.drawString(
this.drawSlot(153, 46); UnitDisplay.getDisplayShort(
this.drawSlot(153, 66); this.tileEntity.getFortronEnergy()
this.drawSlot(153, 86); * TileEntityCoercionDeriver.FORTRON_UE_RATIO,
this.drawSlot(8, 73); UnitDisplay.Unit.JOULES
this.drawSlot(26, 73); ) + "/"
this.drawForce(8, 115, + UnitDisplay.getDisplayShort(
Math.min(this.tileEntity.getFortronEnergy() / this.tileEntity.getFortronCapacity()
(float)this.tileEntity.getFortronCapacity(), * TileEntityCoercionDeriver.FORTRON_UE_RATIO,
1.0f)); UnitDisplay.Unit.JOULES
} ),
8,
@Override 105,
protected void actionPerformed(final GuiButton guibutton) { 4210752
super.actionPerformed(guibutton); );
if (guibutton.id == 1) { super.drawGuiContainerForegroundLayer(x, y);
ModularForceFieldSystem.channel.sendToServer( }
new PacketTile(PacketTile.Type.TOGGLE_MODE,
new Vector3(this.tileEntity), new NBTTagCompound())); @Override
protected void
drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
super.drawGuiContainerBackgroundLayer(f, x, y);
this.drawSlot(153, 46);
this.drawSlot(153, 66);
this.drawSlot(153, 86);
this.drawSlot(8, 73);
this.drawSlot(26, 73);
this.drawForce(
8,
115,
Math.min(
this.tileEntity.getFortronEnergy()
/ (float) this.tileEntity.getFortronCapacity(),
1.0f
)
);
}
@Override
protected void actionPerformed(final GuiButton guibutton) {
super.actionPerformed(guibutton);
if (guibutton.id == 1) {
ModularForceFieldSystem.channel.sendToServer(new PacketTile(
PacketTile.Type.TOGGLE_MODE,
new Vector3(this.tileEntity),
new NBTTagCompound()
));
}
} }
}
} }

View File

@ -14,93 +14,119 @@ import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class GuiInterdictionMatrix extends GuiBase { public class GuiInterdictionMatrix extends GuiBase {
private TileEntityInterdictionMatrix tileEntity; private TileEntityInterdictionMatrix tileEntity;
public GuiInterdictionMatrix(final EntityPlayer player, public GuiInterdictionMatrix(
final TileEntityInterdictionMatrix tileEntity) { final EntityPlayer player, final TileEntityInterdictionMatrix tileEntity
super(new ContainerInterdictionMatrix(player, tileEntity), tileEntity); ) {
this.tileEntity = tileEntity; super(new ContainerInterdictionMatrix(player, tileEntity), tileEntity);
} this.tileEntity = tileEntity;
@Override
public void initGui() {
super.textFieldPos = new Vector2(110.0, 91.0);
super.initGui();
this.buttonList.add(new GuiButton(1, this.width / 2 - 80,
this.height / 2 - 65, 50, 20, "Banned"));
}
@Override
protected void actionPerformed(final GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == 1) {
ModularForceFieldSystem.channel.sendToServer(
new PacketTile(PacketTile.Type.TOGGLE_MODE,
new Vector3(this.tileEntity), new NBTTagCompound()));
} }
}
@Override @Override
protected void drawGuiContainerForegroundLayer(final int x, final int y) { public void initGui() {
this.fontRendererObj.drawString( super.textFieldPos = new Vector2(110.0, 91.0);
this.tileEntity.getInventoryName(), super.initGui();
this.xSize / 2 - this.fontRendererObj.getStringWidth( this.buttonList.add(
this.tileEntity.getInventoryName()) / new GuiButton(1, this.width / 2 - 80, this.height / 2 - 65, 50, 20, "Banned")
2, );
6, 4210752);
this.drawTextWithTooltip("warn", "%1: " + this.tileEntity.getWarningRange(),
35, 19, x, y);
this.drawTextWithTooltip(
"action", "%1: " + this.tileEntity.getActionRange(), 100, 19, x, y);
this.drawTextWithTooltip("filterMode", "%1:", 9, 32, x, y);
if (!this.tileEntity.isBanMode()) {
if (this.buttonList.get(1) instanceof GuiButton) {
((GuiButton)this.buttonList.get(1)).displayString = "Allowed";
}
} else if (this.buttonList.get(1) instanceof GuiButton) {
((GuiButton)this.buttonList.get(1)).displayString = "Banned";
} }
this.drawTextWithTooltip("frequency", "%1:", 8, 93, x, y);
super.textFieldFrequency.drawTextBox();
this.drawTextWithTooltip("fortron",
"%1: " +
UnitDisplay.getDisplayShort(
this.tileEntity.getFortronEnergy() * TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES) +
"/" +
UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCapacity() * TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES),
8, 110, x, y);
this.fontRendererObj.drawString(
"§4-" + UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCost() * 20,
UnitDisplay.Unit.JOULES),
120, 121, 4210752);
super.drawGuiContainerForegroundLayer(x, y);
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float var1, final int x, protected void actionPerformed(final GuiButton guiButton) {
final int y) { super.actionPerformed(guiButton);
super.drawGuiContainerBackgroundLayer(var1, x, y); if (guiButton.id == 1) {
for (int var2 = 0; var2 < 2; ++var2) { ModularForceFieldSystem.channel.sendToServer(new PacketTile(
for (int var3 = 0; var3 < 4; ++var3) { PacketTile.Type.TOGGLE_MODE,
this.drawSlot(98 + var3 * 18, 30 + var2 * 18); new Vector3(this.tileEntity),
} new NBTTagCompound()
));
}
} }
for (int var4 = 0; var4 < 9; ++var4) {
if (this.tileEntity.isBanMode()) { @Override
this.drawSlot(8 + var4 * 18, 68, SlotType.NONE, 1.0f, 0.8f, 0.8f); protected void drawGuiContainerForegroundLayer(final int x, final int y) {
} else { this.fontRendererObj.drawString(
this.drawSlot(8 + var4 * 18, 68, SlotType.NONE, 0.8f, 1.0f, 0.8f); this.tileEntity.getInventoryName(),
} this.xSize / 2
- this.fontRendererObj.getStringWidth(this.tileEntity.getInventoryName())
/ 2,
6,
4210752
);
this.drawTextWithTooltip(
"warn", "%1: " + this.tileEntity.getWarningRange(), 35, 19, x, y
);
this.drawTextWithTooltip(
"action", "%1: " + this.tileEntity.getActionRange(), 100, 19, x, y
);
this.drawTextWithTooltip("filterMode", "%1:", 9, 32, x, y);
if (!this.tileEntity.isBanMode()) {
if (this.buttonList.get(1) instanceof GuiButton) {
((GuiButton) this.buttonList.get(1)).displayString = "Allowed";
}
} else if (this.buttonList.get(1) instanceof GuiButton) {
((GuiButton) this.buttonList.get(1)).displayString = "Banned";
}
this.drawTextWithTooltip("frequency", "%1:", 8, 93, x, y);
super.textFieldFrequency.drawTextBox();
this.drawTextWithTooltip(
"fortron",
"%1: "
+ UnitDisplay.getDisplayShort(
this.tileEntity.getFortronEnergy()
* TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES
)
+ "/"
+ UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCapacity()
* TileEntityCoercionDeriver.FORTRON_UE_RATIO,
UnitDisplay.Unit.JOULES
),
8,
110,
x,
y
);
this.fontRendererObj.drawString(
"§4-"
+ UnitDisplay.getDisplayShort(
this.tileEntity.getFortronCost() * 20, UnitDisplay.Unit.JOULES
),
120,
121,
4210752
);
super.drawGuiContainerForegroundLayer(x, y);
}
@Override
protected void
drawGuiContainerBackgroundLayer(final float var1, final int x, final int y) {
super.drawGuiContainerBackgroundLayer(var1, x, y);
for (int var2 = 0; var2 < 2; ++var2) {
for (int var3 = 0; var3 < 4; ++var3) {
this.drawSlot(98 + var3 * 18, 30 + var2 * 18);
}
}
for (int var4 = 0; var4 < 9; ++var4) {
if (this.tileEntity.isBanMode()) {
this.drawSlot(8 + var4 * 18, 68, SlotType.NONE, 1.0f, 0.8f, 0.8f);
} else {
this.drawSlot(8 + var4 * 18, 68, SlotType.NONE, 0.8f, 1.0f, 0.8f);
}
}
this.drawSlot(68, 88);
this.drawSlot(86, 88);
this.drawForce(
8,
120,
Math.min(
this.tileEntity.getFortronEnergy()
/ (float) this.tileEntity.getFortronCapacity(),
1.0f
)
);
} }
this.drawSlot(68, 88);
this.drawSlot(86, 88);
this.drawForce(8, 120,
Math.min(this.tileEntity.getFortronEnergy() /
(float)this.tileEntity.getFortronCapacity(),
1.0f));
}
} }

View File

@ -17,9 +17,14 @@ public class GuiButtonPress extends GuiButton {
public boolean stuck; public boolean stuck;
private GuiBase mainGui; private GuiBase mainGui;
public GuiButtonPress(final int id, final int x, final int y, public GuiButtonPress(
final Vector2 offset, final GuiBase mainGui, final int id,
final String name) { final int x,
final int y,
final Vector2 offset,
final GuiBase mainGui,
final String name
) {
super(id, x, y, 18, 18, name); super(id, x, y, 18, 18, name);
this.offset = new Vector2(); this.offset = new Vector2();
this.stuck = false; this.stuck = false;
@ -27,13 +32,17 @@ public class GuiButtonPress extends GuiButton {
this.mainGui = mainGui; this.mainGui = mainGui;
} }
public GuiButtonPress(final int id, final int x, final int y, public GuiButtonPress(
final Vector2 offset, final GuiBase mainGui) { final int id,
final int x,
final int y,
final Vector2 offset,
final GuiBase mainGui
) {
this(id, x, y, offset, mainGui, ""); this(id, x, y, offset, mainGui, "");
} }
public GuiButtonPress(final int id, final int x, final int y, public GuiButtonPress(final int id, final int x, final int y, final Vector2 offset) {
final Vector2 offset) {
this(id, x, y, offset, null, ""); this(id, x, y, offset, null, "");
} }
@ -42,48 +51,62 @@ public class GuiButtonPress extends GuiButton {
} }
@Override @Override
public void drawButton(final Minecraft minecraft, final int x, public void drawButton(final Minecraft minecraft, final int x, final int y) {
final int y) {
if (this.visible) { if (this.visible) {
Minecraft.getMinecraft().renderEngine.bindTexture( Minecraft.getMinecraft().renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/gui/gui_button.png")); new ResourceLocation("mffs", "textures/gui/gui_button.png")
);
if (this.stuck) { if (this.stuck) {
GL11.glColor4f(0.6f, 0.6f, 0.6f, 1.0f); GL11.glColor4f(0.6f, 0.6f, 0.6f, 1.0f);
} else if (this.isPointInRegion(this.xPosition, this.yPosition, } else if (this.isPointInRegion(
this.width, this.height, x, y)) { this.xPosition, this.yPosition, this.width, this.height, x, y
)) {
GL11.glColor4f(0.85f, 0.85f, 0.85f, 1.0f); GL11.glColor4f(0.85f, 0.85f, 0.85f, 1.0f);
} else { } else {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} }
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.drawTexturedModalRect(
this.offset.intX(), this.offset.intY(), this.xPosition,
this.width, this.height); this.yPosition,
this.offset.intX(),
this.offset.intY(),
this.width,
this.height
);
this.mouseDragged(minecraft, x, y); this.mouseDragged(minecraft, x, y);
} }
} }
@Override @Override
protected void mouseDragged(final Minecraft minecraft, final int x, protected void mouseDragged(final Minecraft minecraft, final int x, final int y) {
final int y) { if (this.mainGui != null && this.displayString != null
if (this.mainGui != null && this.displayString != null && && this.displayString.length() > 0
this.displayString.length() > 0 && && this.isPointInRegion(
this.isPointInRegion(this.xPosition, this.yPosition, this.width, this.xPosition, this.yPosition, this.width, this.height, x, y
this.height, x, y)) { )) {
final String title = TranslationHelper.getLocal("gui." + this.displayString + ".name"); final String title
this.mainGui.tooltip = TranslationHelper.getLocal("gui." + this.displayString + ".tooltip"); = TranslationHelper.getLocal("gui." + this.displayString + ".name");
this.mainGui.tooltip
= TranslationHelper.getLocal("gui." + this.displayString + ".tooltip");
if (title != null && title.length() > 0) { if (title != null && title.length() > 0) {
this.mainGui.tooltip = title + ": " + this.mainGui.tooltip; this.mainGui.tooltip = title + ": " + this.mainGui.tooltip;
} }
} }
} }
protected boolean isPointInRegion(final int x, final int y, final int width, protected boolean isPointInRegion(
final int height, int checkX, int checkY) { final int x,
final int y,
final int width,
final int height,
int checkX,
int checkY
) {
final int var7 = 0; final int var7 = 0;
final int var8 = 0; final int var8 = 0;
checkX -= var7; checkX -= var7;
checkY -= var8; checkY -= var8;
return checkX >= x - 1 && checkX < x + width + 1 && checkY >= y - 1 && return checkX >= x - 1 && checkX < x + width + 1 && checkY >= y - 1
checkY < y + height + 1; && checkY < y + height + 1;
} }
} }

View File

@ -1,23 +1,28 @@
// //
// Decompiled by Procyon v0.6.0 // Decompiled by Procyon v0.6.0
// //
package mffs.gui.button; package mffs.gui.button;
import net.minecraft.client.Minecraft;
import universalelectricity.core.vector.Vector2;
import mffs.base.GuiBase; import mffs.base.GuiBase;
import mffs.tileentity.TileEntityFortronCapacitor; import mffs.tileentity.TileEntityFortronCapacitor;
import net.minecraft.client.Minecraft;
import universalelectricity.core.vector.Vector2;
public class GuiButtonPressTransferMode extends GuiButtonPress public class GuiButtonPressTransferMode extends GuiButtonPress {
{
private TileEntityFortronCapacitor tileEntity; private TileEntityFortronCapacitor tileEntity;
public GuiButtonPressTransferMode(final int id, final int x, final int y, final GuiBase mainGui, final TileEntityFortronCapacitor tileEntity) { public GuiButtonPressTransferMode(
final int id,
final int x,
final int y,
final GuiBase mainGui,
final TileEntityFortronCapacitor tileEntity
) {
super(id, x, y, new Vector2(), mainGui); super(id, x, y, new Vector2(), mainGui);
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
} }
@Override @Override
public void drawButton(final Minecraft minecraft, final int x, final int y) { public void drawButton(final Minecraft minecraft, final int x, final int y) {
String transferName = this.tileEntity.getTransferMode().name().toLowerCase(); String transferName = this.tileEntity.getTransferMode().name().toLowerCase();

View File

@ -16,8 +16,9 @@ public class GuiIcon extends GuiButton {
public ItemStack[] itemStacks; public ItemStack[] itemStacks;
private int index; private int index;
public GuiIcon(final int par1, final int par2, final int par3, public GuiIcon(
final ItemStack... itemStacks) { final int par1, final int par2, final int par3, final ItemStack... itemStacks
) {
super(par1, par2, par3, 20, 20, ""); super(par1, par2, par3, 20, 20, "");
this.index = 0; this.index = 0;
this.itemStacks = itemStacks; this.itemStacks = itemStacks;
@ -30,19 +31,24 @@ public class GuiIcon extends GuiButton {
} }
@Override @Override
public void drawButton(final Minecraft par1Minecraft, final int par2, public void
final int par3) { drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
super.drawButton(par1Minecraft, par2, par3); super.drawButton(par1Minecraft, par2, par3);
if (this.visible && this.itemStacks[this.index] != null) { if (this.visible && this.itemStacks[this.index] != null) {
int yDisplacement = 2; int yDisplacement = 2;
if (this.itemStacks[this.index].getItem() == Item.getItemFromBlock(Blocks.torch) || if (this.itemStacks[this.index].getItem()
this.itemStacks[this.index].getItem() == Item.getItemFromBlock(Blocks.redstone_torch)) { == Item.getItemFromBlock(Blocks.torch)
|| this.itemStacks[this.index].getItem()
== Item.getItemFromBlock(Blocks.redstone_torch)) {
yDisplacement = 0; yDisplacement = 0;
} else if (this.itemStacks[this.index].getItem() instanceof ItemBlock) { } else if (this.itemStacks[this.index].getItem() instanceof ItemBlock) {
yDisplacement = 3; yDisplacement = 3;
} }
this.drawItemStack(this.itemStacks[this.index], this.xPosition, this.drawItemStack(
this.yPosition + yDisplacement); this.itemStacks[this.index],
this.xPosition,
this.yPosition + yDisplacement
);
} }
} }
@ -56,9 +62,11 @@ public class GuiIcon extends GuiButton {
this.zLevel = 500.0f; this.zLevel = 500.0f;
GuiIcon.itemRenderer.zLevel = 500.0f; GuiIcon.itemRenderer.zLevel = 500.0f;
GuiIcon.itemRenderer.renderItemAndEffectIntoGUI( GuiIcon.itemRenderer.renderItemAndEffectIntoGUI(
fontRenderer, mc.renderEngine, itemStack, x, y); fontRenderer, mc.renderEngine, itemStack, x, y
GuiIcon.itemRenderer.renderItemOverlayIntoGUI(fontRenderer, mc.renderEngine, );
itemStack, x, y); GuiIcon.itemRenderer.renderItemOverlayIntoGUI(
fontRenderer, mc.renderEngine, itemStack, x, y
);
this.zLevel = 0.0f; this.zLevel = 0.0f;
GuiIcon.itemRenderer.zLevel = 0.0f; GuiIcon.itemRenderer.zLevel = 0.0f;
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();

View File

@ -2,6 +2,7 @@ package mffs.item;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.card.ICardLink; import mffs.api.card.ICardLink;
@ -23,123 +24,164 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemRemoteController public class ItemRemoteController extends ItemCardFrequency implements ICardLink {
extends ItemCardFrequency implements ICardLink { public ItemRemoteController() {
public ItemRemoteController() { super("remoteController"); } super("remoteController");
@Override
public void addInformation(final ItemStack itemStack,
final EntityPlayer player, final List list,
final boolean b) {
super.addInformation(itemStack, player, list, b);
final Vector3 position = this.getLink(itemStack);
if (position != null) {
final Block blockId = position.getBlock(player.worldObj);
if (blockId != null) {
list.add("Linked with: " + blockId.getLocalizedName());
list.add(position.intX() + ", " + position.intY() + ", " +
position.intZ());
return;
}
} }
list.add("Not linked.");
}
@Override @Override
public boolean onItemUse(final ItemStack itemStack, final EntityPlayer player, public void addInformation(
final World world, final int x, final int y, final ItemStack itemStack,
final int z, final int side, final float hitX, final EntityPlayer player,
final float hitY, final float hitZ) { final List list,
if (player.isSneaking()) { final boolean b
if (!world.isRemote) { ) {
final Vector3 vector = new Vector3(x, y, z); super.addInformation(itemStack, player, list, b);
this.setLink(itemStack, vector); final Vector3 position = this.getLink(itemStack);
if (vector.getBlock((IBlockAccess)world) != null) { if (position != null) {
player.addChatMessage(new ChatComponentText( final Block blockId = position.getBlock(player.worldObj);
"Linked remote to position: " + x + ", " + y + ", " + z + if (blockId != null) {
" with block: " + vector.getBlock(world).getLocalizedName())); list.add("Linked with: " + blockId.getLocalizedName());
} list.add(
} position.intX() + ", " + position.intY() + ", " + position.intZ()
return true; );
} return;
return false;
}
@Override
public ItemStack onItemRightClick(final ItemStack itemStack,
final World world,
final EntityPlayer entityPlayer) {
if (!entityPlayer.isSneaking()) {
final Vector3 position = this.getLink(itemStack);
if (position != null) {
final Block blockId = position.getBlock(world);
if (blockId != null) {
final Chunk chunk =
world.getChunkFromBlockCoords(position.intX(), position.intZ());
if (chunk != null && chunk.isChunkLoaded &&
(MFFSHelper.hasPermission(
world, position,
PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK,
entityPlayer) ||
MFFSHelper.hasPermission(
world, position, Permission.REMOTE_CONTROL, entityPlayer))) {
final double requiredEnergy =
Vector3.distance(new Vector3((Entity)entityPlayer), position) *
10.0;
int receivedEnergy = 0;
final Set<IFortronFrequency> fortronTiles =
FrequencyGrid.instance().getFortronTiles(
world, new Vector3((Entity)entityPlayer), 50,
this.getFrequency(itemStack));
for (final IFortronFrequency fortronTile : fortronTiles) {
final int consumedEnergy = fortronTile.requestFortron(
(int)Math.ceil(requiredEnergy / fortronTiles.size()), true);
if (consumedEnergy > 0) {
if (world.isRemote) {
ModularForceFieldSystem.proxy.renderBeam(
world,
new Vector3((Entity)entityPlayer)
.add(new Vector3(
0.0, entityPlayer.getEyeHeight() - 0.2, 0.0)),
new Vector3((TileEntity)fortronTile).add(0.5), 0.6f, 0.6f,
1.0f, 20);
}
receivedEnergy += consumedEnergy;
}
if (receivedEnergy >= requiredEnergy) {
try {
blockId.onBlockActivated(world, position.intX(),
position.intY(), position.intZ(),
entityPlayer, 0, 0.0f, 0.0f, 0.0f);
} catch (final Exception e) {
e.printStackTrace();
}
return itemStack;
}
} }
}
list.add("Not linked.");
}
@Override
public boolean onItemUse(
final ItemStack itemStack,
final EntityPlayer player,
final World world,
final int x,
final int y,
final int z,
final int side,
final float hitX,
final float hitY,
final float hitZ
) {
if (player.isSneaking()) {
if (!world.isRemote) { if (!world.isRemote) {
entityPlayer.addChatMessage(new ChatComponentText( final Vector3 vector = new Vector3(x, y, z);
"Unable to harness " + this.setLink(itemStack, vector);
UnitDisplay.getDisplay( if (vector.getBlock((IBlockAccess) world) != null) {
requiredEnergy, UnitDisplay.Unit.JOULES) + player.addChatMessage(new ChatComponentText(
" from the Fortron field.")); "Linked remote to position: " + x + ", " + y + ", " + z
+ " with block: " + vector.getBlock(world).getLocalizedName()
));
}
} }
} return true;
} }
} return false;
} }
return itemStack;
}
@Override @Override
public void setLink(final ItemStack itemStack, final Vector3 position) { public ItemStack onItemRightClick(
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); final ItemStack itemStack, final World world, final EntityPlayer entityPlayer
nbt.setTag("position", position.writeToNBT(new NBTTagCompound())); ) {
} if (!entityPlayer.isSneaking()) {
final Vector3 position = this.getLink(itemStack);
if (position != null) {
final Block blockId = position.getBlock(world);
if (blockId != null) {
final Chunk chunk
= world.getChunkFromBlockCoords(position.intX(), position.intZ());
if (chunk != null && chunk.isChunkLoaded
&& (MFFSHelper.hasPermission(
world,
position,
PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK,
entityPlayer
)
|| MFFSHelper.hasPermission(
world, position, Permission.REMOTE_CONTROL, entityPlayer
))) {
final double requiredEnergy
= Vector3.distance(
new Vector3((Entity) entityPlayer), position
)
* 10.0;
int receivedEnergy = 0;
final Set<IFortronFrequency> fortronTiles
= FrequencyGrid.instance().getFortronTiles(
world,
new Vector3((Entity) entityPlayer),
50,
this.getFrequency(itemStack)
);
for (final IFortronFrequency fortronTile : fortronTiles) {
final int consumedEnergy = fortronTile.requestFortron(
(int) Math.ceil(requiredEnergy / fortronTiles.size()),
true
);
if (consumedEnergy > 0) {
if (world.isRemote) {
ModularForceFieldSystem.proxy.renderBeam(
world,
new Vector3((Entity) entityPlayer)
.add(new Vector3(
0.0,
entityPlayer.getEyeHeight() - 0.2,
0.0
)),
new Vector3((TileEntity) fortronTile).add(0.5),
0.6f,
0.6f,
1.0f,
20
);
}
receivedEnergy += consumedEnergy;
}
if (receivedEnergy >= requiredEnergy) {
try {
blockId.onBlockActivated(
world,
position.intX(),
position.intY(),
position.intZ(),
entityPlayer,
0,
0.0f,
0.0f,
0.0f
);
} catch (final Exception e) {
e.printStackTrace();
}
return itemStack;
}
}
if (!world.isRemote) {
entityPlayer.addChatMessage(new ChatComponentText(
"Unable to harness "
+ UnitDisplay.getDisplay(
requiredEnergy, UnitDisplay.Unit.JOULES
)
+ " from the Fortron field."
));
}
}
}
}
}
return itemStack;
}
@Override @Override
public Vector3 getLink(final ItemStack itemStack) { public void setLink(final ItemStack itemStack, final Vector3 position) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
return Vector3.readFromNBT(nbt.getCompoundTag("position")); nbt.setTag("position", position.writeToNBT(new NBTTagCompound()));
} }
@Override
public Vector3 getLink(final ItemStack itemStack) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
return Vector3.readFromNBT(nbt.getCompoundTag("position"));
}
} }

View File

@ -1,7 +1,8 @@
package mffs.item.card; package mffs.item.card;
import icbm.api.IItemFrequency;
import java.util.List; import java.util.List;
import icbm.api.IItemFrequency;
import mffs.base.TileEntityFrequency; import mffs.base.TileEntityFrequency;
import mffs.card.ItemCard; import mffs.card.ItemCard;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -12,66 +13,83 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemCardFrequency extends ItemCard implements IItemFrequency { public class ItemCardFrequency extends ItemCard implements IItemFrequency {
public ItemCardFrequency(final String name) { super(name); } public ItemCardFrequency(final String name) {
super(name);
public ItemCardFrequency() { this("cardFrequency"); }
@Override
public void addInformation(final ItemStack itemStack,
final EntityPlayer par2EntityPlayer,
final List list, final boolean par4) {
list.add("Frequency: " + this.getFrequency(itemStack));
}
@Override
public int getFrequency(final ItemStack itemStack) {
if (itemStack != null) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
return itemStack.getTagCompound().getInteger("frequency");
} }
return 0;
}
@Override public ItemCardFrequency() {
public void setFrequency(final int frequency, final ItemStack itemStack) { this("cardFrequency");
if (itemStack != null) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setInteger("frequency", frequency);
} }
}
@Override @Override
public ItemStack onItemRightClick(final ItemStack itemStack, public void addInformation(
final World world, final ItemStack itemStack,
final EntityPlayer player) { final EntityPlayer par2EntityPlayer,
if (!world.isRemote && player.isSneaking()) { final List list,
this.setFrequency(world.rand.nextInt(15), itemStack); final boolean par4
player.addChatMessage(new ChatComponentText( ) {
"Generated random frequency: " + this.getFrequency(itemStack))); list.add("Frequency: " + this.getFrequency(itemStack));
} }
return itemStack;
}
@Override @Override
public boolean onItemUse(final ItemStack itemStack, final EntityPlayer player, public int getFrequency(final ItemStack itemStack) {
final World world, final int x, final int y, if (itemStack != null) {
final int z, final int side, final float hitX, if (itemStack.getTagCompound() == null) {
final float hitY, final float hitZ) { itemStack.setTagCompound(new NBTTagCompound());
final TileEntity tileEntity = world.getTileEntity(x, y, z); }
if (tileEntity instanceof TileEntityFrequency) { return itemStack.getTagCompound().getInteger("frequency");
if (!world.isRemote) { }
((TileEntityFrequency)tileEntity) return 0;
.setFrequency(this.getFrequency(itemStack)); }
world.markBlockForUpdate(x, y, z);
player.addChatMessage(new ChatComponentText( @Override
"Frequency set to: " + this.getFrequency(itemStack))); public void setFrequency(final int frequency, final ItemStack itemStack) {
} if (itemStack != null) {
return true; if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setInteger("frequency", frequency);
}
}
@Override
public ItemStack onItemRightClick(
final ItemStack itemStack, final World world, final EntityPlayer player
) {
if (!world.isRemote && player.isSneaking()) {
this.setFrequency(world.rand.nextInt(15), itemStack);
player.addChatMessage(new ChatComponentText(
"Generated random frequency: " + this.getFrequency(itemStack)
));
}
return itemStack;
}
@Override
public boolean onItemUse(
final ItemStack itemStack,
final EntityPlayer player,
final World world,
final int x,
final int y,
final int z,
final int side,
final float hitX,
final float hitY,
final float hitZ
) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityFrequency) {
if (!world.isRemote) {
((TileEntityFrequency) tileEntity)
.setFrequency(this.getFrequency(itemStack));
world.markBlockForUpdate(x, y, z);
player.addChatMessage(new ChatComponentText(
"Frequency set to: " + this.getFrequency(itemStack)
));
}
return true;
}
return false;
} }
return false;
}
} }

View File

@ -1,6 +1,7 @@
package mffs.item.card; package mffs.item.card;
import java.util.List; import java.util.List;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import mffs.api.card.ICardIdentification; import mffs.api.card.ICardIdentification;
import mffs.api.security.Permission; import mffs.api.security.Permission;
@ -13,94 +14,96 @@ import net.minecraft.world.World;
import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.TranslationHelper;
public class ItemCardID extends ItemCard implements ICardIdentification { public class ItemCardID extends ItemCard implements ICardIdentification {
public ItemCardID() {
public ItemCardID() { super("cardIdentification"); } super("cardIdentification");
public ItemCardID(final String name) { super(name); }
@Override
public boolean hitEntity(final ItemStack itemStack,
final EntityLivingBase entityLiving,
final EntityLivingBase par3EntityLiving) {
if (entityLiving instanceof EntityPlayer) {
this.setUsername(itemStack,
((EntityPlayer)entityLiving).getDisplayName());
} }
return false;
}
@Override public ItemCardID(final String name) {
public void addInformation(final ItemStack itemStack, super(name);
final EntityPlayer player, final List info,
final boolean b) {
if (this.getUsername(itemStack) != null &&
!this.getUsername(itemStack).isEmpty()) {
info.add("Username: " + this.getUsername(itemStack));
} else {
info.add("Unidentified");
} }
String tooltip = "";
boolean isFirst = true; @Override
for (final Permission permission : Permission.getPermissions()) { public boolean hitEntity(
if (this.hasPermission(itemStack, permission)) { final ItemStack itemStack,
if (!isFirst) { final EntityLivingBase entityLiving,
tooltip += ", "; final EntityLivingBase par3EntityLiving
) {
if (entityLiving instanceof EntityPlayer) {
this.setUsername(itemStack, ((EntityPlayer) entityLiving).getDisplayName());
} }
isFirst = false; return false;
tooltip +=
TranslationHelper.getLocal("gui." + permission.name + ".name");
}
} }
if (tooltip != null && tooltip.length() > 0) {
info.addAll(MFFSHelper.splitStringPerWord(tooltip, 5)); @Override
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List info,
final boolean b
) {
if (this.getUsername(itemStack) != null
&& !this.getUsername(itemStack).isEmpty()) {
info.add("Username: " + this.getUsername(itemStack));
} else {
info.add("Unidentified");
}
String tooltip = "";
boolean isFirst = true;
for (final Permission permission : Permission.getPermissions()) {
if (this.hasPermission(itemStack, permission)) {
if (!isFirst) {
tooltip += ", ";
}
isFirst = false;
tooltip += TranslationHelper.getLocal("gui." + permission.name + ".name");
}
}
if (tooltip != null && tooltip.length() > 0) {
info.addAll(MFFSHelper.splitStringPerWord(tooltip, 5));
}
} }
}
@Override @Override
public ItemStack onItemRightClick(final ItemStack itemStack, public ItemStack onItemRightClick(
final World par2World, final ItemStack itemStack, final World par2World, final EntityPlayer entityPlayer
final EntityPlayer entityPlayer) { ) {
this.setUsername(itemStack, entityPlayer.getDisplayName()); this.setUsername(itemStack, entityPlayer.getDisplayName());
return itemStack; return itemStack;
}
@Override
public void setUsername(final ItemStack itemStack, final String username) {
final NBTTagCompound nbtTagCompound =
MFFSHelper.getNBTTagCompound(itemStack);
nbtTagCompound.setString("name", username);
}
@Override
public String getUsername(final ItemStack itemStack) {
final NBTTagCompound nbtTagCompound =
MFFSHelper.getNBTTagCompound(itemStack);
if (nbtTagCompound != null && nbtTagCompound.getString("name") != "") {
return nbtTagCompound.getString("name");
} }
return null;
}
@Override @Override
public boolean hasPermission(final ItemStack itemStack, public void setUsername(final ItemStack itemStack, final String username) {
final Permission permission) { final NBTTagCompound nbtTagCompound = MFFSHelper.getNBTTagCompound(itemStack);
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); nbtTagCompound.setString("name", username);
return nbt.getBoolean("mffs_permission_" + permission.id); }
}
@Override @Override
public boolean addPermission(final ItemStack itemStack, public String getUsername(final ItemStack itemStack) {
final Permission permission) { final NBTTagCompound nbtTagCompound = MFFSHelper.getNBTTagCompound(itemStack);
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); if (nbtTagCompound != null && nbtTagCompound.getString("name") != "") {
nbt.setBoolean("mffs_permission_" + permission.id, true); return nbtTagCompound.getString("name");
return false; }
} return null;
}
@Override @Override
public boolean removePermission(final ItemStack itemStack, public boolean hasPermission(final ItemStack itemStack, final Permission permission) {
final Permission permission) { final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); return nbt.getBoolean("mffs_permission_" + permission.id);
nbt.setBoolean("mffs_permission_" + permission.id, false); }
return false;
} @Override
public boolean addPermission(final ItemStack itemStack, final Permission permission) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
nbt.setBoolean("mffs_permission_" + permission.id, true);
return false;
}
@Override
public boolean
removePermission(final ItemStack itemStack, final Permission permission) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
nbt.setBoolean("mffs_permission_" + permission.id, false);
return false;
}
} }

View File

@ -4,5 +4,7 @@ import mffs.api.card.ICardInfinite;
import mffs.card.ItemCard; import mffs.card.ItemCard;
public class ItemCardInfinite extends ItemCard implements ICardInfinite { public class ItemCardInfinite extends ItemCard implements ICardInfinite {
public ItemCardInfinite() { super("cardInfinite"); } public ItemCardInfinite() {
super("cardInfinite");
}
} }

View File

@ -1,6 +1,7 @@
package mffs.item.card; package mffs.item.card;
import java.util.List; import java.util.List;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import mffs.api.card.ICardLink; import mffs.api.card.ICardLink;
import mffs.card.ItemCard; import mffs.card.ItemCard;
@ -15,52 +16,67 @@ import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemCardLink extends ItemCard implements ICardLink { public class ItemCardLink extends ItemCard implements ICardLink {
public ItemCardLink() { super("cardLink"); } public ItemCardLink() {
super("cardLink");
@Override
public void addInformation(final ItemStack itemStack,
final EntityPlayer player, final List list,
final boolean b) {
final Vector3 position = this.getLink(itemStack);
if (position != null) {
final Block blockId =
position.getBlock((IBlockAccess)((Entity)player).worldObj);
if (blockId != null) {
list.add("Linked with: " + blockId.getLocalizedName());
list.add(position.intX() + ", " + position.intY() + ", " +
position.intZ());
return;
}
} }
list.add("Not linked.");
}
public boolean onItemUse(final ItemStack itemStack, final EntityPlayer player, @Override
final World world, final int x, final int y, public void addInformation(
final int z, final int par7, final float par8, final ItemStack itemStack,
final float par9, final float par10) { final EntityPlayer player,
if (!world.isRemote) { final List list,
final Vector3 vector = new Vector3(x, y, z); final boolean b
this.setLink(itemStack, vector); ) {
Block block = vector.getBlock(world); final Vector3 position = this.getLink(itemStack);
if (block != null) { if (position != null) {
player.addChatMessage(new ChatComponentText( final Block blockId
"Linked card to position: " + x + ", " + y + ", " + z + = position.getBlock((IBlockAccess) ((Entity) player).worldObj);
" with block: " + block.getLocalizedName())); if (blockId != null) {
} list.add("Linked with: " + blockId.getLocalizedName());
list.add(
position.intX() + ", " + position.intY() + ", " + position.intZ()
);
return;
}
}
list.add("Not linked.");
} }
return true;
}
@Override public boolean onItemUse(
public void setLink(final ItemStack itemStack, final Vector3 position) { final ItemStack itemStack,
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); final EntityPlayer player,
nbt.setTag("position", position.writeToNBT(new NBTTagCompound())); final World world,
} final int x,
final int y,
final int z,
final int par7,
final float par8,
final float par9,
final float par10
) {
if (!world.isRemote) {
final Vector3 vector = new Vector3(x, y, z);
this.setLink(itemStack, vector);
Block block = vector.getBlock(world);
if (block != null) {
player.addChatMessage(new ChatComponentText(
"Linked card to position: " + x + ", " + y + ", " + z
+ " with block: " + block.getLocalizedName()
));
}
}
return true;
}
@Override @Override
public Vector3 getLink(final ItemStack itemStack) { public void setLink(final ItemStack itemStack, final Vector3 position) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
return Vector3.readFromNBT(nbt.getCompoundTag("position")); nbt.setTag("position", position.writeToNBT(new NBTTagCompound()));
} }
@Override
public Vector3 getLink(final ItemStack itemStack) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
return Vector3.readFromNBT(nbt.getCompoundTag("position"));
}
} }

View File

@ -1,25 +1,30 @@
package mffs.item.mode; package mffs.item.mode;
import universalelectricity.core.vector.Vector3;
import mffs.api.IFieldInteraction;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.api.modules.IProjectorMode; import mffs.api.modules.IProjectorMode;
import mffs.base.ItemBase; import mffs.base.ItemBase;
import universalelectricity.core.vector.Vector3;
public abstract class ItemMode extends ItemBase implements IProjectorMode public abstract class ItemMode extends ItemBase implements IProjectorMode {
{
public ItemMode(final String name) { public ItemMode(final String name) {
super(name); super(name);
this.setMaxStackSize(1); this.setMaxStackSize(1);
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void render(final IProjector projector, final double x, final double y, final double z, final float f, final long ticks) { public void render(
} final IProjector projector,
final double x,
final double y,
final double z,
final float f,
final long ticks
) {}
@Override @Override
public boolean isInField(final IFieldInteraction projector, final Vector3 position) { public boolean isInField(final IFieldInteraction projector, final Vector3 position) {
return false; return false;

View File

@ -1,10 +1,11 @@
package mffs.item.mode; package mffs.item.mode;
import java.util.HashSet;
import java.util.Set;
import calclavia.lib.CalculationHelper; import calclavia.lib.CalculationHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashSet;
import java.util.Set;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.render.model.ModelCube; import mffs.render.model.ModelCube;
@ -14,66 +15,75 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.vector.Region3; import universalelectricity.prefab.vector.Region3;
public class ItemModeCube extends ItemMode { public class ItemModeCube extends ItemMode {
public ItemModeCube(final String name) { super(name); } public ItemModeCube(final String name) {
super(name);
public ItemModeCube(final int i) { this("modeCube"); }
@Override
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale();
for (float x = (float)(-negScale.intX()); x <= posScale.intX(); x += 0.5f) {
for (float z = (float)(-negScale.intZ()); z <= posScale.intZ();
z += 0.5f) {
for (float y = (float)(-negScale.intY()); y <= posScale.intY();
y += 0.5f) {
if (y == -negScale.intY() || y == posScale.intY() ||
x == -negScale.intX() || x == posScale.intX() ||
z == -negScale.intZ() || z == posScale.intZ()) {
fieldBlocks.add(new Vector3(x, y, z));
}
}
}
} }
return fieldBlocks;
}
@Override public ItemModeCube(final int i) {
public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) { this("modeCube");
final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale();
for (int x = -negScale.intX(); x <= posScale.intX(); ++x) {
for (int z = -negScale.intZ(); z <= posScale.intZ(); ++z) {
for (int y = -negScale.intY(); y <= posScale.intY(); ++y) {
fieldBlocks.add(new Vector3(x, y, z));
}
}
} }
return fieldBlocks;
}
@Override @Override
public boolean isInField(final IFieldInteraction projector, public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Vector3 position) { final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 projectorPos = new Vector3((TileEntity)projector); final Vector3 posScale = projector.getPositiveScale();
projectorPos.add(projector.getTranslation()); final Vector3 negScale = projector.getNegativeScale();
final Vector3 relativePosition = position.clone().subtract(projectorPos); for (float x = (float) (-negScale.intX()); x <= posScale.intX(); x += 0.5f) {
CalculationHelper.rotateByAngle(relativePosition, for (float z = (float) (-negScale.intZ()); z <= posScale.intZ(); z += 0.5f) {
-projector.getRotationYaw(), for (float y = (float) (-negScale.intY()); y <= posScale.intY();
-projector.getRotationPitch()); y += 0.5f) {
final Region3 region = if (y == -negScale.intY() || y == posScale.intY()
new Region3(projector.getNegativeScale().clone().multiply(-1.0), || x == -negScale.intX() || x == posScale.intX()
projector.getPositiveScale()); || z == -negScale.intZ() || z == posScale.intZ()) {
return region.isIn(relativePosition); fieldBlocks.add(new Vector3(x, y, z));
} }
}
}
}
return fieldBlocks;
}
@SideOnly(Side.CLIENT) @Override
@Override public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) {
public void render(final IProjector projector, final double x, final double y, final Set<Vector3> fieldBlocks = new HashSet<>();
final double z, final float f, final long ticks) { final Vector3 posScale = projector.getPositiveScale();
GL11.glScalef(0.5f, 0.5f, 0.5f); final Vector3 negScale = projector.getNegativeScale();
ModelCube.INSTNACE.render(); for (int x = -negScale.intX(); x <= posScale.intX(); ++x) {
} for (int z = -negScale.intZ(); z <= posScale.intZ(); ++z) {
for (int y = -negScale.intY(); y <= posScale.intY(); ++y) {
fieldBlocks.add(new Vector3(x, y, z));
}
}
}
return fieldBlocks;
}
@Override
public boolean isInField(final IFieldInteraction projector, final Vector3 position) {
final Vector3 projectorPos = new Vector3((TileEntity) projector);
projectorPos.add(projector.getTranslation());
final Vector3 relativePosition = position.clone().subtract(projectorPos);
CalculationHelper.rotateByAngle(
relativePosition, -projector.getRotationYaw(), -projector.getRotationPitch()
);
final Region3 region = new Region3(
projector.getNegativeScale().clone().multiply(-1.0),
projector.getPositiveScale()
);
return region.isIn(relativePosition);
}
@SideOnly(Side.CLIENT)
@Override
public void render(
final IProjector projector,
final double x,
final double y,
final double z,
final float f,
final long ticks
) {
GL11.glScalef(0.5f, 0.5f, 0.5f);
ModelCube.INSTNACE.render();
}
} }

View File

@ -1,9 +1,10 @@
package mffs.item.mode; package mffs.item.mode;
import java.util.HashSet;
import java.util.Set;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashSet;
import java.util.Set;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
@ -13,86 +14,103 @@ import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModeSphere extends ItemMode { public class ItemModeSphere extends ItemMode {
public ItemModeSphere(final int i) { super("modeSphere"); } public ItemModeSphere(final int i) {
super("modeSphere");
@Override
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>();
final int radius = projector.getModuleCount(
ModularForceFieldSystem.itemModuleScale, new int[0]);
for (int steps = (int)Math.ceil(3.141592653589793 /
Math.atan(1.0 / radius / 2.0)),
phi_n = 0;
phi_n < 2 * steps; ++phi_n) {
for (int theta_n = 0; theta_n < steps; ++theta_n) {
final double phi = 6.283185307179586 / steps * phi_n;
final double theta = 3.141592653589793 / steps * theta_n;
final Vector3 point =
new Vector3(Math.sin(theta) * Math.cos(phi), Math.cos(theta),
Math.sin(theta) * Math.sin(phi))
.multiply(radius);
fieldBlocks.add(point);
}
} }
return fieldBlocks;
}
@Override @Override
public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) { public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>(); final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 translation = projector.getTranslation(); final int radius = projector.getModuleCount(
for (int radius = projector.getModuleCount( ModularForceFieldSystem.itemModuleScale, new int[0]
ModularForceFieldSystem.itemModuleScale, new int[0]), );
x = -radius; for (int steps
x <= radius; ++x) { = (int) Math.ceil(3.141592653589793 / Math.atan(1.0 / radius / 2.0)),
for (int z = -radius; z <= radius; ++z) { phi_n = 0;
for (int y = -radius; y <= radius; ++y) { phi_n < 2 * steps;
final Vector3 position = new Vector3(x, y, z); ++phi_n) {
if (this.isInField( for (int theta_n = 0; theta_n < steps; ++theta_n) {
projector, final double phi = 6.283185307179586 / steps * phi_n;
Vector3.add(position, new Vector3((TileEntity)projector)) final double theta = 3.141592653589793 / steps * theta_n;
.add(translation))) { final Vector3 point = new Vector3(
fieldBlocks.add(position); Math.sin(theta) * Math.cos(phi),
} Math.cos(theta),
Math.sin(theta) * Math.sin(phi)
)
.multiply(radius);
fieldBlocks.add(point);
}
} }
} return fieldBlocks;
} }
return fieldBlocks;
}
@Override @Override
public boolean isInField(final IFieldInteraction projector, public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) {
final Vector3 position) { final Set<Vector3> fieldBlocks = new HashSet<>();
return new Vector3((TileEntity)projector) final Vector3 translation = projector.getTranslation();
.add(projector.getTranslation()) for (int radius = projector.getModuleCount(
.distanceTo(position) < ModularForceFieldSystem.itemModuleScale, new int[0]
projector.getModuleCount(ModularForceFieldSystem.itemModuleScale, ),
new int[0]); x = -radius;
} x <= radius;
++x) {
for (int z = -radius; z <= radius; ++z) {
for (int y = -radius; y <= radius; ++y) {
final Vector3 position = new Vector3(x, y, z);
if (this.isInField(
projector,
Vector3.add(position, new Vector3((TileEntity) projector))
.add(translation)
)) {
fieldBlocks.add(position);
}
}
}
}
return fieldBlocks;
}
@SideOnly(Side.CLIENT) @Override
@Override public boolean isInField(final IFieldInteraction projector, final Vector3 position) {
public void render(final IProjector projector, final double x1, return new Vector3((TileEntity) projector)
final double y1, final double z1, final float f, .add(projector.getTranslation())
final long ticks) { .distanceTo(position)
final float scale = 0.15f; < projector.getModuleCount(
GL11.glScalef(scale, scale, scale); ModularForceFieldSystem.itemModuleScale, new int[0]
final float radius = 1.5f; );
for (int steps = (int)Math.ceil(3.141592653589793 / }
Math.atan(1.0 / radius / 2.0)),
@SideOnly(Side.CLIENT)
@Override
public void render(
final IProjector projector,
final double x1,
final double y1,
final double z1,
final float f,
final long ticks
) {
final float scale = 0.15f;
GL11.glScalef(scale, scale, scale);
final float radius = 1.5f;
for (int steps
= (int) Math.ceil(3.141592653589793 / Math.atan(1.0 / radius / 2.0)),
phi_n = 0; phi_n = 0;
phi_n < 2 * steps; ++phi_n) { phi_n < 2 * steps;
for (int theta_n = 0; theta_n < steps; ++theta_n) { ++phi_n) {
final double phi = 6.283185307179586 / steps * phi_n; for (int theta_n = 0; theta_n < steps; ++theta_n) {
final double theta = 3.141592653589793 / steps * theta_n; final double phi = 6.283185307179586 / steps * phi_n;
final Vector3 vector = final double theta = 3.141592653589793 / steps * theta_n;
new Vector3(Math.sin(theta) * Math.cos(phi), Math.cos(theta), final Vector3 vector = new Vector3(
Math.sin(theta) * Math.sin(phi)); Math.sin(theta) * Math.cos(phi),
vector.multiply(radius); Math.cos(theta),
GL11.glTranslated(vector.x, vector.y, vector.z); Math.sin(theta) * Math.sin(phi)
ModelCube.INSTNACE.render(); );
GL11.glTranslated(-vector.x, -vector.y, -vector.z); vector.multiply(radius);
} GL11.glTranslated(vector.x, vector.y, vector.z);
ModelCube.INSTNACE.render();
GL11.glTranslated(-vector.x, -vector.y, -vector.z);
}
}
} }
}
} }

View File

@ -1,34 +1,41 @@
package mffs.item.mode; package mffs.item.mode;
import java.util.HashSet;
import java.util.Set;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import mffs.render.model.ModelPlane; import mffs.api.IFieldInteraction;
import org.lwjgl.opengl.GL11;
import mffs.api.IProjector; import mffs.api.IProjector;
import universalelectricity.core.vector.Vector3; import mffs.render.model.ModelPlane;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity; import org.lwjgl.opengl.GL11;
import java.util.HashSet; import universalelectricity.core.vector.Vector3;
import java.util.Set;
import mffs.api.IFieldInteraction;
public class ItemModeTube extends ItemModeCube public class ItemModeTube extends ItemModeCube {
{
public ItemModeTube() { public ItemModeTube() {
super("modeTube"); super("modeTube");
} }
@Override @Override
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) { public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>(); final Set<Vector3> fieldBlocks = new HashSet<>();
final ForgeDirection direction = projector.getDirection((IBlockAccess)((TileEntity)projector).getWorldObj(), ((TileEntity)projector).xCoord, ((TileEntity)projector).yCoord, ((TileEntity)projector).zCoord); final ForgeDirection direction = projector.getDirection(
(IBlockAccess) ((TileEntity) projector).getWorldObj(),
((TileEntity) projector).xCoord,
((TileEntity) projector).yCoord,
((TileEntity) projector).zCoord
);
final Vector3 posScale = projector.getPositiveScale(); final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale(); final Vector3 negScale = projector.getNegativeScale();
for (float x = (float)(-negScale.intX()); x <= posScale.intX(); x += 0.5f) { for (float x = (float) (-negScale.intX()); x <= posScale.intX(); x += 0.5f) {
for (float z = (float)(-negScale.intZ()); z <= posScale.intZ(); z += 0.5f) { for (float z = (float) (-negScale.intZ()); z <= posScale.intZ(); z += 0.5f) {
for (float y = (float)(-negScale.intY()); y <= posScale.intY(); y += 0.5f) { for (float y = (float) (-negScale.intY()); y <= posScale.intY();
if (direction != ForgeDirection.UP && direction != ForgeDirection.DOWN && (y == -negScale.intY() || y == posScale.intY())) { y += 0.5f) {
if (direction != ForgeDirection.UP && direction != ForgeDirection.DOWN
&& (y == -negScale.intY() || y == posScale.intY())) {
fieldBlocks.add(new Vector3(x, y, z)); fieldBlocks.add(new Vector3(x, y, z));
} }
else if (direction != ForgeDirection.NORTH && direction != ForgeDirection.SOUTH && (z == -negScale.intZ() || z == posScale.intZ())) { else if (direction != ForgeDirection.NORTH && direction != ForgeDirection.SOUTH && (z == -negScale.intZ() || z == posScale.intZ())) {
@ -42,10 +49,17 @@ public class ItemModeTube extends ItemModeCube
} }
return fieldBlocks; return fieldBlocks;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void render(final IProjector projector, final double x, final double y, final double z, final float f, final long ticks) { public void render(
final IProjector projector,
final double x,
final double y,
final double z,
final float f,
final long ticks
) {
GL11.glScalef(0.5f, 0.5f, 0.5f); GL11.glScalef(0.5f, 0.5f, 0.5f);
GL11.glTranslatef(-0.5f, 0.0f, 0.0f); GL11.glTranslatef(-0.5f, 0.0f, 0.0f);
ModelPlane.INSTNACE.render(); ModelPlane.INSTNACE.render();

View File

@ -2,6 +2,7 @@ package mffs.item.module;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.api.modules.IModule; import mffs.api.modules.IModule;
@ -13,56 +14,62 @@ import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModule extends ItemBase implements IModule { public class ItemModule extends ItemBase implements IModule {
private float fortronCost; private float fortronCost;
public ItemModule(final String name) { public ItemModule(final String name) {
super(name); super(name);
this.fortronCost = 0.5f; this.fortronCost = 0.5f;
} }
@Override @Override
public void addInformation(final ItemStack itemStack, public void addInformation(
final EntityPlayer player, final List info, final ItemStack itemStack,
final boolean b) { final EntityPlayer player,
info.add("Fortron: " + this.getFortronCost(1.0f)); final List info,
super.addInformation(itemStack, player, info, b); final boolean b
} ) {
info.add("Fortron: " + this.getFortronCost(1.0f));
super.addInformation(itemStack, player, info, b);
}
@Override @Override
public void onCalculate(final IFieldInteraction projector, public void
final Set<Vector3> position) {} onCalculate(final IFieldInteraction projector, final Set<Vector3> position) {}
@Override @Override
public boolean onProject(final IProjector projector, public boolean onProject(final IProjector projector, final Set<Vector3> fields) {
final Set<Vector3> fields) { return false;
return false; }
}
@Override @Override
public int onProject(final IProjector projector, final Vector3 position) { public int onProject(final IProjector projector, final Vector3 position) {
return 0; return 0;
} }
@Override @Override
public boolean onCollideWithForceField(final World world, final int x, public boolean onCollideWithForceField(
final int y, final int z, final World world,
final Entity entity, final int x,
final ItemStack moduleStack) { final int y,
return false; final int z,
} final Entity entity,
final ItemStack moduleStack
) {
return false;
}
public ItemModule setCost(final float cost) { public ItemModule setCost(final float cost) {
this.fortronCost = cost; this.fortronCost = cost;
return this; return this;
} }
public ItemModule setMaxStackSize(final int par1) { public ItemModule setMaxStackSize(final int par1) {
super.setMaxStackSize(par1); super.setMaxStackSize(par1);
return this; return this;
} }
@Override @Override
public float getFortronCost(final float amplifier) { public float getFortronCost(final float amplifier) {
return this.fortronCost * amplifier; return this.fortronCost * amplifier;
} }
} }

View File

@ -1,21 +1,24 @@
package mffs.item.module.interdiction; package mffs.item.module.interdiction;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.security.IInterdictionMatrix;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.INpc; import net.minecraft.entity.INpc;
import net.minecraft.entity.monster.IMob; import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.EntityLivingBase;
import mffs.api.security.IInterdictionMatrix;
public class ItemModuleAntiFriendly extends ItemModuleInterdictionMatrix public class ItemModuleAntiFriendly extends ItemModuleInterdictionMatrix {
{
public ItemModuleAntiFriendly() { public ItemModuleAntiFriendly() {
super("moduleAntiFriendly"); super("moduleAntiFriendly");
} }
@Override @Override
public boolean onDefend(final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving) { public boolean onDefend(
final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving
) {
if (!(entityLiving instanceof IMob) || entityLiving instanceof INpc) { if (!(entityLiving instanceof IMob) || entityLiving instanceof INpc) {
entityLiving.attackEntityFrom(ModularForceFieldSystem.damagefieldShock, Integer.MAX_VALUE); entityLiving.attackEntityFrom(
ModularForceFieldSystem.damagefieldShock, Integer.MAX_VALUE
);
} }
return false; return false;
} }

View File

@ -1,19 +1,20 @@
package mffs.item.module.interdiction; package mffs.item.module.interdiction;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.security.IInterdictionMatrix;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.INpc; import net.minecraft.entity.INpc;
import net.minecraft.entity.monster.IMob; import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.EntityLivingBase;
import mffs.api.security.IInterdictionMatrix;
public class ItemModuleAntiHostile extends ItemModuleInterdictionMatrix public class ItemModuleAntiHostile extends ItemModuleInterdictionMatrix {
{
public ItemModuleAntiHostile() { public ItemModuleAntiHostile() {
super("moduleAntiHostile"); super("moduleAntiHostile");
} }
@Override @Override
public boolean onDefend(final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving) { public boolean onDefend(
final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving
) {
if (entityLiving instanceof IMob && !(entityLiving instanceof INpc)) { if (entityLiving instanceof IMob && !(entityLiving instanceof INpc)) {
entityLiving.attackEntityFrom(ModularForceFieldSystem.damagefieldShock, 20); entityLiving.attackEntityFrom(ModularForceFieldSystem.damagefieldShock, 20);
} }

View File

@ -9,31 +9,37 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
public class ItemModuleAntiPersonnel extends ItemModuleInterdictionMatrix { public class ItemModuleAntiPersonnel extends ItemModuleInterdictionMatrix {
public ItemModuleAntiPersonnel() { super("moduleAntiPersonnel"); } public ItemModuleAntiPersonnel() {
super("moduleAntiPersonnel");
@Override }
public boolean onDefend(final IInterdictionMatrix interdictionMatrix,
final EntityLivingBase entityLiving) { @Override
final boolean hasPermission = false; public boolean onDefend(
if (!hasPermission && entityLiving instanceof EntityPlayer) { final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving
final EntityPlayer player = (EntityPlayer)entityLiving; ) {
if (!player.capabilities.isCreativeMode && final boolean hasPermission = false;
!player.isEntityInvulnerable()) { if (!hasPermission && entityLiving instanceof EntityPlayer) {
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { final EntityPlayer player = (EntityPlayer) entityLiving;
if (player.inventory.getStackInSlot(i) != null) { if (!player.capabilities.isCreativeMode && !player.isEntityInvulnerable()) {
interdictionMatrix.mergeIntoInventory( for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
player.inventory.getStackInSlot(i)); if (player.inventory.getStackInSlot(i) != null) {
player.inventory.setInventorySlotContents(i, (ItemStack)null); interdictionMatrix.mergeIntoInventory(
} player.inventory.getStackInSlot(i)
} );
player.attackEntityFrom(ModularForceFieldSystem.damagefieldShock, player.inventory.setInventorySlotContents(i, (ItemStack) null);
Integer.MAX_VALUE); }
interdictionMatrix.requestFortron(Settings.INTERDICTION_MURDER_ENERGY, }
false); player.attackEntityFrom(
player.addChatMessage(new ChatComponentText( ModularForceFieldSystem.damagefieldShock, Integer.MAX_VALUE
"[" + interdictionMatrix.getInventoryName() + "] Fairwell.")); );
} interdictionMatrix.requestFortron(
Settings.INTERDICTION_MURDER_ENERGY, false
);
player.addChatMessage(new ChatComponentText(
"[" + interdictionMatrix.getInventoryName() + "] Fairwell."
));
}
}
return false;
} }
return false;
}
} }

View File

@ -1,6 +1,7 @@
package mffs.item.module.interdiction; package mffs.item.module.interdiction;
import java.util.Set; import java.util.Set;
import mffs.api.security.IBiometricIdentifier; import mffs.api.security.IBiometricIdentifier;
import mffs.api.security.IInterdictionMatrix; import mffs.api.security.IInterdictionMatrix;
import mffs.api.security.Permission; import mffs.api.security.Permission;
@ -11,67 +12,72 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
public class ItemModuleConfiscate extends ItemModuleInterdictionMatrix { public class ItemModuleConfiscate extends ItemModuleInterdictionMatrix {
public ItemModuleConfiscate() { super("moduleConfiscate"); } public ItemModuleConfiscate() {
super("moduleConfiscate");
}
@Override @Override
public boolean onDefend(final IInterdictionMatrix interdictionMatrix, public boolean onDefend(
final EntityLivingBase entityLiving) { final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving
if (entityLiving instanceof EntityPlayer) { ) {
final EntityPlayer player = (EntityPlayer)entityLiving; if (entityLiving instanceof EntityPlayer) {
final IBiometricIdentifier biometricIdentifier = final EntityPlayer player = (EntityPlayer) entityLiving;
interdictionMatrix.getBiometricIdentifier(); final IBiometricIdentifier biometricIdentifier
if (biometricIdentifier != null && = interdictionMatrix.getBiometricIdentifier();
biometricIdentifier.isAccessGranted( if (biometricIdentifier != null
player.getDisplayName(), && biometricIdentifier.isAccessGranted(
Permission.DEFENSE_STATION_CONFISCATION)) { player.getDisplayName(), Permission.DEFENSE_STATION_CONFISCATION
return false; )) {
} return false;
}
final Set<ItemStack> controlledStacks =
interdictionMatrix.getFilteredItems();
int confiscationCount = 0;
IInventory inventory = null;
if (entityLiving instanceof EntityPlayer) {
final IBiometricIdentifier biometricIdentifier2 =
interdictionMatrix.getBiometricIdentifier();
if (biometricIdentifier2 != null &&
biometricIdentifier2.isAccessGranted(
((EntityPlayer)entityLiving).getDisplayName(),
Permission.BYPASS_INTERDICTION_MATRIX)) {
return false;
}
final EntityPlayer player2 = (EntityPlayer)entityLiving;
inventory = (IInventory)player2.inventory;
} else if (entityLiving instanceof IInventory) {
inventory = (IInventory)entityLiving;
}
if (inventory != null) {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
final ItemStack checkStack = inventory.getStackInSlot(i);
if (checkStack != null) {
boolean stacksMatch = false;
for (final ItemStack itemStack : controlledStacks) {
if (itemStack != null && itemStack.isItemEqual(checkStack)) {
stacksMatch = true;
break;
} }
}
if ((interdictionMatrix.getFilterMode() && stacksMatch) ||
(!interdictionMatrix.getFilterMode() && !stacksMatch)) {
interdictionMatrix.mergeIntoInventory(inventory.getStackInSlot(i));
inventory.setInventorySlotContents(i, (ItemStack)null);
++confiscationCount;
}
} }
} final Set<ItemStack> controlledStacks = interdictionMatrix.getFilteredItems();
if (confiscationCount > 0 && entityLiving instanceof EntityPlayer) { int confiscationCount = 0;
((EntityPlayer)entityLiving) IInventory inventory = null;
.addChatMessage(new ChatComponentText( if (entityLiving instanceof EntityPlayer) {
"[" + interdictionMatrix.getInventoryName() + "] " + final IBiometricIdentifier biometricIdentifier2
confiscationCount + " of your item(s) has been confiscated.")); = interdictionMatrix.getBiometricIdentifier();
} if (biometricIdentifier2 != null
interdictionMatrix.requestFortron(confiscationCount, true); && biometricIdentifier2.isAccessGranted(
((EntityPlayer) entityLiving).getDisplayName(),
Permission.BYPASS_INTERDICTION_MATRIX
)) {
return false;
}
final EntityPlayer player2 = (EntityPlayer) entityLiving;
inventory = (IInventory) player2.inventory;
} else if (entityLiving instanceof IInventory) {
inventory = (IInventory) entityLiving;
}
if (inventory != null) {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
final ItemStack checkStack = inventory.getStackInSlot(i);
if (checkStack != null) {
boolean stacksMatch = false;
for (final ItemStack itemStack : controlledStacks) {
if (itemStack != null && itemStack.isItemEqual(checkStack)) {
stacksMatch = true;
break;
}
}
if ((interdictionMatrix.getFilterMode() && stacksMatch)
|| (!interdictionMatrix.getFilterMode() && !stacksMatch)) {
interdictionMatrix.mergeIntoInventory(inventory.getStackInSlot(i)
);
inventory.setInventorySlotContents(i, (ItemStack) null);
++confiscationCount;
}
}
}
if (confiscationCount > 0 && entityLiving instanceof EntityPlayer) {
((EntityPlayer) entityLiving)
.addChatMessage(new ChatComponentText(
"[" + interdictionMatrix.getInventoryName() + "] "
+ confiscationCount + " of your item(s) has been confiscated."
));
}
interdictionMatrix.requestFortron(confiscationCount, true);
}
return false;
} }
return false;
}
} }

View File

@ -1,6 +1,7 @@
package mffs.item.module.interdiction; package mffs.item.module.interdiction;
import java.util.List; import java.util.List;
import mffs.api.modules.IInterdictionMatrixModule; import mffs.api.modules.IInterdictionMatrixModule;
import mffs.api.security.IInterdictionMatrix; import mffs.api.security.IInterdictionMatrix;
import mffs.item.module.ItemModule; import mffs.item.module.ItemModule;
@ -10,19 +11,25 @@ import net.minecraft.item.ItemStack;
public class ItemModuleInterdictionMatrix public class ItemModuleInterdictionMatrix
extends ItemModule implements IInterdictionMatrixModule { extends ItemModule implements IInterdictionMatrixModule {
public ItemModuleInterdictionMatrix(final String name) { super(name); } public ItemModuleInterdictionMatrix(final String name) {
super(name);
}
@Override @Override
public void addInformation(final ItemStack itemStack, public void addInformation(
final EntityPlayer player, final List info, final ItemStack itemStack,
final boolean b) { final EntityPlayer player,
info.add("§4Interdiction Matrix"); final List info,
super.addInformation(itemStack, player, info, b); final boolean b
} ) {
info.add("§4Interdiction Matrix");
super.addInformation(itemStack, player, info, b);
}
@Override @Override
public boolean onDefend(final IInterdictionMatrix interdictionMatrix, public boolean onDefend(
final EntityLivingBase entityLiving) { final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving
return false; ) {
} return false;
}
} }

View File

@ -1,21 +1,26 @@
package mffs.item.module.interdiction; package mffs.item.module.interdiction;
import mffs.api.security.IInterdictionMatrix;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.entity.EntityLivingBase;
import mffs.api.security.IInterdictionMatrix;
public class ItemModuleWarn extends ItemModuleInterdictionMatrix public class ItemModuleWarn extends ItemModuleInterdictionMatrix {
{
public ItemModuleWarn() { public ItemModuleWarn() {
super("moduleWarn"); super("moduleWarn");
} }
@Override @Override
public boolean onDefend(final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving) { public boolean onDefend(
final IInterdictionMatrix interdictionMatrix, final EntityLivingBase entityLiving
) {
final boolean hasPermission = false; final boolean hasPermission = false;
if (!hasPermission && entityLiving instanceof EntityPlayer) { if (!hasPermission && entityLiving instanceof EntityPlayer) {
((EntityPlayer)entityLiving).addChatMessage(new ChatComponentText("[" + interdictionMatrix.getInventoryName() + "] Leave this zone immediately. You have no right to enter.")); ((EntityPlayer) entityLiving)
.addChatMessage(new ChatComponentText(
"[" + interdictionMatrix.getInventoryName()
+ "] Leave this zone immediately. You have no right to enter."
));
} }
return false; return false;
} }

View File

@ -1,7 +1,5 @@
package mffs.item.module.projector; package mffs.item.module.projector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
@ -9,6 +7,9 @@ import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.Settings; import mffs.Settings;
@ -34,306 +35,340 @@ import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModeCustom extends ItemMode implements ICache { public class ItemModeCustom extends ItemMode implements ICache {
private final HashMap<String, Object> cache; private final HashMap<String, Object> cache;
public ItemModeCustom() { public ItemModeCustom() {
super("modeCustom"); super("modeCustom");
this.cache = new HashMap<>(); this.cache = new HashMap<>();
}
@Override
public void addInformation(final ItemStack itemStack,
final EntityPlayer par2EntityPlayer,
final List list, final boolean par4) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
list.add("Mode: " + (nbt.getBoolean("mode") ? "Additive" : "Substraction"));
final Vector3 point1 = Vector3.readFromNBT(nbt.getCompoundTag("point1"));
list.add("Point 1: " + point1.intX() + ", " + point1.intY() + ", " +
point1.intZ());
final Vector3 point2 = Vector3.readFromNBT(nbt.getCompoundTag("point2"));
list.add("Point 2: " + point2.intX() + ", " + point2.intY() + ", " +
point2.intZ());
final int modeID = nbt.getInteger("id");
if (modeID > 0) {
list.add("Mode ID: " + modeID);
final int fieldSize = nbt.getInteger("fieldSize");
if (fieldSize > 0) {
list.add("Field size: " + fieldSize);
} else {
list.add("Field not saved.");
}
} }
if (GuiScreen.isShiftKeyDown()) {
super.addInformation(itemStack, par2EntityPlayer, list, par4);
} else {
list.add("Hold shift for more...");
}
}
public ItemStack onItemRightClick(final ItemStack itemStack, @Override
final World world, public void addInformation(
final EntityPlayer entityPlayer) { final ItemStack itemStack,
if (!world.isRemote) { final EntityPlayer par2EntityPlayer,
if (entityPlayer.isSneaking()) { final List list,
final boolean par4
) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
if (nbt != null) { list.add("Mode: " + (nbt.getBoolean("mode") ? "Additive" : "Substraction"));
final Vector3 point1 = final Vector3 point1 = Vector3.readFromNBT(nbt.getCompoundTag("point1"));
Vector3.readFromNBT(nbt.getCompoundTag("point1")); list.add(
final Vector3 point2 = "Point 1: " + point1.intX() + ", " + point1.intY() + ", " + point1.intZ()
Vector3.readFromNBT(nbt.getCompoundTag("point2")); );
if (nbt.hasKey("point1") && nbt.hasKey("point2") && final Vector3 point2 = Vector3.readFromNBT(nbt.getCompoundTag("point2"));
!point1.equals(point2) && list.add(
point1.distanceTo(point2) < Settings.MAX_FORCE_FIELD_SCALE) { "Point 2: " + point2.intX() + ", " + point2.intY() + ", " + point2.intZ()
nbt.removeTag("point1"); );
nbt.removeTag("point2"); final int modeID = nbt.getInteger("id");
Vector3 midPoint = new Vector3(); if (modeID > 0) {
midPoint.x = (point1.x + point2.x) / 2.0; list.add("Mode ID: " + modeID);
midPoint.y = (point1.y + point2.y) / 2.0; final int fieldSize = nbt.getInteger("fieldSize");
midPoint.z = (point1.z + point2.z) / 2.0; if (fieldSize > 0) {
midPoint = midPoint.floor(); list.add("Field size: " + fieldSize);
point1.subtract(midPoint);
point2.subtract(midPoint);
final Vector3 minPoint = new Vector3(Math.min(point1.x, point2.x),
Math.min(point1.y, point2.y),
Math.min(point1.z, point2.z));
final Vector3 maxPoint = new Vector3(Math.max(point1.x, point2.x),
Math.max(point1.y, point2.y),
Math.max(point1.z, point2.z));
File saveFile = Paths
.get(this.getSaveDirectory().getPath(),
"custom_mode_" + this.getModeID(itemStack))
.toFile();
// TODO: WTF happened to NBTFileLoader?!
NBTTagCompound saveNBT = null;
try {
saveNBT = CompressedStreamTools.read(saveFile);
} catch (IOException e1) {
throw new UncheckedIOException(e1);
}
// NBTTagCompound saveNBT = NBTFileLoader.loadData(
// this.getSaveDirectory(),
// "custom_mode_" + this.getModeID(itemStack));
if (saveNBT == null) {
saveNBT = new NBTTagCompound();
}
NBTTagList list;
if (saveNBT.hasKey("fieldPoints")) {
list = (NBTTagList)saveNBT.getTag("fieldPoints");
} else { } else {
list = new NBTTagList(); list.add("Field not saved.");
} }
for (int x = minPoint.intX(); x <= maxPoint.intX(); ++x) {
for (int y = minPoint.intY(); y <= maxPoint.intY(); ++y) {
for (int z = minPoint.intZ(); z <= maxPoint.intZ(); ++z) {
final Vector3 position = new Vector3(x, y, z);
final Vector3 targetCheck = Vector3.add(midPoint, position);
final Block blockID = targetCheck.getBlock(world);
if (blockID != Blocks.air) {
if (nbt.getBoolean("mode")) {
final NBTTagCompound vectorTag = new NBTTagCompound();
position.writeToNBT(vectorTag);
vectorTag.setInteger("blockID",
Block.getIdFromBlock(blockID));
vectorTag.setInteger(
"blockMetadata",
targetCheck.getBlockMetadata((IBlockAccess)world));
list.appendTag((NBTBase)vectorTag);
} else {
for (int i = 0; i < list.tagCount(); ++i) {
final Vector3 vector = Vector3.readFromNBT(
(NBTTagCompound)list.getCompoundTagAt(i));
if (vector.equals(position)) {
list.removeTag(i);
}
}
}
}
}
}
}
saveNBT.setTag("fieldPoints", (NBTBase)list);
nbt.setInteger("fieldSize", list.tagCount());
try {
CompressedStreamTools.write(saveNBT, saveFile);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
// NBTFileLoader.saveData(this.getSaveDirectory(),
// "custom_mode_" + this.getModeID(itemStack),
// saveNBT);
this.clearCache();
entityPlayer.addChatMessage(
new ChatComponentText("Field structure saved."));
}
} }
} else { if (GuiScreen.isShiftKeyDown()) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); super.addInformation(itemStack, par2EntityPlayer, list, par4);
if (nbt != null) {
nbt.setBoolean("mode", !nbt.getBoolean("mode"));
entityPlayer.addChatMessage(new ChatComponentText(
"Changed selection mode to " +
(nbt.getBoolean("mode") ? "additive" : "substraction")));
}
}
}
return itemStack;
}
public boolean onItemUse(final ItemStack itemStack,
final EntityPlayer entityPlayer, final World world,
final int x, final int y, final int z,
final int par7, final float par8, final float par9,
final float par10) {
if (!world.isRemote) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
if (nbt != null) {
final Vector3 point1 =
Vector3.readFromNBT(nbt.getCompoundTag("point1"));
if (!nbt.hasKey("point1") ||
point1.equals(new Vector3(0.0, 0.0, 0.0))) {
nbt.setTag("point1",
new Vector3(x, y, z).writeToNBT(new NBTTagCompound()));
entityPlayer.addChatMessage(new ChatComponentText(
"Set point 1: " + x + ", " + y + ", " + z + "."));
} else { } else {
nbt.setTag("point2", list.add("Hold shift for more...");
new Vector3(x, y, z).writeToNBT(new NBTTagCompound()));
entityPlayer.addChatMessage(new ChatComponentText(
"Set point 2: " + x + ", " + y + ", " + z + "."));
} }
}
} }
return true;
}
public int getModeID(final ItemStack itemStack) { public ItemStack onItemRightClick(
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack); final ItemStack itemStack, final World world, final EntityPlayer entityPlayer
int id = nbt.getInteger("id"); ) {
if (id <= 0) { if (!world.isRemote) {
nbt.setInteger("id", this.getNextAvaliableID()); if (entityPlayer.isSneaking()) {
id = nbt.getInteger("id"); final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
} if (nbt != null) {
return id; final Vector3 point1
} = Vector3.readFromNBT(nbt.getCompoundTag("point1"));
final Vector3 point2
= Vector3.readFromNBT(nbt.getCompoundTag("point2"));
if (nbt.hasKey("point1") && nbt.hasKey("point2")
&& !point1.equals(point2)
&& point1.distanceTo(point2) < Settings.MAX_FORCE_FIELD_SCALE) {
nbt.removeTag("point1");
nbt.removeTag("point2");
Vector3 midPoint = new Vector3();
midPoint.x = (point1.x + point2.x) / 2.0;
midPoint.y = (point1.y + point2.y) / 2.0;
midPoint.z = (point1.z + point2.z) / 2.0;
midPoint = midPoint.floor();
point1.subtract(midPoint);
point2.subtract(midPoint);
final Vector3 minPoint = new Vector3(
Math.min(point1.x, point2.x),
Math.min(point1.y, point2.y),
Math.min(point1.z, point2.z)
);
final Vector3 maxPoint = new Vector3(
Math.max(point1.x, point2.x),
Math.max(point1.y, point2.y),
Math.max(point1.z, point2.z)
);
File saveFile = Paths
.get(
this.getSaveDirectory().getPath(),
"custom_mode_" + this.getModeID(itemStack)
)
.toFile();
// TODO: WTF happened to NBTFileLoader?!
NBTTagCompound saveNBT = null;
try {
saveNBT = CompressedStreamTools.read(saveFile);
} catch (IOException e1) {
throw new UncheckedIOException(e1);
}
public int getNextAvaliableID() { // NBTTagCompound saveNBT = NBTFileLoader.loadData(
int i = 1; // this.getSaveDirectory(),
i += this.getSaveDirectory().list().length; // "custom_mode_" + this.getModeID(itemStack));
return i;
}
public File getSaveDirectory() { if (saveNBT == null) {
final File saveDirectory = saveNBT = new NBTTagCompound();
// TODO: might be wrong path? }
Paths.get(MinecraftServer.getServer().getFolderName(), "saves") NBTTagList list;
.toFile(); if (saveNBT.hasKey("fieldPoints")) {
if (!saveDirectory.exists()) { list = (NBTTagList) saveNBT.getTag("fieldPoints");
saveDirectory.mkdir(); } else {
} list = new NBTTagList();
final File file = new File(saveDirectory, "mffs"); }
if (!file.exists()) { for (int x = minPoint.intX(); x <= maxPoint.intX(); ++x) {
file.mkdir(); for (int y = minPoint.intY(); y <= maxPoint.intY(); ++y) {
} for (int z = minPoint.intZ(); z <= maxPoint.intZ(); ++z) {
return file; final Vector3 position = new Vector3(x, y, z);
} final Vector3 targetCheck
= Vector3.add(midPoint, position);
final Block blockID = targetCheck.getBlock(world);
if (blockID != Blocks.air) {
if (nbt.getBoolean("mode")) {
final NBTTagCompound vectorTag
= new NBTTagCompound();
position.writeToNBT(vectorTag);
vectorTag.setInteger(
"blockID", Block.getIdFromBlock(blockID)
);
vectorTag.setInteger(
"blockMetadata",
targetCheck.getBlockMetadata((IBlockAccess
) world)
);
list.appendTag((NBTBase) vectorTag);
} else {
for (int i = 0; i < list.tagCount(); ++i) {
final Vector3 vector
= Vector3.readFromNBT((NBTTagCompound
) list.getCompoundTagAt(i));
if (vector.equals(position)) {
list.removeTag(i);
}
}
}
}
}
}
}
saveNBT.setTag("fieldPoints", (NBTBase) list);
nbt.setInteger("fieldSize", list.tagCount());
public Set<Vector3> getFieldBlocks(final IFieldInteraction projector, try {
final ItemStack itemStack) { CompressedStreamTools.write(saveNBT, saveFile);
return this.getFieldBlockMap(projector, itemStack).keySet(); } catch (IOException e) {
} throw new UncheckedIOException(e);
}
public HashMap<Vector3, int[]> // NBTFileLoader.saveData(this.getSaveDirectory(),
getFieldBlockMap(final IFieldInteraction projector, // "custom_mode_" + this.getModeID(itemStack),
final ItemStack itemStack) { // saveNBT);
final String cacheID = "itemStack_" + itemStack.hashCode(); this.clearCache();
if (Settings.USE_CACHE && this.cache.containsKey(cacheID) && entityPlayer.addChatMessage(
this.cache.get(cacheID) instanceof HashMap) { new ChatComponentText("Field structure saved.")
return (HashMap<Vector3, int[]>)this.cache.get(cacheID); );
} }
final float scale = }
projector.getModuleCount(ModularForceFieldSystem.itemModuleScale, } else {
new int[0]) / final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
3.0f; if (nbt != null) {
final HashMap<Vector3, int[]> fieldBlocks = new HashMap<>(); nbt.setBoolean("mode", !nbt.getBoolean("mode"));
if (this.getSaveDirectory() != null) { entityPlayer.addChatMessage(new ChatComponentText(
NBTTagCompound nbt = null; "Changed selection mode to "
try { + (nbt.getBoolean("mode") ? "additive" : "substraction")
nbt = CompressedStreamTools.read( ));
Paths }
.get(this.getSaveDirectory().getPath(), }
"custom_mode_" + this.getModeID(itemStack))
.toFile());
} catch (IOException e) {
e.printStackTrace();
}
// final NBTTagCompound nbt = NBTFileLoader.loadData(
// this.getSaveDirectory(), "custom_mode_" + this.getModeID(itemStack));
if (nbt != null) {
final NBTTagList nbtTagList = nbt.getTagList("fieldPoints", 10);
for (int i = 0; i < nbtTagList.tagCount(); ++i) {
final NBTTagCompound vectorTag =
(NBTTagCompound)nbtTagList.getCompoundTagAt(i);
final Vector3 position = Vector3.readFromNBT(vectorTag);
if (scale > 0.0f) {
position.multiply(scale);
}
final int[] blockInfo = {vectorTag.getInteger("blockID"),
vectorTag.getInteger("blockMetadata")};
if (position != null) {
fieldBlocks.put(position, blockInfo);
}
} }
} return itemStack;
if (Settings.USE_CACHE) {
this.cache.put(cacheID, fieldBlocks);
}
} }
return fieldBlocks;
}
@Override public boolean onItemUse(
public Object getCache(final String cacheID) { final ItemStack itemStack,
return this.cache.get(cacheID); final EntityPlayer entityPlayer,
} final World world,
final int x,
final int y,
final int z,
final int par7,
final float par8,
final float par9,
final float par10
) {
if (!world.isRemote) {
final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
if (nbt != null) {
final Vector3 point1 = Vector3.readFromNBT(nbt.getCompoundTag("point1"));
if (!nbt.hasKey("point1") || point1.equals(new Vector3(0.0, 0.0, 0.0))) {
nbt.setTag(
"point1", new Vector3(x, y, z).writeToNBT(new NBTTagCompound())
);
entityPlayer.addChatMessage(new ChatComponentText(
"Set point 1: " + x + ", " + y + ", " + z + "."
));
} else {
nbt.setTag(
"point2", new Vector3(x, y, z).writeToNBT(new NBTTagCompound())
);
entityPlayer.addChatMessage(new ChatComponentText(
"Set point 2: " + x + ", " + y + ", " + z + "."
));
}
}
}
return true;
}
@Override public int getModeID(final ItemStack itemStack) {
public void clearCache(final String cacheID) { final NBTTagCompound nbt = MFFSHelper.getNBTTagCompound(itemStack);
this.cache.remove(cacheID); int id = nbt.getInteger("id");
} if (id <= 0) {
nbt.setInteger("id", this.getNextAvaliableID());
id = nbt.getInteger("id");
}
return id;
}
@Override public int getNextAvaliableID() {
public void clearCache() { int i = 1;
this.cache.clear(); i += this.getSaveDirectory().list().length;
} return i;
}
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) { public File getSaveDirectory() {
return this.getFieldBlocks(projector, projector.getModeStack()); final File saveDirectory =
} // TODO: might be wrong path?
Paths.get(MinecraftServer.getServer().getFolderName(), "saves").toFile();
if (!saveDirectory.exists()) {
saveDirectory.mkdir();
}
final File file = new File(saveDirectory, "mffs");
if (!file.exists()) {
file.mkdir();
}
return file;
}
@Override public Set<Vector3>
public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) { getFieldBlocks(final IFieldInteraction projector, final ItemStack itemStack) {
return this.getExteriorPoints(projector); return this.getFieldBlockMap(projector, itemStack).keySet();
} }
@Override public HashMap<Vector3, int[]>
public boolean isInField(final IFieldInteraction projector, getFieldBlockMap(final IFieldInteraction projector, final ItemStack itemStack) {
final Vector3 position) { final String cacheID = "itemStack_" + itemStack.hashCode();
return false; if (Settings.USE_CACHE && this.cache.containsKey(cacheID)
} && this.cache.get(cacheID) instanceof HashMap) {
return (HashMap<Vector3, int[]>) this.cache.get(cacheID);
}
final float scale = projector.getModuleCount(
ModularForceFieldSystem.itemModuleScale, new int[0]
)
/ 3.0f;
final HashMap<Vector3, int[]> fieldBlocks = new HashMap<>();
if (this.getSaveDirectory() != null) {
NBTTagCompound nbt = null;
try {
nbt = CompressedStreamTools.read(
Paths
.get(
this.getSaveDirectory().getPath(),
"custom_mode_" + this.getModeID(itemStack)
)
.toFile()
);
} catch (IOException e) {
e.printStackTrace();
}
// final NBTTagCompound nbt = NBTFileLoader.loadData(
// this.getSaveDirectory(), "custom_mode_" + this.getModeID(itemStack));
if (nbt != null) {
final NBTTagList nbtTagList = nbt.getTagList("fieldPoints", 10);
for (int i = 0; i < nbtTagList.tagCount(); ++i) {
final NBTTagCompound vectorTag
= (NBTTagCompound) nbtTagList.getCompoundTagAt(i);
final Vector3 position = Vector3.readFromNBT(vectorTag);
if (scale > 0.0f) {
position.multiply(scale);
}
final int[] blockInfo = { vectorTag.getInteger("blockID"),
vectorTag.getInteger("blockMetadata") };
if (position != null) {
fieldBlocks.put(position, blockInfo);
}
}
}
if (Settings.USE_CACHE) {
this.cache.put(cacheID, fieldBlocks);
}
}
return fieldBlocks;
}
@SideOnly(Side.CLIENT) @Override
@Override public Object getCache(final String cacheID) {
public void render(final IProjector projector, final double x, final double y, return this.cache.get(cacheID);
final double z, final float f, final long ticks) { }
final IProjectorMode[] modes = {ModularForceFieldSystem.itemModeCube,
ModularForceFieldSystem.itemModeSphere, @Override
ModularForceFieldSystem.itemModeTube, public void clearCache(final String cacheID) {
ModularForceFieldSystem.itemModePyramid}; this.cache.remove(cacheID);
modes[((TileEntity)projector).getWorldObj().rand.nextInt(modes.length - 1)] }
.render(projector, x, y, z, f, ticks);
} @Override
public void clearCache() {
this.cache.clear();
}
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
return this.getFieldBlocks(projector, projector.getModeStack());
}
@Override
public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) {
return this.getExteriorPoints(projector);
}
@Override
public boolean isInField(final IFieldInteraction projector, final Vector3 position) {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public void render(
final IProjector projector,
final double x,
final double y,
final double z,
final float f,
final long ticks
) {
final IProjectorMode[] modes = { ModularForceFieldSystem.itemModeCube,
ModularForceFieldSystem.itemModeSphere,
ModularForceFieldSystem.itemModeTube,
ModularForceFieldSystem.itemModePyramid };
modes[((TileEntity) projector).getWorldObj().rand.nextInt(modes.length - 1)]
.render(projector, x, y, z, f, ticks);
}
} }

View File

@ -1,10 +1,11 @@
package mffs.item.module.projector; package mffs.item.module.projector;
import java.util.HashSet;
import java.util.Set;
import calclavia.lib.CalculationHelper; import calclavia.lib.CalculationHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashSet;
import java.util.Set;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.item.mode.ItemMode; import mffs.item.mode.ItemMode;
@ -14,109 +15,112 @@ import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModeCylinder extends ItemMode { public class ItemModeCylinder extends ItemMode {
public ItemModeCylinder() {
public ItemModeCylinder() { super("modeCylinder"); } super("modeCylinder");
@Override
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale();
final int radius = (posScale.intX() + negScale.intX() + posScale.intZ() +
negScale.intZ()) /
2;
final int height = posScale.intY() + negScale.intY();
for (float x = (float)(-radius); x <= radius; ++x) {
for (float z = (float)(-radius); z <= radius; ++z) {
for (float y = 0.0f; y < height; ++y) {
if ((y == 0.0f || y == height - 1) &&
x * x + z * z + 0.0f <= radius * radius) {
fieldBlocks.add(new Vector3(x, y, z));
}
if (x * x + z * z + 0.0f <= radius * radius &&
x * x + z * z + 0.0f >= (radius - 1) * (radius - 1)) {
fieldBlocks.add(new Vector3(x, y, z));
}
}
}
} }
return fieldBlocks;
}
@Override @Override
public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) { public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>(); final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 translation = projector.getTranslation(); final Vector3 posScale = projector.getPositiveScale();
final Vector3 posScale = projector.getPositiveScale(); final Vector3 negScale = projector.getNegativeScale();
final Vector3 negScale = projector.getNegativeScale(); final int radius
final int radius = (posScale.intX() + negScale.intX() + posScale.intZ() + = (posScale.intX() + negScale.intX() + posScale.intZ() + negScale.intZ()) / 2;
negScale.intZ()) / final int height = posScale.intY() + negScale.intY();
2; for (float x = (float) (-radius); x <= radius; ++x) {
final int height = posScale.intY() + negScale.intY(); for (float z = (float) (-radius); z <= radius; ++z) {
for (int x = -radius; x <= radius; ++x) { for (float y = 0.0f; y < height; ++y) {
for (int z = -radius; z <= radius; ++z) { if ((y == 0.0f || y == height - 1)
for (int y = 0; y < height; ++y) { && x * x + z * z + 0.0f <= radius * radius) {
final Vector3 position = new Vector3(x, y, z); fieldBlocks.add(new Vector3(x, y, z));
if (this.isInField( }
projector, if (x * x + z * z + 0.0f <= radius * radius
Vector3.add(position, new Vector3((TileEntity)projector)) && x * x + z * z + 0.0f >= (radius - 1) * (radius - 1)) {
.add(translation))) { fieldBlocks.add(new Vector3(x, y, z));
fieldBlocks.add(position); }
} }
} }
} }
} return fieldBlocks;
return fieldBlocks; }
}
@Override
@Override public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) {
public boolean isInField(final IFieldInteraction projector, final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 position) { final Vector3 translation = projector.getTranslation();
final Vector3 posScale = projector.getPositiveScale(); final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale(); final Vector3 negScale = projector.getNegativeScale();
final int radius = (posScale.intX() + negScale.intX() + posScale.intZ() + final int radius
negScale.intZ()) / = (posScale.intX() + negScale.intX() + posScale.intZ() + negScale.intZ()) / 2;
2; final int height = posScale.intY() + negScale.intY();
final Vector3 projectorPos = new Vector3((TileEntity)projector); for (int x = -radius; x <= radius; ++x) {
projectorPos.add(projector.getTranslation()); for (int z = -radius; z <= radius; ++z) {
final Vector3 relativePosition = position.clone().subtract(projectorPos); for (int y = 0; y < height; ++y) {
CalculationHelper.rotateByAngle(relativePosition, final Vector3 position = new Vector3(x, y, z);
-projector.getRotationYaw(), if (this.isInField(
-projector.getRotationPitch()); projector,
return relativePosition.x * relativePosition.x + Vector3.add(position, new Vector3((TileEntity) projector))
relativePosition.z * relativePosition.z + 0.0 <= .add(translation)
radius * radius; )) {
} fieldBlocks.add(position);
}
@SideOnly(Side.CLIENT) }
@Override }
public void render(final IProjector projector, final double x, final double y, }
final double z, final float f, final long ticks) { return fieldBlocks;
final float scale = 0.15f; }
final float detail = 0.5f;
GL11.glScalef(scale, scale, scale); @Override
final float radius = 1.5f; public boolean isInField(final IFieldInteraction projector, final Vector3 position) {
int i = 0; final Vector3 posScale = projector.getPositiveScale();
for (float renderX = -radius; renderX <= radius; renderX += detail) { final Vector3 negScale = projector.getNegativeScale();
for (float renderZ = -radius; renderZ <= radius; renderZ += detail) { final int radius
for (float renderY = -radius; renderY <= radius; renderY += detail) { = (posScale.intX() + negScale.intX() + posScale.intZ() + negScale.intZ()) / 2;
if ((renderX * renderX + renderZ * renderZ + 0.0f <= final Vector3 projectorPos = new Vector3((TileEntity) projector);
radius * radius && projectorPos.add(projector.getTranslation());
renderX * renderX + renderZ * renderZ + 0.0f >= final Vector3 relativePosition = position.clone().subtract(projectorPos);
(radius - 1.0f) * (radius - 1.0f)) || CalculationHelper.rotateByAngle(
((renderY == 0.0f || renderY == radius - 1.0f) && relativePosition, -projector.getRotationYaw(), -projector.getRotationPitch()
renderX * renderX + renderZ * renderZ + 0.0f <= );
radius * radius)) { return relativePosition.x * relativePosition.x
if (i % 2 == 0) { + relativePosition.z * relativePosition.z + 0.0
final Vector3 vector = new Vector3(renderX, renderY, renderZ); <= radius * radius;
GL11.glTranslated(vector.x, vector.y, vector.z); }
ModelCube.INSTNACE.render();
GL11.glTranslated(-vector.x, -vector.y, -vector.z); @SideOnly(Side.CLIENT)
@Override
public void render(
final IProjector projector,
final double x,
final double y,
final double z,
final float f,
final long ticks
) {
final float scale = 0.15f;
final float detail = 0.5f;
GL11.glScalef(scale, scale, scale);
final float radius = 1.5f;
int i = 0;
for (float renderX = -radius; renderX <= radius; renderX += detail) {
for (float renderZ = -radius; renderZ <= radius; renderZ += detail) {
for (float renderY = -radius; renderY <= radius; renderY += detail) {
if ((renderX * renderX + renderZ * renderZ + 0.0f <= radius * radius
&& renderX * renderX + renderZ * renderZ + 0.0f
>= (radius - 1.0f) * (radius - 1.0f))
|| ((renderY == 0.0f || renderY == radius - 1.0f)
&& renderX * renderX + renderZ * renderZ + 0.0f
<= radius * radius)) {
if (i % 2 == 0) {
final Vector3 vector = new Vector3(renderX, renderY, renderZ);
GL11.glTranslated(vector.x, vector.y, vector.z);
ModelCube.INSTNACE.render();
GL11.glTranslated(-vector.x, -vector.y, -vector.z);
}
++i;
}
}
} }
++i;
}
} }
}
} }
}
} }

View File

@ -1,10 +1,11 @@
package mffs.item.module.projector; package mffs.item.module.projector;
import java.util.HashSet;
import java.util.Set;
import calclavia.lib.CalculationHelper; import calclavia.lib.CalculationHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashSet;
import java.util.Set;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.item.mode.ItemMode; import mffs.item.mode.ItemMode;
@ -15,123 +16,152 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.vector.Region3; import universalelectricity.prefab.vector.Region3;
public class ItemModePyramid extends ItemMode { public class ItemModePyramid extends ItemMode {
public ItemModePyramid() { super("modePyramid"); } public ItemModePyramid() {
super("modePyramid");
@Override
public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale();
final int xStretch = posScale.intX() + negScale.intX();
final int yStretch = posScale.intY() + negScale.intY();
final int zStretch = posScale.intZ() + negScale.intZ();
final Vector3 translation = new Vector3(0.0, -negScale.intY(), 0.0);
for (float y = 0.0f; y <= yStretch; ++y) {
for (float x = (float)(-xStretch); x <= xStretch; ++x) {
for (float z = (float)(-zStretch); z <= zStretch; ++z) {
final double yTest = y / yStretch * 8.0f;
final double xzPositivePlane =
(1.0f - x / xStretch - z / zStretch) * 8.0f;
final double xzNegativePlane =
(1.0f + x / xStretch - z / zStretch) * 8.0f;
if (x >= 0.0f && z >= 0.0f &&
Math.round(xzPositivePlane) == Math.round(yTest)) {
fieldBlocks.add(new Vector3(x, y, z).add(translation));
fieldBlocks.add(new Vector3(x, y, -z).add(translation));
}
if (x <= 0.0f && z >= 0.0f &&
Math.round(xzNegativePlane) == Math.round(yTest)) {
fieldBlocks.add(new Vector3(x, y, -z).add(translation));
fieldBlocks.add(new Vector3(x, y, z).add(translation));
}
if (y == 0.0f &&
Math.abs(x) + Math.abs(z) < (xStretch + yStretch) / 2) {
fieldBlocks.add(new Vector3(x, y, z).add(translation));
}
}
}
} }
return fieldBlocks;
}
@Override @Override
public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) { public Set<Vector3> getExteriorPoints(final IFieldInteraction projector) {
final Set<Vector3> fieldBlocks = new HashSet<>(); final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 posScale = projector.getPositiveScale(); final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale(); final Vector3 negScale = projector.getNegativeScale();
final int xStretch = posScale.intX() + negScale.intX(); final int xStretch = posScale.intX() + negScale.intX();
final int yStretch = posScale.intY() + negScale.intY(); final int yStretch = posScale.intY() + negScale.intY();
final int zStretch = posScale.intZ() + negScale.intZ(); final int zStretch = posScale.intZ() + negScale.intZ();
final Vector3 translation = new Vector3(0.0, -0.4, 0.0); final Vector3 translation = new Vector3(0.0, -negScale.intY(), 0.0);
for (float x = (float)(-xStretch); x <= xStretch; ++x) {
for (float z = (float)(-zStretch); z <= zStretch; ++z) {
for (float y = 0.0f; y <= yStretch; ++y) { for (float y = 0.0f; y <= yStretch; ++y) {
final Vector3 position = new Vector3(x, y, z).add(translation); for (float x = (float) (-xStretch); x <= xStretch; ++x) {
if (this.isInField( for (float z = (float) (-zStretch); z <= zStretch; ++z) {
projector, final double yTest = y / yStretch * 8.0f;
Vector3.add(position, new Vector3((TileEntity)projector)))) { final double xzPositivePlane
fieldBlocks.add(position); = (1.0f - x / xStretch - z / zStretch) * 8.0f;
} final double xzNegativePlane
= (1.0f + x / xStretch - z / zStretch) * 8.0f;
if (x >= 0.0f && z >= 0.0f
&& Math.round(xzPositivePlane) == Math.round(yTest)) {
fieldBlocks.add(new Vector3(x, y, z).add(translation));
fieldBlocks.add(new Vector3(x, y, -z).add(translation));
}
if (x <= 0.0f && z >= 0.0f
&& Math.round(xzNegativePlane) == Math.round(yTest)) {
fieldBlocks.add(new Vector3(x, y, -z).add(translation));
fieldBlocks.add(new Vector3(x, y, z).add(translation));
}
if (y == 0.0f
&& Math.abs(x) + Math.abs(z) < (xStretch + yStretch) / 2) {
fieldBlocks.add(new Vector3(x, y, z).add(translation));
}
}
}
} }
} return fieldBlocks;
} }
return fieldBlocks;
}
@Override @Override
public boolean isInField(final IFieldInteraction projector, public Set<Vector3> getInteriorPoints(final IFieldInteraction projector) {
final Vector3 position) { final Set<Vector3> fieldBlocks = new HashSet<>();
final Vector3 posScale = projector.getPositiveScale().clone(); final Vector3 posScale = projector.getPositiveScale();
final Vector3 negScale = projector.getNegativeScale().clone(); final Vector3 negScale = projector.getNegativeScale();
final int xStretch = posScale.intX() + negScale.intX(); final int xStretch = posScale.intX() + negScale.intX();
final int yStretch = posScale.intY() + negScale.intY(); final int yStretch = posScale.intY() + negScale.intY();
final int zStretch = posScale.intZ() + negScale.intZ(); final int zStretch = posScale.intZ() + negScale.intZ();
final Vector3 projectorPos = new Vector3((TileEntity)projector); final Vector3 translation = new Vector3(0.0, -0.4, 0.0);
projectorPos.add(projector.getTranslation()); for (float x = (float) (-xStretch); x <= xStretch; ++x) {
projectorPos.add(new Vector3(0.0, -negScale.intY() + 1, 0.0)); for (float z = (float) (-zStretch); z <= zStretch; ++z) {
final Vector3 relativePosition = position.clone().subtract(projectorPos); for (float y = 0.0f; y <= yStretch; ++y) {
CalculationHelper.rotateByAngle(relativePosition, final Vector3 position = new Vector3(x, y, z).add(translation);
-projector.getRotationYaw(), if (this.isInField(
-projector.getRotationPitch()); projector,
final Region3 region = new Region3(negScale.multiply(-1.0), posScale); Vector3.add(position, new Vector3((TileEntity) projector))
return region.isIn(relativePosition) && relativePosition.y > 0.0 && )) {
1.0 - Math.abs(relativePosition.x) / xStretch - fieldBlocks.add(position);
Math.abs(relativePosition.z) / zStretch > }
relativePosition.y / yStretch; }
} }
}
return fieldBlocks;
}
@SideOnly(Side.CLIENT) @Override
@Override public boolean isInField(final IFieldInteraction projector, final Vector3 position) {
public void render(final IProjector projector, final double x, final double y, final Vector3 posScale = projector.getPositiveScale().clone();
final double z, final float f, final long ticks) { final Vector3 negScale = projector.getNegativeScale().clone();
final Tessellator tessellator = Tessellator.instance; final int xStretch = posScale.intX() + negScale.intX();
GL11.glPushMatrix(); final int yStretch = posScale.intY() + negScale.intY();
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f); final int zStretch = posScale.intZ() + negScale.intZ();
final float height = 0.5f; final Vector3 projectorPos = new Vector3((TileEntity) projector);
final float width = 0.3f; projectorPos.add(projector.getTranslation());
final int uvMaxX = 2; projectorPos.add(new Vector3(0.0, -negScale.intY() + 1, 0.0));
final int uvMaxY = 2; final Vector3 relativePosition = position.clone().subtract(projectorPos);
final Vector3 translation = new Vector3(0.0, -0.4, 0.0); CalculationHelper.rotateByAngle(
tessellator.startDrawing(6); relativePosition, -projector.getRotationYaw(), -projector.getRotationPitch()
tessellator.setColorRGBA(72, 198, 255, 255); );
tessellator.addVertexWithUV(0.0 + translation.x, 0.0 + translation.y, final Region3 region = new Region3(negScale.multiply(-1.0), posScale);
0.0 + translation.z, 0.0, 0.0); return region.isIn(relativePosition) && relativePosition.y > 0.0
tessellator.addVertexWithUV(-width + translation.x, height + translation.y, && 1.0 - Math.abs(relativePosition.x) / xStretch
-width + translation.z, (double)(-uvMaxX), - Math.abs(relativePosition.z) / zStretch
(double)(-uvMaxY)); > relativePosition.y / yStretch;
tessellator.addVertexWithUV(-width + translation.x, height + translation.y, }
width + translation.z, (double)(-uvMaxX),
(double)uvMaxY); @SideOnly(Side.CLIENT)
tessellator.addVertexWithUV(width + translation.x, height + translation.y, @Override
width + translation.z, (double)uvMaxX, public void render(
(double)uvMaxY); final IProjector projector,
tessellator.addVertexWithUV(width + translation.x, height + translation.y, final double x,
-width + translation.z, (double)uvMaxX, final double y,
(double)(-uvMaxY)); final double z,
tessellator.addVertexWithUV(-width + translation.x, height + translation.y, final float f,
-width + translation.z, (double)(-uvMaxX), final long ticks
(double)(-uvMaxY)); ) {
tessellator.draw(); final Tessellator tessellator = Tessellator.instance;
GL11.glPopMatrix(); GL11.glPushMatrix();
} GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
final float height = 0.5f;
final float width = 0.3f;
final int uvMaxX = 2;
final int uvMaxY = 2;
final Vector3 translation = new Vector3(0.0, -0.4, 0.0);
tessellator.startDrawing(6);
tessellator.setColorRGBA(72, 198, 255, 255);
tessellator.addVertexWithUV(
0.0 + translation.x, 0.0 + translation.y, 0.0 + translation.z, 0.0, 0.0
);
tessellator.addVertexWithUV(
-width + translation.x,
height + translation.y,
-width + translation.z,
(double) (-uvMaxX),
(double) (-uvMaxY)
);
tessellator.addVertexWithUV(
-width + translation.x,
height + translation.y,
width + translation.z,
(double) (-uvMaxX),
(double) uvMaxY
);
tessellator.addVertexWithUV(
width + translation.x,
height + translation.y,
width + translation.z,
(double) uvMaxX,
(double) uvMaxY
);
tessellator.addVertexWithUV(
width + translation.x,
height + translation.y,
-width + translation.z,
(double) uvMaxX,
(double) (-uvMaxY)
);
tessellator.addVertexWithUV(
-width + translation.x,
height + translation.y,
-width + translation.z,
(double) (-uvMaxX),
(double) (-uvMaxY)
);
tessellator.draw();
GL11.glPopMatrix();
}
} }

View File

@ -2,12 +2,13 @@ package mffs.item.module.projector;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import mffs.IDelayedEventHandler; import mffs.IDelayedEventHandler;
import mffs.MFFSHelper; import mffs.MFFSHelper;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.base.PacketFxs;
import mffs.api.Blacklist; import mffs.api.Blacklist;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.base.PacketFxs;
import mffs.base.TileEntityInventory; import mffs.base.TileEntityInventory;
import mffs.event.BlockDropDelayedEvent; import mffs.event.BlockDropDelayedEvent;
import mffs.event.BlockInventoryDropDelayedEvent; import mffs.event.BlockInventoryDropDelayedEvent;
@ -33,8 +34,7 @@ public class ItemModuleDisintegration extends ItemModule {
} }
@Override @Override
public boolean onProject(final IProjector projector, public boolean onProject(final IProjector projector, final Set<Vector3> fields) {
final Set<Vector3> fields) {
this.blockCount = 0; this.blockCount = 0;
return false; return false;
} }
@ -43,11 +43,15 @@ public class ItemModuleDisintegration extends ItemModule {
public int onProject(final IProjector projector, final Vector3 position) { public int onProject(final IProjector projector, final Vector3 position) {
if (projector.getTicks() % 40L == 0L) { if (projector.getTicks() % 40L == 0L) {
final TileEntity tileEntity = (TileEntity) projector; final TileEntity tileEntity = (TileEntity) projector;
final Block block = position.getBlock((IBlockAccess) tileEntity.getWorldObj()); final Block block
= position.getBlock((IBlockAccess) tileEntity.getWorldObj());
if (block != Blocks.air) { if (block != Blocks.air) {
if (projector.getModuleCount( if (projector.getModuleCount(
ModularForceFieldSystem.itemModuleCamouflage, new int[0]) > 0) { ModularForceFieldSystem.itemModuleCamouflage, new int[0]
final int blockMetadata = position.getBlockMetadata((IBlockAccess) tileEntity.getWorldObj()); )
> 0) {
final int blockMetadata = position.getBlockMetadata((IBlockAccess
) tileEntity.getWorldObj());
final Set<ItemStack> filterStacks = new HashSet<>(); final Set<ItemStack> filterStacks = new HashSet<>();
for (final int i : projector.getModuleSlots()) { for (final int i : projector.getModuleSlots()) {
final ItemStack checkStack = projector.getStackInSlot(i); final ItemStack checkStack = projector.getStackInSlot(i);
@ -58,8 +62,8 @@ public class ItemModuleDisintegration extends ItemModule {
} }
boolean contains = false; boolean contains = false;
for (final ItemStack filterStack : filterStacks) { for (final ItemStack filterStack : filterStacks) {
if (filterStack.isItemEqual( if (filterStack.isItemEqual(new ItemStack(block, 1, blockMetadata)
new ItemStack(block, 1, blockMetadata))) { )) {
contains = true; contains = true;
break; break;
} }
@ -68,8 +72,8 @@ public class ItemModuleDisintegration extends ItemModule {
return 1; return 1;
} }
} }
if (Blacklist.disintegrationBlacklist.contains(block) || if (Blacklist.disintegrationBlacklist.contains(block)
block instanceof IFluidBlock) { || block instanceof IFluidBlock) {
return 1; return 1;
} }
@ -79,26 +83,38 @@ public class ItemModuleDisintegration extends ItemModule {
fxsData.setInteger("type", 2); fxsData.setInteger("type", 2);
ModularForceFieldSystem.channel.sendToAll( ModularForceFieldSystem.channel.sendToAll(
new PacketFxs(new Vector3((TileEntity) projector), fxsData)); new PacketFxs(new Vector3((TileEntity) projector), fxsData)
);
if (projector.getModuleCount( if (projector.getModuleCount(
ModularForceFieldSystem.itemModuleCollection, new int[0]) > 0) { ModularForceFieldSystem.itemModuleCollection, new int[0]
)
> 0) {
((TileEntityForceFieldProjector) projector) ((TileEntityForceFieldProjector) projector)
.getDelayedEvents() .getDelayedEvents()
.add(new BlockInventoryDropDelayedEvent( .add(new BlockInventoryDropDelayedEvent(
(IDelayedEventHandler) projector, 39, block, (IDelayedEventHandler) projector,
tileEntity.getWorldObj(), position, 39,
(TileEntityInventory) projector)); block,
tileEntity.getWorldObj(),
position,
(TileEntityInventory) projector
));
} else { } else {
((TileEntityForceFieldProjector) projector) ((TileEntityForceFieldProjector) projector)
.getDelayedEvents() .getDelayedEvents()
.add(new BlockDropDelayedEvent( .add(new BlockDropDelayedEvent(
(IDelayedEventHandler) projector, 39, block, (IDelayedEventHandler) projector,
tileEntity.getWorldObj(), position)); 39,
block,
tileEntity.getWorldObj(),
position
));
} }
if (this.blockCount++ >= projector.getModuleCount(ModularForceFieldSystem.itemModuleSpeed, if (this.blockCount++
new int[0]) / >= projector.getModuleCount(
3) { ModularForceFieldSystem.itemModuleSpeed, new int[0]
) / 3) {
return 2; return 2;
} }
return 1; return 1;

View File

@ -1,8 +1,9 @@
package mffs.item.module.projector; package mffs.item.module.projector;
import icbm.api.IBlockFrequency;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import icbm.api.IBlockFrequency;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.api.fortron.IFortronFrequency; import mffs.api.fortron.IFortronFrequency;
@ -13,36 +14,36 @@ import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModuleFusion extends ItemModule { public class ItemModuleFusion extends ItemModule {
public ItemModuleFusion() { public ItemModuleFusion() {
super("moduleFusion"); super("moduleFusion");
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setCost(1.0f); this.setCost(1.0f);
} }
@Override @Override
public boolean onProject(final IProjector projector, public boolean onProject(final IProjector projector, final Set<Vector3> fieldBlocks) {
final Set<Vector3> fieldBlocks) { final Set<IBlockFrequency> machines
final Set<IBlockFrequency> machines = FrequencyGrid.instance().get( = FrequencyGrid.instance().get(((IFortronFrequency) projector).getFrequency()
((IFortronFrequency)projector).getFrequency()); );
for (final IBlockFrequency compareProjector : machines) { for (final IBlockFrequency compareProjector : machines) {
if (compareProjector instanceof IProjector && if (compareProjector instanceof IProjector && compareProjector != projector
compareProjector != projector && && ((TileEntity) compareProjector).getWorldObj()
((TileEntity)compareProjector).getWorldObj() == == ((TileEntity) projector).getWorldObj()
((TileEntity)projector).getWorldObj() && && ((TileEntityBase) compareProjector).isActive()
((TileEntityBase)compareProjector).isActive() && && ((IProjector) compareProjector).getMode() != null) {
((IProjector)compareProjector).getMode() != null) { final Iterator<Vector3> it = fieldBlocks.iterator();
final Iterator<Vector3> it = fieldBlocks.iterator(); while (it.hasNext()) {
while (it.hasNext()) { final Vector3 position = it.next();
final Vector3 position = it.next(); if (((IProjector) compareProjector)
if (((IProjector)compareProjector) .getMode()
.getMode() .isInField(
.isInField((IFieldInteraction)compareProjector, (IFieldInteraction) compareProjector, position.clone()
position.clone())) { )) {
it.remove(); it.remove();
} }
} }
} }
}
return false;
} }
return false;
}
} }

View File

@ -2,23 +2,26 @@ package mffs.item.module.projector;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import mffs.api.IFieldInteraction; import mffs.api.IFieldInteraction;
import mffs.item.module.ItemModule; import mffs.item.module.ItemModule;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModuleManipulator extends ItemModule { public class ItemModuleManipulator extends ItemModule {
public ItemModuleManipulator() { super("moduleManipulator"); } public ItemModuleManipulator() {
super("moduleManipulator");
@Override }
public void onCalculate(final IFieldInteraction projector,
final Set<Vector3> fieldBlocks) { @Override
final Iterator<Vector3> it = fieldBlocks.iterator(); public void
while (it.hasNext()) { onCalculate(final IFieldInteraction projector, final Set<Vector3> fieldBlocks) {
final Vector3 position = it.next(); final Iterator<Vector3> it = fieldBlocks.iterator();
if (position.y < ((TileEntity)projector).yCoord) { while (it.hasNext()) {
it.remove(); final Vector3 position = it.next();
} if (position.y < ((TileEntity) projector).yCoord) {
it.remove();
}
}
} }
}
} }

View File

@ -8,17 +8,24 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemModuleShock extends ItemModule { public class ItemModuleShock extends ItemModule {
public ItemModuleShock() { super("moduleShock"); } public ItemModuleShock() {
super("moduleShock");
@Override }
public boolean onCollideWithForceField(final World world, final int x,
final int y, final int z, @Override
final Entity entity, public boolean onCollideWithForceField(
final ItemStack moduleStack) { final World world,
if (entity instanceof EntityLiving) { final int x,
entity.attackEntityFrom(ModularForceFieldSystem.damagefieldShock, final int y,
moduleStack.stackSize); final int z,
final Entity entity,
final ItemStack moduleStack
) {
if (entity instanceof EntityLiving) {
entity.attackEntityFrom(
ModularForceFieldSystem.damagefieldShock, moduleStack.stackSize
);
}
return false;
} }
return false;
}
} }

View File

@ -1,6 +1,7 @@
package mffs.item.module.projector; package mffs.item.module.projector;
import java.util.Set; import java.util.Set;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.item.module.ItemModule; import mffs.item.module.ItemModule;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
@ -11,22 +12,22 @@ import net.minecraftforge.fluids.IFluidBlock;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
public class ItemModuleSponge extends ItemModule { public class ItemModuleSponge extends ItemModule {
public ItemModuleSponge() { public ItemModuleSponge() {
super("moduleSponge"); super("moduleSponge");
this.setMaxStackSize(1); this.setMaxStackSize(1);
} }
@Override @Override
public boolean onProject(final IProjector projector, public boolean onProject(final IProjector projector, final Set<Vector3> fields) {
final Set<Vector3> fields) { if (projector.getTicks() % 60L == 0L) {
if (projector.getTicks() % 60L == 0L) { final World world = ((TileEntity) projector).getWorldObj();
final World world = ((TileEntity)projector).getWorldObj(); for (final Vector3 point : projector.getInteriorPoints()) {
for (final Vector3 point : projector.getInteriorPoints()) { if (point.getBlock(world) instanceof IFluidBlock
if (point.getBlock(world) instanceof IFluidBlock || point.getBlock(world) instanceof BlockLiquid) { || point.getBlock(world) instanceof BlockLiquid) {
point.setBlock(world, Blocks.air); point.setBlock(world, Blocks.air);
} }
} }
}
return super.onProject(projector, fields);
} }
return super.onProject(projector, fields);
}
} }

View File

@ -1,12 +1,13 @@
package mffs.item.module.projector; package mffs.item.module.projector;
import calclavia.lib.CalculationHelper;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set; import java.util.Set;
import mffs.base.PacketFxs;
import calclavia.lib.CalculationHelper;
import mffs.ModularForceFieldSystem; import mffs.ModularForceFieldSystem;
import mffs.api.Blacklist; import mffs.api.Blacklist;
import mffs.api.IProjector; import mffs.api.IProjector;
import mffs.base.PacketFxs;
import mffs.item.module.ItemModule; import mffs.item.module.ItemModule;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -32,8 +33,7 @@ public class ItemModuleStablize extends ItemModule {
} }
@Override @Override
public boolean onProject(final IProjector projector, public boolean onProject(final IProjector projector, final Set<Vector3> fields) {
final Set<Vector3> fields) {
this.blockCount = 0; this.blockCount = 0;
return false; return false;
} }
@ -43,28 +43,36 @@ public class ItemModuleStablize extends ItemModule {
int[] blockInfo = null; int[] blockInfo = null;
if (projector.getTicks() % 40L == 0L) { if (projector.getTicks() % 40L == 0L) {
if (projector.getMode() instanceof ItemModeCustom) { if (projector.getMode() instanceof ItemModeCustom) {
final HashMap<Vector3, int[]> fieldBlocks = ((ItemModeCustom) projector.getMode()) final HashMap<Vector3, int[]> fieldBlocks
.getFieldBlockMap(projector, projector.getModeStack()); = ((ItemModeCustom) projector.getMode())
final Vector3 fieldCenter = new Vector3((TileEntity) projector).add(projector.getTranslation()); .getFieldBlockMap(projector, projector.getModeStack());
final Vector3 fieldCenter
= new Vector3((TileEntity) projector).add(projector.getTranslation());
final Vector3 relativePosition = position.clone().subtract(fieldCenter); final Vector3 relativePosition = position.clone().subtract(fieldCenter);
CalculationHelper.rotateByAngle(relativePosition, CalculationHelper.rotateByAngle(
-projector.getRotationYaw(), relativePosition,
-projector.getRotationPitch()); -projector.getRotationYaw(),
-projector.getRotationPitch()
);
blockInfo = fieldBlocks.get(relativePosition.round()); blockInfo = fieldBlocks.get(relativePosition.round());
} }
for (int dir = 0; dir < 6; ++dir) { for (int dir = 0; dir < 6; ++dir) {
final ForgeDirection direction = ForgeDirection.getOrientation(dir); final ForgeDirection direction = ForgeDirection.getOrientation(dir);
final TileEntity tileEntity = VectorHelper.getTileEntityFromSide( final TileEntity tileEntity = VectorHelper.getTileEntityFromSide(
((TileEntity) projector).getWorldObj(), ((TileEntity) projector).getWorldObj(),
new Vector3((TileEntity) projector), direction); new Vector3((TileEntity) projector),
direction
);
if (tileEntity instanceof IInventory) { if (tileEntity instanceof IInventory) {
final IInventory inventory = (IInventory) tileEntity; final IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) { for (int i = 0; i < inventory.getSizeInventory(); ++i) {
final ItemStack checkStack = inventory.getStackInSlot(i); final ItemStack checkStack = inventory.getStackInSlot(i);
if (checkStack != null && checkStack.getItem() instanceof ItemBlock) { if (checkStack != null
&& checkStack.getItem() instanceof ItemBlock) {
if (blockInfo != null) { if (blockInfo != null) {
if (Block.getBlockById(blockInfo[0]) != Block if (Block.getBlockById(blockInfo[0])
.getBlockFromItem((ItemBlock) checkStack.getItem())) { != Block.getBlockFromItem((ItemBlock
) checkStack.getItem())) {
continue; continue;
} }
} }
@ -72,28 +80,42 @@ public class ItemModuleStablize extends ItemModule {
if (((TileEntity) projector) if (((TileEntity) projector)
.getWorldObj() .getWorldObj()
.canPlaceEntityOnSide( .canPlaceEntityOnSide(
Block.getBlockFromItem( Block.getBlockFromItem((ItemBlock
(ItemBlock) checkStack.getItem()), ) checkStack.getItem()),
position.intX(), position.intY(), position.intZ(), position.intX(),
false, 0, (Entity) null, checkStack)) { position.intY(),
position.intZ(),
false,
0,
(Entity) null,
checkStack
)) {
final int metadata = (blockInfo != null) final int metadata = (blockInfo != null)
? blockInfo[1] ? blockInfo[1]
: (checkStack.getHasSubtypes() : (checkStack.getHasSubtypes()
? checkStack.getItemDamage() ? checkStack.getItemDamage()
: 0); : 0);
final Block block = (blockInfo != null) final Block block = (blockInfo != null)
? Block.getBlockById(blockInfo[0]) ? Block.getBlockById(blockInfo[0])
: null; : null;
if (Blacklist.stabilizationBlacklist.contains(block) || if (Blacklist.stabilizationBlacklist.contains(block)
block instanceof IFluidBlock) { || block instanceof IFluidBlock) {
return 1; return 1;
} }
((ItemBlock) checkStack.getItem()) ((ItemBlock) checkStack.getItem())
.placeBlockAt(checkStack, (EntityPlayer) null, .placeBlockAt(
((TileEntity) projector).getWorldObj(), checkStack,
position.intX(), position.intY(), (EntityPlayer) null,
position.intZ(), 0, 0.0f, 0.0f, 0.0f, ((TileEntity) projector).getWorldObj(),
metadata); position.intX(),
position.intY(),
position.intZ(),
0,
0.0f,
0.0f,
0.0f,
metadata
);
inventory.decrStackSize(i, 1); inventory.decrStackSize(i, 1);
NBTTagCompound fxsData = new NBTTagCompound(); NBTTagCompound fxsData = new NBTTagCompound();
@ -101,12 +123,17 @@ public class ItemModuleStablize extends ItemModule {
position.writeToNBT(fxsData); position.writeToNBT(fxsData);
fxsData.setInteger("type", 1); fxsData.setInteger("type", 1);
ModularForceFieldSystem.channel.sendToAll(new PacketFxs( ModularForceFieldSystem.channel.sendToAll(
new Vector3((TileEntity) projector), fxsData)); new PacketFxs(
new Vector3((TileEntity) projector), fxsData
)
);
if (this.blockCount++ >= projector.getModuleCount( if (this.blockCount++
ModularForceFieldSystem.itemModuleSpeed, new int[0]) / >= projector.getModuleCount(
3) { ModularForceFieldSystem.itemModuleSpeed,
new int[0]
) / 3) {
return 2; return 2;
} }
return 1; return 1;

View File

@ -4,11 +4,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
public interface IRecipeAdapter { public interface IRecipeAdapter {
public void setOutput(ItemStack item); public void setOutput(ItemStack item);
public void setPattern(String... pattern); public void setPattern(String... pattern);
public void addIngredient(Object... ingredients); public void addIngredient(Object... ingredients);
public IRecipe create(); public IRecipe create();
} }

View File

@ -6,44 +6,48 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class RecipeBuilder { public class RecipeBuilder {
IRecipeAdapter adapter; IRecipeAdapter adapter;
public RecipeBuilder(IRecipeAdapter adapter) { this.adapter = adapter; } public RecipeBuilder(IRecipeAdapter adapter) {
this.adapter = adapter;
}
public RecipeBuilder output(ItemStack stack) { public RecipeBuilder output(ItemStack stack) {
this.adapter.setOutput(stack); this.adapter.setOutput(stack);
return this; return this;
} }
public RecipeBuilder output(Item item) { public RecipeBuilder output(Item item) {
this.adapter.setOutput(new ItemStack(item)); this.adapter.setOutput(new ItemStack(item));
return this; return this;
} }
public RecipeBuilder output(Block block) { public RecipeBuilder output(Block block) {
this.adapter.setOutput(new ItemStack(block)); this.adapter.setOutput(new ItemStack(block));
return this; return this;
} }
public RecipeBuilder output(Block block, int count) { public RecipeBuilder output(Block block, int count) {
this.adapter.setOutput(new ItemStack(block, count)); this.adapter.setOutput(new ItemStack(block, count));
return this; return this;
} }
public RecipeBuilder output(Item item, int count) { public RecipeBuilder output(Item item, int count) {
this.adapter.setOutput(new ItemStack(item, count)); this.adapter.setOutput(new ItemStack(item, count));
return this; return this;
} }
public RecipeBuilder pattern(String... pat) { public RecipeBuilder pattern(String... pat) {
this.adapter.setPattern(pat); this.adapter.setPattern(pat);
return this; return this;
} }
public RecipeBuilder ingredient(Object... i) { public RecipeBuilder ingredient(Object... i) {
this.adapter.addIngredient(i); this.adapter.addIngredient(i);
return this; return this;
} }
public void register() { GameRegistry.addRecipe(this.adapter.create()); } public void register() {
GameRegistry.addRecipe(this.adapter.create());
}
} }

View File

@ -1,41 +1,42 @@
package mffs.recipe; package mffs.recipe;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
public class ShapedOreRecipeAdapter implements IRecipeAdapter { public class ShapedOreRecipeAdapter implements IRecipeAdapter {
ItemStack output; ItemStack output;
String[] pattern; String[] pattern;
ArrayList<Object> ingredients = new ArrayList<>(); ArrayList<Object> ingredients = new ArrayList<>();
@Override @Override
public void setOutput(ItemStack item) { public void setOutput(ItemStack item) {
this.output = item; this.output = item;
} }
@Override @Override
public void setPattern(String... pattern) { public void setPattern(String... pattern) {
this.pattern = pattern; this.pattern = pattern;
} }
@Override @Override
public void addIngredient(Object... ingredients) { public void addIngredient(Object... ingredients) {
this.ingredients.add(ingredients[0]); this.ingredients.add(ingredients[0]);
this.ingredients.add(ingredients[1]); this.ingredients.add(ingredients[1]);
} }
@Override @Override
public IRecipe create() { public IRecipe create() {
ArrayList<Object> args = new ArrayList<>(); ArrayList<Object> args = new ArrayList<>();
for (String pat : this.pattern) for (String pat : this.pattern)
args.add(pat); args.add(pat);
for (Object ing : this.ingredients) for (Object ing : this.ingredients)
args.add(ing); args.add(ing);
return new ShapedOreRecipe(this.output, args.toArray()); return new ShapedOreRecipe(this.output, args.toArray());
} }
} }

View File

@ -1,31 +1,32 @@
package mffs.recipe; package mffs.recipe;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
public class ShapelessOreRecipeAdapter implements IRecipeAdapter { public class ShapelessOreRecipeAdapter implements IRecipeAdapter {
ItemStack output; ItemStack output;
ArrayList<Object> ingredients = new ArrayList<>(); ArrayList<Object> ingredients = new ArrayList<>();
@Override @Override
public void setOutput(ItemStack item) { public void setOutput(ItemStack item) {
this.output = item; this.output = item;
} }
@Override @Override
public void setPattern(String... pattern) { public void setPattern(String... pattern) {
throw new UnsupportedOperationException("Shapeless recipe has no pattern!"); throw new UnsupportedOperationException("Shapeless recipe has no pattern!");
} }
@Override @Override
public void addIngredient(Object... ingredients) { public void addIngredient(Object... ingredients) {
this.ingredients.add(ingredients[0]); this.ingredients.add(ingredients[0]);
} }
@Override @Override
public IRecipe create() { public IRecipe create() {
return new ShapelessOreRecipe(this.output, this.ingredients.toArray()); return new ShapelessOreRecipe(this.output, this.ingredients.toArray());
} }
} }

View File

@ -15,171 +15,185 @@ import universalelectricity.core.vector.Vector3;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class FXBeam extends EntityFX { public class FXBeam extends EntityFX {
double movX; double movX;
double movY; double movY;
double movZ; double movZ;
private float length; private float length;
private float rotYaw; private float rotYaw;
private float rotPitch; private float rotPitch;
private float prevYaw; private float prevYaw;
private float prevPitch; private float prevPitch;
private Vector3 target; private Vector3 target;
private float endModifier; private float endModifier;
private boolean reverse; private boolean reverse;
private boolean pulse; private boolean pulse;
private int rotationSpeed; private int rotationSpeed;
private float prevSize; private float prevSize;
public FXBeam(final World par1World, final Vector3 position, public FXBeam(
final Vector3 target, final float red, final float green, final World par1World,
final float blue, final int age) { final Vector3 position,
super(par1World, position.x, position.y, position.z, 0.0, 0.0, 0.0); final Vector3 target,
this.movX = 0.0; final float red,
this.movY = 0.0; final float green,
this.movZ = 0.0; final float blue,
this.length = 0.0f; final int age
this.rotYaw = 0.0f; ) {
this.rotPitch = 0.0f; super(par1World, position.x, position.y, position.z, 0.0, 0.0, 0.0);
this.prevYaw = 0.0f; this.movX = 0.0;
this.prevPitch = 0.0f; this.movY = 0.0;
this.target = new Vector3(); this.movZ = 0.0;
this.endModifier = 1.0f; this.length = 0.0f;
this.reverse = false; this.rotYaw = 0.0f;
this.pulse = true; this.rotPitch = 0.0f;
this.rotationSpeed = 20; this.prevYaw = 0.0f;
this.prevSize = 0.0f; this.prevPitch = 0.0f;
this.setRGB(red, green, blue); this.target = new Vector3();
this.setSize(0.02f, 0.02f); this.endModifier = 1.0f;
((Entity)this).noClip = true; this.reverse = false;
((Entity)this).motionX = 0.0; this.pulse = true;
((Entity)this).motionY = 0.0; this.rotationSpeed = 20;
((Entity)this).motionZ = 0.0; this.prevSize = 0.0f;
this.target = target; this.setRGB(red, green, blue);
final float xd = (float)(((Entity)this).posX - this.target.x); this.setSize(0.02f, 0.02f);
final float yd = (float)(((Entity)this).posY - this.target.y); ((Entity) this).noClip = true;
final float zd = (float)(((Entity)this).posZ - this.target.z); ((Entity) this).motionX = 0.0;
this.length = (float)new Vector3((Entity)this).distanceTo(this.target); ((Entity) this).motionY = 0.0;
final double var7 = MathHelper.sqrt_double((double)(xd * xd + zd * zd)); ((Entity) this).motionZ = 0.0;
this.rotYaw = (float)(Math.atan2(xd, zd) * 180.0 / 3.141592653589793); this.target = target;
this.rotPitch = (float)(Math.atan2(yd, var7) * 180.0 / 3.141592653589793); final float xd = (float) (((Entity) this).posX - this.target.x);
this.prevYaw = this.rotYaw; final float yd = (float) (((Entity) this).posY - this.target.y);
this.prevPitch = this.rotPitch; final float zd = (float) (((Entity) this).posZ - this.target.z);
super.particleMaxAge = age; this.length = (float) new Vector3((Entity) this).distanceTo(this.target);
final EntityLivingBase renderentity = final double var7 = MathHelper.sqrt_double((double) (xd * xd + zd * zd));
Minecraft.getMinecraft().renderViewEntity; this.rotYaw = (float) (Math.atan2(xd, zd) * 180.0 / 3.141592653589793);
int visibleDistance = 50; this.rotPitch = (float) (Math.atan2(yd, var7) * 180.0 / 3.141592653589793);
if (!Minecraft.getMinecraft().gameSettings.fancyGraphics) { this.prevYaw = this.rotYaw;
visibleDistance = 25; this.prevPitch = this.rotPitch;
super.particleMaxAge = age;
final EntityLivingBase renderentity = Minecraft.getMinecraft().renderViewEntity;
int visibleDistance = 50;
if (!Minecraft.getMinecraft().gameSettings.fancyGraphics) {
visibleDistance = 25;
}
if (renderentity.getDistance(
((Entity) this).posX, ((Entity) this).posY, ((Entity) this).posZ
)
> visibleDistance) {
super.particleMaxAge = 0;
}
} }
if (renderentity.getDistance(((Entity)this).posX, ((Entity)this).posY,
((Entity)this).posZ) > visibleDistance) {
super.particleMaxAge = 0;
}
}
public void onUpdate() { public void onUpdate() {
((Entity)this).prevPosX = ((Entity)this).posX; ((Entity) this).prevPosX = ((Entity) this).posX;
((Entity)this).prevPosY = ((Entity)this).posY; ((Entity) this).prevPosY = ((Entity) this).posY;
((Entity)this).prevPosZ = ((Entity)this).posZ; ((Entity) this).prevPosZ = ((Entity) this).posZ;
this.prevYaw = this.rotYaw; this.prevYaw = this.rotYaw;
this.prevPitch = this.rotPitch; this.prevPitch = this.rotPitch;
final float xd = (float)(((Entity)this).posX - this.target.x); final float xd = (float) (((Entity) this).posX - this.target.x);
final float yd = (float)(((Entity)this).posY - this.target.y); final float yd = (float) (((Entity) this).posY - this.target.y);
final float zd = (float)(((Entity)this).posZ - this.target.z); final float zd = (float) (((Entity) this).posZ - this.target.z);
this.length = MathHelper.sqrt_float(xd * xd + yd * yd + zd * zd); this.length = MathHelper.sqrt_float(xd * xd + yd * yd + zd * zd);
final double var7 = MathHelper.sqrt_double((double)(xd * xd + zd * zd)); final double var7 = MathHelper.sqrt_double((double) (xd * xd + zd * zd));
this.rotYaw = (float)(Math.atan2(xd, zd) * 180.0 / 3.141592653589793); this.rotYaw = (float) (Math.atan2(xd, zd) * 180.0 / 3.141592653589793);
this.rotPitch = (float)(Math.atan2(yd, var7) * 180.0 / 3.141592653589793); this.rotPitch = (float) (Math.atan2(yd, var7) * 180.0 / 3.141592653589793);
if (super.particleAge++ >= super.particleMaxAge) { if (super.particleAge++ >= super.particleMaxAge) {
this.setDead(); this.setDead();
}
} }
}
public void setRGB(final float r, final float g, final float b) { public void setRGB(final float r, final float g, final float b) {
super.particleRed = r; super.particleRed = r;
super.particleGreen = g; super.particleGreen = g;
super.particleBlue = b; super.particleBlue = b;
} }
public void renderParticle(final Tessellator tessellator, final float f, public void renderParticle(
final float f1, final float f2, final float f3, final Tessellator tessellator,
final float f4, final float f5) { final float f,
tessellator.draw(); final float f1,
GL11.glPushMatrix(); final float f2,
final float var9 = 1.0f; final float f3,
final float slide = (float)((Entity)this).worldObj.getTotalWorldTime(); final float f4,
final float rot = ((Entity)this).worldObj.provider.getWorldTime() % final float f5
(360 / this.rotationSpeed) * this.rotationSpeed + ) {
this.rotationSpeed * f; tessellator.draw();
float size = 1.0f; GL11.glPushMatrix();
if (this.pulse) { final float var9 = 1.0f;
size = Math.min(super.particleAge / 4.0f, 1.0f); final float slide = (float) ((Entity) this).worldObj.getTotalWorldTime();
size = this.prevSize + (size - this.prevSize) * f; final float rot = ((Entity) this).worldObj.provider.getWorldTime()
% (360 / this.rotationSpeed) * this.rotationSpeed
+ this.rotationSpeed * f;
float size = 1.0f;
if (this.pulse) {
size = Math.min(super.particleAge / 4.0f, 1.0f);
size = this.prevSize + (size - this.prevSize) * f;
}
float op = 0.5f;
if (this.pulse && super.particleMaxAge - super.particleAge <= 4) {
op = 0.5f - (4 - (super.particleMaxAge - super.particleAge)) * 0.1f;
}
Minecraft.getMinecraft().renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/blocks/fortron.png")
);
GL11.glTexParameterf(3553, 10242, 10497.0f);
GL11.glTexParameterf(3553, 10243, 10497.0f);
GL11.glDisable(2884);
float var10 = slide + f;
if (this.reverse) {
var10 *= -1.0f;
}
final float var11 = -var10 * 0.2f - MathHelper.floor_float(-var10 * 0.1f);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 1);
GL11.glDepthMask(false);
final float xx = (float
) (((Entity) this).prevPosX
+ (((Entity) this).posX - ((Entity) this).prevPosX) * f - EntityFX.interpPosX);
final float yy = (float
) (((Entity) this).prevPosY
+ (((Entity) this).posY - ((Entity) this).prevPosY) * f - EntityFX.interpPosY);
final float zz = (float
) (((Entity) this).prevPosZ
+ (((Entity) this).posZ - ((Entity) this).prevPosZ) * f - EntityFX.interpPosZ);
GL11.glTranslated((double) xx, (double) yy, (double) zz);
final float ry = this.prevYaw + (this.rotYaw - this.prevYaw) * f;
final float rp = this.prevPitch + (this.rotPitch - this.prevPitch) * f;
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(180.0f + ry, 0.0f, 0.0f, -1.0f);
GL11.glRotatef(rp, 1.0f, 0.0f, 0.0f);
final double var12 = -0.15 * size;
final double var13 = 0.15 * size;
final double var44b = -0.15 * size * this.endModifier;
final double var17b = 0.15 * size * this.endModifier;
GL11.glRotatef(rot, 0.0f, 1.0f, 0.0f);
for (int t = 0; t < 3; ++t) {
final double var14 = this.length * size * var9;
final double var15 = 0.0;
final double var16 = 1.0;
final double var17 = -1.0f + var11 + t / 3.0f;
final double var18 = this.length * size * var9 + var17;
GL11.glRotatef(60.0f, 0.0f, 1.0f, 0.0f);
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(
super.particleRed, super.particleGreen, super.particleBlue, op
);
tessellator.addVertexWithUV(var44b, var14, 0.0, var16, var18);
tessellator.addVertexWithUV(var12, 0.0, 0.0, var16, var17);
tessellator.addVertexWithUV(var13, 0.0, 0.0, var15, var17);
tessellator.addVertexWithUV(var17b, var14, 0.0, var15, var18);
tessellator.draw();
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glEnable(2884);
GL11.glPopMatrix();
tessellator.startDrawingQuads();
this.prevSize = size;
Minecraft.getMinecraft().renderEngine.bindTexture(
new ResourceLocation("textures/particle/particles.png")
);
} }
float op = 0.5f;
if (this.pulse && super.particleMaxAge - super.particleAge <= 4) {
op = 0.5f - (4 - (super.particleMaxAge - super.particleAge)) * 0.1f;
}
Minecraft.getMinecraft().renderEngine.bindTexture(
new ResourceLocation("mffs", "textures/blocks/fortron.png"));
GL11.glTexParameterf(3553, 10242, 10497.0f);
GL11.glTexParameterf(3553, 10243, 10497.0f);
GL11.glDisable(2884);
float var10 = slide + f;
if (this.reverse) {
var10 *= -1.0f;
}
final float var11 = -var10 * 0.2f - MathHelper.floor_float(-var10 * 0.1f);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 1);
GL11.glDepthMask(false);
final float xx =
(float)(((Entity)this).prevPosX +
(((Entity)this).posX - ((Entity)this).prevPosX) * f -
EntityFX.interpPosX);
final float yy =
(float)(((Entity)this).prevPosY +
(((Entity)this).posY - ((Entity)this).prevPosY) * f -
EntityFX.interpPosY);
final float zz =
(float)(((Entity)this).prevPosZ +
(((Entity)this).posZ - ((Entity)this).prevPosZ) * f -
EntityFX.interpPosZ);
GL11.glTranslated((double)xx, (double)yy, (double)zz);
final float ry = this.prevYaw + (this.rotYaw - this.prevYaw) * f;
final float rp = this.prevPitch + (this.rotPitch - this.prevPitch) * f;
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(180.0f + ry, 0.0f, 0.0f, -1.0f);
GL11.glRotatef(rp, 1.0f, 0.0f, 0.0f);
final double var12 = -0.15 * size;
final double var13 = 0.15 * size;
final double var44b = -0.15 * size * this.endModifier;
final double var17b = 0.15 * size * this.endModifier;
GL11.glRotatef(rot, 0.0f, 1.0f, 0.0f);
for (int t = 0; t < 3; ++t) {
final double var14 = this.length * size * var9;
final double var15 = 0.0;
final double var16 = 1.0;
final double var17 = -1.0f + var11 + t / 3.0f;
final double var18 = this.length * size * var9 + var17;
GL11.glRotatef(60.0f, 0.0f, 1.0f, 0.0f);
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(super.particleRed, super.particleGreen,
super.particleBlue, op);
tessellator.addVertexWithUV(var44b, var14, 0.0, var16, var18);
tessellator.addVertexWithUV(var12, 0.0, 0.0, var16, var17);
tessellator.addVertexWithUV(var13, 0.0, 0.0, var15, var17);
tessellator.addVertexWithUV(var17b, var14, 0.0, var15, var18);
tessellator.draw();
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glEnable(2884);
GL11.glPopMatrix();
tessellator.startDrawingQuads();
this.prevSize = size;
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("textures/particle/particles.png"));
}
} }

View File

@ -18,76 +18,93 @@ import universalelectricity.core.vector.Vector3;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class FXHologram extends EntityFX { public class FXHologram extends EntityFX {
private Vector3 targetPosition; private Vector3 targetPosition;
public FXHologram(final World par1World, final Vector3 position, public FXHologram(
final float red, final float green, final float blue, final World par1World,
final int age) { final Vector3 position,
super(par1World, position.x, position.y, position.z); final float red,
this.targetPosition = null; final float green,
this.setRBGColorF(red, green, blue); final float blue,
super.particleMaxAge = age; final int age
((Entity)this).noClip = true; ) {
} super(par1World, position.x, position.y, position.z);
this.targetPosition = null;
public FXHologram setTarget(final Vector3 targetPosition) { this.setRBGColorF(red, green, blue);
this.targetPosition = targetPosition; super.particleMaxAge = age;
((Entity)this).motionX = ((Entity) this).noClip = true;
(this.targetPosition.x - ((Entity)this).posX) / super.particleMaxAge;
((Entity)this).motionY =
(this.targetPosition.y - ((Entity)this).posY) / super.particleMaxAge;
((Entity)this).motionZ =
(this.targetPosition.z - ((Entity)this).posZ) / super.particleMaxAge;
return this;
}
public void onUpdate() {
((Entity)this).prevPosX = ((Entity)this).posX;
((Entity)this).prevPosY = ((Entity)this).posY;
((Entity)this).prevPosZ = ((Entity)this).posZ;
if (super.particleAge++ >= super.particleMaxAge) {
this.setDead();
return;
} }
if (this.targetPosition != null) {
this.moveEntity(((Entity)this).motionX, ((Entity)this).motionY,
((Entity)this).motionZ);
}
}
public void renderParticle(final Tessellator tessellator, final float f, public FXHologram setTarget(final Vector3 targetPosition) {
final float f1, final float f2, final float f3, this.targetPosition = targetPosition;
final float f4, final float f5) { ((Entity) this).motionX
tessellator.draw(); = (this.targetPosition.x - ((Entity) this).posX) / super.particleMaxAge;
GL11.glPushMatrix(); ((Entity) this).motionY
final float xx = = (this.targetPosition.y - ((Entity) this).posY) / super.particleMaxAge;
(float)(((Entity)this).prevPosX + ((Entity) this).motionZ
(((Entity)this).posX - ((Entity)this).prevPosX) * f - = (this.targetPosition.z - ((Entity) this).posZ) / super.particleMaxAge;
EntityFX.interpPosX); return this;
final float yy = }
(float)(((Entity)this).prevPosY +
(((Entity)this).posY - ((Entity)this).prevPosY) * f - public void onUpdate() {
EntityFX.interpPosY); ((Entity) this).prevPosX = ((Entity) this).posX;
final float zz = ((Entity) this).prevPosY = ((Entity) this).posY;
(float)(((Entity)this).prevPosZ + ((Entity) this).prevPosZ = ((Entity) this).posZ;
(((Entity)this).posZ - ((Entity)this).prevPosZ) * f - if (super.particleAge++ >= super.particleMaxAge) {
EntityFX.interpPosZ); this.setDead();
GL11.glTranslated((double)xx, (double)yy, (double)zz); return;
GL11.glScalef(1.01f, 1.01f, 1.01f); }
float op = 0.5f; if (this.targetPosition != null) {
if (super.particleMaxAge - super.particleAge <= 4) { this.moveEntity(
op = 0.5f - (5 - (super.particleMaxAge - super.particleAge)) * 0.1f; ((Entity) this).motionX, ((Entity) this).motionY, ((Entity) this).motionZ
);
}
}
public void renderParticle(
final Tessellator tessellator,
final float f,
final float f1,
final float f2,
final float f3,
final float f4,
final float f5
) {
tessellator.draw();
GL11.glPushMatrix();
final float xx = (float
) (((Entity) this).prevPosX
+ (((Entity) this).posX - ((Entity) this).prevPosX) * f - EntityFX.interpPosX);
final float yy = (float
) (((Entity) this).prevPosY
+ (((Entity) this).posY - ((Entity) this).prevPosY) * f - EntityFX.interpPosY);
final float zz = (float
) (((Entity) this).prevPosZ
+ (((Entity) this).posZ - ((Entity) this).prevPosZ) * f - EntityFX.interpPosZ);
GL11.glTranslated((double) xx, (double) yy, (double) zz);
GL11.glScalef(1.01f, 1.01f, 1.01f);
float op = 0.5f;
if (super.particleMaxAge - super.particleAge <= 4) {
op = 0.5f - (5 - (super.particleMaxAge - super.particleAge)) * 0.1f;
}
GL11.glColor4d(
(double) super.particleRed,
(double) super.particleGreen,
(double) super.particleBlue,
(double) (op * 2.0f)
);
CalclaviaRenderHelper.disableLighting();
CalclaviaRenderHelper.enableBlending();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture
);
CalclaviaRenderHelper.renderNormalBlockAsItem(
(Block) ModularForceFieldSystem.blockForceField, 0, new RenderBlocks()
);
CalclaviaRenderHelper.disableBlending();
GL11.glPopMatrix();
tessellator.startDrawingQuads();
Minecraft.getMinecraft().renderEngine.bindTexture(
new ResourceLocation("textures/particle/particles.png")
);
} }
GL11.glColor4d((double)super.particleRed, (double)super.particleGreen,
(double)super.particleBlue, (double)(op * 2.0f));
CalclaviaRenderHelper.disableLighting();
CalclaviaRenderHelper.enableBlending();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
CalclaviaRenderHelper.renderNormalBlockAsItem(
(Block)ModularForceFieldSystem.blockForceField, 0, new RenderBlocks());
CalclaviaRenderHelper.disableBlending();
GL11.glPopMatrix();
tessellator.startDrawingQuads();
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("textures/particle/particles.png"));
}
} }

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