chore: format code

This commit is contained in:
LordMZTE 2023-02-10 17:51:10 +01:00
parent e2e2182522
commit a267d10ac2
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
96 changed files with 3815 additions and 1754 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"]

3
.gitignore vendored
View file

@ -4,3 +4,6 @@ build
run
bin
off
.settings
.classpath
.project

View file

@ -32,8 +32,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
public class ClientProxy
extends CommonProxy {
public class ClientProxy extends CommonProxy {
@Override
public void preInit() {
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
@ -42,27 +41,52 @@ extends CommonProxy {
@Override
public void init() {
super.init();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, (TileEntitySpecialRenderer)new RenderConveyorBelt());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, (TileEntitySpecialRenderer)new RenderRejector());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, (TileEntitySpecialRenderer)new RenderManipulator());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, (TileEntitySpecialRenderer)new RenderCrate());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArmbot.class, (TileEntitySpecialRenderer)new RenderArmbot());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, (TileEntitySpecialRenderer)new RenderDetector());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCraneController.class, (TileEntitySpecialRenderer)new RenderCraneController());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCraneRail.class, (TileEntitySpecialRenderer)new RenderCraneFrame());
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityConveyorBelt.class,
(TileEntitySpecialRenderer) new RenderConveyorBelt()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityRejector.class, (TileEntitySpecialRenderer) new RenderRejector()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityManipulator.class,
(TileEntitySpecialRenderer) new RenderManipulator()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityCrate.class, (TileEntitySpecialRenderer) new RenderCrate()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityArmbot.class, (TileEntitySpecialRenderer) new RenderArmbot()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityDetector.class, (TileEntitySpecialRenderer) new RenderDetector()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityCraneController.class,
(TileEntitySpecialRenderer) new RenderCraneController()
);
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityCraneRail.class, (TileEntitySpecialRenderer) new RenderCraneFrame()
);
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object
getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 1: {
return new GuiImprinter(player.inventory, (TileEntityImprinter)tileEntity);
return new GuiImprinter(
player.inventory, (TileEntityImprinter) tileEntity
);
}
case 2: {
if (tileEntity == null || !(tileEntity instanceof TileEntityEncoder)) break;
return new GuiEncoder(player.inventory, (TileEntityEncoder)tileEntity);
if (tileEntity == null || !(tileEntity instanceof TileEntityEncoder))
break;
return new GuiEncoder(
player.inventory, (TileEntityEncoder) tileEntity
);
}
}
}
@ -74,4 +98,3 @@ extends CommonProxy {
return GuiScreen.isCtrlKeyDown();
}
}

View file

@ -12,23 +12,33 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@SideOnly(value = Side.CLIENT)
public class GuiAutoCrafting
extends GuiContainer {
public GuiAutoCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) {
super((Container)new ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5));
public class GuiAutoCrafting extends GuiContainer {
public GuiAutoCrafting(
InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5
) {
super((Container
) new ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5));
}
protected void drawGuiContainerForegroundLayer() {
this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"AutoCrafter"), 28, 6, 0x404040);
this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"container.inventory"), 8, this.ySize - 96 + 2, 0x404040);
this.fontRendererObj.drawString(
StatCollector.translateToLocal((String) "AutoCrafter"), 28, 6, 0x404040
);
this.fontRendererObj.drawString(
StatCollector.translateToLocal((String) "container.inventory"),
8,
this.ySize - 96 + 2,
0x404040
);
}
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
this.mc.renderEngine.getTexture(new ResourceLocation("assemblyline", "textures/gui/gui_crafting.png"));
this.mc.renderEngine.getTexture(
new ResourceLocation("assemblyline", "textures/gui/gui_crafting.png")
);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -5,13 +5,11 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(value = Side.CLIENT)
@Deprecated
public class GuiButtonImage
extends GuiButton {
public class GuiButtonImage extends GuiButton {
private int type = 0;
public GuiButtonImage(int par1, int par2, int par3, int type) {
@ -22,16 +20,21 @@ extends GuiButton {
@Override
public void drawButton(Minecraft par1Minecraft, int width, int hight) {
if (this.visible) {
par1Minecraft.getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/gui@.png"));
par1Minecraft.getTextureManager().bindTexture(
new ResourceLocation("assemblyline", "textures/gui@.png")
);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f);
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
boolean var4 = width >= this.xPosition && hight >= this.yPosition
&& width < this.xPosition + this.width
&& hight < this.yPosition + this.height;
int var5 = 106;
int var6 = 0;
if (var4) {
var5 += this.height;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
this.drawTexturedModalRect(
this.xPosition, this.yPosition, var6, var5, this.width, this.height
);
}
}
}

View file

@ -1,18 +1,26 @@
package assemblyline.client.gui;
import cpw.mods.fml.client.GuiScrollingList;
import java.util.ArrayList;
import cpw.mods.fml.client.GuiScrollingList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
public class GuiCommandList
extends GuiScrollingList {
public class GuiCommandList extends GuiScrollingList {
private ArrayList commands = new ArrayList();
private int selIndex = -1;
private Minecraft mc;
public GuiCommandList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) {
public GuiCommandList(
Minecraft client,
int width,
int height,
int top,
int bottom,
int left,
int entryHeight
) {
super(client, width, height, top, bottom, left, entryHeight);
this.mc = client;
}
@ -34,10 +42,32 @@ extends GuiScrollingList {
}
protected void drawBackground() {
GuiCommandList.drawOutlineRect(this.left, this.left + this.listWidth, this.top, this.top + this.listHeight, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f);
GuiCommandList.drawOutlineRect(
this.left,
this.left + this.listWidth,
this.top,
this.top + this.listHeight,
0.0f,
0.0f,
0.0f,
0.5f,
0.5f,
0.5f
);
}
public static void drawOutlineRect(int x1, int y1, int x2, int y2, float rR, float rG, float rB, float lR, float lG, float lB) {
public static void drawOutlineRect(
int x1,
int y1,
int x2,
int y2,
float rR,
float rG,
float rB,
float lR,
float lG,
float lB
) {
Tessellator tesselator = Tessellator.instance;
GL11.glEnable((int) 3042);
GL11.glDisable((int) 3553);
@ -80,14 +110,27 @@ extends GuiScrollingList {
GL11.glDisable((int) 3042);
}
protected void drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator) {
protected void
drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator) {
if (slotID < this.commands.size()) {
String command = (String) this.commands.get(slotID);
if (this.isSelected(slotID)) {
GuiCommandList.drawOutlineRect(this.left, this.left + width, this.top + slotY, this.top + slotY + slotHeight, -1.0f, -1.0f, -1.0f, 0.5f, 0.5f, 0.5f);
GuiCommandList.drawOutlineRect(
this.left,
this.left + width,
this.top + slotY,
this.top + slotY + slotHeight,
-1.0f,
-1.0f,
-1.0f,
0.5f,
0.5f,
0.5f
);
}
this.mc.fontRenderer.drawString(command, this.left + 4, slotY + 4, 0xAAAAAA, false);
this.mc.fontRenderer.drawString(
command, this.left + 4, slotY + 4, 0xAAAAAA, false
);
}
}
}

View file

@ -1,13 +1,13 @@
package assemblyline.client.gui;
import java.util.ArrayList;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.encoder.ContainerEncoder;
import assemblyline.common.machine.encoder.IInventoryWatcher;
import assemblyline.common.machine.encoder.ItemDisk;
import assemblyline.common.machine.encoder.TileEntityEncoder;
import assemblyline.common.network.MessageEncoder;
import java.util.ArrayList;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
@ -17,16 +17,12 @@ import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
public class GuiEncoder
extends GuiContainer
implements IInventoryWatcher {
public class GuiEncoder extends GuiContainer implements IInventoryWatcher {
private static final int MAX_COMMANDS = 6;
private int containerWidth;
private int containerHeight;
@ -53,11 +49,40 @@ implements IInventoryWatcher {
Keyboard.enableRepeatEvents((boolean) true);
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.addButton = new GuiButton(0, this.containerWidth + (this.xSize - 25), this.containerHeight + 128 + 0, 18, 20, "+");
this.delButton = new GuiButton(1, this.containerWidth + (this.xSize - 43), this.containerHeight + 128 + 0, 18, 20, "-");
this.pUpButton = new GuiButton(2, this.containerWidth + (this.xSize - 25), this.containerHeight + 46 + 0, 18, 20, "");
this.pDnButton = new GuiButton(3, this.containerWidth + (this.xSize - 25), this.containerHeight + 106 + 0, 18, 20, "");
this.commandField = new GuiTextField(this.fontRendererObj, 8, 129, this.xSize - 52, 18);
this.addButton = new GuiButton(
0,
this.containerWidth + (this.xSize - 25),
this.containerHeight + 128 + 0,
18,
20,
"+"
);
this.delButton = new GuiButton(
1,
this.containerWidth + (this.xSize - 43),
this.containerHeight + 128 + 0,
18,
20,
"-"
);
this.pUpButton = new GuiButton(
2,
this.containerWidth + (this.xSize - 25),
this.containerHeight + 46 + 0,
18,
20,
""
);
this.pDnButton = new GuiButton(
3,
this.containerWidth + (this.xSize - 25),
this.containerHeight + 106 + 0,
18,
20,
""
);
this.commandField
= new GuiTextField(this.fontRendererObj, 8, 129, this.xSize - 52, 18);
this.buttonList.add(this.addButton);
this.buttonList.add(this.delButton);
this.buttonList.add(this.pUpButton);
@ -72,12 +97,16 @@ implements IInventoryWatcher {
switch (button.id) {
case 0: {
ItemStack disk;
if (this.commandField.getText().equals("")) break;
if (this.tileEntity != null && (disk = this.tileEntity.getStackInSlot(0)) != null) {
if (this.commandField.getText().equals(""))
break;
if (this.tileEntity != null
&& (disk = this.tileEntity.getStackInSlot(0)) != null) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("create", true);
nbt.setString("newCommand", this.commandField.getText());
AssemblyLine.NETWORK.sendToServer(new MessageEncoder(new Vector3(this.tileEntity), nbt));
AssemblyLine.NETWORK.sendToServer(
new MessageEncoder(new Vector3(this.tileEntity), nbt)
);
}
this.minCommand = this.commands.size() - 6 + 1;
if (this.minCommand < 0) {
@ -88,24 +117,30 @@ implements IInventoryWatcher {
break;
}
case 1: {
if (this.tileEntity == null) break;
if (this.tileEntity == null)
break;
ItemStack disk = this.tileEntity.getStackInSlot(0);
if (disk != null && this.selCommand >= 0 && this.selCommand < this.commands.size()) {
if (disk != null && this.selCommand >= 0
&& this.selCommand < this.commands.size()) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("create", false);
nbt.setInteger("commandToRemove", this.selCommand);
AssemblyLine.NETWORK.sendToServer(new MessageEncoder(new Vector3(this.tileEntity), nbt));
AssemblyLine.NETWORK.sendToServer(
new MessageEncoder(new Vector3(this.tileEntity), nbt)
);
}
this.selCommand = -1;
break;
}
case 2: {
if (this.minCommand <= 0) break;
if (this.minCommand <= 0)
break;
--this.minCommand;
break;
}
case 3: {
if (this.minCommand + 6 >= this.commands.size()) break;
if (this.minCommand + 6 >= this.commands.size())
break;
++this.minCommand;
}
}
@ -115,15 +150,25 @@ implements IInventoryWatcher {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f);
GL11.glDisable((int) 2896);
this.fontRendererObj.drawString(TranslationHelper.getLocal("tile.encoder.name"), 68, 8, 0x404040);
this.fontRendererObj.drawString(
TranslationHelper.getLocal("tile.encoder.name"), 68, 8, 0x404040
);
this.fontRendererObj.drawString("Disk:", 56, 28, 0x404040);
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.pUpButton.xPosition - this.containerWidth + 6), (float)(this.pUpButton.yPosition - this.containerHeight + 7), (float)0.0f);
GL11.glTranslatef(
(float) (this.pUpButton.xPosition - this.containerWidth + 6),
(float) (this.pUpButton.yPosition - this.containerHeight + 7),
(float) 0.0f
);
this.fontRendererObj.drawString("^", 1, 1, 0x444444);
this.fontRendererObj.drawString("^", 0, 0, 0xFFFFFF);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.pDnButton.xPosition - this.containerWidth + 6), (float)(this.pDnButton.yPosition - this.containerHeight + 7), (float)0.0f);
GL11.glTranslatef(
(float) (this.pDnButton.xPosition - this.containerWidth + 6),
(float) (this.pDnButton.yPosition - this.containerHeight + 7),
(float) 0.0f
);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
GL11.glTranslatef((float) -5.0f, (float) -4.0f, (float) 0.0f);
this.fontRendererObj.drawString("^", -1, -1, 0x444444);
@ -137,30 +182,54 @@ implements IInventoryWatcher {
private void drawCommands() {
for (int i = this.minCommand; i < this.minCommand + 6; ++i) {
if (i < 0 || i >= this.commands.size()) continue;
if (i < 0 || i >= this.commands.size())
continue;
int relativeCommand = i - this.minCommand;
String command = ((String) this.commands.get(i)).toUpperCase();
this.drawCommand(command, 8, 47 + relativeCommand * (this.fontRendererObj.FONT_HEIGHT + 4), this.selCommand == i);
this.drawCommand(
command,
8,
47 + relativeCommand * (this.fontRendererObj.FONT_HEIGHT + 4),
this.selCommand == i
);
}
}
private void drawCommand(String command, int x, int y, boolean selected) {
if (selected) {
GuiEncoder.drawOutlineRect(x, y, x + 142, y + this.fontRendererObj.FONT_HEIGHT + 4, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
GuiEncoder.drawOutlineRect(
x,
y,
x + 142,
y + this.fontRendererObj.FONT_HEIGHT + 4,
0.0f,
0.0f,
0.0f,
1.0f,
1.0f,
1.0f
);
}
this.fontRendererObj.drawString(command, x + 3, y + this.fontRendererObj.FONT_HEIGHT / 2 - 1, 0xFFFFFF, false);
this.fontRendererObj.drawString(
command, x + 3, y + this.fontRendererObj.FONT_HEIGHT / 2 - 1, 0xFFFFFF, false
);
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
this.commandField.mouseClicked(x - this.containerWidth, y - this.containerHeight, button);
this.commandField.mouseClicked(
x - this.containerWidth, y - this.containerHeight, button
);
if (button == 0) {
if (x >= this.containerWidth + 8) {
if (y >= this.containerHeight + 47 + 0) {
if (x <= this.containerWidth + (this.xSize - 25)) {
if (y <= this.containerHeight + 46 + 80 + 0) {
this.listClicked(x - (this.containerWidth + 8), y - (this.containerHeight + 47 + 0));
this.listClicked(
x - (this.containerWidth + 8),
y - (this.containerHeight + 47 + 0)
);
} else {
this.selCommand = -1;
}
@ -207,7 +276,8 @@ implements IInventoryWatcher {
if (this.selCommand < this.minCommand && this.selCommand >= 0) {
this.minCommand = this.selCommand;
}
if (this.selCommand >= this.minCommand + 6 && this.selCommand < this.commands.size()) {
if (this.selCommand >= this.minCommand + 6
&& this.selCommand < this.commands.size()) {
this.minCommand = this.selCommand - 6 + 1;
}
} else if (keycode == 208) {
@ -215,7 +285,8 @@ implements IInventoryWatcher {
if (this.selCommand >= this.commands.size()) {
this.selCommand = -1;
}
if (this.selCommand >= this.minCommand + 6 && this.selCommand < this.commands.size()) {
if (this.selCommand >= this.minCommand + 6
&& this.selCommand < this.commands.size()) {
this.minCommand = this.selCommand - 6 + 1;
}
if (this.selCommand < this.minCommand && this.selCommand >= 0) {
@ -226,13 +297,39 @@ implements IInventoryWatcher {
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
this.mc.renderEngine.bindTexture(new ResourceLocation("assemblyline", "textures/gui/gui_encoder.png"));
this.mc.renderEngine.bindTexture(
new ResourceLocation("assemblyline", "textures/gui/gui_encoder.png")
);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f);
this.drawTexturedModalRect(this.containerWidth, this.containerHeight + 0, 0, 0, this.xSize, this.ySize);
GuiEncoder.drawOutlineRect(this.containerWidth + 7, this.containerHeight + 46 + 0, this.containerWidth + (this.xSize - 25), this.containerHeight + 46 + 80 + 0, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f);
this.drawTexturedModalRect(
this.containerWidth, this.containerHeight + 0, 0, 0, this.xSize, this.ySize
);
GuiEncoder.drawOutlineRect(
this.containerWidth + 7,
this.containerHeight + 46 + 0,
this.containerWidth + (this.xSize - 25),
this.containerHeight + 46 + 80 + 0,
0.0f,
0.0f,
0.0f,
0.5f,
0.5f,
0.5f
);
}
public static void drawOutlineRect(int x1, int y1, int x2, int y2, float rR, float rG, float rB, float lR, float lG, float lB) {
public static void drawOutlineRect(
int x1,
int y1,
int x2,
int y2,
float rR,
float rG,
float rB,
float lR,
float lG,
float lB
) {
Tessellator tesselator = Tessellator.instance;
GL11.glEnable((int) 3042);
GL11.glDisable((int) 3553);
@ -279,7 +376,8 @@ implements IInventoryWatcher {
if (this.commands != null) {
ItemStack disk;
this.commands.clear();
if (this.tileEntity != null && (disk = this.tileEntity.getStackInSlot(0)) != null) {
if (this.tileEntity != null
&& (disk = this.tileEntity.getStackInSlot(0)) != null) {
this.commands = ItemDisk.getCommands(disk);
}
if (this.minCommand + 6 >= this.commands.size()) {
@ -302,4 +400,3 @@ implements IInventoryWatcher {
this.updateCommands();
}
}

View file

@ -6,17 +6,17 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.prefab.TranslationHelper;
public class GuiImprinter
extends GuiContainer {
public class GuiImprinter extends GuiContainer {
private int containerWidth;
private int containerHeight;
private TileEntityImprinter tileEntity;
public GuiImprinter(InventoryPlayer par1InventoryPlayer, TileEntityImprinter tileEntity) {
public GuiImprinter(
InventoryPlayer par1InventoryPlayer, TileEntityImprinter tileEntity
) {
super((Container) new ContainerImprinter(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
this.ySize = 201;
@ -25,17 +25,24 @@ extends GuiContainer {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRendererObj.drawString("Use Inventories:", 70, 58, 0x404040);
this.fontRendererObj.drawString("" + this.tileEntity.searchInventories, 105, 67, 0x404040);
this.fontRendererObj.drawString(TranslationHelper.getLocal("tile.imprinter.name"), 68, 6, 0x404040);
this.fontRendererObj.drawString(
"" + this.tileEntity.searchInventories, 105, 67, 0x404040
);
this.fontRendererObj.drawString(
TranslationHelper.getLocal("tile.imprinter.name"), 68, 6, 0x404040
);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
this.mc.renderEngine.bindTexture(new ResourceLocation("assemblyline", "textures/gui/gui_imprinter.png"));
this.mc.renderEngine.bindTexture(
new ResourceLocation("assemblyline", "textures/gui/gui_imprinter.png")
);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f);
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize);
this.drawTexturedModalRect(
this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize
);
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelAngledBelt
extends ModelBase {
public class ModelAngledBelt extends ModelBase {
ModelRenderer MRoller1;
ModelRenderer bBELT;
ModelRenderer MRoller2;
@ -65,4 +64,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -5,8 +5,7 @@ import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
public class ModelArmbot
extends ModelBase {
public class ModelArmbot extends ModelBase {
ModelRenderer baseTop;
ModelRenderer base;
ModelRenderer armMountRight;
@ -111,7 +110,8 @@ extends ModelBase {
this.setRotation(this.clampClawLower3, 2.897247f, 0.0f, 0.0f);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
public void
render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.render(f5, entity.rotationYaw, entity.rotationPitch);
@ -129,12 +129,16 @@ extends ModelBase {
GL11.glPushMatrix();
GL11.glRotatef((float) rotationYaw, (float) 0.0f, (float) 1.0f, (float) 0.0f);
GL11.glTranslatef((float) 0.0f, (float) 0.9f, (float) 0.0f);
GL11.glRotatef((float)(-rotationPitch), (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glRotatef(
(float) (-rotationPitch), (float) 1.0f, (float) 0.0f, (float) 0.0f
);
GL11.glTranslatef((float) 0.0f, (float) -0.9f, (float) 0.0f);
this.armLower.render(f5);
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.0f, (float) 0.1f, (float) -0.35f);
GL11.glRotatef((float)(-rotationPitch), (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glRotatef(
(float) (-rotationPitch), (float) 1.0f, (float) 0.0f, (float) 0.0f
);
GL11.glTranslatef((float) 0.0f, (float) -0.05f, (float) 0.35f);
this.armUpper.render(f5);
this.clampBody.render(f5);
@ -151,4 +155,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelConveyorBelt
extends ModelBase {
public class ModelConveyorBelt extends ModelBase {
ModelRenderer bBELTLong;
ModelRenderer FBELT;
ModelRenderer BacBELT;
@ -158,7 +157,9 @@ extends ModelBase {
this.setRotation(this.c1, 0.0f, 0.0f, 0.0f);
}
public void render(float f5, float radians, boolean front, boolean back, boolean above, boolean legs) {
public void render(
float f5, float radians, boolean front, boolean back, boolean above, boolean legs
) {
boolean rightCap;
boolean mid = front && back;
boolean leftCap = !front && back;
@ -214,4 +215,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelCraneArmMount
extends ModelBase {
public class ModelCraneArmMount extends ModelBase {
private ModelRenderer RailGuard1;
private ModelRenderer ArmMount;
private ModelRenderer RailGuard2;
@ -84,4 +83,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelCraneController
extends ModelBase {
public class ModelCraneController extends ModelBase {
ModelRenderer Base2;
ModelRenderer Base;
ModelRenderer ConnectorFront;
@ -114,4 +113,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelCraneRail
extends ModelBase {
public class ModelCraneRail extends ModelBase {
ModelRenderer SegmentUBLeft;
ModelRenderer SegmentUFLeft;
ModelRenderer SegmentBFLeft;
@ -381,7 +380,15 @@ extends ModelBase {
this.SegmentBBLeft.setRotationPoint(4.0f, 19.0f, 3.0f);
}
public void render(boolean up, boolean down, boolean left, boolean right, boolean front, boolean back, boolean foot) {
public void render(
boolean up,
boolean down,
boolean left,
boolean right,
boolean front,
boolean back,
boolean foot
) {
float scale = 0.0625f;
if (up) {
this.SegmentLBUp.render(scale);
@ -451,4 +458,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelDropBox
extends ModelBase {
public class ModelDropBox extends ModelBase {
ModelRenderer Left;
ModelRenderer Top;
ModelRenderer Front;
@ -100,4 +99,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -2,7 +2,6 @@ package assemblyline.client.model;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class ModelHelper {
@ -15,7 +14,8 @@ public class ModelHelper {
private static float texScale = 16.0f;
private static boolean clip = false;
private static void drawQuadRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, ForgeDirection side) {
private static void
drawQuadRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, ForgeDirection side) {
float yMax;
float xMax;
GL11.glBegin((int) 7);
@ -93,7 +93,9 @@ public class ModelHelper {
GL11.glEnd();
}
private static void drawCuboidRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, Vec3 v5, Vec3 v6, Vec3 v7, Vec3 v8) {
private static void drawCuboidRaw(
Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, Vec3 v5, Vec3 v6, Vec3 v7, Vec3 v8
) {
ModelHelper.drawQuadRaw(v1, v2, v3, v4, ForgeDirection.UP);
ModelHelper.drawQuadRaw(v7, v6, v3, v2, ForgeDirection.EAST);
ModelHelper.drawQuadRaw(v5, v6, v7, v8, ForgeDirection.DOWN);
@ -102,7 +104,9 @@ public class ModelHelper {
ModelHelper.drawQuadRaw(v8, v7, v2, v1, ForgeDirection.SOUTH);
}
public static void drawCuboid(float xOffset, float yOffset, float zOffset, float xSize, float ySize, float zSize) {
public static void drawCuboid(
float xOffset, float yOffset, float zOffset, float xSize, float ySize, float zSize
) {
float x = xOffset;
float y = yOffset;
float z = zOffset;
@ -139,4 +143,3 @@ public class ModelHelper {
ModelHelper.clip = clip;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelLaserDrill
extends ModelBase {
public class ModelLaserDrill extends ModelBase {
ModelRenderer Tip;
ModelRenderer Upper_plating;
ModelRenderer Middle_plating;
@ -132,4 +131,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelManipulator
extends ModelBase {
public class ModelManipulator extends ModelBase {
ModelRenderer bBELTLong;
ModelRenderer FBELT;
ModelRenderer BacPanel;
@ -186,4 +185,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelRejectorPiston
extends ModelBase {
public class ModelRejectorPiston extends ModelBase {
ModelRenderer BodyBottom;
ModelRenderer PistonFace2;
ModelRenderer PistonShaft;
@ -154,4 +153,3 @@ extends ModelBase {
model.rotateAngleZ = z;
}
}

View file

@ -16,26 +16,31 @@ import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
@SideOnly(value = Side.CLIENT)
public class BlockRenderingHandler
implements ISimpleBlockRenderingHandler {
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler {
public static BlockRenderingHandler instance = new BlockRenderingHandler();
public static final int BLOCK_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static final int BLOCK_RENDER_ID
= RenderingRegistry.getNextAvailableRenderId();
private ModelConveyorBelt modelConveyorBelt = new ModelConveyorBelt();
private ModelRejectorPiston modelEjector = new ModelRejectorPiston();
private ModelManipulator modelInjector = new ModelManipulator();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
public void
renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
if (block == AssemblyLine.blockConveyorBelt) {
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.0f, (float) 1.5f, (float) 0.0f);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/belt/frame0.png"));
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(
new ResourceLocation("assemblyline", "textures/models/belt/frame0.png")
);
this.modelConveyorBelt.render(0.0625f, 0.0f, false, false, false, false);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockRejector) {
FMLClientHandler.instance().getClient().getTextureManager();
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/rejector.png"));
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(
new ResourceLocation("assemblyline", "textures/models/rejector.png")
);
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.6f, (float) 1.5f, (float) 0.6f);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
@ -44,7 +49,9 @@ implements ISimpleBlockRenderingHandler {
this.modelEjector.renderPiston(0.0625f, 1);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockManipulator) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/manipulator1.png"));
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(
new ResourceLocation("assemblyline", "textures/models/manipulator1.png")
);
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.6f, (float) 1.5f, (float) 0.6f);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
@ -52,7 +59,9 @@ implements ISimpleBlockRenderingHandler {
this.modelInjector.render(0.0625f, true, 0);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockArmbot) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/armbot.png"));
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(
new ResourceLocation("assemblyline", "textures/models/armbot.png")
);
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.4f, (float) 0.8f, (float) 0.0f);
GL11.glScalef((float) 0.7f, (float) 0.7f, (float) 0.7f);
@ -61,7 +70,11 @@ implements ISimpleBlockRenderingHandler {
RenderArmbot.MODEL.render(0.0625f, 0.0f, 0.0f);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockCraneController) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/crane_controller_off.png"));
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(
new ResourceLocation(
"assemblyline", "textures/models/crane_controller_off.png"
)
);
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.0f, (float) 1.0f, (float) 0.0f);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
@ -69,7 +82,9 @@ implements ISimpleBlockRenderingHandler {
RenderCraneController.MODEL.render(0.0625f, false, false);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockCraneFrame) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/crane_frame.png"));
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(
new ResourceLocation("assemblyline", "textures/models/crane_frame.png")
);
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.0f, (float) 1.0f, (float) 0.0f);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
@ -80,7 +95,15 @@ implements ISimpleBlockRenderingHandler {
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
public boolean renderWorldBlock(
IBlockAccess world,
int x,
int y,
int z,
Block block,
int modelId,
RenderBlocks renderer
) {
return false;
}
@ -94,4 +117,3 @@ implements ISimpleBlockRenderingHandler {
return BLOCK_RENDER_ID;
}
}

View file

@ -13,46 +13,83 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
public class RenderArmbot
extends TileEntitySpecialRenderer {
public class RenderArmbot extends TileEntitySpecialRenderer {
public static final ModelArmbot MODEL = new ModelArmbot();
public static final String TEXTURE = "armbot.png";
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
public void
renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
if (tileEntity instanceof TileEntityArmbot) {
EntityClientPlayerMP player;
MovingObjectPosition objectPosition;
String cmdText = ((TileEntityArmbot) tileEntity).getCommandDisplayText();
if (!(cmdText == null || cmdText.isEmpty() || (objectPosition = (player = Minecraft.getMinecraft().thePlayer).rayTrace(8.0, 1.0f)) == null || objectPosition.blockX != tileEntity.xCoord || objectPosition.blockY != tileEntity.yCoord && objectPosition.blockY != tileEntity.yCoord + 1 || objectPosition.blockZ != tileEntity.zCoord)) {
RenderHelper.renderFloatingText(cmdText, (float)x + 0.5f, (float)y + 0.25f, (float)z + 0.5f, 0xFFFFFF);
if (!(cmdText == null || cmdText.isEmpty()
|| (objectPosition
= (player = Minecraft.getMinecraft().thePlayer).rayTrace(8.0, 1.0f))
== null
|| objectPosition.blockX != tileEntity.xCoord
|| objectPosition.blockY != tileEntity.yCoord
&& objectPosition.blockY != tileEntity.yCoord + 1
|| objectPosition.blockZ != tileEntity.zCoord)) {
RenderHelper.renderFloatingText(
cmdText,
(float) x + 0.5f,
(float) y + 0.25f,
(float) z + 0.5f,
0xFFFFFF
);
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/armbot.png"));
this.bindTexture(
new ResourceLocation("assemblyline", "textures/models/armbot.png")
);
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glTranslatef(
(float) ((float) x + 0.5f),
(float) ((float) y + 1.5f),
(float) ((float) z + 0.5f)
);
GL11.glScalef((float) 1.0f, (float) -1.0f, (float) -1.0f);
MODEL.render(0.0625f, ((TileEntityArmbot)tileEntity).renderYaw, ((TileEntityArmbot)tileEntity).renderPitch);
MODEL.render(
0.0625f,
((TileEntityArmbot) tileEntity).renderYaw,
((TileEntityArmbot) tileEntity).renderPitch
);
GL11.glPopMatrix();
Vector3 handPosition = ((TileEntityArmbot) tileEntity).getDeltaHandPosition();
handPosition.add(0.5);
handPosition.add(new Vector3(x, y, z));
RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
RenderItem renderItem = (RenderItem
) RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
for (ItemStack itemStack : ((TileEntityArmbot)tileEntity).getGrabbedItems()) {
if (itemStack == null) continue;
for (ItemStack itemStack :
((TileEntityArmbot) tileEntity).getGrabbedItems()) {
if (itemStack == null)
continue;
if (((TileEntityArmbot) tileEntity).renderEntityItem == null) {
((TileEntityArmbot)tileEntity).renderEntityItem = new EntityItem(tileEntity.getWorldObj(), 0.0, 0.0, 0.0, itemStack);
} else if (!itemStack.isItemEqual(((TileEntityArmbot)tileEntity).renderEntityItem.getEntityItem())) {
((TileEntityArmbot)tileEntity).renderEntityItem = new EntityItem(tileEntity.getWorldObj(), 0.0, 0.0, 0.0, itemStack);
((TileEntityArmbot) tileEntity).renderEntityItem = new EntityItem(
tileEntity.getWorldObj(), 0.0, 0.0, 0.0, itemStack
);
} else if (!itemStack.isItemEqual(((TileEntityArmbot) tileEntity)
.renderEntityItem.getEntityItem()
)) {
((TileEntityArmbot) tileEntity).renderEntityItem = new EntityItem(
tileEntity.getWorldObj(), 0.0, 0.0, 0.0, itemStack
);
}
renderItem.doRender(((TileEntityArmbot)tileEntity).renderEntityItem, handPosition.x, handPosition.y, handPosition.z, 0.0f, f);
renderItem.doRender(
((TileEntityArmbot) tileEntity).renderEntityItem,
handPosition.x,
handPosition.y,
handPosition.z,
0.0f,
f
);
break;
}
}
}
}

View file

@ -9,98 +9,159 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(value = Side.CLIENT)
public class RenderConveyorBelt
extends TileEntitySpecialRenderer {
public class RenderConveyorBelt extends TileEntitySpecialRenderer {
public static final ModelConveyorBelt MODEL = new ModelConveyorBelt();
public static final ModelAngledBelt MODEL2 = new ModelAngledBelt();
private void renderAModelAt(TileEntityConveyorBelt tileEntity, double x, double y, double z, float f) {
private void renderAModelAt(
TileEntityConveyorBelt tileEntity, double x, double y, double z, float f
) {
boolean mid = tileEntity.getIsMiddleBelt();
TileEntityConveyorBelt.SlantType slantType = tileEntity.getSlant();
int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glTranslatef(
(float) ((float) x + 0.5f),
(float) ((float) y + 1.5f),
(float) ((float) z + 0.5f)
);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
int frame = tileEntity.getAnimationFrame();
if (slantType != null && slantType != TileEntityConveyorBelt.SlantType.NONE) {
boolean slantAdjust;
switch (face) {
case 2: {
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 3: {
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) 0.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 4: {
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) 90.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 5: {
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) -90.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
}
}
if (slantType == TileEntityConveyorBelt.SlantType.UP) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/slantedbelt/frame" + frame + ".png"));
this.bindTexture(new ResourceLocation(
"assemblyline", "textures/models/slantedbelt/frame" + frame + ".png"
));
GL11.glTranslatef((float) 0.0f, (float) 0.8f, (float) -0.8f);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 1.0f);
slantAdjust = false;
TileEntity test = tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord + tileEntity.getDirection().offsetX, tileEntity.yCoord, tileEntity.zCoord + tileEntity.getDirection().offsetZ);
if (test != null && test instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)test).getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
GL11.glRotatef((float)10.0f, (float)1.0f, (float)0.0f, (float)0.0f);
TileEntity test = tileEntity.getWorldObj().getTileEntity(
tileEntity.xCoord + tileEntity.getDirection().offsetX,
tileEntity.yCoord,
tileEntity.zCoord + tileEntity.getDirection().offsetZ
);
if (test != null && test instanceof TileEntityConveyorBelt
&& ((TileEntityConveyorBelt) test).getSlant()
== TileEntityConveyorBelt.SlantType.TOP) {
GL11.glRotatef(
(float) 10.0f, (float) 1.0f, (float) 0.0f, (float) 0.0f
);
slantAdjust = true;
}
MODEL2.render(0.0625f, true);
} else if (slantType == TileEntityConveyorBelt.SlantType.DOWN) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/slantedbelt/frame" + frame + ".png"));
this.bindTexture(new ResourceLocation(
"assemblyline", "textures/models/slantedbelt/frame" + frame + ".png"
));
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f);
slantAdjust = false;
TileEntity test = tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord - tileEntity.getDirection().offsetX, tileEntity.yCoord, tileEntity.zCoord - tileEntity.getDirection().offsetZ);
if (test != null && test instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)test).getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
GL11.glRotatef((float)-10.0f, (float)1.0f, (float)0.0f, (float)0.0f);
TileEntity test = tileEntity.getWorldObj().getTileEntity(
tileEntity.xCoord - tileEntity.getDirection().offsetX,
tileEntity.yCoord,
tileEntity.zCoord - tileEntity.getDirection().offsetZ
);
if (test != null && test instanceof TileEntityConveyorBelt
&& ((TileEntityConveyorBelt) test).getSlant()
== TileEntityConveyorBelt.SlantType.TOP) {
GL11.glRotatef(
(float) -10.0f, (float) 1.0f, (float) 0.0f, (float) 0.0f
);
GL11.glTranslatef((float) 0.0f, (float) 0.25f, (float) 0.0f);
slantAdjust = true;
}
MODEL2.render(0.0625f, slantAdjust);
} else {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/belt/frame" + frame + ".png"));
this.bindTexture(new ResourceLocation(
"assemblyline", "textures/models/belt/frame" + frame + ".png"
));
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f);
GL11.glTranslatef((float) 0.0f, (float) -0.68f, (float) 0.0f);
MODEL.render(0.0625f, (float)Math.toRadians(tileEntity.wheelRotation), tileEntity.getIsLastBelt(), tileEntity.getIsFirstBelt(), false, false);
MODEL.render(
0.0625f,
(float) Math.toRadians(tileEntity.wheelRotation),
tileEntity.getIsLastBelt(),
tileEntity.getIsFirstBelt(),
false,
false
);
}
} else {
switch (face) {
case 2: {
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) 0.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 3: {
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 4: {
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) -90.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 5: {
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef(
(float) 90.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
}
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/belt/frame" + frame + ".png"));
MODEL.render(0.0625f, (float)Math.toRadians(tileEntity.wheelRotation), tileEntity.getIsLastBelt(), tileEntity.getIsFirstBelt(), false, true);
this.bindTexture(new ResourceLocation(
"assemblyline", "textures/models/belt/frame" + frame + ".png"
));
MODEL.render(
0.0625f,
(float) Math.toRadians(tileEntity.wheelRotation),
tileEntity.getIsLastBelt(),
tileEntity.getIsFirstBelt(),
false,
true
);
}
Block ent = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
Block ent = tileEntity.getWorldObj().getBlock(
tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord
);
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
public void renderTileEntityAt(
TileEntity tileEntity, double var2, double var4, double var6, float var8
) {
this.renderAModelAt((TileEntityConveyorBelt) tileEntity, var2, var4, var6, var8);
}
}

View file

@ -6,20 +6,29 @@ import assemblyline.common.machine.crane.TileEntityCraneController;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class RenderCraneController
extends RenderImprintable {
public class RenderCraneController extends RenderImprintable {
public static final String TEXTURE = "crane_controller_off.png";
public static final String TEXTURE_VALID = "crane_controller_on.png";
public static final ModelCraneController MODEL = new ModelCraneController();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
public void
renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
if (tileEntity != null && tileEntity instanceof TileEntityCraneController) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/" + (((TileEntityCraneController)tileEntity).isCraneValid() ? TEXTURE_VALID : TEXTURE)));
ForgeDirection front = ForgeDirection.getOrientation((int)tileEntity.getWorldObj().getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
this.bindTexture(new ResourceLocation(
"assemblyline",
"textures/models/"
+ (((TileEntityCraneController) tileEntity).isCraneValid()
? TEXTURE_VALID
: TEXTURE)
));
ForgeDirection front = ForgeDirection.getOrientation(
(int) tileEntity.getWorldObj().getBlockMetadata(
tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord
)
);
ForgeDirection right = CraneHelper.rotateClockwise(front);
float angle = 0.0f;
switch (front) {
@ -38,8 +47,20 @@ extends RenderImprintable {
int tX = tileEntity.xCoord;
int tY = tileEntity.yCoord;
int tZ = tileEntity.zCoord;
boolean connectFront = CraneHelper.canFrameConnectTo(tileEntity, tX + front.offsetX, tY, tZ + front.offsetZ, front.getOpposite());
boolean connectRight = CraneHelper.canFrameConnectTo(tileEntity, tX + right.offsetX, tY, tZ + right.offsetZ, right.getOpposite());
boolean connectFront = CraneHelper.canFrameConnectTo(
tileEntity,
tX + front.offsetX,
tY,
tZ + front.offsetZ,
front.getOpposite()
);
boolean connectRight = CraneHelper.canFrameConnectTo(
tileEntity,
tX + right.offsetX,
tY,
tZ + right.offsetZ,
right.getOpposite()
);
GL11.glPushMatrix();
GL11.glTranslated((double) (x + 0.5), (double) (y + 1.5), (double) (z + 0.5));
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
@ -50,4 +71,3 @@ extends RenderImprintable {
}
}
}

View file

@ -7,38 +7,59 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class RenderCraneFrame
extends TileEntitySpecialRenderer {
public class RenderCraneFrame extends TileEntitySpecialRenderer {
public static final String TEXTURE = "crane_frame.png";
public static final ModelCraneRail MODEL = new ModelCraneRail();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
public void
renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
if (tileEntity != null && tileEntity instanceof TileEntityCraneRail) {
int tX = tileEntity.xCoord;
int tY = tileEntity.yCoord;
int tZ = tileEntity.zCoord;
boolean renderUp = CraneHelper.canFrameConnectTo(tileEntity, tX, tY + 1, tZ, ForgeDirection.DOWN);
boolean renderDown = CraneHelper.canFrameConnectTo(tileEntity, tX, tY - 1, tZ, ForgeDirection.UP);
boolean renderLeft = CraneHelper.canFrameConnectTo(tileEntity, tX - 1, tY, tZ, ForgeDirection.EAST);
boolean renderRight = CraneHelper.canFrameConnectTo(tileEntity, tX + 1, tY, tZ, ForgeDirection.WEST);
boolean renderFront = CraneHelper.canFrameConnectTo(tileEntity, tX, tY, tZ - 1, ForgeDirection.SOUTH);
boolean renderBack = CraneHelper.canFrameConnectTo(tileEntity, tX, tY, tZ + 1, ForgeDirection.NORTH);
boolean renderFoot = tileEntity.getWorldObj().isSideSolid(tX, tY - 1, tZ, ForgeDirection.UP);
boolean renderUp = CraneHelper.canFrameConnectTo(
tileEntity, tX, tY + 1, tZ, ForgeDirection.DOWN
);
boolean renderDown = CraneHelper.canFrameConnectTo(
tileEntity, tX, tY - 1, tZ, ForgeDirection.UP
);
boolean renderLeft = CraneHelper.canFrameConnectTo(
tileEntity, tX - 1, tY, tZ, ForgeDirection.EAST
);
boolean renderRight = CraneHelper.canFrameConnectTo(
tileEntity, tX + 1, tY, tZ, ForgeDirection.WEST
);
boolean renderFront = CraneHelper.canFrameConnectTo(
tileEntity, tX, tY, tZ - 1, ForgeDirection.SOUTH
);
boolean renderBack = CraneHelper.canFrameConnectTo(
tileEntity, tX, tY, tZ + 1, ForgeDirection.NORTH
);
boolean renderFoot
= tileEntity.getWorldObj().isSideSolid(tX, tY - 1, tZ, ForgeDirection.UP);
if (renderLeft && renderRight || renderFront && renderBack) {
renderFoot = false;
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/crane_frame.png"));
this.bindTexture(
new ResourceLocation("assemblyline", "textures/models/crane_frame.png")
);
GL11.glPushMatrix();
GL11.glTranslated((double) (x + 0.5), (double) (y + 1.5), (double) (z + 0.5));
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
GL11.glEnable((int) 2896);
MODEL.render(renderUp, renderDown && !renderFoot, renderLeft, renderRight, renderFront, renderBack, renderFoot);
MODEL.render(
renderUp,
renderDown && !renderFoot,
renderLeft,
renderRight,
renderFront,
renderBack,
renderFoot
);
GL11.glPopMatrix();
}
}
}

View file

@ -15,21 +15,21 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
public class RenderCrate
extends TileEntitySpecialRenderer {
public class RenderCrate extends TileEntitySpecialRenderer {
private final RenderBlocks renderBlocks = new RenderBlocks();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
public void
renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
Vector3 vec = new Vector3(x, y, z);
double distance = vec.distanceTo(new Vector3(0.0, 0.0, 0.0));
if (tileEntity instanceof TileEntityCrate && distance < 15.0) {
TileEntityCrate tileCrate = (TileEntityCrate) tileEntity;
RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
RenderItem renderItem = (RenderItem
) RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
String itemName = "Empty";
String amount = "";
ItemStack itemStack = tileCrate.getStackInSlot(0);
@ -39,44 +39,89 @@ extends TileEntitySpecialRenderer {
}
for (int side = 2; side < 6; ++side) {
ForgeDirection direction = ForgeDirection.getOrientation((int) side);
if (tileCrate.getWorldObj().isSideSolid(tileCrate.xCoord + direction.offsetX, tileCrate.yCoord, tileCrate.zCoord + direction.offsetZ, direction.getOpposite())) continue;
if (tileCrate.getWorldObj().isSideSolid(
tileCrate.xCoord + direction.offsetX,
tileCrate.yCoord,
tileCrate.zCoord + direction.offsetZ,
direction.getOpposite()
))
continue;
this.setupLight(tileCrate, direction.offsetX, direction.offsetZ);
OpenGlHelper.setLightmapTextureCoords((int)OpenGlHelper.lightmapTexUnit, (float)240.0f, (float)240.0f);
OpenGlHelper.setLightmapTextureCoords(
(int) OpenGlHelper.lightmapTexUnit, (float) 240.0f, (float) 240.0f
);
if (itemStack != null) {
GL11.glPushMatrix();
switch (side) {
case 2: {
GL11.glTranslated((double)(x + 0.65), (double)(y + 0.9), (double)(z - 0.01));
GL11.glTranslated(
(double) (x + 0.65),
(double) (y + 0.9),
(double) (z - 0.01)
);
break;
}
case 3: {
GL11.glTranslated((double)(x + 0.35), (double)(y + 0.9), (double)(z + 1.01));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glTranslated(
(double) (x + 0.35),
(double) (y + 0.9),
(double) (z + 1.01)
);
GL11.glRotatef(
(float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 4: {
GL11.glTranslated((double)(x - 0.01), (double)(y + 0.9), (double)(z + 0.35));
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glTranslated(
(double) (x - 0.01),
(double) (y + 0.9),
(double) (z + 0.35)
);
GL11.glRotatef(
(float) 90.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
break;
}
case 5: {
GL11.glTranslated((double)(x + 1.01), (double)(y + 0.9), (double)(z + 0.65));
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glTranslated(
(double) (x + 1.01),
(double) (y + 0.9),
(double) (z + 0.65)
);
GL11.glRotatef(
(float) -90.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f
);
}
}
float scale = 0.03125f;
GL11.glScalef((float)(0.6f * scale), (float)(0.6f * scale), (float)0.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glScalef(
(float) (0.6f * scale), (float) (0.6f * scale), (float) 0.0f
);
GL11.glRotatef(
(float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f
);
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
GL11.glDisable((int) 2896);
if (!ForgeHooksClient.renderInventoryItem((RenderBlocks)this.renderBlocks, renderEngine, (ItemStack)itemStack, (boolean)true, (float)0.0f, (float)0.0f, (float)0.0f)) {
renderItem.renderItemIntoGUI(this.func_147498_b(), renderEngine, itemStack, 0, 0);
if (!ForgeHooksClient.renderInventoryItem(
(RenderBlocks) this.renderBlocks,
renderEngine,
(ItemStack) itemStack,
(boolean) true,
(float) 0.0f,
(float) 0.0f,
(float) 0.0f
)) {
renderItem.renderItemIntoGUI(
this.func_147498_b(), renderEngine, itemStack, 0, 0
);
}
GL11.glEnable((int) 2896);
GL11.glPopMatrix();
}
this.renderText(itemName, side, 0.02f, x, y - (double) 0.35f, z);
if (amount == "") continue;
if (amount == "")
continue;
this.renderText(amount, side, 0.02f, x, y - (double) 0.15f, z);
}
}
@ -84,17 +129,33 @@ extends TileEntitySpecialRenderer {
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference) {
World world = tileEntity.getWorldObj();
if (world.getBlock(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference).isOpaqueCube()) {
if (world
.getBlock(
tileEntity.xCoord + xDifference,
tileEntity.yCoord,
tileEntity.zCoord + zDifference
)
.isOpaqueCube()) {
return;
}
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
int br = world.getLightBrightnessForSkyBlocks(
tileEntity.xCoord + xDifference,
tileEntity.yCoord,
tileEntity.zCoord + zDifference,
0
);
int var11 = br % 65536;
int var12 = br / 65536;
float scale = 0.6f;
OpenGlHelper.setLightmapTextureCoords((int)OpenGlHelper.lightmapTexUnit, (float)((float)var11 * scale), (float)((float)var12 * scale));
OpenGlHelper.setLightmapTextureCoords(
(int) OpenGlHelper.lightmapTexUnit,
(float) ((float) var11 * scale),
(float) ((float) var12 * scale)
);
}
private void renderText(String text, int side, float maxScale, double x, double y, double z) {
private void
renderText(String text, int side, float maxScale, double x, double y, double z) {
GL11.glPushMatrix();
GL11.glPolygonOffset((float) -10.0f, (float) -10.0f);
GL11.glEnable((int) 32823);
@ -128,7 +189,9 @@ extends TileEntitySpecialRenderer {
GL11.glRotatef((float) 90.0f, (float) 1.0f, (float) 0.0f, (float) 0.0f);
}
}
GL11.glTranslatef((float)(displayWidth / 2.0f), (float)1.0f, (float)(displayHeight / 2.0f));
GL11.glTranslatef(
(float) (displayWidth / 2.0f), (float) 1.0f, (float) (displayHeight / 2.0f)
);
GL11.glRotatef((float) -90.0f, (float) 1.0f, (float) 0.0f, (float) 0.0f);
FontRenderer fontRenderer = super.func_147498_b();
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
@ -148,11 +211,12 @@ extends TileEntitySpecialRenderer {
int offsetX = (realWidth - requiredWidth) / 2;
int offsetY = (realHeight - requiredHeight) / 2;
GL11.glDisable((int) 2896);
fontRenderer.drawString("\u00a7f" + text, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2, 1);
fontRenderer.drawString(
"\u00a7f" + text, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2, 1
);
GL11.glEnable((int) 2896);
GL11.glDepthMask((boolean) true);
GL11.glDisable((int) 32823);
GL11.glPopMatrix();
}
}

View file

@ -8,10 +8,10 @@ import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
@SideOnly(value = Side.CLIENT)
public class RenderDetector
extends RenderImprintable {
public class RenderDetector extends RenderImprintable {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
public void
renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
super.renderTileEntityAt(tileEntity, x, y, z, var8);
}
@ -35,4 +35,3 @@ extends RenderImprintable {
GL11.glPopMatrix();
}
}

View file

@ -11,7 +11,8 @@ public class RenderHelper {
RenderHelper.renderFloatingText(text, x, y, z, 0xFFFFFF);
}
public static void renderFloatingText(String text, float x, float y, float z, int color) {
public static void
renderFloatingText(String text, float x, float y, float z, int color) {
RenderManager renderManager = RenderManager.instance;
FontRenderer fontRenderer = renderManager.getFontRenderer();
float scale = 0.027f;
@ -19,11 +20,17 @@ public class RenderHelper {
GL11.glPushMatrix();
GL11.glTranslatef((float) (x + 0.0f), (float) (y + 2.3f), (float) z);
GL11.glNormal3f((float) 0.0f, (float) 1.0f, (float) 0.0f);
GL11.glRotatef((float)(-renderManager.playerViewY), (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)renderManager.playerViewX, (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glRotatef(
(float) (-renderManager.playerViewY), (float) 0.0f, (float) 1.0f, (float) 0.0f
);
GL11.glRotatef(
(float) renderManager.playerViewX, (float) 1.0f, (float) 0.0f, (float) 0.0f
);
GL11.glScalef((float) (-scale), (float) (-scale), (float) scale);
GL11.glDisable((int) 2896);
OpenGlHelper.setLightmapTextureCoords((int)OpenGlHelper.lightmapTexUnit, (float)240.0f, (float)240.0f);
OpenGlHelper.setLightmapTextureCoords(
(int) OpenGlHelper.lightmapTexUnit, (float) 240.0f, (float) 240.0f
);
GL11.glDepthMask((boolean) false);
GL11.glDisable((int) 2929);
GL11.glEnable((int) 3042);
@ -41,14 +48,17 @@ public class RenderHelper {
tessellator.draw();
GL11.glEnable((int) 3553);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 0.5f);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
fontRenderer.drawString(
text, -fontRenderer.getStringWidth(text) / 2, yOffset, color
);
GL11.glEnable((int) 2929);
GL11.glDepthMask((boolean) true);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
fontRenderer.drawString(
text, -fontRenderer.getStringWidth(text) / 2, yOffset, color
);
GL11.glEnable((int) 2896);
GL11.glDisable((int) 3042);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f);
GL11.glPopMatrix();
}
}

View file

@ -1,8 +1,9 @@
package assemblyline.client.render;
import java.util.ArrayList;
import assemblyline.common.machine.imprinter.ItemImprinter;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -11,24 +12,55 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
public abstract class RenderImprintable
extends TileEntitySpecialRenderer {
public abstract class RenderImprintable extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
public void
renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
EntityClientPlayerMP player;
MovingObjectPosition objectPosition;
TileEntityFilterable tileFilterable;
ItemStack filter;
if (tileEntity != null && tileEntity instanceof TileEntityFilterable && (filter = (tileFilterable = (TileEntityFilterable)tileEntity).getFilter()) != null && (objectPosition = (player = Minecraft.getMinecraft().thePlayer).rayTrace(8.0, 1.0f)) != null && objectPosition.blockX == tileFilterable.xCoord && objectPosition.blockY == tileFilterable.yCoord && objectPosition.blockZ == tileFilterable.zCoord) {
if (tileEntity != null && tileEntity instanceof TileEntityFilterable
&& (filter = (tileFilterable = (TileEntityFilterable) tileEntity).getFilter())
!= null
&& (objectPosition
= (player = Minecraft.getMinecraft().thePlayer).rayTrace(8.0, 1.0f))
!= null
&& objectPosition.blockX == tileFilterable.xCoord
&& objectPosition.blockY == tileFilterable.yCoord
&& objectPosition.blockZ == tileFilterable.zCoord) {
ArrayList filters = ItemImprinter.getFilters(filter);
for (int i = 0; i < filters.size(); ++i) {
if (((TileEntityFilterable) tileEntity).isInverted()) {
RenderHelper.renderFloatingText(((ItemStack)filters.get(i)).getTooltip((EntityPlayer)player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float)x + 0.5f, (float)y + (float)i * 0.25f - 1.0f, (float)z + 0.5f, 0xFF8888);
RenderHelper.renderFloatingText(
((ItemStack) filters.get(i))
.getTooltip(
(EntityPlayer) player,
Minecraft.getMinecraft().gameSettings.advancedItemTooltips
)
.get(0)
.toString(),
(float) x + 0.5f,
(float) y + (float) i * 0.25f - 1.0f,
(float) z + 0.5f,
0xFF8888
);
continue;
}
RenderHelper.renderFloatingText(((ItemStack)filters.get(i)).getTooltip((EntityPlayer)player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float)x + 0.5f, (float)y + (float)i * 0.25f - 1.0f, (float)z + 0.5f, 0x88FF88);
RenderHelper.renderFloatingText(
((ItemStack) filters.get(i))
.getTooltip(
(EntityPlayer) player,
Minecraft.getMinecraft().gameSettings.advancedItemTooltips
)
.get(0)
.toString(),
(float) x + 0.5f,
(float) y + (float) i * 0.25f - 1.0f,
(float) z + 0.5f,
0x88FF88
);
}
}
}
}

View file

@ -4,22 +4,30 @@ import assemblyline.client.model.ModelManipulator;
import assemblyline.common.machine.TileEntityManipulator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class RenderManipulator
extends RenderImprintable {
public class RenderManipulator extends RenderImprintable {
private ModelManipulator model = new ModelManipulator();
private void renderAModelAt(TileEntityManipulator tileEntity, double x, double y, double z, float f) {
private void renderAModelAt(
TileEntityManipulator tileEntity, double x, double y, double z, float f
) {
int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glTranslatef(
(float) ((float) x + 0.5f),
(float) ((float) y + 1.5f),
(float) ((float) z + 0.5f)
);
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 0.0f, (float) 1.0f);
if (tileEntity.isOutput()) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/manipulator1.png"));
this.bindTexture(
new ResourceLocation("assemblyline", "textures/models/manipulator1.png")
);
} else {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/manipulator2.png"));
this.bindTexture(
new ResourceLocation("assemblyline", "textures/models/manipulator2.png")
);
}
if (face == 2) {
GL11.glRotatef((float) 0.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f);
@ -35,9 +43,10 @@ extends RenderImprintable {
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
public void renderTileEntityAt(
TileEntity tileEntity, double var2, double var4, double var6, float var8
) {
this.renderAModelAt((TileEntityManipulator) tileEntity, var2, var4, var6, var8);
super.renderTileEntityAt(tileEntity, var2, var4, var6, var8);
}
}

View file

@ -4,23 +4,28 @@ import assemblyline.client.model.ModelRejectorPiston;
import assemblyline.common.machine.TileEntityRejector;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class RenderRejector
extends RenderImprintable {
public class RenderRejector extends RenderImprintable {
private ModelRejectorPiston model = new ModelRejectorPiston();
private void renderAModelAt(TileEntityRejector tileEntity, double x, double y, double z, float f) {
private void
renderAModelAt(TileEntityRejector tileEntity, double x, double y, double z, float f) {
boolean fire = tileEntity.firePiston;
int face = tileEntity.getDirection().ordinal();
int pos = 0;
if (fire) {
pos = 8;
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/rejector.png"));
this.bindTexture(
new ResourceLocation("assemblyline", "textures/models/rejector.png")
);
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glTranslatef(
(float) ((float) x + 0.5f),
(float) ((float) y + 1.5f),
(float) ((float) z + 0.5f)
);
GL11.glScalef((float) 1.0f, (float) -1.0f, (float) -1.0f);
if (face == 2) {
GL11.glRotatef((float) 180.0f, (float) 0.0f, (float) 1.0f, (float) 0.0f);
@ -38,9 +43,10 @@ extends RenderImprintable {
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
public void renderTileEntityAt(
TileEntity tileEntity, double var2, double var4, double var6, float var8
) {
this.renderAModelAt((TileEntityRejector) tileEntity, var2, var4, var6, var8);
super.renderTileEntityAt(tileEntity, var2, var4, var6, var8);
}
}

View file

@ -1,5 +1,9 @@
package assemblyline.common;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Logger;
import assemblyline.common.CommonProxy;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockCrate;
@ -23,9 +27,9 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IGuiHandler;
@ -33,9 +37,6 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@ -48,13 +49,22 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.multiblock.BlockMulti;
@Mod(modid="AssemblyLine", name="Assembly Line", version=AssemblyLine.VERSION, dependencies="required-after:basiccomponents", useMetadata=true)
@Mod(
modid = "AssemblyLine",
name = "Assembly Line",
version = AssemblyLine.VERSION,
dependencies = "required-after:basiccomponents",
useMetadata = true
)
public class AssemblyLine {
public static final String MOD_ID = "AssemblyLine";
public static final String MOD_NAME = "Assembly Line";
public static final String VERSION = "1.0.2";
public static final String CHANNEL = "AssemblyLine";
@SidedProxy(clientSide="assemblyline.client.ClientProxy", serverSide="assemblyline.common.CommonProxy")
@SidedProxy(
clientSide = "assemblyline.client.ClientProxy",
serverSide = "assemblyline.common.CommonProxy"
)
public static CommonProxy proxy;
@Mod.Instance(value = "AssemblyLine")
public static AssemblyLine instance;
@ -104,11 +114,14 @@ public class AssemblyLine {
blockTurntable = new BlockTurntable();
itemImprint = new ItemImprinter();
itemDisk = new ItemDisk();
REQUIRE_NO_POWER = !CONFIGURATION.get("general", "requirePower", true).getBoolean(true);
REQUIRE_NO_POWER
= !CONFIGURATION.get("general", "requirePower", true).getBoolean(true);
CONFIGURATION.save();
NetworkRegistry.INSTANCE.registerGuiHandler((Object) this, (IGuiHandler) proxy);
NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
NETWORK.registerMessage(new MessageEncoderHandler(), MessageEncoder.class, 0, Side.SERVER);
NETWORK.registerMessage(
new MessageEncoderHandler(), MessageEncoder.class, 0, Side.SERVER
);
GameRegistry.registerBlock(blockConveyorBelt, "conveyor_belt");
GameRegistry.registerBlock(blockCrate, ItemBlockCrate.class, "crate");
GameRegistry.registerBlock(blockManipulator, "manipulator");
@ -131,42 +144,186 @@ public class AssemblyLine {
public void load(FMLInitializationEvent evt) {
proxy.init();
GrabDictionary.registerList();
FMLog.info("Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages.");
FMLog.info(
"Loaded: "
+ TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED)
+ " languages."
);
this.createStandardRecipes();
this.createUERecipes();
}
private void createUERecipes() {
System.out.println("BasicComponents Found...adding UE recipes for Assembly Line.");
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockArmbot, new Object[]{"II ", "SIS", "MCM", Character.valueOf('S'), "plateSteel", Character.valueOf('C'), "circuitAdvanced", Character.valueOf('I'), "ingotSteel", Character.valueOf('M'), "motor"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(itemDisk, new Object[]{"III", "ICI", "III", Character.valueOf('I'), itemImprint, Character.valueOf('C'), "circuitAdvanced"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockEncoder, new Object[]{"SIS", "SCS", "SSS", Character.valueOf('I'), itemImprint, Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitAdvanced"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockDetector, new Object[]{"SES", "SCS", "S S", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitBasic", Character.valueOf('E'), Items.ender_eye}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 10), new Object[]{"III", "WMW", Character.valueOf('I'), "ingotSteel", Character.valueOf('W'), Blocks.planks, Character.valueOf('M'), "motor"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockRejector, new Object[]{"WPW", "@R@", Character.valueOf('@'), "ingotSteel", Character.valueOf('R'), Items.redstone, Character.valueOf('P'), Blocks.piston, Character.valueOf('C'), "circuitBasic", Character.valueOf('W'), "copperWire"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockTurntable, new Object[]{"M", "P", Character.valueOf('M'), "motor", Character.valueOf('P'), Blocks.piston}));
GameRegistry.addRecipe((IRecipe)new ShapelessOreRecipe(new ItemStack(blockManipulator, 2), new Object[]{Blocks.dispenser, "circuitBasic"}));
System.out.println("BasicComponents Found...adding UE recipes for Assembly Line."
);
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
blockArmbot,
new Object[] { "II ",
"SIS",
"MCM",
Character.valueOf('S'),
"plateSteel",
Character.valueOf('C'),
"circuitAdvanced",
Character.valueOf('I'),
"ingotSteel",
Character.valueOf('M'),
"motor" }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
itemDisk,
new Object[] { "III",
"ICI",
"III",
Character.valueOf('I'),
itemImprint,
Character.valueOf('C'),
"circuitAdvanced" }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
blockEncoder,
new Object[] { "SIS",
"SCS",
"SSS",
Character.valueOf('I'),
itemImprint,
Character.valueOf('S'),
"ingotSteel",
Character.valueOf('C'),
"circuitAdvanced" }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
blockDetector,
new Object[] { "SES",
"SCS",
"S S",
Character.valueOf('S'),
"ingotSteel",
Character.valueOf('C'),
"circuitBasic",
Character.valueOf('E'),
Items.ender_eye }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(blockConveyorBelt, 10),
new Object[] { "III",
"WMW",
Character.valueOf('I'),
"ingotSteel",
Character.valueOf('W'),
Blocks.planks,
Character.valueOf('M'),
"motor" }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
blockRejector,
new Object[] { "WPW",
"@R@",
Character.valueOf('@'),
"ingotSteel",
Character.valueOf('R'),
Items.redstone,
Character.valueOf('P'),
Blocks.piston,
Character.valueOf('C'),
"circuitBasic",
Character.valueOf('W'),
"copperWire" }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
blockTurntable,
new Object[] { "M",
"P",
Character.valueOf('M'),
"motor",
Character.valueOf('P'),
Blocks.piston }
));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(blockManipulator, 2),
new Object[] { Blocks.dispenser, "circuitBasic" }
));
}
private void createStandardRecipes() {
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(itemImprint, 2), new Object[]{"R", "P", "I", Character.valueOf('P'), Items.paper, Character.valueOf('R'), Items.redstone, Character.valueOf('I'), new ItemStack(Items.dye, 1, 0)}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockImprinter, new Object[]{"SIS", "SPS", "WCW", Character.valueOf('S'), Items.iron_ingot, Character.valueOf('C'), Blocks.chest, Character.valueOf('W'), Blocks.crafting_table, Character.valueOf('P'), Blocks.piston, Character.valueOf('I'), new ItemStack(Items.dye, 1, 0)}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockCrate, 1, 0), new Object[]{"TST", "S S", "TST", Character.valueOf('S'), Items.iron_ingot, Character.valueOf('T'), Blocks.log}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockCrate, 1, 1), new Object[]{"TST", "SCS", "TST", Character.valueOf('C'), new ItemStack(blockCrate, 1, 0), Character.valueOf('S'), Items.iron_ingot, Character.valueOf('T'), Blocks.log}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockCrate, 1, 2), new Object[]{"TST", "SCS", "TST", Character.valueOf('C'), new ItemStack(blockCrate, 1, 1), Character.valueOf('S'), Items.iron_ingot, Character.valueOf('T'), Blocks.log}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(itemImprint, 2),
new Object[] { "R",
"P",
"I",
Character.valueOf('P'),
Items.paper,
Character.valueOf('R'),
Items.redstone,
Character.valueOf('I'),
new ItemStack(Items.dye, 1, 0) }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
blockImprinter,
new Object[] { "SIS",
"SPS",
"WCW",
Character.valueOf('S'),
Items.iron_ingot,
Character.valueOf('C'),
Blocks.chest,
Character.valueOf('W'),
Blocks.crafting_table,
Character.valueOf('P'),
Blocks.piston,
Character.valueOf('I'),
new ItemStack(Items.dye, 1, 0) }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(blockCrate, 1, 0),
new Object[] { "TST",
"S S",
"TST",
Character.valueOf('S'),
Items.iron_ingot,
Character.valueOf('T'),
Blocks.log }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(blockCrate, 1, 1),
new Object[] { "TST",
"SCS",
"TST",
Character.valueOf('C'),
new ItemStack(blockCrate, 1, 0),
Character.valueOf('S'),
Items.iron_ingot,
Character.valueOf('T'),
Blocks.log }
));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(blockCrate, 1, 2),
new Object[] { "TST",
"SCS",
"TST",
Character.valueOf('C'),
new ItemStack(blockCrate, 1, 1),
Character.valueOf('S'),
Items.iron_ingot,
Character.valueOf('T'),
Blocks.log }
));
}
public static void printSidedData(String data) {
System.out.print(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT ? "[C]" : "[S]");
System.out.print(
FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT ? "[C]" : "[S]"
);
System.out.println(" " + data);
}
static {
LANGUAGES_SUPPORTED = new String[] { "en_US" };
CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity/AssemblyLine.cfg"));
CONFIGURATION = new Configuration(new File(
Loader.instance().getConfigDir(), "UniversalElectricity/AssemblyLine.cfg"
));
ic2Wrench = null;
FMLog = Logger.getLogger(MOD_NAME);
REQUIRE_NO_POWER = false;
}
}

View file

@ -1,5 +1,11 @@
package assemblyline.common;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.TileEntityManipulator;
import assemblyline.common.machine.TileEntityRejector;
@ -15,41 +21,48 @@ import assemblyline.common.machine.imprinter.TileEntityImprinter;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.prefab.multiblock.TileEntityMulti;
public class CommonProxy
implements IGuiHandler {
public class CommonProxy implements IGuiHandler {
public static final int GUI_IMPRINTER = 1;
public static final int GUI_ENCODER = 2;
public void preInit() {
}
public void preInit() {}
public void init() {
GameRegistry.registerTileEntity(TileEntityConveyorBelt.class, (String)"ALConveyorBelt");
GameRegistry.registerTileEntity(
TileEntityConveyorBelt.class, (String) "ALConveyorBelt"
);
GameRegistry.registerTileEntity(TileEntityRejector.class, (String) "ALSorter");
GameRegistry.registerTileEntity(TileEntityManipulator.class, (String)"ALManipulator");
GameRegistry.registerTileEntity(
TileEntityManipulator.class, (String) "ALManipulator"
);
GameRegistry.registerTileEntity(TileEntityCrate.class, (String) "ALCrate");
GameRegistry.registerTileEntity(TileEntityDetector.class, (String) "ALDetector");
GameRegistry.registerTileEntity(TileEntityEncoder.class, (String) "ALEncoder");
GameRegistry.registerTileEntity(TileEntityArmbot.class, (String) "ALArmbot");
GameRegistry.registerTileEntity(TileEntityCraneController.class, (String)"ALCraneController");
GameRegistry.registerTileEntity(TileEntityCraneRail.class, (String)"ALCraneRail");
GameRegistry.registerTileEntity(TileEntityImprinter.class, (String)"ALImprinter");
GameRegistry.registerTileEntity(
TileEntityCraneController.class, (String) "ALCraneController"
);
GameRegistry.registerTileEntity(
TileEntityCraneRail.class, (String) "ALCraneRail"
);
GameRegistry.registerTileEntity(
TileEntityImprinter.class, (String) "ALImprinter"
);
GameRegistry.registerTileEntity(TileEntityMulti.class, (String) "ALMulti");
}
private void extractZipToLocation(File zipFile, String sourceFolder, String destFolder) {
private void
extractZipToLocation(File zipFile, String sourceFolder, String destFolder) {
try {
File destFile = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getFile("."), destFolder);
File destFile = new File(
FMLCommonHandler.instance().getMinecraftServerInstance().getFile("."),
destFolder
);
String destinationName = destFile.getAbsolutePath();
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
@ -62,12 +75,16 @@ implements IGuiHandler {
zipentry = zipinputstream.getNextEntry();
continue;
}
String entryName = destinationName + zipentryName.substring(Math.min(zipentryName.length(), sourceFolder.length() - 1));
String entryName = destinationName
+ zipentryName.substring(
Math.min(zipentryName.length(), sourceFolder.length() - 1)
);
entryName = entryName.replace('/', File.separatorChar);
entryName = entryName.replace('\\', File.separatorChar);
File newFile = new File(entryName);
if (zipentry.isDirectory()) {
if (!newFile.mkdirs()) break;
if (!newFile.mkdirs())
break;
zipentry = zipinputstream.getNextEntry();
continue;
}
@ -80,30 +97,36 @@ implements IGuiHandler {
zipentry = zipinputstream.getNextEntry();
}
zipinputstream.close();
}
catch (Exception e) {
} catch (Exception e) {
System.out.println("Error while loading AssemblyLine Lua libraries: ");
e.printStackTrace();
}
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object
getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 1: {
return new ContainerImprinter(player.inventory, (TileEntityImprinter)tileEntity);
return new ContainerImprinter(
player.inventory, (TileEntityImprinter) tileEntity
);
}
case 2: {
if (tileEntity == null || !(tileEntity instanceof TileEntityEncoder)) break;
return new ContainerEncoder(player.inventory, (TileEntityEncoder)tileEntity);
if (tileEntity == null || !(tileEntity instanceof TileEntityEncoder))
break;
return new ContainerEncoder(
player.inventory, (TileEntityEncoder) tileEntity
);
}
}
}
return null;
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object
getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@ -111,4 +134,3 @@ implements IGuiHandler {
return false;
}
}

View file

@ -32,4 +32,3 @@ public class Pair {
return this.left.equals(pairo.getKey()) && this.right.equals(pairo.getValue());
}
}

View file

@ -1,8 +1,9 @@
package assemblyline.common;
import assemblyline.common.block.TileEntityCrate;
import java.util.ArrayList;
import java.util.List;
import assemblyline.common.block.TileEntityCrate;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
@ -10,9 +11,13 @@ import universalelectricity.core.vector.VectorHelper;
public class PathfinderCrate {
public IPathCallBack callBackCheck = new IPathCallBack() {
@Override
public boolean isValidNode(PathfinderCrate finder, ForgeDirection direction, TileEntity provider, TileEntity node) {
public boolean isValidNode(
PathfinderCrate finder,
ForgeDirection direction,
TileEntity provider,
TileEntity node
) {
return node instanceof TileEntityCrate;
}
@ -35,8 +40,20 @@ public class PathfinderCrate {
return false;
}
for (int i = 0; i < 6; ++i) {
TileEntity connectedTile = VectorHelper.getTileEntityFromSide(provider.getWorldObj(), new Vector3(provider), ForgeDirection.getOrientation((int)i));
if (this.iteratedNodes.contains((Object)connectedTile) || !this.callBackCheck.isValidNode(this, ForgeDirection.getOrientation((int)i), provider, connectedTile) || this.findNodes(connectedTile)) continue;
TileEntity connectedTile = VectorHelper.getTileEntityFromSide(
provider.getWorldObj(),
new Vector3(provider),
ForgeDirection.getOrientation((int) i)
);
if (this.iteratedNodes.contains((Object) connectedTile)
|| !this.callBackCheck.isValidNode(
this,
ForgeDirection.getOrientation((int) i),
provider,
connectedTile
)
|| this.findNodes(connectedTile))
continue;
return false;
}
}
@ -55,9 +72,10 @@ public class PathfinderCrate {
}
public static interface IPathCallBack {
public boolean isValidNode(PathfinderCrate var1, ForgeDirection var2, TileEntity var3, TileEntity var4);
public boolean isValidNode(
PathfinderCrate var1, ForgeDirection var2, TileEntity var3, TileEntity var4
);
public boolean onSearch(PathfinderCrate var1, TileEntity var2);
}
}

View file

@ -4,8 +4,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class TabAssemblyLine
extends CreativeTabs {
public class TabAssemblyLine extends CreativeTabs {
public static final TabAssemblyLine INSTANCE = new TabAssemblyLine("assemblyline");
public static ItemStack itemStack;
@ -22,4 +21,3 @@ extends CreativeTabs {
return itemStack.getItem();
}
}

View file

@ -10,8 +10,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockAdvanced;
public abstract class BlockALMachine
extends BlockAdvanced {
public abstract class BlockALMachine extends BlockAdvanced {
public IIcon machine_icon;
public BlockALMachine(Material material) {
@ -26,7 +25,8 @@ extends BlockAdvanced {
@SideOnly(value = Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
public IIcon
getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return this.machine_icon;
}
@ -40,6 +40,4 @@ extends BlockAdvanced {
public TileEntity createTileEntity(World w, int meta) {
return this.createNewTileEntity(w, meta);
}
}

View file

@ -1,11 +1,12 @@
package assemblyline.common.block;
import java.util.List;
import assemblyline.common.AssemblyLine;
import assemblyline.common.PathfinderCrate;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -22,8 +23,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
public class BlockCrate
extends BlockALMachine {
public class BlockCrate extends BlockALMachine {
IIcon crate_icon;
public BlockCrate() {
@ -59,8 +59,20 @@ extends BlockALMachine {
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
if (super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ)) {
public boolean onBlockActivated(
World world,
int x,
int y,
int z,
EntityPlayer entityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
if (super.onBlockActivated(
world, x, y, z, entityPlayer, side, hitX, hitY, hitZ
)) {
return true;
}
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityCrate) {
@ -68,8 +80,11 @@ extends BlockALMachine {
boolean allMode = world.getWorldTime() - tileEntity.prevClickTime < 10L;
tileEntity.prevClickTime = world.getWorldTime();
ItemStack current = entityPlayer.inventory.getCurrentItem();
if (side == 1 || side > 1 && (double)hitY > 0.5 || !entityPlayer.capabilities.isCreativeMode) {
if (current != null && (current.getMaxStackSize() > 1 || current.getItem() == Item.getItemFromBlock(this))) {
if (side == 1 || side > 1 && (double) hitY > 0.5
|| !entityPlayer.capabilities.isCreativeMode) {
if (current != null
&& (current.getMaxStackSize() > 1
|| current.getItem() == Item.getItemFromBlock(this))) {
this.tryInsert(tileEntity, entityPlayer, allMode);
}
} else if (side == 0 || side > 1 && (double) hitY <= 0.5) {
@ -79,22 +94,30 @@ extends BlockALMachine {
return true;
}
public void tryInsert(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode, boolean doSearch) {
boolean success = allMode ? this.insertAllItems(tileEntity, player) : this.insertCurrentItem(tileEntity, player);
public void tryInsert(
TileEntityCrate tileEntity, EntityPlayer player, boolean allMode, boolean doSearch
) {
boolean success = allMode ? this.insertAllItems(tileEntity, player)
: this.insertCurrentItem(tileEntity, player);
if (!success && doSearch) {
PathfinderCrate pathfinder = new PathfinderCrate().init(tileEntity);
for (TileEntity checkTile : pathfinder.iteratedNodes) {
if (!(checkTile instanceof TileEntityCrate)) continue;
AssemblyLine.blockCrate.tryInsert((TileEntityCrate)checkTile, player, allMode, false);
if (!(checkTile instanceof TileEntityCrate))
continue;
AssemblyLine.blockCrate.tryInsert(
(TileEntityCrate) checkTile, player, allMode, false
);
}
}
}
public void tryInsert(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode) {
public void
tryInsert(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode) {
this.tryInsert(tileEntity, player, allMode, true);
}
public void tryEject(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode) {
public void
tryEject(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode) {
if (allMode && !player.isSneaking()) {
this.ejectItems(tileEntity, player, tileEntity.getMaxLimit());
} else if (player.isSneaking()) {
@ -111,16 +134,27 @@ extends BlockALMachine {
ItemStack currentStack = player.getCurrentEquippedItem();
if (currentStack != null) {
if (currentStack.isStackable()) {
if (tileEntity.getStackInSlot(0) != null && !tileEntity.getStackInSlot(0).isItemEqual(currentStack)) {
if (tileEntity.getStackInSlot(0) != null
&& !tileEntity.getStackInSlot(0).isItemEqual(currentStack)) {
return false;
}
player.inventory.setInventorySlotContents(player.inventory.currentItem, BlockCrate.putIn(tileEntity, currentStack));
player.inventory.setInventorySlotContents(
player.inventory.currentItem,
BlockCrate.putIn(tileEntity, currentStack)
);
return true;
}
if (currentStack.getItem() == Item.getItemFromBlock(AssemblyLine.blockCrate)) {
ItemStack containedStack = ItemBlockCrate.getContainingItemStack(currentStack);
if (currentStack.getItem()
== Item.getItemFromBlock(AssemblyLine.blockCrate)) {
ItemStack containedStack
= ItemBlockCrate.getContainingItemStack(currentStack);
ItemStack crateStack = tileEntity.getStackInSlot(0);
if (containedStack != null && (crateStack == null || crateStack != null && containedStack.getItem() == crateStack.getItem() && containedStack.getItemDamage() == crateStack.getItemDamage())) {
if (containedStack != null
&& (crateStack == null
|| crateStack != null
&& containedStack.getItem() == crateStack.getItem()
&& containedStack.getItemDamage()
== crateStack.getItemDamage())) {
ItemStack returned = BlockCrate.putIn(tileEntity, containedStack);
ItemBlockCrate.setContainingItemStack(currentStack, returned);
return true;
@ -142,10 +176,14 @@ extends BlockALMachine {
boolean success = false;
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack currentStack = player.inventory.getStackInSlot(i);
if (currentStack == null || !requestStack.isItemEqual(currentStack)) continue;
player.inventory.setInventorySlotContents(i, BlockCrate.putIn(tileEntity, currentStack));
if (currentStack == null || !requestStack.isItemEqual(currentStack))
continue;
player.inventory.setInventorySlotContents(
i, BlockCrate.putIn(tileEntity, currentStack)
);
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
((EntityPlayerMP) player)
.sendContainerToPlayer(player.inventoryContainer);
}
success = true;
}
@ -154,7 +192,8 @@ extends BlockALMachine {
return false;
}
public boolean ejectItems(TileEntityCrate tileEntity, EntityPlayer player, int requestSize) {
public boolean
ejectItems(TileEntityCrate tileEntity, EntityPlayer player, int requestSize) {
World world = tileEntity.getWorldObj();
ItemStack containingStack = tileEntity.getStackInSlot(0);
if (containingStack != null) {
@ -163,7 +202,9 @@ extends BlockALMachine {
ItemStack dropStack = containingStack.copy();
dropStack.stackSize = amountToTake;
if (!world.isRemote) {
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, dropStack);
EntityItem entityItem = new EntityItem(
world, player.posX, player.posY, player.posZ, dropStack
);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld((Entity) entityItem);
}
@ -199,17 +240,37 @@ extends BlockALMachine {
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
TileEntityCrate tileEntity;
ItemStack containingStack;
if (!world.isRemote && world.getTileEntity(x, y, z) != null && (containingStack = (tileEntity = (TileEntityCrate)world.getTileEntity(x, y, z)).getStackInSlot(0)) != null && containingStack.stackSize > 0) {
if (!world.isRemote && world.getTileEntity(x, y, z) != null
&& (containingStack
= (tileEntity = (TileEntityCrate) world.getTileEntity(x, y, z))
.getStackInSlot(0))
!= null
&& containingStack.stackSize > 0) {
float var6 = 0.7f;
double var7 = (double)(world.rand.nextFloat() * var6) + (double)(1.0f - var6) * 0.5;
double var9 = (double)(world.rand.nextFloat() * var6) + (double)(1.0f - var6) * 0.5;
double var11 = (double)(world.rand.nextFloat() * var6) + (double)(1.0f - var6) * 0.5;
double var7
= (double) (world.rand.nextFloat() * var6) + (double) (1.0f - var6) * 0.5;
double var9
= (double) (world.rand.nextFloat() * var6) + (double) (1.0f - var6) * 0.5;
double var11
= (double) (world.rand.nextFloat() * var6) + (double) (1.0f - var6) * 0.5;
ItemStack dropStack = new ItemStack((Block) this, 1, tileEntity.getTier());
ItemBlockCrate.setContainingItemStack(dropStack, containingStack);
EntityItem var13 = new EntityItem(world, (double)x + var7, (double)y + var9, (double)z + var11, dropStack);
EntityItem var13 = new EntityItem(
world, (double) x + var7, (double) y + var9, (double) z + var11, dropStack
);
var13.delayBeforeCanPickup = 10;
world.spawnEntityInWorld((Entity) var13);
tileEntity.setInventorySlotContents(0, null);
@ -236,4 +297,3 @@ extends BlockALMachine {
}
}
}

View file

@ -1,10 +1,11 @@
package assemblyline.common.block;
import java.util.Random;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -20,8 +21,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRotatable;
public class BlockTurntable
extends BlockALMachine {
public class BlockTurntable extends BlockALMachine {
private IIcon top;
public BlockTurntable() {
@ -60,9 +60,11 @@ extends BlockALMachine {
return this.machine_icon;
}
public static int determineOrientation(World world, int x, int y, int z, EntityPlayer entityPlayer) {
public static int
determineOrientation(World world, int x, int y, int z, EntityPlayer entityPlayer) {
int var7;
if (MathHelper.abs((float)((float)entityPlayer.posX - (float)x)) < 2.0f && MathHelper.abs((float)((float)entityPlayer.posZ - (float)z)) < 2.0f) {
if (MathHelper.abs((float) ((float) entityPlayer.posX - (float) x)) < 2.0f
&& MathHelper.abs((float) ((float) entityPlayer.posZ - (float) z)) < 2.0f) {
double var5 = entityPlayer.posY + 1.82 - (double) entityPlayer.yOffset;
if (var5 - (double) y > 2.0) {
return 1;
@ -71,12 +73,26 @@ extends BlockALMachine {
return 0;
}
}
return (var7 = MathHelper.floor_double((double)((double)(entityPlayer.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3) == 0 ? 2 : (var7 == 1 ? 5 : (var7 == 2 ? 3 : (var7 == 3 ? 4 : 0)));
return (var7 = MathHelper.floor_double((double
) ((double) (entityPlayer.rotationYaw * 4.0f / 360.0f) + 0.5))
& 3)
== 0
? 2
: (var7 == 1 ? 5 : (var7 == 2 ? 3 : (var7 == 3 ? 4 : 0)));
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack) {
int metadata = BlockTurntable.determineOrientation(world, x, y, z, (EntityPlayer)par5EntityLiving);
public void onBlockPlacedBy(
World world,
int x,
int y,
int z,
EntityLivingBase par5EntityLiving,
ItemStack stack
) {
int metadata = BlockTurntable.determineOrientation(
world, x, y, z, (EntityPlayer) par5EntityLiving
);
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
world.scheduleBlockUpdate(x, y, z, this, 20);
}
@ -100,7 +116,9 @@ extends BlockALMachine {
rotatable = (IRotatable) block;
}
if (rotatable != null) {
ForgeDirection newDir = ((IRotatable)tileEntity).getDirection((IBlockAccess)world, x, y, z);
ForgeDirection newDir
= ((IRotatable) tileEntity)
.getDirection((IBlockAccess) world, x, y, z);
switch (newDir) {
case EAST:
newDir = ForgeDirection.SOUTH;
@ -116,14 +134,21 @@ extends BlockALMachine {
break;
default:
break;
}
rotatable.setDirection(world, x, y, z, newDir);
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
world.playSoundEffect((double)x + 0.5, (double)y + 0.5, (double)z + 0.5, "tile.piston.in", 0.5f, world.rand.nextFloat() * 0.15f + 0.6f);
world.markBlockForUpdate(
position.intX(), position.intY(), position.intZ()
);
world.playSoundEffect(
(double) x + 0.5,
(double) y + 0.5,
(double) z + 0.5,
"tile.piston.in",
0.5f,
world.rand.nextFloat() * 0.15f + 0.6f
);
}
}
catch (Exception e) {
} catch (Exception e) {
System.out.println("Failed to rotate:");
e.printStackTrace();
}
@ -135,4 +160,3 @@ extends BlockALMachine {
return null;
}
}

View file

@ -13,8 +13,7 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemBlockCrate
extends ItemBlock {
public class ItemBlockCrate extends ItemBlock {
public ItemBlockCrate(Block block) {
super(block);
this.setMaxStackSize(1);
@ -26,7 +25,9 @@ extends ItemBlock {
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
public void addInformation(
ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4
) {
ItemStack containingStack = ItemBlockCrate.getContainingItemStack(itemStack);
if (containingStack != null) {
par3List.add(containingStack.getDisplayName());
@ -37,17 +38,27 @@ extends ItemBlock {
}
@Override
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5) {
public void onUpdate(
ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5
) {
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
ItemStack containingStack = ItemBlockCrate.getContainingItemStack(itemStack);
if (containingStack != null) {
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int)((float)containingStack.stackSize / (float)TileEntityCrate.getMaxLimit(itemStack.getItemDamage())) * 5));
player.addPotionEffect(new PotionEffect(
Potion.moveSlowdown.id,
5,
(int
) ((float) containingStack.stackSize
/ (float) TileEntityCrate.getMaxLimit(itemStack.getItemDamage()))
* 5
));
}
}
}
public static void setContainingItemStack(ItemStack itemStack, ItemStack containingStack) {
public static void
setContainingItemStack(ItemStack itemStack, ItemStack containingStack) {
if (itemStack.stackTagCompound == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
@ -68,8 +79,10 @@ extends ItemBlock {
itemStack.setTagCompound(new NBTTagCompound());
return null;
}
NBTTagCompound itemTagCompound = itemStack.getTagCompound().getCompoundTag("Item");
ItemStack containingStack = ItemStack.loadItemStackFromNBT((NBTTagCompound)itemTagCompound);
NBTTagCompound itemTagCompound
= itemStack.getTagCompound().getCompoundTag("Item");
ItemStack containingStack
= ItemStack.loadItemStackFromNBT((NBTTagCompound) itemTagCompound);
if (containingStack != null) {
containingStack.stackSize = itemStack.getTagCompound().getInteger("Count");
}
@ -82,15 +95,30 @@ extends ItemBlock {
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) {
public boolean placeBlockAt(
ItemStack stack,
EntityPlayer player,
World world,
int x,
int y,
int z,
int side,
float hitX,
float hitY,
float hitZ,
int metadata
) {
if (super.placeBlockAt(
stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata
)) {
ItemStack containingItem = ItemBlockCrate.getContainingItemStack(stack);
if (world.getTileEntity(x, y, z) != null && containingItem != null && containingItem.stackSize > 0) {
TileEntityCrate tileEntity = (TileEntityCrate)world.getTileEntity(x, y, z);
if (world.getTileEntity(x, y, z) != null && containingItem != null
&& containingItem.stackSize > 0) {
TileEntityCrate tileEntity
= (TileEntityCrate) world.getTileEntity(x, y, z);
tileEntity.setInventorySlotContents(0, containingItem);
}
}
return true;
}
}

View file

@ -15,10 +15,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import universalelectricity.prefab.implement.ITier;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class TileEntityCrate
extends TileEntityAdvanced
implements ITier,
IInventory {
public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInventory {
private ItemStack[] containingItems = new ItemStack[1];
public long prevClickTime = -1000L;
@ -42,13 +39,14 @@ IInventory {
}
/*@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) {
public void handlePacketData(INetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) {
if (this.field_70331_k.isRemote) {
try {
if (dataStream.readBoolean()) {
if (this.containingItems[0] == null) {
this.containingItems[0] = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
} else {
this.containingItems[0] = new ItemStack(dataStream.readInt(),
dataStream.readInt(), dataStream.readInt()); } else {
this.containingItems[0].field_77993_c = dataStream.readInt();
this.containingItems[0].stackSize = dataStream.readInt();
this.containingItems[0].setItemDamage(dataStream.readInt());
@ -69,7 +67,11 @@ IInventory {
NBTTagCompound nbt = pkt.func_148857_g();
if (nbt.getBoolean("containsItems")) {
if (containingItems[0] == null) {
containingItems[0] = new ItemStack(Item.getItemById(nbt.getShort("id")), nbt.getByte("Count"), nbt.getShort("Damage"));
containingItems[0] = new ItemStack(
Item.getItemById(nbt.getShort("id")),
nbt.getByte("Count"),
nbt.getShort("Damage")
);
} else {
containingItems[0].readFromNBT(nbt);
}
@ -85,12 +87,16 @@ IInventory {
if (this.containingItems[0] != null) {
nbt.setBoolean("containsItems", true);
containingItems[0].writeToNBT(nbt);
//return PacketManager.getPacket("AssemblyLine", this, new Object[]{true, this.containingItems[0].field_77993_c, this.containingItems[0].stackSize, this.containingItems[0].getItemDamage()});
//return PacketManager.getPacket("AssemblyLine", this, new Object[]{true,
//this.containingItems[0].field_77993_c, this.containingItems[0].stackSize,
//this.containingItems[0].getItemDamage()});
} else {
nbt.setBoolean("containsItems", false);
}
//return PacketManager.getPacket("AssemblyLine", this, new Object[]{false});
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
return new S35PacketUpdateTileEntity(
xCoord, yCoord, zCoord, getBlockMetadata(), nbt
);
}
@Override
@ -145,16 +151,20 @@ IInventory {
@Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this
? false
: par1EntityPlayer.getDistanceSq(
(double) this.xCoord + 0.5,
(double) this.yCoord + 0.5,
(double) this.zCoord + 0.5
) <= 64.0;
}
@Override
public void openInventory() {
}
public void openInventory() {}
@Override
public void closeInventory() {
}
public void closeInventory() {}
@Override
public void readFromNBT(NBTTagCompound nbt) {
@ -164,8 +174,10 @@ IInventory {
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
NBTTagCompound var4 = (NBTTagCompound) var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 < 0 || var5 >= this.containingItems.length) continue;
this.containingItems[var5] = ItemStack.loadItemStackFromNBT((NBTTagCompound)var4);
if (var5 < 0 || var5 >= this.containingItems.length)
continue;
this.containingItems[var5]
= ItemStack.loadItemStackFromNBT((NBTTagCompound) var4);
}
if (this.containingItems[0] != null) {
this.containingItems[0].stackSize = nbt.getInteger("Count");
@ -177,7 +189,8 @@ IInventory {
super.writeToNBT(nbt);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3) {
if (this.containingItems[var3] == null) continue;
if (this.containingItems[var3] == null)
continue;
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
this.containingItems[var3].writeToNBT(var4);
@ -211,7 +224,9 @@ IInventory {
@Override
public void setTier(int tier) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, tier, 3);
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, tier, 3
);
}
@Override
@ -224,4 +239,3 @@ IInventory {
return true;
}
}

View file

@ -6,8 +6,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockBeltSorter
extends BlockALMachine {
public class BlockBeltSorter extends BlockALMachine {
public BlockBeltSorter() {
super(Material.iron);
this.setCreativeTab(TabAssemblyLine.INSTANCE);
@ -20,4 +19,3 @@ extends BlockALMachine {
return null;
}
}

View file

@ -11,28 +11,55 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
public class BlockManipulator
extends BlockImprintable {
public class BlockManipulator extends BlockImprintable {
public BlockManipulator() {
super("manipulator", UniversalElectricity.machine, TabAssemblyLine.INSTANCE);
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.29f, 1.0f);
}
public AxisAlignedBB func_71911_a_(World par1World, int par2, int par3, int par4) {
return AxisAlignedBB.getBoundingBox((double)par2, (double)par3, (double)par4, (double)par2 + 1.0, (double)par3 + 1.0, (double)par4 + 1.0);
return AxisAlignedBB.getBoundingBox(
(double) par2,
(double) par3,
(double) par4,
(double) par2 + 1.0,
(double) par3 + 1.0,
(double) par4 + 1.0
);
}
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onSneakMachineActivated(
World world,
int x,
int y,
int z,
EntityPlayer entityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityManipulator) {
((TileEntityManipulator)tileEntity).selfPulse = !((TileEntityManipulator)tileEntity).selfPulse;
((TileEntityManipulator) tileEntity).selfPulse
= !((TileEntityManipulator) tileEntity).selfPulse;
}
return true;
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onSneakUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityManipulator) {
TileEntityManipulator manip = (TileEntityManipulator) tileEntity;
@ -79,4 +106,3 @@ extends BlockImprintable {
return 0;
}
}

View file

@ -9,8 +9,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
public class BlockRejector
extends BlockImprintable {
public class BlockRejector extends BlockImprintable {
public BlockRejector() {
super("rejector", UniversalElectricity.machine, TabAssemblyLine.INSTANCE);
}
@ -36,4 +35,3 @@ extends BlockImprintable {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
}

View file

@ -7,22 +7,29 @@ import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.prefab.tile.TileEntityElectricityRunnable;
public abstract class TileEntityAssemblyNetwork
extends TileEntityElectricityRunnable {
public abstract class TileEntityAssemblyNetwork extends TileEntityElectricityRunnable {
public int powerTransferRange = 0;
public boolean isRunning() {
return AssemblyLine.REQUIRE_NO_POWER || this.powerTransferRange > 0 || this.wattsReceived > this.getRequest().getWatts();
return AssemblyLine.REQUIRE_NO_POWER || this.powerTransferRange > 0
|| this.wattsReceived > this.getRequest().getWatts();
}
public void updatePowerTransferRange() {
int maximumTransferRange = 0;
for (int i = 0; i < 6; ++i) {
ForgeDirection direction = ForgeDirection.getOrientation((int) i);
TileEntity tileEntity = this.worldObj.getTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork)) continue;
TileEntityAssemblyNetwork assemblyNetwork = (TileEntityAssemblyNetwork)tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange) continue;
TileEntity tileEntity = this.worldObj.getTileEntity(
this.xCoord + direction.offsetX,
this.yCoord + direction.offsetY,
this.zCoord + direction.offsetZ
);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork))
continue;
TileEntityAssemblyNetwork assemblyNetwork
= (TileEntityAssemblyNetwork) tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange)
continue;
maximumTransferRange = assemblyNetwork.powerTransferRange;
}
this.powerTransferRange = Math.max(maximumTransferRange - 1, 0);
@ -46,8 +53,7 @@ extends TileEntityElectricityRunnable {
}
}
protected void onUpdate() {
}
protected void onUpdate() {}
@Override
public ElectricityPack getRequest() {
@ -70,4 +76,3 @@ extends TileEntityElectricityRunnable {
this.wattsReceived = nbt.getDouble("wattsReceived");
}
}

View file

@ -1,10 +1,11 @@
package assemblyline.common.machine;
import java.util.List;
import assemblyline.api.IManipulator;
import assemblyline.common.block.BlockCrate;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
@ -22,10 +23,7 @@ import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.multiblock.TileEntityMulti;
public class TileEntityManipulator
extends TileEntityFilterable
implements IRotatable,
IRedstoneReceptor,
IManipulator {
extends TileEntityFilterable implements IRotatable, IRedstoneReceptor, IManipulator {
public boolean selfPulse = false;
private boolean isOutput = false;
private boolean isRedstonePowered = false;
@ -75,20 +73,41 @@ IManipulator {
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
if (outputPosition.getTileEntity((IBlockAccess)this.worldObj) instanceof TileEntityManipulator && ((TileEntityManipulator)outputPosition.getTileEntity((IBlockAccess)this.worldObj)).getDirection() == this.getDirection().getOpposite()) {
if (outputPosition.getTileEntity((IBlockAccess) this.worldObj)
instanceof TileEntityManipulator
&& ((TileEntityManipulator
) outputPosition.getTileEntity((IBlockAccess) this.worldObj))
.getDirection()
== this.getDirection().getOpposite()) {
return;
}
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox((double)inputPosition.x, (double)inputPosition.y, (double)inputPosition.z, (double)(inputPosition.x + 1.0), (double)(inputPosition.y + 1.0), (double)(inputPosition.z + 1.0));
List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(
(double) inputPosition.x,
(double) inputPosition.y,
(double) inputPosition.z,
(double) (inputPosition.x + 1.0),
(double) (inputPosition.y + 1.0),
(double) (inputPosition.z + 1.0)
);
List<EntityItem> itemsInBound
= this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
for (EntityItem entity : itemsInBound) {
if (entity.isDead) continue;
if (entity.isDead)
continue;
ItemStack remainingStack = entity.getEntityItem().copy();
if (this.getFilter() != null && !this.isFiltering(remainingStack)) continue;
if ((remainingStack = this.tryPlaceInPosition(remainingStack, outputUp, ForgeDirection.DOWN)) != null) {
remainingStack = this.tryPlaceInPosition(remainingStack, outputDown, ForgeDirection.UP);
if (this.getFilter() != null && !this.isFiltering(remainingStack))
continue;
if ((remainingStack
= this.tryPlaceInPosition(remainingStack, outputUp, ForgeDirection.DOWN))
!= null) {
remainingStack = this.tryPlaceInPosition(
remainingStack, outputDown, ForgeDirection.UP
);
}
if (remainingStack != null) {
remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getDirection().getOpposite());
remainingStack = this.tryPlaceInPosition(
remainingStack, outputPosition, this.getDirection().getOpposite()
);
}
if (remainingStack != null && remainingStack.stackSize > 0) {
this.throwItem(outputPosition, remainingStack);
@ -113,7 +132,9 @@ IManipulator {
itemStack = this.tryGrabFromPosition(inputDown, ForgeDirection.UP);
}
if (itemStack == null) {
itemStack = this.tryGrabFromPosition(inputPosition, this.getDirection().getOpposite());
itemStack = this.tryGrabFromPosition(
inputPosition, this.getDirection().getOpposite()
);
}
if (itemStack != null && itemStack.stackSize > 0) {
this.throwItem(outputPosition, itemStack);
@ -122,7 +143,13 @@ IManipulator {
public void throwItem(Vector3 outputPosition, ItemStack items) {
if (!this.worldObj.isRemote) {
EntityItem entityItem = new EntityItem(this.worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, items);
EntityItem entityItem = new EntityItem(
this.worldObj,
outputPosition.x + 0.5,
outputPosition.y + 0.8,
outputPosition.z + 0.5,
items
);
entityItem.motionX = 0.0;
entityItem.motionZ = 0.0;
entityItem.motionY /= 5.0;
@ -131,28 +158,47 @@ IManipulator {
}
}
private ItemStack tryPlaceInPosition(ItemStack itemStack, Vector3 position, ForgeDirection direction) {
private ItemStack
tryPlaceInPosition(ItemStack itemStack, Vector3 position, ForgeDirection direction) {
TileEntity tileEntity = position.getTileEntity((IBlockAccess) this.worldObj);
if (tileEntity != null && itemStack != null) {
if (tileEntity instanceof TileEntityMulti) {
Vector3 mainBlockPosition = ((TileEntityMulti)tileEntity).mainBlockPosition;
if (mainBlockPosition != null && !(mainBlockPosition.getTileEntity((IBlockAccess)this.worldObj) instanceof TileEntityMulti)) {
return this.tryPlaceInPosition(itemStack, mainBlockPosition, direction);
Vector3 mainBlockPosition
= ((TileEntityMulti) tileEntity).mainBlockPosition;
if (mainBlockPosition != null
&& !(
mainBlockPosition.getTileEntity((IBlockAccess) this.worldObj)
instanceof TileEntityMulti
)) {
return this.tryPlaceInPosition(
itemStack, mainBlockPosition, direction
);
}
} else if (tileEntity instanceof TileEntityChest) {
TileEntityChest[] chests = new TileEntityChest[]{(TileEntityChest)tileEntity, null};
TileEntityChest[] chests
= new TileEntityChest[] { (TileEntityChest) tileEntity, null };
for (int i = 2; i < 6; ++i) {
ForgeDirection searchDirection = ForgeDirection.getOrientation((int)i);
ForgeDirection searchDirection
= ForgeDirection.getOrientation((int) i);
Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity((IBlockAccess)this.worldObj) == null || searchPosition.getTileEntity((IBlockAccess)this.worldObj).getClass() != chests[0].getClass()) continue;
chests[1] = (TileEntityChest)searchPosition.getTileEntity((IBlockAccess)this.worldObj);
if (searchPosition.getTileEntity((IBlockAccess) this.worldObj) == null
|| searchPosition.getTileEntity((IBlockAccess) this.worldObj)
.getClass()
!= chests[0].getClass())
continue;
chests[1] = (TileEntityChest
) searchPosition.getTileEntity((IBlockAccess) this.worldObj);
break;
}
for (TileEntityChest chest : chests) {
if (chest == null) continue;
if (chest == null)
continue;
for (int i = 0; i < chest.getSizeInventory(); ++i) {
if ((itemStack = this.addStackToInventory(i, (IInventory)chest, itemStack)) != null) continue;
if ((itemStack
= this.addStackToInventory(i, (IInventory) chest, itemStack))
!= null)
continue;
return null;
}
}
@ -163,14 +209,22 @@ IManipulator {
if (tileEntity instanceof ISidedInventory) {
int startIndex;
ISidedInventory inventory = (ISidedInventory) tileEntity;
for (int i : inventory.getAccessibleSlotsFromSide(direction.ordinal())) {
if ((itemStack = this.addStackToInventory(i, (IInventory)inventory, itemStack)) != null) continue;
for (int i :
inventory.getAccessibleSlotsFromSide(direction.ordinal())) {
if ((itemStack = this.addStackToInventory(
i, (IInventory) inventory, itemStack
))
!= null)
continue;
return null;
}
} else if (tileEntity instanceof IInventory) {
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
if ((itemStack = this.addStackToInventory(i, inventory, itemStack)) != null) continue;
if ((itemStack
= this.addStackToInventory(i, inventory, itemStack))
!= null)
continue;
return null;
}
}
@ -182,7 +236,8 @@ IManipulator {
return itemStack;
}
public ItemStack addStackToInventory(int slotIndex, IInventory inventory, ItemStack itemStack) {
public ItemStack
addStackToInventory(int slotIndex, IInventory inventory, ItemStack itemStack) {
if (inventory.getSizeInventory() > slotIndex) {
ItemStack stackInInventory = inventory.getStackInSlot(slotIndex);
if (stackInInventory == null) {
@ -192,11 +247,22 @@ IManipulator {
}
return null;
}
if (stackInInventory.isItemEqual(itemStack) && stackInInventory.isStackable()) {
if (stackInInventory.isItemEqual(itemStack)
&& stackInInventory.isStackable()) {
stackInInventory = stackInInventory.copy();
int stackLim = Math.min(inventory.getInventoryStackLimit(), itemStack.getMaxStackSize());
int rejectedAmount = Math.max(stackInInventory.stackSize + itemStack.stackSize - stackLim, 0);
stackInInventory.stackSize = Math.min(Math.max(stackInInventory.stackSize + itemStack.stackSize - rejectedAmount, 0), inventory.getInventoryStackLimit());
int stackLim = Math.min(
inventory.getInventoryStackLimit(), itemStack.getMaxStackSize()
);
int rejectedAmount = Math.max(
stackInInventory.stackSize + itemStack.stackSize - stackLim, 0
);
stackInInventory.stackSize = Math.min(
Math.max(
stackInInventory.stackSize + itemStack.stackSize - rejectedAmount,
0
),
inventory.getInventoryStackLimit()
);
itemStack.stackSize = rejectedAmount;
inventory.setInventorySlotContents(slotIndex, stackInInventory);
}
@ -217,50 +283,70 @@ IManipulator {
block7: {
returnStack = null;
tileEntity = position.getTileEntity((IBlockAccess) this.worldObj);
if (tileEntity == null) break block6;
if (!(tileEntity instanceof TileEntityMulti)) break block7;
if (tileEntity == null)
break block6;
if (!(tileEntity instanceof TileEntityMulti))
break block7;
Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition;
if (mainBlockPosition != null && !(mainBlockPosition.getTileEntity((IBlockAccess)this.worldObj) instanceof TileEntityMulti)) {
if (mainBlockPosition != null
&& !(
mainBlockPosition.getTileEntity((IBlockAccess) this.worldObj)
instanceof TileEntityMulti
)) {
return this.tryGrabFromPosition(mainBlockPosition, direction);
}
break block6;
}
if (!(tileEntity instanceof TileEntityChest)) break block8;
TileEntityChest[] chests = new TileEntityChest[]{(TileEntityChest)tileEntity, null};
if (!(tileEntity instanceof TileEntityChest))
break block8;
TileEntityChest[] chests
= new TileEntityChest[] { (TileEntityChest) tileEntity, null };
for (int i = 2; i < 6; ++i) {
ForgeDirection searchDirection = ForgeDirection.getOrientation((int) i);
Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity((IBlockAccess)this.worldObj) == null || searchPosition.getTileEntity((IBlockAccess)this.worldObj).getClass() != chests[0].getClass()) continue;
chests[1] = (TileEntityChest)searchPosition.getTileEntity((IBlockAccess)this.worldObj);
if (searchPosition.getTileEntity((IBlockAccess) this.worldObj) == null
|| searchPosition.getTileEntity((IBlockAccess) this.worldObj).getClass()
!= chests[0].getClass())
continue;
chests[1] = (TileEntityChest
) searchPosition.getTileEntity((IBlockAccess) this.worldObj);
break;
}
for (TileEntityChest chest : chests) {
if (chest == null) continue;
if (chest == null)
continue;
for (int i = 0; i < chest.getSizeInventory(); ++i) {
ItemStack itemStack = this.removeStackFromInventory(i, (IInventory)chest);
if (itemStack == null) continue;
ItemStack itemStack
= this.removeStackFromInventory(i, (IInventory) chest);
if (itemStack == null)
continue;
returnStack = itemStack;
break block6;
}
}
break block6;
}
if (!(tileEntity instanceof ISidedInventory)) break block9;
if (!(tileEntity instanceof ISidedInventory))
break block9;
ISidedInventory inventory = (ISidedInventory) tileEntity;
for (int i : inventory.getAccessibleSlotsFromSide(direction.ordinal())) {
ItemStack itemStack = this.removeStackFromInventory(i, (IInventory)inventory);
if (itemStack == null) continue;
ItemStack itemStack
= this.removeStackFromInventory(i, (IInventory) inventory);
if (itemStack == null)
continue;
returnStack = itemStack;
break block6;
}
break block6;
}
if (!(tileEntity instanceof IInventory)) break block6;
if (!(tileEntity instanceof IInventory))
break block6;
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
ItemStack itemStack = this.removeStackFromInventory(i, inventory);
if (itemStack == null) continue;
if (itemStack == null)
continue;
returnStack = itemStack;
break;
}
@ -309,4 +395,3 @@ IManipulator {
return dir != this.getDirection();
}
}

View file

@ -1,7 +1,8 @@
package assemblyline.common.machine;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.List;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
@ -12,8 +13,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class TileEntityRejector
extends TileEntityFilterable {
public class TileEntityRejector extends TileEntityFilterable {
public boolean firePiston = false;
@Override
@ -29,20 +29,29 @@ extends TileEntityFilterable {
this.firePiston = false;
Vector3 searchPosition = new Vector3(this);
searchPosition.modifyPositionFromSide(this.getDirection());
TileEntity tileEntity = searchPosition.getTileEntity((IBlockAccess)this.worldObj);
TileEntity tileEntity
= searchPosition.getTileEntity((IBlockAccess) this.worldObj);
try {
boolean flag = false;
if (this.isRunning()) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox((double)searchPosition.x, (double)searchPosition.y, (double)searchPosition.z, (double)(searchPosition.x + 1.0), (double)(searchPosition.y + 1.0), (double)(searchPosition.z + 1.0));
List<Entity> entitiesInFront = this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(
(double) searchPosition.x,
(double) searchPosition.y,
(double) searchPosition.z,
(double) (searchPosition.x + 1.0),
(double) (searchPosition.y + 1.0),
(double) (searchPosition.z + 1.0)
);
List<Entity> entitiesInFront
= this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesInFront) {
if (!this.canEntityBeThrow(entity)) continue;
if (!this.canEntityBeThrow(entity))
continue;
this.throwItem(this.getDirection(), entity);
flag = true;
}
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -82,4 +91,3 @@ extends TileEntityFilterable {
return dir != this.getDirection();
}
}

View file

@ -1,11 +1,12 @@
package assemblyline.common.machine.armbot;
import java.util.Random;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -15,8 +16,7 @@ import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.IMultiBlock;
public class BlockArmbot
extends BlockALMachine {
public class BlockArmbot extends BlockALMachine {
public BlockArmbot() {
super(UniversalElectricity.machine);
this.setBlockName("armbot");
@ -32,7 +32,17 @@ extends BlockALMachine {
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
public boolean onMachineActivated(
World world,
int x,
int y,
int z,
EntityPlayer player,
int par6,
float par7,
float par8,
float par9
) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof IMultiBlock) {
return ((IMultiBlock) tileEntity).onActivated(player);
@ -76,4 +86,3 @@ extends BlockALMachine {
return true;
}
}

View file

@ -1,5 +1,9 @@
package assemblyline.common.machine.armbot;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import assemblyline.api.IArmbot;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
@ -20,10 +24,6 @@ import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import dark.library.helpers.ItemFindingHelper;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
@ -47,13 +47,8 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.multiblock.IMultiBlock;
public class TileEntityArmbot
extends TileEntityAssemblyNetwork
implements IMultiBlock,
IInventory,
IElectricityStorage,
IArmbot,
IPeripheral {
public class TileEntityArmbot extends TileEntityAssemblyNetwork
implements IMultiBlock, IInventory, IElectricityStorage, IArmbot, IPeripheral {
private final CommandManager commandManager = new CommandManager();
private static final int PACKET_COMMANDS = 128;
protected ItemStack disk = null;
@ -78,17 +73,20 @@ IPeripheral {
public void onUpdate() {
Vector3 handPosition = this.getHandPosition();
for (Entity entity : this.grabbedEntities) {
if (entity == null) continue;
if (entity == null)
continue;
entity.setPosition(handPosition.x, handPosition.y, handPosition.z);
entity.motionX = 0.0;
entity.motionY = 0.0;
entity.motionZ = 0.0;
if (!(entity instanceof EntityItem)) continue;
if (!(entity instanceof EntityItem))
continue;
((EntityItem) entity).delayBeforeCanPickup = 20;
((EntityItem) entity).age = 0;
}
if (this.isRunning()) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.disk == null && this.computersAttached == 0) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER
&& this.disk == null && this.computersAttached == 0) {
this.commandManager.clear();
if (this.grabbedEntities.size() > 0 || this.grabbedItems.size() > 0) {
this.addCommand(CommandDrop.class);
@ -109,12 +107,13 @@ IPeripheral {
this.displayText = "";
} else {
try {
Command curCommand = (Command)this.commandManager.getCommands().get(this.commandManager.getCurrentTask());
Command curCommand = (Command) this.commandManager.getCommands().get(
this.commandManager.getCurrentTask()
);
if (curCommand != null) {
this.displayText = curCommand.toString();
}
}
catch (Exception ex) {
} catch (Exception ex) {
// empty catch block
}
}
@ -143,15 +142,34 @@ IPeripheral {
while (this.renderYaw > 360.0f) {
this.renderYaw -= 360.0f;
}
if (this.ticks % 5L == 0L && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
this.worldObj.playSound((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "assemblyline:conveyor", 0.8f, 1.7f, true);
if (this.ticks % 5L == 0L
&& FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
this.worldObj.playSound(
(double) this.xCoord,
(double) this.yCoord,
(double) this.zCoord,
"assemblyline:conveyor",
0.8f,
1.7f,
true
);
}
float f = Math.abs(this.renderYaw - this.rotationYaw);
this.getClass();
if (f < 1.3f + 0.1f) {
this.renderYaw = this.rotationYaw;
}
for (Entity e : (List<Entity>)this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)(this.yCoord + 2), (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 3), (double)(this.zCoord + 1)))) {
for (Entity e : (List<Entity>) this.worldObj.getEntitiesWithinAABB(
Entity.class,
AxisAlignedBB.getBoundingBox(
(double) this.xCoord,
(double) (this.yCoord + 2),
(double) this.zCoord,
(double) (this.xCoord + 1),
(double) (this.yCoord + 3),
(double) (this.zCoord + 1)
)
)) {
e.rotationYaw = this.renderYaw;
}
}
@ -171,15 +189,34 @@ IPeripheral {
while (this.renderPitch > 60.0f) {
this.renderPitch -= 60.0f;
}
if (this.ticks % 4L == 0L && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
this.worldObj.playSound((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "assemblyline:conveyor", 2.0f, 2.5f, true);
if (this.ticks % 4L == 0L
&& FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
this.worldObj.playSound(
(double) this.xCoord,
(double) this.yCoord,
(double) this.zCoord,
"assemblyline:conveyor",
2.0f,
2.5f,
true
);
}
float f = Math.abs(this.renderPitch - this.rotationPitch);
this.getClass();
if (f < 1.3f + 0.1f) {
this.renderPitch = this.rotationPitch;
}
for (Entity e : (List<Entity>)this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)(this.yCoord + 2), (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 3), (double)(this.zCoord + 1)))) {
for (Entity e : (List<Entity>) this.worldObj.getEntitiesWithinAABB(
Entity.class,
AxisAlignedBB.getBoundingBox(
(double) this.xCoord,
(double) (this.yCoord + 2),
(double) this.zCoord,
(double) (this.xCoord + 1),
(double) (this.yCoord + 3),
(double) (this.zCoord + 1)
)
)) {
e.rotationPitch = this.renderPitch;
}
}
@ -195,14 +232,19 @@ IPeripheral {
while (this.rotationPitch > 60.0f) {
this.rotationPitch -= 60.0f;
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.ticks % 20L == 0L) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER
&& this.ticks % 20L == 0L) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
public Command getCurrentCommand() {
if (this.commandManager.hasTasks() && this.commandManager.getCurrentTask() >= 0 && this.commandManager.getCurrentTask() < this.commandManager.getCommands().size()) {
return (Command)this.commandManager.getCommands().get(this.commandManager.getCurrentTask());
if (this.commandManager.hasTasks() && this.commandManager.getCurrentTask() >= 0
&& this.commandManager.getCurrentTask()
< this.commandManager.getCommands().size()) {
return (Command) this.commandManager.getCommands().get(
this.commandManager.getCurrentTask()
);
}
return null;
}
@ -231,7 +273,9 @@ IPeripheral {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setTag("data", data);
nbt.setInteger("transferRange", this.powerTransferRange);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
return new S35PacketUpdateTileEntity(
xCoord, yCoord, zCoord, getBlockMetadata(), nbt
);
}
@Override
@ -299,7 +343,13 @@ IPeripheral {
@Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this
? false
: par1EntityPlayer.getDistanceSq(
(double) this.xCoord + 0.5,
(double) this.yCoord + 0.5,
(double) this.zCoord + 0.5
) <= 64.0;
}
@Override
@ -320,7 +370,9 @@ IPeripheral {
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
this.disk = diskNBT != null ? ItemStack.loadItemStackFromNBT((NBTTagCompound)diskNBT) : null;
this.disk = diskNBT != null
? ItemStack.loadItemStackFromNBT((NBTTagCompound) diskNBT)
: null;
this.rotationYaw = nbt.getFloat("yaw");
this.rotationPitch = nbt.getFloat("pitch");
if (this.worldObj != null && this.worldObj.isRemote) {
@ -331,15 +383,19 @@ IPeripheral {
this.grabbedEntities.clear();
for (int i = 0; i < entities.tagCount(); ++i) {
NBTTagCompound entityTag = (NBTTagCompound) entities.getCompoundTagAt(i);
if (entityTag == null) continue;
Entity entity = EntityList.createEntityFromNBT((NBTTagCompound)entityTag, (World)this.worldObj);
if (entityTag == null)
continue;
Entity entity = EntityList.createEntityFromNBT(
(NBTTagCompound) entityTag, (World) this.worldObj
);
this.grabbedEntities.add(entity);
}
NBTTagList items = nbt.getTagList("items", 10);
this.grabbedItems.clear();
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound itemTag = (NBTTagCompound) items.getCompoundTagAt(i);
if (itemTag == null) continue;
if (itemTag == null)
continue;
ItemStack item = ItemStack.loadItemStackFromNBT((NBTTagCompound) itemTag);
this.grabbedItems.add(item);
}
@ -359,7 +415,8 @@ IPeripheral {
nbt.setInteger("curTask", this.commandManager.getCurrentTask());
NBTTagList entities = new NBTTagList();
for (Entity entity : this.grabbedEntities) {
if (entity == null) continue;
if (entity == null)
continue;
NBTTagCompound entityNBT = new NBTTagCompound();
entity.writeToNBT(entityNBT);
entity.writeToNBTOptional(entityNBT);
@ -368,7 +425,8 @@ IPeripheral {
nbt.setTag("entities", (NBTBase) entities);
NBTTagList items = new NBTTagList();
for (ItemStack itemStack : this.grabbedItems) {
if (itemStack == null) continue;
if (itemStack == null)
continue;
NBTTagCompound entityNBT = new NBTTagCompound();
itemStack.writeToNBT(entityNBT);
items.appendTag((NBTBase) entityNBT);
@ -396,14 +454,17 @@ IPeripheral {
ItemStack containingStack = this.getStackInSlot(0);
if (containingStack != null) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
EntityItem dropStack = new EntityItem(this.worldObj, player.posX, player.posY, player.posZ, containingStack);
EntityItem dropStack = new EntityItem(
this.worldObj, player.posX, player.posY, player.posZ, containingStack
);
dropStack.delayBeforeCanPickup = 0;
this.worldObj.spawnEntityInWorld((Entity) dropStack);
}
this.setInventorySlotContents(0, null);
return true;
}
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemDisk) {
if (player.getCurrentEquippedItem() != null
&& player.getCurrentEquippedItem().getItem() instanceof ItemDisk) {
this.setInventorySlotContents(0, player.getCurrentEquippedItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true;
@ -418,10 +479,12 @@ IPeripheral {
for (String commandString : commands) {
String commandName = commandString.split(" ")[0];
Class command = Command.getCommand(commandName);
if (command == null) continue;
if (command == null)
continue;
ArrayList<String> commandParameters = new ArrayList<String>();
for (String param : commandString.split(" ")) {
if (param.equals(commandName)) continue;
if (param.equals(commandName))
continue;
commandParameters.add(param);
}
this.addCommand(command, commandParameters.toArray(new String[0]));
@ -448,13 +511,19 @@ IPeripheral {
@Override
public void onCreate(Vector3 placedPosition) {
AssemblyLine.blockMulti.makeFakeBlock(this.worldObj, Vector3.add(placedPosition, new Vector3(0.0, 1.0, 0.0)), placedPosition);
AssemblyLine.blockMulti.makeFakeBlock(
this.worldObj,
Vector3.add(placedPosition, new Vector3(0.0, 1.0, 0.0)),
placedPosition
);
}
@Override
public void onDestroy(TileEntity callingBlock) {
this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.air, 0, 3);
this.worldObj.setBlock(this.xCoord, this.yCoord + 1, this.zCoord, Blocks.air, 0, 3);
this.worldObj.setBlock(
this.xCoord, this.yCoord + 1, this.zCoord, Blocks.air, 0, 3
);
}
@Override
@ -464,21 +533,27 @@ IPeripheral {
@Override
public String[] getMethodNames() {
return new String[]{"rotateBy", "rotateTo", "grab", "drop", "reset", "isWorking", "touchingEntity", "use", "fire", "return", "clear", "isHolding"};
return new String[] { "rotateBy", "rotateTo", "grab", "drop",
"reset", "isWorking", "touchingEntity", "use",
"fire", "return", "clear", "isHolding" };
}
@Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException {
public Object[] callMethod(
IComputerAccess computer, ILuaContext context, int method, Object[] arguments
) throws LuaException, InterruptedException {
switch (method) {
case 0: {
if (arguments.length > 0) {
try {
double yaw = (Double) arguments[0];
double pitch = (Double) arguments[1];
this.addCommand(CommandRotateBy.class, new String[]{Double.toString(yaw), Double.toString(pitch)});
this.addCommand(
CommandRotateBy.class,
new String[] { Double.toString(yaw), Double.toString(pitch) }
);
break;
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
@ -490,10 +565,12 @@ IPeripheral {
try {
double yaw = (Double) arguments[0];
double pitch = (Double) arguments[1];
this.addCommand(CommandRotateTo.class, new String[]{Double.toString(yaw), Double.toString(pitch)});
this.addCommand(
CommandRotateTo.class,
new String[] { Double.toString(yaw), Double.toString(pitch) }
);
break;
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
@ -518,10 +595,22 @@ IPeripheral {
}
case 6: {
Vector3 serachPosition = this.getHandPosition();
List found = this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double)(serachPosition.x - 0.5), (double)(serachPosition.y - 0.5), (double)(serachPosition.z - 0.5), (double)(serachPosition.x + 0.5), (double)(serachPosition.y + 0.5), (double)(serachPosition.z + 0.5)));
List found = this.worldObj.getEntitiesWithinAABB(
Entity.class,
AxisAlignedBB.getBoundingBox(
(double) (serachPosition.x - 0.5),
(double) (serachPosition.y - 0.5),
(double) (serachPosition.z - 0.5),
(double) (serachPosition.x + 0.5),
(double) (serachPosition.y + 0.5),
(double) (serachPosition.z + 0.5)
)
);
if (found != null && found.size() > 0) {
for (int i = 0; i < found.size(); ++i) {
if (found.get(i) == null || found.get(i) instanceof EntityPlayer || ((Entity)found.get((int)i)).ridingEntity != null) continue;
if (found.get(i) == null || found.get(i) instanceof EntityPlayer
|| ((Entity) found.get((int) i)).ridingEntity != null)
continue;
return new Object[] { true };
}
}
@ -531,10 +620,11 @@ IPeripheral {
if (arguments.length > 0) {
try {
int times = (Integer) arguments[0];
this.addCommand(CommandUse.class, new String[]{Integer.toString(times)});
this.addCommand(
CommandUse.class, new String[] { Integer.toString(times) }
);
break;
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
@ -546,10 +636,11 @@ IPeripheral {
if (arguments.length > 0) {
try {
float strength = (float) ((Double) arguments[0]).doubleValue();
this.addCommand(CommandFire.class, new String[]{Float.toString(strength)});
this.addCommand(
CommandFire.class, new String[] { Float.toString(strength) }
);
break;
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
@ -629,7 +720,9 @@ IPeripheral {
@Override
public void dropItem(ItemStack itemStack) {
Vector3 handPosition = this.getHandPosition();
this.worldObj.spawnEntityInWorld((Entity)new EntityItem(this.worldObj, handPosition.x, handPosition.y, handPosition.z, itemStack));
this.worldObj.spawnEntityInWorld((Entity) new EntityItem(
this.worldObj, handPosition.x, handPosition.y, handPosition.z, itemStack
));
this.grabbedItems.remove((Object) itemStack);
}
@ -638,14 +731,21 @@ IPeripheral {
Vector3 handPosition = this.getHandPosition();
Iterator it = this.grabbedItems.iterator();
while (it.hasNext()) {
ItemFindingHelper.dropItemStackExact(this.worldObj, handPosition.x, handPosition.y, handPosition.z, (ItemStack)it.next());
ItemFindingHelper.dropItemStackExact(
this.worldObj,
handPosition.x,
handPosition.y,
handPosition.z,
(ItemStack) it.next()
);
}
this.grabbedEntities.clear();
this.grabbedItems.clear();
}
public boolean isProvidingPowerSide(ForgeDirection dir) {
return this.isProvidingPower && dir.getOpposite() == this.getFacingDirectionFromAngle();
return this.isProvidingPower
&& dir.getOpposite() == this.getFacingDirectionFromAngle();
}
public ForgeDirection getFacingDirectionFromAngle() {
@ -681,4 +781,3 @@ IPeripheral {
return super.equals(other);
}
}

View file

@ -1,11 +1,12 @@
package assemblyline.common.machine.belt;
import java.util.List;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
@ -20,8 +21,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockConveyorBelt
extends BlockALMachine {
public class BlockConveyorBelt extends BlockALMachine {
public BlockConveyorBelt() {
super(UniversalElectricity.machine);
this.setBlockName("conveyorBelt");
@ -32,8 +32,10 @@ extends BlockALMachine {
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityConveyorBelt) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)world.getTileEntity(x, y, z);
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP || tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
TileEntityConveyorBelt tileEntity
= (TileEntityConveyorBelt) world.getTileEntity(x, y, z);
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP
|| tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.96f, 1.0f);
return;
}
@ -46,49 +48,144 @@ extends BlockALMachine {
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
public AxisAlignedBB
getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
TileEntity t = world.getTileEntity(x, y, z);
if (t != null && t instanceof TileEntityConveyorBelt) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP || tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
return AxisAlignedBB.getBoundingBox((double)x + this.minX, (double)y + this.minY, (double)z + this.minZ, (double)x + 1.0, (double)y + 1.0, (double)z + 1.0);
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP
|| tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + this.minY,
(double) z + this.minZ,
(double) x + 1.0,
(double) y + 1.0,
(double) z + 1.0
);
}
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
return AxisAlignedBB.getBoundingBox((double)x + this.minX, (double)y + (double)0.68f, (double)z + this.minZ, (double)x + this.maxX, (double)y + (double)0.98f, (double)z + this.maxZ);
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + (double) 0.68f,
(double) z + this.minZ,
(double) x + this.maxX,
(double) y + (double) 0.98f,
(double) z + this.maxZ
);
}
}
return AxisAlignedBB.getBoundingBox((double)x + this.minX, (double)y + this.minY, (double)z + this.minZ, (double)x + this.maxX, (double)y + this.maxY, (double)z + this.maxZ);
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + this.minY,
(double) z + this.minZ,
(double) x + this.maxX,
(double) y + this.maxY,
(double) z + this.maxZ
);
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
public void addCollisionBoxesToList(
World world,
int x,
int y,
int z,
AxisAlignedBB par5AxisAlignedBB,
List par6List,
Entity par7Entity
) {
AxisAlignedBB newBounds;
TileEntity t = world.getTileEntity(x, y, z);
if (t != null && t instanceof TileEntityConveyorBelt) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP || tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
AxisAlignedBB boundBottom = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.3, (double)(z + 1));
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP
|| tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
AxisAlignedBB boundBottom = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
(double) y + 0.3,
(double) (z + 1)
);
AxisAlignedBB boundTop = null;
ForgeDirection direction = tileEntity.getDirection();
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP) {
if (direction.offsetX > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)((float)x + (float)direction.offsetX / 2.0f), (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)(z + 1));
boundTop = AxisAlignedBB.getBoundingBox(
(double) ((float) x + (float) direction.offsetX / 2.0f),
(double) y,
(double) z,
(double) (x + 1),
(double) y + 0.8,
(double) (z + 1)
);
} else if (direction.offsetX < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)((float)x + (float)direction.offsetX / -2.0f), (double)y + 0.8, (double)(z + 1));
boundTop = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) ((float) x + (float) direction.offsetX / -2.0f),
(double) y + 0.8,
(double) (z + 1)
);
} else if (direction.offsetZ > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)((float)z + (float)direction.offsetZ / 2.0f), (double)(x + 1), (double)y + 0.8, (double)(z + 1));
boundTop = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) ((float) z + (float) direction.offsetZ / 2.0f),
(double) (x + 1),
(double) y + 0.8,
(double) (z + 1)
);
} else if (direction.offsetZ < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)((float)z + (float)direction.offsetZ / -2.0f));
boundTop = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
(double) y + 0.8,
(double) ((float) z + (float) direction.offsetZ / -2.0f)
);
}
} else if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
if (direction.offsetX > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)((float)x + (float)direction.offsetX / 2.0f), (double)y + 0.8, (double)(z + 1));
boundTop = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) ((float) x + (float) direction.offsetX / 2.0f),
(double) y + 0.8,
(double) (z + 1)
);
} else if (direction.offsetX < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)((float)x + (float)direction.offsetX / -2.0f), (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)(z + 1));
boundTop = AxisAlignedBB.getBoundingBox(
(double) ((float) x + (float) direction.offsetX / -2.0f),
(double) y,
(double) z,
(double) (x + 1),
(double) y + 0.8,
(double) (z + 1)
);
} else if (direction.offsetZ > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)((float)z + (float)direction.offsetZ / 2.0f));
boundTop = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
(double) y + 0.8,
(double) ((float) z + (float) direction.offsetZ / 2.0f)
);
} else if (direction.offsetZ < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)((float)z + (float)direction.offsetZ / -2.0f), (double)(x + 1), (double)y + 0.8, (double)(z + 1));
boundTop = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) ((float) z + (float) direction.offsetZ / -2.0f),
(double) (x + 1),
(double) y + 0.8,
(double) (z + 1)
);
}
}
if (par5AxisAlignedBB.intersectsWith(boundBottom)) {
@ -100,21 +197,45 @@ extends BlockALMachine {
return;
}
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
AxisAlignedBB newBounds2 = AxisAlignedBB.getBoundingBox((double)x, (double)y + 0.68, (double)z, (double)(x + 1), (double)y + 0.98, (double)(z + 1));
AxisAlignedBB newBounds2 = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y + 0.68,
(double) z,
(double) (x + 1),
(double) y + 0.98,
(double) (z + 1)
);
if (newBounds2 != null && par5AxisAlignedBB.intersectsWith(newBounds2)) {
par6List.add(newBounds2);
}
return;
}
}
if ((newBounds = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.3, (double)(z + 1))) != null && par5AxisAlignedBB.intersectsWith(newBounds)) {
if ((newBounds = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
(double) y + 0.3,
(double) (z + 1)
)) != null
&& par5AxisAlignedBB.intersectsWith(newBounds)) {
par6List.add(newBounds);
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack) {
int angle = MathHelper.floor_double((double)((double)(par5EntityLiving.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3;
public void onBlockPlacedBy(
World world,
int x,
int y,
int z,
EntityLivingBase par5EntityLiving,
ItemStack stack
) {
int angle = MathHelper.floor_double((double
) ((double) (par5EntityLiving.rotationYaw * 4.0f / 360.0f) + 0.5))
& 3;
int change = 2;
switch (angle) {
case 0: {
@ -137,7 +258,17 @@ extends BlockALMachine {
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
int original = world.getBlockMetadata(x, y, z);
int change = 2;
switch (original) {
@ -162,8 +293,19 @@ extends BlockALMachine {
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)world.getTileEntity(x, y, z);
public boolean onSneakUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
TileEntityConveyorBelt tileEntity
= (TileEntityConveyorBelt) world.getTileEntity(x, y, z);
int slantOrdinal = tileEntity.getSlant().ordinal() + 1;
if (slantOrdinal >= TileEntityConveyorBelt.SlantType.values().length) {
slantOrdinal = 0;
@ -173,8 +315,10 @@ extends BlockALMachine {
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)world.getTileEntity(x, y, z);
public void
onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
TileEntityConveyorBelt tileEntity
= (TileEntityConveyorBelt) world.getTileEntity(x, y, z);
tileEntity.updatePowerTransferRange();
if (tileEntity.IgnoreList.contains((Object) entity)) {
return;
@ -190,7 +334,11 @@ extends BlockALMachine {
acceleration *= 5.0f;
maxSpeed *= 10.0f;
}
entity.addVelocity((double)((float)direction.offsetX * acceleration), 0.0, (double)((float)direction.offsetZ * acceleration));
entity.addVelocity(
(double) ((float) direction.offsetX * acceleration),
0.0,
(double) ((float) direction.offsetZ * acceleration)
);
if (direction.offsetX != 0 && Math.abs(entity.motionX) > (double) maxSpeed) {
entity.motionX = (float) direction.offsetX * maxSpeed;
entity.motionZ = 0.0;
@ -211,8 +359,20 @@ extends BlockALMachine {
}
++((EntityItem) entity).age;
boolean foundSneaking = false;
for (EntityPlayer player : (List<EntityPlayer>) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((double)(x - 1), (double)(y - 1), (double)(z - 1), (double)(x + 1), (double)(y + 1), (double)(z + 1)))) {
if (!player.isSneaking()) continue;
for (EntityPlayer player :
(List<EntityPlayer>) world.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getBoundingBox(
(double) (x - 1),
(double) (y - 1),
(double) (z - 1),
(double) (x + 1),
(double) (y + 1),
(double) (z + 1)
)
)) {
if (!player.isSneaking())
continue;
foundSneaking = true;
}
((EntityItem) entity).delayBeforeCanPickup = foundSneaking ? 0 : 20;
@ -254,4 +414,3 @@ extends BlockALMachine {
return 0;
}
}

View file

@ -1,14 +1,13 @@
package assemblyline.common.machine.belt;
import java.util.ArrayList;
import java.util.List;
import assemblyline.api.IBelt;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
@ -22,9 +21,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
public class TileEntityConveyorBelt
extends TileEntityAssemblyNetwork
implements IBelt,
IRotatable {
extends TileEntityAssemblyNetwork implements IBelt, IRotatable {
public static final int MAX_FRAME = 13;
public static final int MAX_SLANT_FRAME = 23;
public final float acceleration = 0.01f;
@ -40,10 +37,17 @@ IRotatable {
int maximumTransferRange = 0;
for (int i = 0; i < 6; ++i) {
direction = ForgeDirection.getOrientation((int) i);
TileEntity tileEntity = this.worldObj.getTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork)) continue;
TileEntityAssemblyNetwork assemblyNetwork = (TileEntityAssemblyNetwork)tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange) continue;
TileEntity tileEntity = this.worldObj.getTileEntity(
this.xCoord + direction.offsetX,
this.yCoord + direction.offsetY,
this.zCoord + direction.offsetZ
);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork))
continue;
TileEntityAssemblyNetwork assemblyNetwork
= (TileEntityAssemblyNetwork) tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange)
continue;
maximumTransferRange = assemblyNetwork.powerTransferRange;
}
for (int d = 0; d <= 1; ++d) {
@ -52,10 +56,18 @@ IRotatable {
direction = direction.getOpposite();
}
for (int i = -1; i <= 1; ++i) {
TileEntity tileEntity = this.worldObj.getTileEntity(this.xCoord + direction.offsetX, this.yCoord + i, this.zCoord + direction.offsetZ);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork)) continue;
TileEntityAssemblyNetwork assemblyNetwork = (TileEntityAssemblyNetwork)tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange) continue;
TileEntity tileEntity = this.worldObj.getTileEntity(
this.xCoord + direction.offsetX,
this.yCoord + i,
this.zCoord + direction.offsetZ
);
if (tileEntity == null
|| !(tileEntity instanceof TileEntityAssemblyNetwork))
continue;
TileEntityAssemblyNetwork assemblyNetwork
= (TileEntityAssemblyNetwork) tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange)
continue;
maximumTransferRange = assemblyNetwork.powerTransferRange;
}
}
@ -64,18 +76,35 @@ IRotatable {
@Override
public void onUpdate() {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.ticks % 10L == 0L) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER
&& this.ticks % 10L == 0L) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
ArrayList<Entity> newList = new ArrayList<Entity>();
for (Entity ent : this.IgnoreList) {
if (!this.getAffectedEntities().contains((Object)ent)) continue;
if (!this.getAffectedEntities().contains((Object) ent))
continue;
newList.add(ent);
}
this.IgnoreList = newList;
if (this.isRunning() && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) {
if (this.ticks % 10L == 0L && this.worldObj.isRemote && this.worldObj.getBlock(this.xCoord - 1, this.yCoord, this.zCoord) != AssemblyLine.blockConveyorBelt && this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 1) != AssemblyLine.blockConveyorBelt) {
this.worldObj.playSound((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "assemblyline:conveyor", 0.5f, 0.7f, true);
if (this.isRunning()
&& !this.worldObj.isBlockIndirectlyGettingPowered(
this.xCoord, this.yCoord, this.zCoord
)) {
if (this.ticks % 10L == 0L && this.worldObj.isRemote
&& this.worldObj.getBlock(this.xCoord - 1, this.yCoord, this.zCoord)
!= AssemblyLine.blockConveyorBelt
&& this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 1)
!= AssemblyLine.blockConveyorBelt) {
this.worldObj.playSound(
(double) this.xCoord,
(double) this.yCoord,
(double) this.zCoord,
"assemblyline:conveyor",
0.5f,
0.7f,
true
);
}
this.wheelRotation += 40.0f;
if (this.wheelRotation > 360.0f) {
@ -112,7 +141,9 @@ IRotatable {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setDouble("wattsReceived", this.wattsReceived);
nbt.setInteger("slantType", this.slantType.ordinal());
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
return new S35PacketUpdateTileEntity(
xCoord, yCoord, zCoord, getBlockMetadata(), nbt
);
}
public SlantType getSlant() {
@ -130,8 +161,16 @@ IRotatable {
public boolean getIsFirstBelt() {
ForgeDirection front = this.getDirection();
ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = this.worldObj.getTileEntity(this.xCoord + front.offsetX, this.yCoord + front.offsetY, this.zCoord + front.offsetZ);
TileEntity BBelt = this.worldObj.getTileEntity(this.xCoord + back.offsetX, this.yCoord + back.offsetY, this.zCoord + back.offsetZ);
TileEntity fBelt = this.worldObj.getTileEntity(
this.xCoord + front.offsetX,
this.yCoord + front.offsetY,
this.zCoord + front.offsetZ
);
TileEntity BBelt = this.worldObj.getTileEntity(
this.xCoord + back.offsetX,
this.yCoord + back.offsetY,
this.zCoord + back.offsetZ
);
if (fBelt instanceof TileEntityConveyorBelt) {
ForgeDirection TD;
ForgeDirection fD = ((TileEntityConveyorBelt) fBelt).getDirection();
@ -143,9 +182,18 @@ IRotatable {
public boolean getIsMiddleBelt() {
ForgeDirection front = this.getDirection();
ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = this.worldObj.getTileEntity(this.xCoord + front.offsetX, this.yCoord + front.offsetY, this.zCoord + front.offsetZ);
TileEntity BBelt = this.worldObj.getTileEntity(this.xCoord + back.offsetX, this.yCoord + back.offsetY, this.zCoord + back.offsetZ);
if (fBelt instanceof TileEntityConveyorBelt && BBelt instanceof TileEntityConveyorBelt) {
TileEntity fBelt = this.worldObj.getTileEntity(
this.xCoord + front.offsetX,
this.yCoord + front.offsetY,
this.zCoord + front.offsetZ
);
TileEntity BBelt = this.worldObj.getTileEntity(
this.xCoord + back.offsetX,
this.yCoord + back.offsetY,
this.zCoord + back.offsetZ
);
if (fBelt instanceof TileEntityConveyorBelt
&& BBelt instanceof TileEntityConveyorBelt) {
ForgeDirection fD = ((TileEntityConveyorBelt) fBelt).getDirection();
ForgeDirection BD = ((TileEntityConveyorBelt) BBelt).getDirection();
ForgeDirection TD = this.getDirection();
@ -157,8 +205,16 @@ IRotatable {
public boolean getIsLastBelt() {
ForgeDirection front = this.getDirection();
ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = this.worldObj.getTileEntity(this.xCoord + front.offsetX, this.yCoord + front.offsetY, this.zCoord + front.offsetZ);
TileEntity BBelt = this.worldObj.getTileEntity(this.xCoord + back.offsetX, this.yCoord + back.offsetY, this.zCoord + back.offsetZ);
TileEntity fBelt = this.worldObj.getTileEntity(
this.xCoord + front.offsetX,
this.yCoord + front.offsetY,
this.zCoord + front.offsetZ
);
TileEntity BBelt = this.worldObj.getTileEntity(
this.xCoord + back.offsetX,
this.yCoord + back.offsetY,
this.zCoord + back.offsetZ
);
if (BBelt instanceof TileEntityConveyorBelt) {
ForgeDirection TD;
ForgeDirection BD = ((TileEntityConveyorBelt) BBelt).getDirection();
@ -177,8 +233,11 @@ IRotatable {
}
@Override
public void setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
public void
setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3
);
}
@Override
@ -187,28 +246,43 @@ IRotatable {
}
public ForgeDirection getDirection() {
return this.getDirection((IBlockAccess)this.worldObj, this.xCoord, this.yCoord, this.zCoord);
return this.getDirection(
(IBlockAccess) this.worldObj, this.xCoord, this.yCoord, this.zCoord
);
}
public void setDirection(ForgeDirection facingDirection) {
this.setDirection(this.worldObj, this.xCoord, this.yCoord, this.zCoord, facingDirection);
this.setDirection(
this.worldObj, this.xCoord, this.yCoord, this.zCoord, facingDirection
);
}
@Override
public List getAffectedEntities() {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1));
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(
(double) this.xCoord,
(double) this.yCoord,
(double) this.zCoord,
(double) (this.xCoord + 1),
(double) (this.yCoord + 1),
(double) (this.zCoord + 1)
);
return this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
}
public int getAnimationFrame() {
if (!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) {
if (!this.worldObj.isBlockIndirectlyGettingPowered(
this.xCoord, this.yCoord, this.zCoord
)) {
TileEntity te = null;
te = this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
if (te != null && te instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)te).getSlant() == this.slantType) {
if (te != null && te instanceof TileEntityConveyorBelt
&& ((TileEntityConveyorBelt) te).getSlant() == this.slantType) {
return ((TileEntityConveyorBelt) te).getAnimationFrame();
}
te = this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
if (te != null && te instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)te).getSlant() == this.slantType) {
if (te != null && te instanceof TileEntityConveyorBelt
&& ((TileEntityConveyorBelt) te).getSlant() == this.slantType) {
return ((TileEntityConveyorBelt) te).getAnimationFrame();
}
}
@ -220,7 +294,9 @@ IRotatable {
super.readFromNBT(nbt);
this.slantType = SlantType.values()[nbt.getByte("slant")];
if (this.worldObj != null) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, nbt.getInteger("rotation"), 3);
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, nbt.getInteger("rotation"), 3
);
}
}
@ -229,7 +305,10 @@ IRotatable {
super.writeToNBT(nbt);
nbt.setByte("slant", (byte) this.slantType.ordinal());
if (this.worldObj != null) {
nbt.setInteger("rotation", this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
nbt.setInteger(
"rotation",
this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)
);
}
}
@ -250,7 +329,5 @@ IRotatable {
UP,
DOWN,
TOP;
}
}

View file

@ -1,6 +1,3 @@
package assemblyline.common.machine.belt;
public class TileEntityCoveredBelt
extends TileEntityConveyorBelt {
}
public class TileEntityCoveredBelt extends TileEntityConveyorBelt {}

View file

@ -2,10 +2,10 @@ package assemblyline.common.machine.belt;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
public class TileEntityElevatorBelt
extends TileEntityConveyorBelt {
public class TileEntityElevatorBelt extends TileEntityConveyorBelt {
public List conveyList = new ArrayList();
public void doBeltAction() {
@ -13,11 +13,10 @@ extends TileEntityConveyorBelt {
}
public boolean isBellowABelt() {
TileEntity ent = this.worldObj.getTileEntity(this.xCoord, this.xCoord - 1, this.zCoord);
TileEntity ent
= this.worldObj.getTileEntity(this.xCoord, this.xCoord - 1, this.zCoord);
return ent instanceof TileEntityElevatorBelt;
}
public void conveyItemsVertical(boolean extendLife, boolean preventPickUp) {
public void conveyItemsVertical(boolean extendLife, boolean preventPickUp) {}
}
}

View file

@ -1,5 +1,7 @@
package assemblyline.common.machine.command;
import java.util.HashMap;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import assemblyline.common.machine.command.CommandBreak;
import assemblyline.common.machine.command.CommandDrop;
@ -15,7 +17,6 @@ import assemblyline.common.machine.command.CommandReturn;
import assemblyline.common.machine.command.CommandRotateBy;
import assemblyline.common.machine.command.CommandRotateTo;
import assemblyline.common.machine.command.CommandUse;
import java.util.HashMap;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
@ -46,11 +47,9 @@ public abstract class Command {
return false;
}
public void onTaskStart() {
}
public void onTaskStart() {}
public void onTaskEnd() {
}
public void onTaskEnd() {}
public int getTickInterval() {
return 1;
@ -75,8 +74,7 @@ public abstract class Command {
if (this.getArg(i) != null) {
try {
return Integer.parseInt(this.getArg(i));
}
catch (Exception exception) {
} catch (Exception exception) {
// empty catch block
}
}
@ -87,8 +85,7 @@ public abstract class Command {
if (this.getArg(i) != null) {
try {
return Double.parseDouble(this.getArg(i));
}
catch (Exception exception) {
} catch (Exception exception) {
// empty catch block
}
}
@ -99,8 +96,7 @@ public abstract class Command {
if (this.getArg(i) != null) {
try {
return Float.valueOf(Float.parseFloat(this.getArg(i)));
}
catch (Exception exception) {
} catch (Exception exception) {
// empty catch block
}
}
@ -135,4 +131,3 @@ public abstract class Command {
Command.registerCommand("harvest", CommandHarvest.class);
}
}

View file

@ -1,9 +1,10 @@
package assemblyline.common.machine.command;
import java.util.ArrayList;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandRotateTo;
import dark.library.helpers.ItemFindingHelper;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@ -12,8 +13,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import universalelectricity.core.vector.Vector3;
public class CommandBreak
extends Command {
public class CommandBreak extends Command {
private CommandRotateTo rotateToCommand;
int BREAK_TIME = 30;
boolean keep = false;
@ -24,13 +24,38 @@ extends Command {
Vector3 serachPosition = this.tileEntity.getHandPosition();
Block block = serachPosition.getBlock(this.world);
if (block != null && this.BREAK_TIME <= this.ticks) {
ArrayList items = block.getDrops(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), serachPosition.getBlockMetadata((IBlockAccess)this.world), 0);
ArrayList items = block.getDrops(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
serachPosition.getBlockMetadata((IBlockAccess) this.world),
0
);
if (!this.keep || items.size() > 1) {
ItemFindingHelper.dropBlockAsItem(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
ItemFindingHelper.dropBlockAsItem(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ()
);
} else {
this.tileEntity.grabEntity((Entity)new EntityItem(this.world, (double)serachPosition.intX() + 0.5, (double)serachPosition.intY() + 0.5, (double)serachPosition.intZ() + 0.5, (ItemStack)items.get(0)));
this.tileEntity.grabEntity((Entity) new EntityItem(
this.world,
(double) serachPosition.intX() + 0.5,
(double) serachPosition.intY() + 0.5,
(double) serachPosition.intZ() + 0.5,
(ItemStack) items.get(0)
));
}
this.world.setBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), Blocks.air, 0, 3);
this.world.setBlock(
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
Blocks.air,
0,
3
);
return false;
}
return true;
@ -41,4 +66,3 @@ extends Command {
return "BREAK";
}
}

View file

@ -2,13 +2,24 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
public class CommandDrop
extends Command {
public class CommandDrop extends Command {
@Override
protected boolean doTask() {
super.doTask();
this.tileEntity.dropAll();
this.world.playSound((double)this.tileEntity.xCoord, (double)this.tileEntity.yCoord, (double)this.tileEntity.zCoord, "random.pop", 0.2f, ((this.tileEntity.getWorldObj().rand.nextFloat() - this.tileEntity.getWorldObj().rand.nextFloat()) * 0.7f + 1.0f) * 1.0f, true);
this.world.playSound(
(double) this.tileEntity.xCoord,
(double) this.tileEntity.yCoord,
(double) this.tileEntity.zCoord,
"random.pop",
0.2f,
((this.tileEntity.getWorldObj().rand.nextFloat()
- this.tileEntity.getWorldObj().rand.nextFloat())
* 0.7f
+ 1.0f)
* 1.0f,
true
);
return false;
}
@ -17,4 +28,3 @@ extends Command {
return "DROP";
}
}

View file

@ -1,8 +1,9 @@
package assemblyline.common.machine.command;
import java.util.Random;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandDrop;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.projectile.EntityArrow;
@ -12,8 +13,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import universalelectricity.core.vector.Vector3;
public class CommandFire
extends Command {
public class CommandFire extends Command {
private static final float MIN_ACTUAL_PITCH = -80.0f;
private static final float MAX_ACTUAL_PITCH = 80.0f;
private float actualYaw;
@ -52,8 +52,17 @@ extends Command {
if (this.finalVelocity == null) {
this.finalVelocity = new Vector3(0.0, 0.0, 0.0);
}
if (this.tileEntity.getGrabbedEntities().size() > 0 && (held = (Entity)this.tileEntity.getGrabbedEntities().get(0)) != null) {
this.world.playSound((double)this.tileEntity.xCoord, (double)this.tileEntity.yCoord, (double)this.tileEntity.zCoord, "random.bow", this.velocity, 2.0f - this.velocity / 4.0f, true);
if (this.tileEntity.getGrabbedEntities().size() > 0
&& (held = (Entity) this.tileEntity.getGrabbedEntities().get(0)) != null) {
this.world.playSound(
(double) this.tileEntity.xCoord,
(double) this.tileEntity.yCoord,
(double) this.tileEntity.zCoord,
"random.bow",
this.velocity,
2.0f - this.velocity / 4.0f,
true
);
if (held instanceof EntityItem) {
EntityItem item = (EntityItem) held;
ItemStack stack = item.getEntityItem();
@ -63,13 +72,20 @@ extends Command {
--stack.stackSize;
item.setEntityItemStack(stack);
} else {
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[0]).doTask();
this.commandManager
.getNewCommand(this.tileEntity, CommandDrop.class, new String[0])
.doTask();
if (!this.world.isRemote) {
this.world.removeEntity(held);
}
}
if (item.getEntityItem().getItem() == Items.arrow) {
EntityArrow arrow = new EntityArrow(this.world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z);
EntityArrow arrow = new EntityArrow(
this.world,
this.tileEntity.getHandPosition().x,
this.tileEntity.getHandPosition().y,
this.tileEntity.getHandPosition().z
);
arrow.motionX = this.finalVelocity.x;
arrow.motionY = this.finalVelocity.y;
arrow.motionZ = this.finalVelocity.z;
@ -77,7 +93,13 @@ extends Command {
this.world.spawnEntityInWorld((Entity) arrow);
}
} else {
EntityItem item2 = new EntityItem(this.world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z, thrown);
EntityItem item2 = new EntityItem(
this.world,
this.tileEntity.getHandPosition().x,
this.tileEntity.getHandPosition().y,
this.tileEntity.getHandPosition().z,
thrown
);
item2.motionX = this.finalVelocity.x;
item2.motionY = this.finalVelocity.y;
item2.motionZ = this.finalVelocity.z;
@ -86,7 +108,9 @@ extends Command {
}
}
} else {
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[0]).doTask();
this.commandManager
.getNewCommand(this.tileEntity, CommandDrop.class, new String[0])
.doTask();
held.motionX = this.finalVelocity.x;
held.motionY = this.finalVelocity.y;
held.motionZ = this.finalVelocity.z;
@ -125,4 +149,3 @@ extends Command {
return "FIRE " + Float.toString(this.velocity);
}
}

View file

@ -1,9 +1,10 @@
package assemblyline.common.machine.command;
import java.util.List;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.GrabDictionary;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.player.EntityPlayer;
@ -14,8 +15,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import universalelectricity.core.vector.Vector3;
public class CommandGrab
extends Command {
public class CommandGrab extends Command {
public static final float radius = 0.5f;
public boolean child = false;
private TileEntityConveyorBelt belt;
@ -25,15 +25,21 @@ extends Command {
public void onTaskStart() {
super.onTaskStart();
this.entityToInclude = Entity.class;
if (this.getArgs() != null && this.getArgs().length > 0 && this.getArgs()[0] != null) {
if (this.getArg(0).equalsIgnoreCase("baby") || this.getArg(0).equalsIgnoreCase("child")) {
if (this.getArgs() != null && this.getArgs().length > 0
&& this.getArgs()[0] != null) {
if (this.getArg(0).equalsIgnoreCase("baby")
|| this.getArg(0).equalsIgnoreCase("child")) {
this.child = true;
if (this.getArgs().length > 1 && this.getArgs()[1] != null) {
this.entityToInclude = GrabDictionary.get(this.getArg(1)).getEntityClass();
this.entityToInclude
= GrabDictionary.get(this.getArg(1)).getEntityClass();
}
} else {
this.entityToInclude = GrabDictionary.get(this.getArg(0)).getEntityClass();
if (this.getArgs().length > 1 && this.getArgs()[1] != null && (this.getArg(1).equalsIgnoreCase("baby") || this.getArg(0).equalsIgnoreCase("child"))) {
this.entityToInclude
= GrabDictionary.get(this.getArg(0)).getEntityClass();
if (this.getArgs().length > 1 && this.getArgs()[1] != null
&& (this.getArg(1).equalsIgnoreCase("baby")
|| this.getArg(0).equalsIgnoreCase("child"))) {
this.child = true;
}
}
@ -47,7 +53,17 @@ extends Command {
return false;
}
Vector3 serachPosition = this.tileEntity.getHandPosition();
List found = this.world.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox((double)(serachPosition.x - 0.5), (double)(serachPosition.y - 0.5), (double)(serachPosition.z - 0.5), (double)(serachPosition.x + 0.5), (double)(serachPosition.y + 0.5), (double)(serachPosition.z + 0.5)));
List found = this.world.getEntitiesWithinAABB(
this.entityToInclude,
AxisAlignedBB.getBoundingBox(
(double) (serachPosition.x - 0.5),
(double) (serachPosition.y - 0.5),
(double) (serachPosition.z - 0.5),
(double) (serachPosition.x + 0.5),
(double) (serachPosition.y + 0.5),
(double) (serachPosition.z + 0.5)
)
);
TileEntity ent = serachPosition.getTileEntity((IBlockAccess) this.world);
Vector3 searchPostion2 = Vector3.add(serachPosition, new Vector3(0.0, -1.0, 0.0));
TileEntity ent2 = searchPostion2.getTileEntity((IBlockAccess) this.world);
@ -58,9 +74,27 @@ extends Command {
}
if (found != null && found.size() > 0) {
for (int i = 0; i < found.size(); ++i) {
if (found.get(i) == null || found.get(i) instanceof EntityArrow || found.get(i) instanceof EntityPlayer || ((Entity)found.get((int)i)).ridingEntity != null || found.get(i) instanceof EntityAgeable && (!(found.get(i) instanceof EntityAgeable) || this.child != ((EntityAgeable)found.get(i)).isChild())) continue;
if (found.get(i) == null || found.get(i) instanceof EntityArrow
|| found.get(i) instanceof EntityPlayer
|| ((Entity) found.get((int) i)).ridingEntity != null
|| found.get(i) instanceof EntityAgeable
&& (!(found.get(i) instanceof EntityAgeable)
|| this.child != ((EntityAgeable) found.get(i)).isChild()))
continue;
this.tileEntity.grabEntity((Entity) found.get(i));
this.world.playSound((double)this.tileEntity.xCoord, (double)this.tileEntity.yCoord, (double)this.tileEntity.zCoord, "random.pop", 0.2f, ((this.tileEntity.getWorldObj().rand.nextFloat() - this.tileEntity.getWorldObj().rand.nextFloat()) * 0.7f + 1.0f) * 1.0f, true);
this.world.playSound(
(double) this.tileEntity.xCoord,
(double) this.tileEntity.yCoord,
(double) this.tileEntity.zCoord,
"random.pop",
0.2f,
((this.tileEntity.getWorldObj().rand.nextFloat()
- this.tileEntity.getWorldObj().rand.nextFloat())
* 0.7f
+ 1.0f)
* 1.0f,
true
);
if (this.belt != null) {
this.belt.IgnoreEntity((Entity) found.get(i));
}
@ -74,14 +108,20 @@ extends Command {
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.child = taskCompound.getBoolean("child");
this.entityToInclude = GrabDictionary.get(taskCompound.getString("name")).getEntityClass();
this.entityToInclude
= GrabDictionary.get(taskCompound.getString("name")).getEntityClass();
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setBoolean("child", this.child);
taskCompound.setString("name", this.entityToInclude != null ? GrabDictionary.get(this.entityToInclude).getName() : "");
taskCompound.setString(
"name",
this.entityToInclude != null
? GrabDictionary.get(this.entityToInclude).getName()
: ""
);
}
@Override
@ -97,4 +137,3 @@ extends Command {
return "GRAB " + baby + entity;
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.CommandBreak;
import assemblyline.common.machine.command.CommandRotateTo;
public class CommandHarvest
extends CommandBreak {
public class CommandHarvest extends CommandBreak {
private CommandRotateTo rotateToCommand;
@Override
@ -17,4 +16,3 @@ extends CommandBreak {
return "HARVEST";
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandIdle
extends Command {
public class CommandIdle extends Command {
public int idleTime = 80;
private int totalIdleTime = 80;
@ -44,4 +43,3 @@ extends Command {
return "IDLE " + Integer.toString(this.totalIdleTime);
}
}

View file

@ -1,11 +1,12 @@
package assemblyline.common.machine.command;
import java.util.ArrayList;
import java.util.List;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandRepeat;
import cpw.mods.fml.common.FMLLog;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@ -34,22 +35,30 @@ public class CommandManager {
int tempCurrentTask = this.currentTask++;
task.onTaskEnd();
if (!(task instanceof CommandRepeat)) {
this.tasks.set(tempCurrentTask, this.getNewCommand(task.tileEntity, task.getClass(), task.getArgs()));
this.tasks.set(
tempCurrentTask,
this.getNewCommand(
task.tileEntity, task.getClass(), task.getArgs()
)
);
}
}
} else {
this.clear();
}
}
}
catch (Exception e) {
FMLLog.severe((String)"Failed to execute task in Assembly Line.", (Object[])new Object[0]);
} catch (Exception e) {
FMLLog.severe(
(String) "Failed to execute task in Assembly Line.",
(Object[]) new Object[0]
);
e.printStackTrace();
}
++this.ticks;
}
public Command getNewCommand(TileEntityArmbot tileEntity, Class commandClass, String[] parameters) {
public Command
getNewCommand(TileEntityArmbot tileEntity, Class commandClass, String[] parameters) {
try {
Command newCommand = (Command) commandClass.newInstance();
newCommand.world = tileEntity.getWorldObj();
@ -57,15 +66,15 @@ public class CommandManager {
newCommand.commandManager = this;
newCommand.setParameters(parameters);
return newCommand;
}
catch (Exception e) {
} catch (Exception e) {
FMLLog.severe((String) "Failed to add command", (Object[]) new Object[0]);
e.printStackTrace();
return null;
}
}
public void addCommand(TileEntityArmbot tileEntity, Class commandClass, String[] parameters) {
public void
addCommand(TileEntityArmbot tileEntity, Class commandClass, String[] parameters) {
Command newCommand = this.getNewCommand(tileEntity, commandClass, parameters);
if (newCommand != null) {
this.tasks.add(newCommand);
@ -116,11 +125,12 @@ public class CommandManager {
pars.add(parameters.getStringTagAt((int) ii));
}
}
Command cmd = this.getNewCommand(tileEntity, cmdClass, pars.toArray(new String[0]));
Command cmd = this.getNewCommand(
tileEntity, cmdClass, pars.toArray(new String[0])
);
cmd.readFromNBT((NBTTagCompound) cmdTag.getTag("customData"));
continue;
}
catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
System.out.println("Error loading CommandManger: ");
e.printStackTrace();
}
@ -141,12 +151,15 @@ public class CommandManager {
if (((Command) this.tasks.get(i)).getArgs().length > 0) {
NBTTagList parameters = new NBTTagList();
for (String par : ((Command) this.tasks.get(i)).getArgs()) {
if (par == null || par.isEmpty()) continue;
if (par == null || par.isEmpty())
continue;
parameters.appendTag((NBTBase) new NBTTagString(par));
}
taskCompound.setTag("parameters", (NBTBase) parameters);
}
taskCompound.setInteger("numParameters", ((Command)this.tasks.get(i)).getArgs().length);
taskCompound.setInteger(
"numParameters", ((Command) this.tasks.get(i)).getArgs().length
);
NBTTagCompound customData = new NBTTagCompound();
((Command) this.tasks.get(i)).writeToNBT(customData);
taskCompound.setTag("customData", customData);
@ -159,4 +172,3 @@ public class CommandManager {
nbt.setInteger("ticks", this.ticks);
}
}

View file

@ -11,8 +11,7 @@ import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class CommandPlace
extends Command {
public class CommandPlace extends Command {
int PLACE_TIME = 30;
@Override
@ -28,21 +27,84 @@ extends Command {
if (block == null && this.ticks >= this.PLACE_TIME) {
for (Entity entity : this.tileEntity.getGrabbedEntities()) {
ItemStack itemStack;
if (!(entity instanceof EntityItem) || (itemStack = ((EntityItem)entity).getEntityItem()) == null) continue;
if (!(entity instanceof EntityItem)
|| (itemStack = ((EntityItem) entity).getEntityItem()) == null)
continue;
if (itemStack.getItem() instanceof ItemBlock) {
((ItemBlock)itemStack.getItem()).placeBlockAt(itemStack, null, this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), 0, 0.5f, 0.5f, 0.5f, itemStack.getItemDamage());
((ItemBlock) itemStack.getItem())
.placeBlockAt(
itemStack,
null,
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
0,
0.5f,
0.5f,
0.5f,
itemStack.getItemDamage()
);
this.tileEntity.dropEntity(entity);
return false;
}
if (!(itemStack.getItem() instanceof IPlantable)) continue;
if (!(itemStack.getItem() instanceof IPlantable))
continue;
IPlantable plantable = (IPlantable) itemStack.getItem();
Block blockBelow = Vector3.add(serachPosition, new Vector3(0.0, -1.0, 0.0)).getBlock((IBlockAccess)this.world);
if (blockBelow == null || !blockBelow.canSustainPlant(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), ForgeDirection.UP, plantable)) continue;
Block plantBlock = plantable.getPlant(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
int blockMetadata = plantable.getPlantMetadata(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
if (!this.world.setBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), plantBlock, blockMetadata, 3) || this.world.getBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ()) != plantBlock) continue;
plantBlock.onBlockPlacedBy(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), null, itemStack);
plantBlock.onPostBlockPlaced(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), blockMetadata);
Block blockBelow
= Vector3.add(serachPosition, new Vector3(0.0, -1.0, 0.0))
.getBlock((IBlockAccess) this.world);
if (blockBelow == null
|| !blockBelow.canSustainPlant(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
ForgeDirection.UP,
plantable
))
continue;
Block plantBlock = plantable.getPlant(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ()
);
int blockMetadata = plantable.getPlantMetadata(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ()
);
if (!this.world.setBlock(
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
plantBlock,
blockMetadata,
3
)
|| this.world.getBlock(
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ()
) != plantBlock)
continue;
plantBlock.onBlockPlacedBy(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
null,
itemStack
);
plantBlock.onPostBlockPlaced(
this.world,
serachPosition.intX(),
serachPosition.intY(),
serachPosition.intZ(),
blockMetadata
);
this.tileEntity.dropEntity(entity);
return false;
}
@ -55,4 +117,3 @@ extends Command {
return "PLACE";
}
}

View file

@ -1,8 +1,9 @@
package assemblyline.common.machine.command;
import java.util.ArrayList;
import assemblyline.common.machine.command.Command;
import dark.library.helpers.ItemFindingHelper;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@ -12,8 +13,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class CommandPowerTo
extends Command {
public class CommandPowerTo extends Command {
private int duration;
private int ticksRan;
@ -41,13 +41,20 @@ extends Command {
this.world.spawnParticle("smoke", loc.x, loc.y, loc.z, 0.0, 0.0, 0.0);
this.world.spawnParticle("flame", loc.x, loc.y, loc.z, 0.0, 0.0, 0.0);
}
Block block = this.world.getBlock(this.tileEntity.getHandPosition().intX(), this.tileEntity.getHandPosition().intY(), this.tileEntity.getHandPosition().intZ());
TileEntity targetTile = this.tileEntity.getHandPosition().getTileEntity((IBlockAccess)this.world);
Block block = this.world.getBlock(
this.tileEntity.getHandPosition().intX(),
this.tileEntity.getHandPosition().intY(),
this.tileEntity.getHandPosition().intZ()
);
TileEntity targetTile
= this.tileEntity.getHandPosition().getTileEntity((IBlockAccess) this.world);
if (this.tileEntity.getGrabbedItems().size() > 0) {
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
stacks.add(new ItemStack(Blocks.redstone_torch, 1, 0));
stacks.add(new ItemStack(Blocks.unlit_redstone_torch, 1, 0));
if (ItemFindingHelper.filterItems(this.tileEntity.getGrabbedItems(), stacks).size() > 0) {
if (ItemFindingHelper.filterItems(this.tileEntity.getGrabbedItems(), stacks)
.size()
> 0) {
this.powerBlock(true);
}
}
@ -57,10 +64,17 @@ extends Command {
public void powerBlock(boolean on) {
this.tileEntity.isProvidingPower = on;
Block block = this.tileEntity.getWorldObj().getBlock(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord);
Block block = this.tileEntity.getWorldObj().getBlock(
this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord
);
for (int i = 2; i < 6; ++i) {
ForgeDirection dir = ForgeDirection.getOrientation((int) i);
this.world.notifyBlockOfNeighborChange(this.tileEntity.xCoord + dir.offsetX, this.tileEntity.yCoord + dir.offsetY, this.tileEntity.zCoord + dir.offsetZ, block);
this.world.notifyBlockOfNeighborChange(
this.tileEntity.xCoord + dir.offsetX,
this.tileEntity.yCoord + dir.offsetY,
this.tileEntity.zCoord + dir.offsetZ,
block
);
}
}
@ -83,4 +97,3 @@ extends Command {
taskCompound.setInteger("useCurTimes", this.ticksRan);
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandRepeat
extends Command {
public class CommandRepeat extends Command {
private int tasksToRepeat;
private int numReps;
private int curReps;
@ -28,7 +27,9 @@ extends Command {
if (this.curReps < this.numReps || this.numReps == -1) {
++this.curReps;
if (this.tasksToRepeat > 0) {
this.commandManager.setCurrentTask(this.commandManager.getCurrentTask() - this.tasksToRepeat - 1);
this.commandManager.setCurrentTask(
this.commandManager.getCurrentTask() - this.tasksToRepeat - 1
);
return;
}
this.commandManager.setCurrentTask(-2);
@ -61,10 +62,13 @@ extends Command {
if (this.tasksToRepeat > 0) {
cmdToTest = this.commandManager.getCurrentTask() - this.tasksToRepeat;
}
if (this.commandManager.hasTasks() && this.commandManager.getCurrentTask() >= 0 && this.commandManager.getCurrentTask() < this.commandManager.getCommands().size()) {
return ((Command)this.commandManager.getCommands().get(cmdToTest)).toString();
if (this.commandManager.hasTasks() && this.commandManager.getCurrentTask() >= 0
&& this.commandManager.getCurrentTask()
< this.commandManager.getCommands().size()) {
return ((Command) this.commandManager.getCommands().get(cmdToTest))
.toString();
}
return "REPEAT " + Integer.toString(this.tasksToRepeat) + " " + (this.numReps > 0 ? Integer.toString(this.numReps) : "");
return "REPEAT " + Integer.toString(this.tasksToRepeat) + " "
+ (this.numReps > 0 ? Integer.toString(this.numReps) : "");
}
}

View file

@ -3,15 +3,16 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandRotateTo;
public class CommandReturn
extends Command {
public class CommandReturn extends Command {
public static final float IDLE_ROTATION_PITCH = 0.0f;
public static final float IDLE_ROTATION_YAW = 0.0f;
private CommandRotateTo rotateToCommand;
@Override
public void onTaskStart() {
this.rotateToCommand = (CommandRotateTo)this.commandManager.getNewCommand(this.tileEntity, CommandRotateTo.class, new String[]{"0", "0"});
this.rotateToCommand = (CommandRotateTo) this.commandManager.getNewCommand(
this.tileEntity, CommandRotateTo.class, new String[] { "0", "0" }
);
this.rotateToCommand.onTaskStart();
}
@ -33,4 +34,3 @@ extends Command {
return "RETURN";
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandRotateBy
extends Command {
public class CommandRotateBy extends Command {
float targetRotationYaw = 0.0f;
float targetRotationPitch = 0.0f;
float deltaPitch = 0.0f;
@ -16,13 +15,15 @@ extends Command {
super.onTaskStart();
this.ticks = 0;
if (this.getArg(0) != null) {
this.targetRotationYaw = this.tileEntity.rotationYaw + this.getFloatArg(0).floatValue();
this.targetRotationYaw
= this.tileEntity.rotationYaw + this.getFloatArg(0).floatValue();
this.deltaYaw = this.getFloatArg(0).floatValue();
} else {
this.targetRotationYaw = this.tileEntity.rotationYaw + 90.0f;
}
if (this.getArg(1) != null) {
this.targetRotationPitch = this.tileEntity.rotationPitch + this.getFloatArg(1).floatValue();
this.targetRotationPitch
= this.tileEntity.rotationPitch + this.getFloatArg(1).floatValue();
this.deltaPitch = this.getFloatArg(1).floatValue();
} else {
this.targetRotationPitch = this.tileEntity.rotationPitch;
@ -57,7 +58,8 @@ extends Command {
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f) {
this.tileEntity.rotationPitch = this.targetRotationPitch;
}
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) {
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch)
> 0.001f) {
return true;
}
return Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f;
@ -79,7 +81,7 @@ extends Command {
@Override
public String toString() {
return "ROTATE " + Float.toString(this.deltaYaw) + " " + Float.toString(this.deltaPitch);
return "ROTATE " + Float.toString(this.deltaYaw) + " "
+ Float.toString(this.deltaPitch);
}
}

View file

@ -3,8 +3,7 @@ package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandRotateTo
extends Command {
public class CommandRotateTo extends Command {
float targetRotationYaw = 0.0f;
float targetRotationPitch = 0.0f;
int totalTicks = 0;
@ -14,8 +13,10 @@ extends Command {
super.onTaskStart();
this.ticks = 0;
this.totalTicks = 0;
this.targetRotationYaw = this.getArg(0) != null ? this.getFloatArg(0).floatValue() : 0.0f;
this.targetRotationPitch = this.getArg(1) != null ? this.getFloatArg(1).floatValue() : 0.0f;
this.targetRotationYaw
= this.getArg(0) != null ? this.getFloatArg(0).floatValue() : 0.0f;
this.targetRotationPitch
= this.getArg(1) != null ? this.getFloatArg(1).floatValue() : 0.0f;
while (this.targetRotationYaw < 0.0f) {
this.targetRotationYaw += 360.0f;
}
@ -42,7 +43,8 @@ extends Command {
super.doTask();
this.tileEntity.rotationYaw = this.targetRotationYaw;
this.tileEntity.rotationPitch = this.targetRotationPitch;
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) {
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch)
> 0.001f) {
return true;
}
return Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f;
@ -50,7 +52,8 @@ extends Command {
@Override
public String toString() {
return "ROTATETO " + Float.toString(this.targetRotationYaw) + " " + Float.toString(this.targetRotationPitch);
return "ROTATETO " + Float.toString(this.targetRotationYaw) + " "
+ Float.toString(this.targetRotationPitch);
}
@Override
@ -67,4 +70,3 @@ extends Command {
taskCompound.setFloat("rotYaw", this.targetRotationYaw);
}
}

View file

@ -8,8 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
public class CommandUse
extends Command {
public class CommandUse extends Command {
private int times;
private int curTimes;
@ -27,8 +26,13 @@ extends Command {
@Override
protected boolean doTask() {
Block block = this.world.getBlock(this.tileEntity.getHandPosition().intX(), this.tileEntity.getHandPosition().intY(), this.tileEntity.getHandPosition().intZ());
TileEntity targetTile = this.tileEntity.getHandPosition().getTileEntity((IBlockAccess)this.world);
Block block = this.world.getBlock(
this.tileEntity.getHandPosition().intX(),
this.tileEntity.getHandPosition().intY(),
this.tileEntity.getHandPosition().intZ()
);
TileEntity targetTile
= this.tileEntity.getHandPosition().getTileEntity((IBlockAccess) this.world);
if (targetTile != null) {
if (targetTile instanceof IArmbotUseable) {
((IArmbotUseable) targetTile).onUse(this.tileEntity, this.getArgs());
@ -37,9 +41,18 @@ extends Command {
}
} else if (block != null) {
try {
boolean f = block.onBlockActivated(this.world, this.tileEntity.getHandPosition().intX(), this.tileEntity.getHandPosition().intY(), this.tileEntity.getHandPosition().intZ(), null, 0, 0.0f, 0.0f, 0.0f);
}
catch (Exception e) {
boolean f = block.onBlockActivated(
this.world,
this.tileEntity.getHandPosition().intX(),
this.tileEntity.getHandPosition().intY(),
this.tileEntity.getHandPosition().intZ(),
null,
0,
0.0f,
0.0f,
0.0f
);
} catch (Exception e) {
e.printStackTrace();
}
}
@ -66,4 +79,3 @@ extends Command {
taskCompound.setInteger("useCurTimes", this.curTimes);
}
}

View file

@ -2,6 +2,7 @@ package assemblyline.common.machine.command;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityItem;
@ -37,14 +38,16 @@ public class GrabDictionary {
if (ob instanceof String) {
String name = (String) ob;
for (GrabDictionary ref : grabList) {
if (!ref.getName().equalsIgnoreCase(name)) continue;
if (!ref.getName().equalsIgnoreCase(name))
continue;
return ref;
}
}
if (ob instanceof Class) {
Class cc = (Class) ob;
for (GrabDictionary ref : grabList) {
if (ref.getEntityClass() != cc) continue;
if (ref.getEntityClass() != cc)
continue;
return ref;
}
}
@ -69,7 +72,8 @@ public class GrabDictionary {
GrabDictionary newGrab = new GrabDictionary(name, eClass);
if (!grabList.contains(newGrab)) {
for (GrabDictionary ref : grabList) {
if (!ref.getName().equalsIgnoreCase(name)) continue;
if (!ref.getName().equalsIgnoreCase(name))
continue;
return;
}
GrabDictionary.getList().add(newGrab);
@ -99,4 +103,3 @@ public class GrabDictionary {
GrabDictionary.registerGrabableEntity("cart", EntityMinecart.class);
}
}

View file

@ -11,8 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockCraneController
extends BlockALMachine {
public class BlockCraneController extends BlockALMachine {
public BlockCraneController() {
super(UniversalElectricity.machine);
this.setBlockName("craneController");
@ -29,23 +28,33 @@ extends BlockALMachine {
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
public void onBlockPlacedBy(
World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack
) {
int rot = (int) Math.min((entity.rotationYaw + 315.0f) % 360.0f / 90.0f, 3.0f);
switch (rot) {
case 0: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.WEST.ordinal(), 3);
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.WEST.ordinal(), 3
);
break;
}
case 1: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.NORTH.ordinal(), 3);
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.NORTH.ordinal(), 3
);
break;
}
case 2: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.EAST.ordinal(), 3);
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.EAST.ordinal(), 3
);
break;
}
default: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.SOUTH.ordinal(), 3);
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.SOUTH.ordinal(), 3
);
}
}
}
@ -61,4 +70,3 @@ extends BlockALMachine {
return new TileEntityCraneController();
}
}

View file

@ -11,8 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockCraneFrame
extends BlockALMachine {
public class BlockCraneFrame extends BlockALMachine {
public BlockCraneFrame() {
super(UniversalElectricity.machine);
this.setBlockName("craneFrame");
@ -20,22 +19,78 @@ extends BlockALMachine {
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
public AxisAlignedBB
getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
TileEntity tE = world.getTileEntity(x, y, z);
if (tE != null && tE instanceof TileEntityCraneRail) {
AxisAlignedBB middle = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75);
AxisAlignedBB up = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.75, (double)0.25, (double)0.75, (double)1.0, (double)0.75);
AxisAlignedBB down = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.0, (double)0.25, (double)0.75, (double)0.25, (double)0.75);
AxisAlignedBB left = AxisAlignedBB.getBoundingBox((double)0.0, (double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75);
AxisAlignedBB right = AxisAlignedBB.getBoundingBox((double)0.75, (double)0.25, (double)0.25, (double)1.0, (double)0.75, (double)0.75);
AxisAlignedBB front = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.0, (double)0.75, (double)0.75, (double)0.25);
AxisAlignedBB back = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75, (double)1.0);
boolean connectUp = CraneHelper.canFrameConnectTo(tE, x, y + 1, z, ForgeDirection.DOWN);
boolean connectDown = CraneHelper.canFrameConnectTo(tE, x, y - 1, z, ForgeDirection.UP);
boolean connectLeft = CraneHelper.canFrameConnectTo(tE, x - 1, y, z, ForgeDirection.EAST);
boolean connectRight = CraneHelper.canFrameConnectTo(tE, x + 1, y, z, ForgeDirection.WEST);
boolean connectFront = CraneHelper.canFrameConnectTo(tE, x, y, z - 1, ForgeDirection.SOUTH);
boolean connectBack = CraneHelper.canFrameConnectTo(tE, x, y, z + 1, ForgeDirection.NORTH);
AxisAlignedBB middle = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.25,
(double) 0.25,
(double) 0.75,
(double) 0.75,
(double) 0.75
);
AxisAlignedBB up = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.75,
(double) 0.25,
(double) 0.75,
(double) 1.0,
(double) 0.75
);
AxisAlignedBB down = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.0,
(double) 0.25,
(double) 0.75,
(double) 0.25,
(double) 0.75
);
AxisAlignedBB left = AxisAlignedBB.getBoundingBox(
(double) 0.0,
(double) 0.25,
(double) 0.25,
(double) 0.25,
(double) 0.75,
(double) 0.75
);
AxisAlignedBB right = AxisAlignedBB.getBoundingBox(
(double) 0.75,
(double) 0.25,
(double) 0.25,
(double) 1.0,
(double) 0.75,
(double) 0.75
);
AxisAlignedBB front = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.25,
(double) 0.0,
(double) 0.75,
(double) 0.75,
(double) 0.25
);
AxisAlignedBB back = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.25,
(double) 0.75,
(double) 0.75,
(double) 0.75,
(double) 1.0
);
boolean connectUp
= CraneHelper.canFrameConnectTo(tE, x, y + 1, z, ForgeDirection.DOWN);
boolean connectDown
= CraneHelper.canFrameConnectTo(tE, x, y - 1, z, ForgeDirection.UP);
boolean connectLeft
= CraneHelper.canFrameConnectTo(tE, x - 1, y, z, ForgeDirection.EAST);
boolean connectRight
= CraneHelper.canFrameConnectTo(tE, x + 1, y, z, ForgeDirection.WEST);
boolean connectFront
= CraneHelper.canFrameConnectTo(tE, x, y, z - 1, ForgeDirection.SOUTH);
boolean connectBack
= CraneHelper.canFrameConnectTo(tE, x, y, z + 1, ForgeDirection.NORTH);
if (connectUp) {
middle.maxY = up.maxY;
}
@ -54,7 +109,14 @@ extends BlockALMachine {
if (connectBack) {
middle.maxZ = back.maxZ;
}
this.setBlockBounds((float)middle.minX, (float)middle.minY, (float)middle.minZ, (float)middle.maxX, (float)middle.maxY, (float)middle.maxZ);
this.setBlockBounds(
(float) middle.minX,
(float) middle.minY,
(float) middle.minZ,
(float) middle.maxX,
(float) middle.maxY,
(float) middle.maxZ
);
middle.offset((double) x, (double) y, (double) z);
return middle;
}
@ -65,19 +127,74 @@ extends BlockALMachine {
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tE = world.getTileEntity(x, y, z);
if (tE != null && tE instanceof TileEntityCraneRail) {
AxisAlignedBB middle = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75);
AxisAlignedBB up = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.75, (double)0.25, (double)0.75, (double)1.0, (double)0.75);
AxisAlignedBB down = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.0, (double)0.25, (double)0.75, (double)0.25, (double)0.75);
AxisAlignedBB left = AxisAlignedBB.getBoundingBox((double)0.0, (double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75);
AxisAlignedBB right = AxisAlignedBB.getBoundingBox((double)0.75, (double)0.25, (double)0.25, (double)1.0, (double)0.75, (double)0.75);
AxisAlignedBB front = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.0, (double)0.75, (double)0.75, (double)0.25);
AxisAlignedBB back = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75, (double)1.0);
boolean connectUp = CraneHelper.canFrameConnectTo(tE, x, y + 1, z, ForgeDirection.DOWN);
boolean connectDown = CraneHelper.canFrameConnectTo(tE, x, y - 1, z, ForgeDirection.UP);
boolean connectLeft = CraneHelper.canFrameConnectTo(tE, x - 1, y, z, ForgeDirection.EAST);
boolean connectRight = CraneHelper.canFrameConnectTo(tE, x + 1, y, z, ForgeDirection.WEST);
boolean connectFront = CraneHelper.canFrameConnectTo(tE, x, y, z - 1, ForgeDirection.SOUTH);
boolean connectBack = CraneHelper.canFrameConnectTo(tE, x, y, z + 1, ForgeDirection.NORTH);
AxisAlignedBB middle = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.25,
(double) 0.25,
(double) 0.75,
(double) 0.75,
(double) 0.75
);
AxisAlignedBB up = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.75,
(double) 0.25,
(double) 0.75,
(double) 1.0,
(double) 0.75
);
AxisAlignedBB down = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.0,
(double) 0.25,
(double) 0.75,
(double) 0.25,
(double) 0.75
);
AxisAlignedBB left = AxisAlignedBB.getBoundingBox(
(double) 0.0,
(double) 0.25,
(double) 0.25,
(double) 0.25,
(double) 0.75,
(double) 0.75
);
AxisAlignedBB right = AxisAlignedBB.getBoundingBox(
(double) 0.75,
(double) 0.25,
(double) 0.25,
(double) 1.0,
(double) 0.75,
(double) 0.75
);
AxisAlignedBB front = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.25,
(double) 0.0,
(double) 0.75,
(double) 0.75,
(double) 0.25
);
AxisAlignedBB back = AxisAlignedBB.getBoundingBox(
(double) 0.25,
(double) 0.25,
(double) 0.75,
(double) 0.75,
(double) 0.75,
(double) 1.0
);
boolean connectUp
= CraneHelper.canFrameConnectTo(tE, x, y + 1, z, ForgeDirection.DOWN);
boolean connectDown
= CraneHelper.canFrameConnectTo(tE, x, y - 1, z, ForgeDirection.UP);
boolean connectLeft
= CraneHelper.canFrameConnectTo(tE, x - 1, y, z, ForgeDirection.EAST);
boolean connectRight
= CraneHelper.canFrameConnectTo(tE, x + 1, y, z, ForgeDirection.WEST);
boolean connectFront
= CraneHelper.canFrameConnectTo(tE, x, y, z - 1, ForgeDirection.SOUTH);
boolean connectBack
= CraneHelper.canFrameConnectTo(tE, x, y, z + 1, ForgeDirection.NORTH);
if (connectUp) {
middle.maxY = up.maxY;
}
@ -96,7 +213,14 @@ extends BlockALMachine {
if (connectBack) {
middle.maxZ = back.maxZ;
}
this.setBlockBounds((float)middle.minX, (float)middle.minY, (float)middle.minZ, (float)middle.maxX, (float)middle.maxY, (float)middle.maxZ);
this.setBlockBounds(
(float) middle.minX,
(float) middle.minY,
(float) middle.minZ,
(float) middle.maxX,
(float) middle.maxY,
(float) middle.maxZ
);
return;
}
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
@ -123,4 +247,3 @@ extends BlockALMachine {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
}

View file

@ -10,16 +10,22 @@ public class CraneHelper {
public static final int MAX_SIZE = 64;
public static boolean isCraneBlock(World world, int x, int y, int z) {
return world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof ICraneConnectable;
return world.getTileEntity(x, y, z) != null
&& world.getTileEntity(x, y, z) instanceof ICraneConnectable;
}
public static boolean isCraneStructureBlock(World world, int x, int y, int z) {
return world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof ICraneStructure;
return world.getTileEntity(x, y, z) != null
&& world.getTileEntity(x, y, z) instanceof ICraneStructure;
}
public static boolean canFrameConnectTo(TileEntity tileEntity, int x, int y, int z, ForgeDirection side) {
if (tileEntity.getWorldObj().getTileEntity(x, y, z) != null && tileEntity.getWorldObj().getTileEntity(x, y, z) instanceof ICraneConnectable) {
return ((ICraneConnectable)tileEntity.getWorldObj().getTileEntity(x, y, z)).canFrameConnectTo(side);
public static boolean
canFrameConnectTo(TileEntity tileEntity, int x, int y, int z, ForgeDirection side) {
if (tileEntity.getWorldObj().getTileEntity(x, y, z) != null
&& tileEntity.getWorldObj().getTileEntity(x, y, z)
instanceof ICraneConnectable) {
return ((ICraneConnectable) tileEntity.getWorldObj().getTileEntity(x, y, z))
.canFrameConnectTo(side);
}
return false;
}
@ -56,4 +62,3 @@ public class CraneHelper {
return ForgeDirection.UNKNOWN;
}
}

View file

@ -7,8 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCraneController
extends TileEntityAssemblyNetwork
implements ICraneConnectable {
extends TileEntityAssemblyNetwork implements ICraneConnectable {
int width = 0;
int height = 0;
int depth = 0;
@ -35,7 +34,8 @@ implements ICraneConnectable {
this.findCraneHeight();
this.findCraneWidth();
this.findCraneDepth();
if (Math.abs(this.height) > 1 && Math.abs(this.width) > 1 && Math.abs(this.depth) > 1) {
if (Math.abs(this.height) > 1 && Math.abs(this.width) > 1
&& Math.abs(this.depth) > 1) {
this.isCraneValid = this.isFrameValid();
}
}
@ -44,24 +44,46 @@ implements ICraneConnectable {
int z;
int x;
for (x = Math.min(0, this.width); x <= Math.max(0, this.width); ++x) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord)) continue;
if (CraneHelper.isCraneStructureBlock(
this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord
))
continue;
return false;
}
for (x = Math.min(0, this.width); x <= Math.max(0, this.width); ++x) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord + this.depth)) continue;
if (CraneHelper.isCraneStructureBlock(
this.worldObj,
this.xCoord + x,
this.yCoord + this.height,
this.zCoord + this.depth
))
continue;
return false;
}
for (z = Math.min(0, this.depth); z <= Math.max(0, this.depth); ++z) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord, this.yCoord + this.height, this.zCoord + z)) continue;
if (CraneHelper.isCraneStructureBlock(
this.worldObj, this.xCoord, this.yCoord + this.height, this.zCoord + z
))
continue;
return false;
}
for (z = Math.min(0, this.depth); z <= Math.max(0, this.depth); ++z) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + this.width, this.yCoord + this.height, this.zCoord + z)) continue;
if (CraneHelper.isCraneStructureBlock(
this.worldObj,
this.xCoord + this.width,
this.yCoord + this.height,
this.zCoord + z
))
continue;
return false;
}
for (x = Math.min(this.width + 1, 1); x <= Math.max(-1, this.width - 1); ++x) {
for (int z2 = Math.min(this.depth + 1, 1); z2 <= Math.max(-1, this.depth - 1); ++z2) {
if (this.worldObj.isAirBlock(this.xCoord + x, this.yCoord + this.height, this.zCoord + z2)) continue;
for (int z2 = Math.min(this.depth + 1, 1); z2 <= Math.max(-1, this.depth - 1);
++z2) {
if (this.worldObj.isAirBlock(
this.xCoord + x, this.yCoord + this.height, this.zCoord + z2
))
continue;
return false;
}
}
@ -74,8 +96,12 @@ implements ICraneConnectable {
return;
}
int x = 0;
ForgeDirection facing = ForgeDirection.getOrientation((int)this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
while (Math.abs(x) <= 64 && CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord)) {
ForgeDirection facing = ForgeDirection.getOrientation((int
) this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
while (Math.abs(x) <= 64
&& CraneHelper.isCraneStructureBlock(
this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord
)) {
if (facing == ForgeDirection.NORTH || facing == ForgeDirection.EAST) {
++x;
continue;
@ -93,8 +119,11 @@ implements ICraneConnectable {
private void findCraneHeight() {
int y;
for (y = 1; this.yCoord + y < 256 && y <= 64 && CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord, this.yCoord + y, this.zCoord); ++y) {
}
for (y = 1; this.yCoord + y < 256 && y <= 64
&& CraneHelper.isCraneStructureBlock(
this.worldObj, this.xCoord, this.yCoord + y, this.zCoord
);
++y) {}
this.height = y - 1;
}
@ -104,8 +133,12 @@ implements ICraneConnectable {
return;
}
int z = 0;
ForgeDirection facing = ForgeDirection.getOrientation((int)this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
while (Math.abs(z) <= 64 && CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord, this.yCoord + this.height, this.zCoord + z)) {
ForgeDirection facing = ForgeDirection.getOrientation((int
) this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
while (Math.abs(z) <= 64
&& CraneHelper.isCraneStructureBlock(
this.worldObj, this.xCoord, this.yCoord + this.height, this.zCoord + z
)) {
if (facing == ForgeDirection.SOUTH || facing == ForgeDirection.EAST) {
++z;
continue;
@ -123,7 +156,8 @@ implements ICraneConnectable {
@Override
public boolean canFrameConnectTo(ForgeDirection side) {
ForgeDirection facing = ForgeDirection.getOrientation((int)this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
ForgeDirection facing = ForgeDirection.getOrientation((int
) this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
if (side == facing) {
return true;
}
@ -156,4 +190,3 @@ implements ICraneConnectable {
return true;
}
}

View file

@ -5,8 +5,7 @@ import assemblyline.common.machine.TileEntityAssemblyNetwork;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCraneRail
extends TileEntityAssemblyNetwork
implements ICraneStructure {
extends TileEntityAssemblyNetwork implements ICraneStructure {
@Override
public boolean canFrameConnectTo(ForgeDirection side) {
return true;
@ -17,4 +16,3 @@ implements ICraneStructure {
return false;
}
}

View file

@ -20,8 +20,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockDetector
extends BlockImprintable {
public class BlockDetector extends BlockImprintable {
IIcon eye_red;
IIcon eye_green;
@ -30,8 +29,12 @@ extends BlockImprintable {
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int angle = MathHelper.floor_double((double)((double)(entity.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3;
public void onBlockPlacedBy(
World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack
) {
int angle = MathHelper.floor_double((double
) ((double) (entity.rotationYaw * 4.0f / 360.0f) + 0.5))
& 3;
int change = 2;
switch (angle) {
case 0: {
@ -70,7 +73,11 @@ extends BlockImprintable {
@Override
public IIcon getIcon(IBlockAccess iBlockAccess, int x, int y, int z, int side) {
TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityDetector && side == ForgeDirection.getOrientation((int)iBlockAccess.getBlockMetadata(x, y, z)).ordinal()) {
if (tileEntity instanceof TileEntityDetector
&& side
== ForgeDirection
.getOrientation((int) iBlockAccess.getBlockMetadata(x, y, z))
.ordinal()) {
if (((TileEntityDetector) tileEntity).isInverted()) {
return this.eye_red;
}
@ -88,7 +95,17 @@ extends BlockImprintable {
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
world.setBlockMetadataWithNotify(x, y, z, side, 3);
return true;
}
@ -111,11 +128,13 @@ extends BlockImprintable {
}
@Override
public boolean isBlockSolid(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
public boolean
isBlockSolid(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return false;
}
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
public boolean
isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
return false;
}
@ -125,16 +144,19 @@ extends BlockImprintable {
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction) {
public int
isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityDetector) {
return ((TileEntityDetector)tileEntity).isPoweringTo(ForgeDirection.getOrientation((int)direction));
return ((TileEntityDetector) tileEntity)
.isPoweringTo(ForgeDirection.getOrientation((int) direction));
}
return 0;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction) {
public int
isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction) {
return this.isProvidingStrongPower(world, x, y, z, direction);
}
@ -143,4 +165,3 @@ extends BlockImprintable {
return new TileEntityDetector();
}
}

View file

@ -1,27 +1,38 @@
package assemblyline.common.machine.detector;
import java.util.ArrayList;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.ArrayList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityDetector
extends TileEntityFilterable {
public class TileEntityDetector extends TileEntityFilterable {
private boolean powering = false;
@Override
public void updateEntity() {
super.updateEntity();
if (!this.worldObj.isRemote && this.ticks % 10L == 0L) {
int metadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1));
int metadata
= this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox(
(double) this.xCoord,
(double) this.yCoord,
(double) this.zCoord,
(double) (this.xCoord + 1),
(double) (this.yCoord + 1),
(double) (this.zCoord + 1)
);
ForgeDirection dir = ForgeDirection.getOrientation((int) metadata);
testArea.offset((double)dir.offsetX, (double)dir.offsetY, (double)dir.offsetZ);
ArrayList entities = (ArrayList)this.worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
testArea.offset(
(double) dir.offsetX, (double) dir.offsetY, (double) dir.offsetZ
);
ArrayList entities = (ArrayList
) this.worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
boolean powerCheck = false;
if (entities.size() > 0) {
if (this.getFilter() != null) {
@ -38,11 +49,17 @@ extends TileEntityFilterable {
}
if (powerCheck != this.powering) {
this.powering = powerCheck;
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector
);
this.worldObj.notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector
);
for (int x = this.xCoord - 1; x <= this.xCoord + 1; ++x) {
for (int z = this.zCoord - 1; z <= this.zCoord + 1; ++z) {
this.worldObj.notifyBlocksOfNeighborChange(x, this.yCoord + 1, z, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(
x, this.yCoord + 1, z, AssemblyLine.blockDetector
);
}
}
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
@ -52,8 +69,12 @@ extends TileEntityFilterable {
@Override
public void invalidate() {
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector
);
this.worldObj.notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector
);
super.invalidate();
}
@ -82,4 +103,3 @@ extends TileEntityFilterable {
return direction != this.getDirection();
}
}

View file

@ -13,8 +13,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockEncoder
extends BlockALMachine {
public class BlockEncoder extends BlockALMachine {
IIcon encoder_side;
IIcon encoder_top;
IIcon encoder_bottom;
@ -50,7 +49,17 @@ extends BlockALMachine {
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
public boolean onMachineActivated(
World world,
int x,
int y,
int z,
EntityPlayer entityPlayer,
int par6,
float par7,
float par8,
float par9
) {
if (!world.isRemote) {
entityPlayer.openGui((Object) AssemblyLine.instance, 2, world, x, y, z);
}
@ -61,4 +70,3 @@ extends BlockALMachine {
return new TileEntityEncoder();
}
}

View file

@ -9,8 +9,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerEncoder
extends Container {
public class ContainerEncoder extends Container {
public static final int Y_OFFSET = 0;
private ItemStack[] containingItems = new ItemStack[1];
private InventoryPlayer inventoryPlayer;
@ -20,14 +19,23 @@ extends Container {
int var3;
this.inventoryPlayer = inventoryPlayer;
this.tileEntity = encoder;
this.addSlotToContainer(new SlotCustom((IInventory)encoder, 0, 80, 24, new ItemStack(AssemblyLine.itemDisk)));
this.addSlotToContainer(new SlotCustom(
(IInventory) encoder, 0, 80, 24, new ItemStack(AssemblyLine.itemDisk)
));
for (var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory)inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 155 + var3 * 18 + 0));
this.addSlotToContainer(new Slot(
(IInventory) inventoryPlayer,
var4 + var3 * 9 + 9,
8 + var4 * 18,
155 + var3 * 18 + 0
));
}
}
for (var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(new Slot((IInventory)inventoryPlayer, var3, 8 + var3 * 18, 213));
this.addSlotToContainer(
new Slot((IInventory) inventoryPlayer, var3, 8 + var3 * 18, 213)
);
}
}
@ -41,7 +49,11 @@ extends Container {
if (slotObj != null && slotObj.getHasStack()) {
ItemStack slotStack = slotObj.getStack();
copyStack = slotStack.copy();
if (slot >= 1 ? this.getSlot(0).isItemValid(slotStack) && !this.mergeItemStack(slotStack, 0, 1, false) : !this.mergeItemStack(slotStack, this.containingItems.length, 37, false)) {
if (slot >= 1 ? this.getSlot(0).isItemValid(slotStack)
&& !this.mergeItemStack(slotStack, 0, 1, false)
: !this.mergeItemStack(
slotStack, this.containingItems.length, 37, false
)) {
return null;
}
if (slotStack.stackSize == 0) {
@ -57,4 +69,3 @@ extends Container {
return copyStack;
}
}

View file

@ -3,4 +3,3 @@ package assemblyline.common.machine.encoder;
public interface IInventoryWatcher {
public void inventoryChanged();
}

View file

@ -1,10 +1,11 @@
package assemblyline.common.machine.encoder;
import java.util.ArrayList;
import java.util.List;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -13,8 +14,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class ItemDisk
extends Item {
public class ItemDisk extends Item {
public ItemDisk() {
super();
this.setUnlocalizedName("disk");
@ -34,7 +34,9 @@ extends Item {
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
public void addInformation(
ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4
) {
ArrayList commands = ItemDisk.getCommands(itemStack);
if (commands.size() > 0) {
if (commands.size() == 1) {
@ -53,7 +55,8 @@ extends Item {
}
NBTTagList nbt = new NBTTagList();
for (int i = 0; i < commands.size(); ++i) {
if (commands.get(i) == null) continue;
if (commands.get(i) == null)
continue;
NBTTagCompound newCompound = new NBTTagCompound();
newCompound.setString("command", (String) commands.get(i));
nbt.appendTag((NBTBase) newCompound);
@ -76,4 +79,3 @@ extends Item {
return commands;
}
}

View file

@ -5,8 +5,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotDisk
extends Slot {
public class SlotDisk extends Slot {
public SlotDisk(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
@ -15,4 +14,3 @@ extends Slot {
return itemStack.getItem() == AssemblyLine.itemDisk;
}
}

View file

@ -5,8 +5,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotDiskResult
extends Slot {
public class SlotDiskResult extends Slot {
public SlotDiskResult(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
@ -25,4 +24,3 @@ extends Slot {
}
}
}

View file

@ -1,12 +1,13 @@
package assemblyline.common.machine.encoder;
import java.util.ArrayList;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.encoder.IInventoryWatcher;
import assemblyline.common.machine.encoder.ItemDisk;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
@ -14,9 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class TileEntityEncoder
extends TileEntityAdvanced
implements ISidedInventory {
public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInventory {
private ItemStack disk;
private IInventoryWatcher watcher;
@ -78,16 +77,20 @@ implements ISidedInventory {
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this
? false
: player.getDistanceSq(
(double) this.xCoord + 0.5,
(double) this.yCoord + 0.5,
(double) this.zCoord + 0.5
) <= 64.0;
}
@Override
public void openInventory() {
}
public void openInventory() {}
@Override
public void closeInventory() {
}
public void closeInventory() {}
public void setWatcher(IInventoryWatcher watcher) {
this.watcher = watcher;
@ -117,7 +120,8 @@ implements ISidedInventory {
}
public void handleMessage(NBTTagCompound nbt) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.disk != null) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER
&& this.disk != null) {
ArrayList<String> tempCmds = ItemDisk.getCommands(this.disk);
if (nbt.getBoolean("create")) {
String newCommand = nbt.getString("newCommand");
@ -160,4 +164,3 @@ implements ISidedInventory {
return side == ForgeDirection.UP.ordinal() ? new int[] { 0 } : new int[0];
}
}

View file

@ -15,8 +15,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import universalelectricity.prefab.implement.IRedstoneReceptor;
public abstract class BlockImprintable
extends BlockALMachine {
public abstract class BlockImprintable extends BlockALMachine {
public BlockImprintable(String name, Material material, CreativeTabs creativeTab) {
super(material);
this.setBlockName(name);
@ -24,22 +23,37 @@ extends BlockALMachine {
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
public boolean onMachineActivated(
World world,
int x,
int y,
int z,
EntityPlayer player,
int par6,
float par7,
float par8,
float par9
) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof IFilterable) {
ItemStack containingStack = ((IFilterable) tileEntity).getFilter();
if (containingStack != null) {
if (!world.isRemote) {
EntityItem dropStack = new EntityItem(world, player.posX, player.posY, player.posZ, containingStack);
EntityItem dropStack = new EntityItem(
world, player.posX, player.posY, player.posZ, containingStack
);
dropStack.delayBeforeCanPickup = 0;
world.spawnEntityInWorld((Entity) dropStack);
}
((IFilterable) tileEntity).setFilter(null);
return true;
}
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemImprinter) {
if (player.getCurrentEquippedItem() != null
&& player.getCurrentEquippedItem().getItem() instanceof ItemImprinter) {
((IFilterable) tileEntity).setFilter(player.getCurrentEquippedItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.inventory.setInventorySlotContents(
player.inventory.currentItem, null
);
return true;
}
}
@ -47,7 +61,17 @@ extends BlockALMachine {
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onSneakUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof TileEntityFilterable) {
((TileEntityFilterable) tileEntity).toggleInversion();
@ -58,7 +82,17 @@ extends BlockALMachine {
}
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
public boolean onSneakMachineActivated(
World world,
int x,
int y,
int z,
EntityPlayer player,
int side,
float hitX,
float hitY,
float hitZ
) {
return this.onMachineActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}
@ -66,14 +100,24 @@ extends BlockALMachine {
public void onNeighborBlockChange(World par1World, int x, int y, int z, Block side) {
super.onNeighborBlockChange(par1World, x, y, z, side);
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneReceptor && par1World.isBlockIndirectlyGettingPowered(x, y, z)) {
if (tileEntity instanceof IRedstoneReceptor
&& par1World.isBlockIndirectlyGettingPowered(x, y, z)) {
((IRedstoneReceptor) par1World.getTileEntity(x, y, z)).onPowerOn();
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack) {
int angle = MathHelper.floor_double((double)((double)(par5EntityLiving.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3;
public void onBlockPlacedBy(
World world,
int x,
int y,
int z,
EntityLivingBase par5EntityLiving,
ItemStack stack
) {
int angle = MathHelper.floor_double((double
) ((double) (par5EntityLiving.rotationYaw * 4.0f / 360.0f) + 0.5))
& 3;
int change = 2;
switch (angle) {
case 0: {
@ -96,7 +140,17 @@ extends BlockALMachine {
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onUseWrench(
World world,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
int original = world.getBlockMetadata(x, y, z);
int change = 2;
switch (original) {
@ -120,4 +174,3 @@ extends BlockALMachine {
return true;
}
}

View file

@ -1,12 +1,12 @@
package assemblyline.common.machine.imprinter;
import java.util.Random;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -20,8 +20,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockImprinter
extends BlockALMachine {
public class BlockImprinter extends BlockALMachine {
IIcon imprinter_side;
IIcon imprinter_top;
IIcon imprinter_bottom;
@ -58,7 +57,17 @@ extends BlockALMachine {
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
public boolean onMachineActivated(
World world,
int x,
int y,
int z,
EntityPlayer entityPlayer,
int par6,
float par7,
float par8,
float par9
) {
if (!world.isRemote) {
entityPlayer.openGui((Object) AssemblyLine.instance, 1, world, x, y, z);
}
@ -66,13 +75,15 @@ extends BlockALMachine {
}
@Override
public void dropEntireInventory(World par1World, int x, int y, int z, Block par5, int par6) {
public void
dropEntireInventory(World par1World, int x, int y, int z, Block par5, int par6) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof TileEntityImprinter) {
TileEntityImprinter inventory = (TileEntityImprinter) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack == null) continue;
if (itemStack == null)
continue;
Random random = new Random();
float var8 = random.nextFloat() * 0.8f + 0.1f;
float var9 = random.nextFloat() * 0.8f + 0.1f;
@ -83,10 +94,21 @@ extends BlockALMachine {
var11 = itemStack.stackSize;
}
itemStack.stackSize -= var11;
if (i == inventory.imprinterMatrix.length + 9 - 1) continue;
EntityItem entityItem = new EntityItem(par1World, (double)((float)x + var8), (double)((float)y + var9), (double)((float)z + var10), new ItemStack(itemStack.getItem(), var11, itemStack.getItemDamage()));
if (i == inventory.imprinterMatrix.length + 9 - 1)
continue;
EntityItem entityItem = new EntityItem(
par1World,
(double) ((float) x + var8),
(double) ((float) y + var9),
(double) ((float) z + var10),
new ItemStack(
itemStack.getItem(), var11, itemStack.getItemDamage()
)
);
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
entityItem.getEntityItem().setTagCompound(
(NBTTagCompound) itemStack.getTagCompound().copy()
);
}
float var13 = 0.05f;
entityItem.motionX = (float) random.nextGaussian() * var13;
@ -99,10 +121,21 @@ extends BlockALMachine {
}
@Override
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
public boolean onUseWrench(
World par1World,
int x,
int y,
int z,
EntityPlayer par5EntityPlayer,
int side,
float hitX,
float hitY,
float hitZ
) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityImprinter) {
((TileEntityImprinter)tileEntity).searchInventories = !((TileEntityImprinter)tileEntity).searchInventories;
((TileEntityImprinter) tileEntity).searchInventories
= !((TileEntityImprinter) tileEntity).searchInventories;
par1World.markBlockForUpdate(x, y, z);
return true;
}
@ -114,4 +147,3 @@ extends BlockALMachine {
return new TileEntityImprinter();
}
}

View file

@ -13,37 +13,63 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerImprinter
extends Container
implements ISlotWatcher {
public class ContainerImprinter extends Container implements ISlotWatcher {
public InventoryPlayer inventoryPlayer;
public TileEntityImprinter tileEntity;
public ContainerImprinter(InventoryPlayer inventoryPlayer, TileEntityImprinter tileEntity) {
public ContainerImprinter(
InventoryPlayer inventoryPlayer, TileEntityImprinter tileEntity
) {
int var3;
this.tileEntity = tileEntity;
this.tileEntity.container = this;
this.inventoryPlayer = inventoryPlayer;
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < 3; ++y) {
this.addSlotToContainer(new WatchedSlot((IInventory)this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this));
this.addSlotToContainer(new WatchedSlot(
(IInventory) this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this
));
}
}
this.addSlotToContainer(new SlotCustom((IInventory)this.tileEntity, 9, 68, 34, new ItemStack(AssemblyLine.itemImprint)));
this.addSlotToContainer(new WatchedSlot((IInventory)this.tileEntity, 10, 92, 34, this));
this.addSlotToContainer(new SlotCraftingResult(this, (IInventory)this.tileEntity, 11, 148, 34));
this.addSlotToContainer(new SlotCustom(
(IInventory) this.tileEntity,
9,
68,
34,
new ItemStack(AssemblyLine.itemImprint)
));
this.addSlotToContainer(
new WatchedSlot((IInventory) this.tileEntity, 10, 92, 34, this)
);
this.addSlotToContainer(
new SlotCraftingResult(this, (IInventory) this.tileEntity, 11, 148, 34)
);
for (int ii = 0; ii < 2; ++ii) {
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new WatchedSlot((IInventory)this.tileEntity, i + ii * 9 + 12, 8 + i * 18, 80 + ii * 18, this));
this.addSlotToContainer(new WatchedSlot(
(IInventory) this.tileEntity,
i + ii * 9 + 12,
8 + i * 18,
80 + ii * 18,
this
));
}
}
for (var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new WatchedSlot((IInventory)inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 120 + var3 * 18, this));
this.addSlotToContainer(new WatchedSlot(
(IInventory) inventoryPlayer,
var4 + var3 * 9 + 9,
8 + var4 * 18,
120 + var3 * 18,
this
));
}
}
for (var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(new WatchedSlot((IInventory)inventoryPlayer, var3, 8 + var3 * 18, 178, this));
this.addSlotToContainer(new WatchedSlot(
(IInventory) inventoryPlayer, var3, 8 + var3 * 18, 178, this
));
}
this.tileEntity.openInventory();
}
@ -71,10 +97,17 @@ implements ISlotWatcher {
if (!this.mergeItemStack(slotStack, 9, 9 + 1, true)) {
return null;
}
} else if (!this.mergeItemStack(slotStack, 12, this.tileEntity.getSizeInventory(), false)) {
} else if (!this.mergeItemStack(
slotStack, 12, this.tileEntity.getSizeInventory(), false
)) {
return null;
}
} else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false)) {
} else if (!this.mergeItemStack(
slotStack,
this.tileEntity.getSizeInventory(),
this.tileEntity.getSizeInventory() + 36,
false
)) {
return null;
}
if (slotStack.stackSize == 0) {
@ -97,4 +130,3 @@ implements ISlotWatcher {
this.detectAndSendChanges();
}
}

View file

@ -3,4 +3,3 @@ package assemblyline.common.machine.imprinter;
public interface ISlotWatcher {
public void slotContentsChanged();
}

View file

@ -1,10 +1,11 @@
package assemblyline.common.machine.imprinter;
import java.util.ArrayList;
import java.util.List;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
@ -17,8 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
public class ItemImprinter
extends Item {
public class ItemImprinter extends Item {
public ItemImprinter() {
super();
this.setUnlocalizedName("imprint");
@ -38,8 +38,10 @@ extends Item {
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
if (entity != null && !(entity instanceof IProjectile) && !(entity instanceof EntityPlayer)) {
public boolean
onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
if (entity != null && !(entity instanceof IProjectile)
&& !(entity instanceof EntityPlayer)) {
String stringName = EntityList.getEntityString((Entity) entity);
player.addChatMessage(new ChatComponentText("Target: " + stringName));
return true;
@ -48,7 +50,9 @@ extends Item {
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
public void addInformation(
ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4
) {
List<ItemStack> filterItems = ItemImprinter.getFilters(itemStack);
if (filterItems.size() > 0) {
for (ItemStack filterItem : filterItems) {
@ -65,7 +69,8 @@ extends Item {
}
NBTTagList nbt = new NBTTagList();
for (int i = 0; i < filterStacks.size(); ++i) {
if (filterStacks.get(i) == null) continue;
if (filterStacks.get(i) == null)
continue;
NBTTagCompound newCompound = new NBTTagCompound();
newCompound.setByte("Slot", (byte) i);
((ItemStack) filterStacks.get(i)).writeToNBT(newCompound);
@ -89,4 +94,3 @@ extends Item {
return filterStacks;
}
}

View file

@ -6,11 +6,12 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotCraftingResult
extends WatchedSlot {
public class SlotCraftingResult extends WatchedSlot {
private ContainerImprinter container;
public SlotCraftingResult(ContainerImprinter container, IInventory inventory, int par2, int par3, int par4) {
public SlotCraftingResult(
ContainerImprinter container, IInventory inventory, int par2, int par3, int par4
) {
super(inventory, par2, par3, par4, container);
this.container = container;
}
@ -28,4 +29,3 @@ extends WatchedSlot {
super.onPickupFromSlot(entityPlayer, itemStack);
}
}

View file

@ -4,11 +4,12 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotCustom
extends Slot {
public class SlotCustom extends Slot {
private ItemStack itemStack;
public SlotCustom(IInventory par1iInventory, int par2, int par3, int par4, ItemStack itemStack) {
public SlotCustom(
IInventory par1iInventory, int par2, int par3, int par4, ItemStack itemStack
) {
super(par1iInventory, par2, par3, par4);
this.itemStack = itemStack;
}
@ -17,4 +18,3 @@ extends Slot {
return itemStack.isItemEqual(this.itemStack);
}
}

View file

@ -5,8 +5,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotImprintResult
extends Slot {
public class SlotImprintResult extends Slot {
public SlotImprintResult(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
@ -25,4 +24,3 @@ extends Slot {
}
}
}

View file

@ -1,10 +1,11 @@
package assemblyline.common.machine.imprinter;
import java.util.ArrayList;
import assemblyline.api.IFilterable;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
@ -17,17 +18,18 @@ import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
public abstract class TileEntityFilterable
extends TileEntityAssemblyNetwork
implements IRotatable,
IFilterable {
extends TileEntityAssemblyNetwork implements IRotatable, IFilterable {
private ItemStack filterItem;
private boolean inverted;
public boolean isFiltering(ItemStack itemStack) {
ArrayList checkStacks;
if (this.getFilter() != null && itemStack != null && (checkStacks = ItemImprinter.getFilters(this.getFilter())) != null) {
if (this.getFilter() != null && itemStack != null
&& (checkStacks = ItemImprinter.getFilters(this.getFilter())) != null) {
for (int i = 0; i < checkStacks.size(); ++i) {
if (checkStacks.get(i) == null || !((ItemStack)checkStacks.get(i)).isItemEqual(itemStack)) continue;
if (checkStacks.get(i) == null
|| !((ItemStack) checkStacks.get(i)).isItemEqual(itemStack))
continue;
return !this.inverted;
}
}
@ -68,23 +70,32 @@ IFilterable {
}
@Override
public void setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
public void
setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(
this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3
);
}
public void setDirection(ForgeDirection facingDirection) {
this.setDirection(this.worldObj, this.xCoord, this.yCoord, this.zCoord, facingDirection);
this.setDirection(
this.worldObj, this.xCoord, this.yCoord, this.zCoord, facingDirection
);
}
public ForgeDirection getDirection() {
return this.getDirection((IBlockAccess)this.worldObj, this.xCoord, this.yCoord, this.zCoord);
return this.getDirection(
(IBlockAccess) this.worldObj, this.xCoord, this.yCoord, this.zCoord
);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), tag);
return new S35PacketUpdateTileEntity(
xCoord, yCoord, zCoord, getBlockMetadata(), tag
);
}
@Override
@ -113,4 +124,3 @@ IFilterable {
this.filterItem = ItemStack.loadItemStackFromNBT((NBTTagCompound) filter);
}
}

View file

@ -1,15 +1,14 @@
package assemblyline.common.machine.imprinter;
import java.util.ArrayList;
import java.util.List;
import assemblyline.api.IArmbot;
import assemblyline.api.IArmbotUseable;
import assemblyline.common.Pair;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
@ -40,8 +39,7 @@ import universalelectricity.prefab.multiblock.TileEntityMulti;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class TileEntityImprinter
extends TileEntityAdvanced
implements ISidedInventory, IArmbotUseable {
extends TileEntityAdvanced implements ISidedInventory, IArmbotUseable {
public static final int IMPRINTER_MATRIX_START = 9;
public static final int INVENTORY_START = 12;
public ItemStack[] craftingMatrix = new ItemStack[9];
@ -58,7 +56,8 @@ implements ISidedInventory, IArmbotUseable {
@Override
public int getSizeInventory() {
return this.craftingMatrix.length + this.imprinterMatrix.length + this.containingItems.length;
return this.craftingMatrix.length + this.imprinterMatrix.length
+ this.containingItems.length;
}
@Override
@ -129,7 +128,8 @@ implements ISidedInventory, IArmbotUseable {
public InventoryCrafting getCraftingMatrix() {
if (this.container != null) {
InventoryCrafting inventoryCrafting = new InventoryCrafting((Container)this.container, 3, 3);
InventoryCrafting inventoryCrafting
= new InventoryCrafting((Container) this.container, 3, 3);
for (int i = 0; i < this.craftingMatrix.length; ++i) {
inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix[i]);
}
@ -146,7 +146,8 @@ implements ISidedInventory, IArmbotUseable {
public boolean isMatrixEmpty() {
for (int i = 0; i < 9; ++i) {
if (this.craftingMatrix[i] == null) continue;
if (this.craftingMatrix[i] == null)
continue;
return false;
}
return true;
@ -156,13 +157,16 @@ implements ISidedInventory, IArmbotUseable {
public void markDirty() {
if (!this.worldObj.isRemote) {
this.isImprinting = false;
if (this.isMatrixEmpty() && this.imprinterMatrix[0] != null && this.imprinterMatrix[1] != null && this.imprinterMatrix[0].getItem() instanceof ItemImprinter) {
if (this.isMatrixEmpty() && this.imprinterMatrix[0] != null
&& this.imprinterMatrix[1] != null
&& this.imprinterMatrix[0].getItem() instanceof ItemImprinter) {
ItemStack outputStack = this.imprinterMatrix[0].copy();
outputStack.stackSize = 1;
ArrayList<ItemStack> filters = ItemImprinter.getFilters(outputStack);
boolean filteringItemExists = false;
for (ItemStack filteredStack : filters) {
if (!filteredStack.isItemEqual(this.imprinterMatrix[1])) continue;
if (!filteredStack.isItemEqual(this.imprinterMatrix[1]))
continue;
filters.remove(filteredStack);
filteringItemExists = true;
break;
@ -180,20 +184,29 @@ implements ISidedInventory, IArmbotUseable {
this.imprinterMatrix[2] = null;
boolean didCraft = false;
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
if (inventoryCrafting != null && (matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj)) != null) {
if (inventoryCrafting != null
&& (matrixOutput = CraftingManager.getInstance().findMatchingRecipe(
inventoryCrafting, this.worldObj
))
!= null) {
System.out.println("Using crafting grid");
this.imprinterMatrix[2] = matrixOutput;
didCraft = true;
}
if (this.imprinterMatrix[0] != null && !didCraft && this.imprinterMatrix[0].getItem() instanceof ItemImprinter) {
if (this.imprinterMatrix[0] != null && !didCraft
&& this.imprinterMatrix[0].getItem() instanceof ItemImprinter) {
System.out.println("Using imprint as grid");
ArrayList<ItemStack> filters = ItemImprinter.getFilters(this.imprinterMatrix[0]);
ArrayList<ItemStack> filters
= ItemImprinter.getFilters(this.imprinterMatrix[0]);
for (ItemStack outputStack : filters) {
Pair idealRecipe;
if (outputStack == null || (idealRecipe = this.getIdealRecipe(outputStack)) == null) continue;
if (outputStack == null
|| (idealRecipe = this.getIdealRecipe(outputStack)) == null)
continue;
ItemStack recipeOutput = (ItemStack) idealRecipe.getKey();
System.out.println("Ideal R: " + recipeOutput.toString());
if (!(recipeOutput != null & recipeOutput.stackSize > 0)) continue;
if (!(recipeOutput != null & recipeOutput.stackSize > 0))
continue;
this.imprinterMatrix[2] = recipeOutput;
didCraft = true;
break;
@ -210,27 +223,44 @@ implements ISidedInventory, IArmbotUseable {
block9: {
block11: {
block10: {
if (itemStack == null) break block9;
if (!this.isImprinting) break block10;
if (itemStack == null)
break block9;
if (!this.isImprinting)
break block10;
this.imprinterMatrix[0] = null;
break block9;
}
if (this.getIdealRecipe(itemStack) == null) break block11;
ItemStack[] requiredItems = (ItemStack[])((ItemStack[])this.getIdealRecipe(itemStack).getValue()).clone();
if (requiredItems == null) break block9;
block2: for (ItemStack searchStack : requiredItems) {
if (searchStack == null) continue;
block3: for (IInventory inventory : this.getAvaliableInventories()) {
if (this.getIdealRecipe(itemStack) == null)
break block11;
ItemStack[] requiredItems
= (ItemStack[]) ((ItemStack[]) this.getIdealRecipe(itemStack).getValue())
.clone();
if (requiredItems == null)
break block9;
block2:
for (ItemStack searchStack : requiredItems) {
if (searchStack == null)
continue;
block3:
for (IInventory inventory : this.getAvaliableInventories()) {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
ItemStack checkStack = inventory.getStackInSlot(i);
if (checkStack == null || !searchStack.isItemEqual(checkStack) && (searchStack.getItem() != checkStack.getItem() || searchStack.getItemDamage() >= 0)) continue;
if (checkStack == null
|| !searchStack.isItemEqual(checkStack)
&& (searchStack.getItem() != checkStack.getItem()
|| searchStack.getItemDamage() >= 0))
continue;
inventory.decrStackSize(i, 1);
break block3;
}
}
for (int i = 0; i < this.containingItems.length; ++i) {
ItemStack checkStack = this.containingItems[i];
if (checkStack == null || !searchStack.isItemEqual(checkStack) && (searchStack.getItem() != checkStack.getItem() || searchStack.getItemDamage() >= 0)) continue;
if (checkStack == null
|| !searchStack.isItemEqual(checkStack)
&& (searchStack.getItem() != checkStack.getItem()
|| searchStack.getItemDamage() >= 0))
continue;
this.decrStackSize(i + 12, 1);
continue block2;
}
@ -239,18 +269,28 @@ implements ISidedInventory, IArmbotUseable {
}
try {
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
MinecraftForge.EVENT_BUS.post(new ItemCraftedEvent(entityPlayer, itemStack, inventoryCrafting));
MinecraftForge.EVENT_BUS.post(
new ItemCraftedEvent(entityPlayer, itemStack, inventoryCrafting)
);
for (int var3 = 0; var3 < inventoryCrafting.getSizeInventory(); ++var3) {
ItemStack var4 = inventoryCrafting.getStackInSlot(var3);
if (var4 == null) continue;
if (var4 == null)
continue;
inventoryCrafting.decrStackSize(var3, 1);
if (!var4.getItem().hasContainerItem()) continue;
if (!var4.getItem().hasContainerItem())
continue;
ItemStack var5 = var4.getItem().getContainerItem(var4);
if (var5.isItemStackDamageable() && var5.getItemDamage() > var5.getMaxDamage()) {
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(entityPlayer, var5));
if (var5.isItemStackDamageable()
&& var5.getItemDamage() > var5.getMaxDamage()) {
MinecraftForge.EVENT_BUS.post(
new PlayerDestroyItemEvent(entityPlayer, var5)
);
var5 = null;
}
if (var5 == null || var4.getItem().doesContainerItemLeaveCraftingGrid(var4) && entityPlayer.inventory.addItemStackToInventory(var5)) continue;
if (var5 == null
|| var4.getItem().doesContainerItemLeaveCraftingGrid(var4)
&& entityPlayer.inventory.addItemStackToInventory(var5))
continue;
if (inventoryCrafting.getStackInSlot(var3) == null) {
inventoryCrafting.setInventorySlotContents(var3, var5);
continue;
@ -260,9 +300,10 @@ implements ISidedInventory, IArmbotUseable {
entityPlayer.dropPlayerItemWithRandomChoice(var5, false);
}
this.replaceCraftingMatrix(inventoryCrafting);
}
catch (Exception e) {
System.out.println("Imprinter: Failed to craft item: " + itemStack.getDisplayName());
} catch (Exception e) {
System.out.println(
"Imprinter: Failed to craft item: " + itemStack.getDisplayName()
);
e.printStackTrace();
}
}
@ -272,28 +313,55 @@ implements ISidedInventory, IArmbotUseable {
for (Object object : CraftingManager.getInstance().getRecipeList()) {
ArrayList hasResources;
Object oreRecipeInput;
if (!(object instanceof IRecipe) || ((IRecipe)object).getRecipeOutput() == null || !outputItem.isItemEqual(((IRecipe)object).getRecipeOutput())) continue;
if (!(object instanceof IRecipe)
|| ((IRecipe) object).getRecipeOutput() == null
|| !outputItem.isItemEqual(((IRecipe) object).getRecipeOutput()))
continue;
if (object instanceof ShapedRecipes) {
if (this.hasResource((Object[])((ShapedRecipes)object).recipeItems) == null) continue;
return new Pair(((IRecipe)object).getRecipeOutput().copy(), ((ShapedRecipes)object).recipeItems);
if (this.hasResource((Object[]) ((ShapedRecipes) object).recipeItems)
== null)
continue;
return new Pair(
((IRecipe) object).getRecipeOutput().copy(),
((ShapedRecipes) object).recipeItems
);
}
if (object instanceof ShapelessRecipes) {
if (this.hasResource((Object[])((ShapelessRecipes)object).recipeItems.toArray(new ItemStack[1])) == null) continue;
return new Pair(((IRecipe)object).getRecipeOutput().copy(), ((ShapelessRecipes)object).recipeItems.toArray(new ItemStack[1]));
if (this.hasResource((Object[]) ((ShapelessRecipes) object)
.recipeItems.toArray(new ItemStack[1]))
== null)
continue;
return new Pair(
((IRecipe) object).getRecipeOutput().copy(),
((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1])
);
}
if (object instanceof ShapedOreRecipe) {
ShapedOreRecipe oreRecipe = (ShapedOreRecipe) object;
oreRecipeInput = (Object[])ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, oreRecipe, new String[]{"input"});
oreRecipeInput = (Object[]) ReflectionHelper.getPrivateValue(
ShapedOreRecipe.class, oreRecipe, new String[] { "input" }
);
hasResources = this.hasResource((Object[]) oreRecipeInput);
if (hasResources == null) continue;
return new Pair(((IRecipe)object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1]));
if (hasResources == null)
continue;
return new Pair(
((IRecipe) object).getRecipeOutput().copy(),
hasResources.toArray(new ItemStack[1])
);
}
if (!(object instanceof ShapelessOreRecipe)) continue;
if (!(object instanceof ShapelessOreRecipe))
continue;
ShapelessOreRecipe oreRecipe = (ShapelessOreRecipe) object;
oreRecipeInput = (ArrayList)ReflectionHelper.getPrivateValue(ShapelessOreRecipe.class, oreRecipe, new String[]{"input"});
oreRecipeInput = (ArrayList) ReflectionHelper.getPrivateValue(
ShapelessOreRecipe.class, oreRecipe, new String[] { "input" }
);
hasResources = this.hasResource(((ArrayList) oreRecipeInput).toArray());
if (hasResources == null) continue;
return new Pair(((IRecipe)object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1]));
if (hasResources == null)
continue;
return new Pair(
((IRecipe) object).getRecipeOutput().copy(),
hasResources.toArray(new ItemStack[1])
);
}
return null;
}
@ -306,39 +374,51 @@ implements ISidedInventory, IArmbotUseable {
dummyImprinter.readFromNBT(cloneData);
ArrayList<ItemStack> actualResources = new ArrayList<ItemStack>();
int itemMatch = 0;
block2: for (Object obj : recipeItems) {
block2:
for (Object obj : recipeItems) {
if (obj instanceof ItemStack) {
ItemStack recipeItem = (ItemStack) obj;
actualResources.add(recipeItem.copy());
if (recipeItem == null || !this.doesItemExist(recipeItem, dummyImprinter)) continue;
if (recipeItem == null
|| !this.doesItemExist(recipeItem, dummyImprinter))
continue;
++itemMatch;
continue;
}
if (!(obj instanceof ArrayList)) continue;
if (!(obj instanceof ArrayList))
continue;
ArrayList ingredientsList = (ArrayList) obj;
Object[] ingredientsArray = ingredientsList.toArray();
for (int x = 0; x < ingredientsArray.length; ++x) {
if (ingredientsArray[x] == null || !(ingredientsArray[x] instanceof ItemStack)) continue;
if (ingredientsArray[x] == null
|| !(ingredientsArray[x] instanceof ItemStack))
continue;
ItemStack recipeItem = (ItemStack) ingredientsArray[x];
actualResources.add(recipeItem.copy());
if (recipeItem == null || !this.doesItemExist(recipeItem, dummyImprinter)) continue;
if (recipeItem == null
|| !this.doesItemExist(recipeItem, dummyImprinter))
continue;
++itemMatch;
continue block2;
}
}
return itemMatch >= actualResources.size() ? actualResources : null;
}
catch (Exception e) {
} catch (Exception e) {
System.out.println("Failed to find recipes in the imprinter.");
e.printStackTrace();
return null;
}
}
private boolean doesItemExist(ItemStack recipeItem, TileEntityImprinter dummyImprinter) {
private boolean
doesItemExist(ItemStack recipeItem, TileEntityImprinter dummyImprinter) {
for (int i = 0; i < dummyImprinter.containingItems.length; ++i) {
ItemStack checkStack = dummyImprinter.containingItems[i];
if (checkStack == null || !recipeItem.isItemEqual(checkStack) && (recipeItem.getItem() != checkStack.getItem() || recipeItem.getItemDamage() >= 0)) continue;
if (checkStack == null
|| !recipeItem.isItemEqual(checkStack)
&& (recipeItem.getItem() != checkStack.getItem()
|| recipeItem.getItemDamage() >= 0))
continue;
dummyImprinter.decrStackSize(i + 12, 1);
return true;
}
@ -348,26 +428,44 @@ implements ISidedInventory, IArmbotUseable {
private List<IInventory> getAvaliableInventories() {
ArrayList<IInventory> inventories = new ArrayList<>();
if (this.searchInventories) {
block0: for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), direction);
if (tileEntity == null) continue;
block0:
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(
this.worldObj, new Vector3(this), direction
);
if (tileEntity == null)
continue;
if (tileEntity instanceof TileEntityMulti) {
Vector3 mainBlockPosition = ((TileEntityMulti)tileEntity).mainBlockPosition;
if (mainBlockPosition == null || !(mainBlockPosition.getTileEntity(this.worldObj) instanceof IInventory)) continue;
inventories.add(((IInventory)mainBlockPosition.getTileEntity(this.worldObj)));
Vector3 mainBlockPosition
= ((TileEntityMulti) tileEntity).mainBlockPosition;
if (mainBlockPosition == null
|| !(
mainBlockPosition.getTileEntity(this.worldObj)
instanceof IInventory
))
continue;
inventories.add(((IInventory
) mainBlockPosition.getTileEntity(this.worldObj)));
continue;
}
if (tileEntity instanceof TileEntityChest) {
inventories.add(((TileEntityChest) tileEntity));
for (int i = 2; i < 6; ++i) {
TileEntity chest = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(tileEntity), ForgeDirection.getOrientation(2));
if (chest == null || chest.getClass() != tileEntity.getClass()) continue;
TileEntity chest = VectorHelper.getTileEntityFromSide(
this.worldObj,
new Vector3(tileEntity),
ForgeDirection.getOrientation(2)
);
if (chest == null || chest.getClass() != tileEntity.getClass())
continue;
inventories.add(((TileEntityChest) chest));
continue block0;
}
continue;
}
if (!(tileEntity instanceof IInventory) || tileEntity instanceof TileEntityImprinter) continue;
if (!(tileEntity instanceof IInventory)
|| tileEntity instanceof TileEntityImprinter)
continue;
inventories.add(((IInventory) tileEntity));
}
}
@ -378,7 +476,9 @@ implements ISidedInventory, IArmbotUseable {
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("searchInventories", this.searchInventories);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
return new S35PacketUpdateTileEntity(
xCoord, yCoord, zCoord, getBlockMetadata(), nbt
);
}
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
@ -398,8 +498,11 @@ implements ISidedInventory, IArmbotUseable {
for (int i = 0; i < var2.tagCount(); ++i) {
NBTTagCompound var4 = (NBTTagCompound) var2.getCompoundTagAt(i);
byte var5 = var4.getByte("Slot");
if (var5 < 0 || var5 >= this.getSizeInventory()) continue;
this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT((NBTTagCompound)var4));
if (var5 < 0 || var5 >= this.getSizeInventory())
continue;
this.setInventorySlotContents(
var5, ItemStack.loadItemStackFromNBT((NBTTagCompound) var4)
);
}
this.searchInventories = nbt.getBoolean("searchInventories");
}
@ -409,7 +512,8 @@ implements ISidedInventory, IArmbotUseable {
super.writeToNBT(nbt);
NBTTagList var2 = new NBTTagList();
for (int i = 0; i < this.getSizeInventory(); ++i) {
if (this.getStackInSlot(i) == null) continue;
if (this.getStackInSlot(i) == null)
continue;
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) i);
this.getStackInSlot(i).writeToNBT(var4);
@ -447,7 +551,13 @@ implements ISidedInventory, IArmbotUseable {
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this
? false
: entityplayer.getDistanceSq(
(double) this.xCoord + 0.5,
(double) this.yCoord + 0.5,
(double) this.zCoord + 0.5
) <= 64.0;
}
@Override
@ -485,4 +595,3 @@ implements ISidedInventory, IArmbotUseable {
return 1;
}
}

View file

@ -3,11 +3,16 @@ package assemblyline.common.machine.imprinter;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
public class WatchedSlot
extends Slot {
public class WatchedSlot extends Slot {
private ISlotWatcher slotWatcher;
public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher) {
public WatchedSlot(
IInventory inventory,
int id,
int xPosition,
int yPosition,
ISlotWatcher slotWatcher
) {
super(inventory, id, xPosition, yPosition);
this.slotWatcher = slotWatcher;
}
@ -18,4 +23,3 @@ extends Slot {
}
}
}

View file

@ -13,7 +13,6 @@ import net.minecraft.nbt.NBTTagCompound;
import universalelectricity.core.vector.Vector3;
public class MessageEncoder implements IMessage {
public NBTTagCompound nbt;
public Vector3 tileLocation;
@ -48,5 +47,4 @@ public class MessageEncoder implements IMessage {
e.printStackTrace();
}
}
}

View file

@ -8,16 +8,16 @@ import cpw.mods.fml.relauncher.Side;
import net.minecraft.tileentity.TileEntity;
public class MessageEncoderHandler implements IMessageHandler<MessageEncoder, IMessage> {
@Override
public IMessage onMessage(MessageEncoder msg, MessageContext ctx) {
if (ctx.side == Side.SERVER) {
TileEntity tile = msg.tileLocation.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
TileEntity tile = msg.tileLocation.getTileEntity(
ctx.getServerHandler().playerEntity.worldObj
);
if (tile instanceof TileEntityEncoder) {
((TileEntityEncoder) tile).handleMessage(msg.nbt);
}
}
return null;
}
}

View file

@ -2,6 +2,7 @@ package dark.library.helpers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@ -12,19 +13,36 @@ import universalelectricity.core.vector.Vector3;
public class ItemFindingHelper {
public static List findAllItemIn(World world, Vector3 start, Vector3 end) {
return world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox((double)start.x, (double)start.y, (double)start.z, (double)end.x, (double)end.y, (double)end.z));
return world.getEntitiesWithinAABB(
EntityItem.class,
AxisAlignedBB.getBoundingBox(
(double) start.x,
(double) start.y,
(double) start.z,
(double) end.x,
(double) end.y,
(double) end.z
)
);
}
public static List findSelectItems(World world, Vector3 start, Vector3 end, List disiredItems) {
public static List
findSelectItems(World world, Vector3 start, Vector3 end, List disiredItems) {
List entityItems = ItemFindingHelper.findAllItemIn(world, start, end);
return ItemFindingHelper.filterEntityItemsList(entityItems, disiredItems);
}
public static List<EntityItem> filterEntityItemsList(List<EntityItem> entityItems, List<ItemStack> disiredItems) {
public static List<EntityItem>
filterEntityItemsList(List<EntityItem> entityItems, List<ItemStack> disiredItems) {
ArrayList<EntityItem> newItemList = new ArrayList<EntityItem>();
block0: for (EntityItem entityItem : entityItems) {
block0:
for (EntityItem entityItem : entityItems) {
for (ItemStack itemStack : disiredItems) {
if (entityItem.getEntityItem().getItem() != itemStack.getItem() || entityItem.getEntityItem().getItemDamage() != itemStack.getItemDamage() || newItemList.contains((Object)entityItem)) continue;
if (entityItem.getEntityItem().getItem() != itemStack.getItem()
|| entityItem.getEntityItem().getItemDamage()
!= itemStack.getItemDamage()
|| newItemList.contains((Object) entityItem))
continue;
newItemList.add(entityItem);
continue block0;
}
@ -35,17 +53,23 @@ public class ItemFindingHelper {
public static List<EntityItem> filterOutEntityItems(List<Entity> entities) {
ArrayList<EntityItem> newEntityList = new ArrayList<EntityItem>();
for (Entity entity : entities) {
if (!(entity instanceof EntityItem)) continue;
if (!(entity instanceof EntityItem))
continue;
newEntityList.add((EntityItem) entity);
}
return newEntityList;
}
public static List<ItemStack> filterItems(List<ItemStack> totalItems, List<ItemStack> desiredItems) {
public static List<ItemStack>
filterItems(List<ItemStack> totalItems, List<ItemStack> desiredItems) {
ArrayList<ItemStack> newItemList = new ArrayList<ItemStack>();
block0: for (ItemStack entityItem : totalItems) {
block0:
for (ItemStack entityItem : totalItems) {
for (ItemStack itemStack : desiredItems) {
if (entityItem.getItem() != itemStack.getItem() || entityItem.getItemDamage() != itemStack.getItemDamage() || newItemList.contains((Object)entityItem)) continue;
if (entityItem.getItem() != itemStack.getItem()
|| entityItem.getItemDamage() != itemStack.getItemDamage()
|| newItemList.contains((Object) entityItem))
continue;
newItemList.add(entityItem);
continue block0;
}
@ -53,7 +77,8 @@ public class ItemFindingHelper {
return newItemList;
}
public static boolean dropItemStackExact(World world, double x, double y, double z, ItemStack stack) {
public static boolean
dropItemStackExact(World world, double x, double y, double z, ItemStack stack) {
if (!world.isRemote && stack != null) {
EntityItem entity = new EntityItem(world, x, y, z, stack);
entity.delayBeforeCanPickup = 10;
@ -68,9 +93,10 @@ public class ItemFindingHelper {
Block block = world.getBlock(x, y, z);
ArrayList<ItemStack> items = block.getDrops(world, x, y, z, meta, 0);
for (ItemStack item : items) {
ItemFindingHelper.dropItemStackExact(world, (double)x + 0.5, (double)y + 0.5, (double)z + 0.5, item);
ItemFindingHelper.dropItemStackExact(
world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5, item
);
}
}
}
}