use of net.minecraft.item.ItemBlock in project LogisticsPipes by RS485.
the class SlotFinderOpenGuiPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
//hack to avoid wrenching blocks
int savedEquipped = player.inventory.currentItem;
boolean foundSlot = false;
//try to find a empty slot
for (int i = 0; i < 9; i++) {
if (player.inventory.getStackInSlot(i) == null) {
foundSlot = true;
player.inventory.currentItem = i;
break;
}
}
//okay, anything that's a block?
if (!foundSlot) {
for (int i = 0; i < 9; i++) {
ItemStack is = player.inventory.getStackInSlot(i);
if (is.getItem() instanceof ItemBlock) {
foundSlot = true;
player.inventory.currentItem = i;
break;
}
}
}
//give up and select whatever is right of the current slot
if (!foundSlot) {
player.inventory.currentItem = (player.inventory.currentItem + 1) % 9;
}
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(player.worldObj, getPosX(), getPosY(), getPosZ());
Iterator<AdjacentTileEntity> adjacentIt = worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).iterator();
boolean found = false;
while (adjacentIt.hasNext()) {
AdjacentTileEntity adjacent = adjacentIt.next();
if (adjacent.tileEntity instanceof IInventory) {
if (!(SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil((IInventory) adjacent.tileEntity) instanceof ISpecialInsertion)) {
continue;
}
}
for (ICraftingRecipeProvider provider : SimpleServiceLocator.craftingRecipeProviders) {
if (provider.canOpenGui(adjacent.tileEntity)) {
found = true;
break;
}
}
if (!found) {
found = (adjacent.tileEntity instanceof IInventory);
}
if (found) {
Block block = adjacent.tileEntity.getBlockType();
int xCoord = adjacent.tileEntity.xCoord;
int yCoord = adjacent.tileEntity.yCoord;
int zCoord = adjacent.tileEntity.zCoord;
if (SimpleServiceLocator.enderStorageProxy.isEnderChestBlock(block)) {
SimpleServiceLocator.enderStorageProxy.openEnderChest(player.worldObj, xCoord, yCoord, zCoord, player);
//@formatter:off
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SlotFinderActivatePacket.class).setTagetPosX(xCoord).setTagetPosY(yCoord).setTagetPosZ(zCoord).setSlot(getSlot()).setPacketPos(this), player);
//@formatter:on
}
if (block != null) {
if (block.onBlockActivated(player.worldObj, xCoord, yCoord, zCoord, player, 0, 0, 0, 0)) {
//@formatter:off
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SlotFinderActivatePacket.class).setTagetPosX(xCoord).setTagetPosY(yCoord).setTagetPosZ(zCoord).setSlot(getSlot()).setPacketPos(this), player);
//@formatter:on
break;
}
}
}
}
player.inventory.currentItem = savedEquipped;
}
use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.
the class SummoningRegistryComponent method compareRing.
public boolean compareRing(int ring, ItemStack[] checkedRingRecipe) {
ItemStack[] recipe;
if (checkedRingRecipe.length < 6) {
return false;
}
switch(ring) {
case 1:
recipe = ring1;
break;
case 2:
recipe = ring2;
break;
case 3:
recipe = ring3;
break;
default:
recipe = ring1;
}
if (recipe.length != 6) {
ItemStack[] newRecipe = new ItemStack[6];
for (int i = 0; i < 6; i++) {
if (i + 1 > recipe.length) {
newRecipe[i] = null;
} else {
newRecipe[i] = recipe[i];
}
}
recipe = newRecipe;
}
boolean[] checkList = new boolean[6];
for (int i = 0; i < 6; i++) {
checkList[i] = false;
}
for (int i = 0; i < 6; i++) {
ItemStack recipeItemStack = recipe[i];
if (recipeItemStack == null) {
continue;
}
boolean test = false;
for (int j = 0; j < 6; j++) {
if (checkList[j]) {
continue;
}
ItemStack checkedItemStack = checkedRingRecipe[j];
if (checkedItemStack == null) {
continue;
}
boolean quickTest = false;
if (recipeItemStack.getItem() instanceof ItemBlock) {
if (checkedItemStack.getItem() instanceof ItemBlock) {
quickTest = true;
}
} else if (!(checkedItemStack.getItem() instanceof ItemBlock)) {
quickTest = true;
}
if (!quickTest) {
continue;
}
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem()) {
test = true;
checkList[j] = true;
break;
}
}
if (!test) {
return false;
}
}
return true;
}
use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.
the class AlchemyRecipe method doesRecipeMatch.
public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel) {
if (slottedBloodOrbLevel < bloodOrbLevel) {
return false;
}
ItemStack[] recipe = new ItemStack[5];
if (items.length < 5) {
return false;
}
if (this.recipe.length != 5) {
ItemStack[] newRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++) {
if (i + 1 > this.recipe.length) {
newRecipe[i] = null;
} else {
newRecipe[i] = this.recipe[i];
}
}
recipe = newRecipe;
} else {
recipe = this.recipe;
}
boolean[] checkList = new boolean[5];
for (int i = 0; i < 5; i++) {
checkList[i] = false;
}
for (int i = 0; i < 5; i++) {
ItemStack recipeItemStack = recipe[i];
if (recipeItemStack == null) {
continue;
}
boolean test = false;
for (int j = 0; j < 5; j++) {
if (checkList[j]) {
continue;
}
ItemStack checkedItemStack = items[j];
if (checkedItemStack == null) {
continue;
}
boolean quickTest = false;
if (recipeItemStack.getItem() instanceof ItemBlock) {
if (checkedItemStack.getItem() instanceof ItemBlock) {
quickTest = true;
}
} else if (!(checkedItemStack.getItem() instanceof ItemBlock)) {
quickTest = true;
}
if (!quickTest) {
continue;
}
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem()) {
test = true;
checkList[j] = true;
break;
}
}
if (!test) {
return false;
}
}
return true;
}
use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.
the class GuiAnimatedStat method render.
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
lastMouseX = mouseX;
lastMouseY = mouseY;
float zLevel = 0;
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
int renderBaseX = (int) (oldBaseX + (baseX - oldBaseX) * partialTicks);
int renderAffectedY = (int) (oldAffectedY + (affectedY - oldAffectedY) * partialTicks);
int renderWidth = (int) (oldWidth + (width - oldWidth) * partialTicks);
int renderHeight = (int) (oldHeight + (height - oldHeight) * partialTicks);
if (leftSided)
renderWidth *= -1;
Gui.drawRect(renderBaseX, renderAffectedY, /* + 1 */
renderBaseX + renderWidth, /*- 1*/
renderAffectedY + renderHeight, backGroundColor);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glLineWidth(3.0F);
GL11.glColor4d(0, 0, 0, 1);
Tessellator tess = Tessellator.instance;
tess.startDrawing(GL11.GL_LINE_LOOP);
tess.addVertex(renderBaseX, renderAffectedY, zLevel);
tess.addVertex(renderBaseX + renderWidth, renderAffectedY, zLevel);
tess.addVertex(renderBaseX + renderWidth, renderAffectedY + renderHeight, zLevel);
tess.addVertex(renderBaseX, renderAffectedY + renderHeight, zLevel);
tess.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
if (leftSided)
renderWidth *= -1;
// if done expanding, draw the information
if (doneExpanding) {
GL11.glPushMatrix();
GL11.glTranslated(renderBaseX + (leftSided ? -renderWidth : 16), renderAffectedY, 0);
GL11.glScaled(textSize, textSize, textSize);
GL11.glTranslated(-renderBaseX - (leftSided ? -renderWidth : 16), -renderAffectedY, 0);
fontRenderer.drawStringWithShadow(title, renderBaseX + (leftSided ? -renderWidth + 2 : 18), renderAffectedY + 2, 0xFFFF00);
for (int i = curScroll; i < textList.size() && i < curScroll + MAX_LINES; i++) {
if (textList.get(i).contains("ยง0") || textList.get(i).contains(EnumChatFormatting.DARK_RED.toString())) {
fontRenderer.drawString(textList.get(i), renderBaseX + (leftSided ? -renderWidth + 2 : 18), renderAffectedY + (i - curScroll) * 10 + 12, 0xFFFFFF);
} else {
fontRenderer.drawStringWithShadow(textList.get(i), renderBaseX + (leftSided ? -renderWidth + 2 : 18), renderAffectedY + (i - curScroll) * 10 + 12, 0xFFFFFF);
}
}
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(renderBaseX, renderAffectedY, 0);
GL11.glEnable(GL11.GL_TEXTURE_2D);
for (IGuiWidget widget : widgets) widget.render(mouseX - renderBaseX, mouseY - renderAffectedY, partialTicks);
GL11.glPopMatrix();
}
if (renderHeight > 16 && renderWidth > 16) {
GL11.glColor4d(1, 1, 1, 1);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (iStack == null) {
if (texture.contains(Textures.GUI_LOCATION)) {
GuiPneumaticContainerBase.drawTexture(texture, renderBaseX - (leftSided ? 16 : 0), renderAffectedY);
} else {
fontRenderer.drawString(texture, renderBaseX - (leftSided ? 16 : 0), renderAffectedY, 0xFFFFFFFF);
}
} else if (gui != null || !(iStack.getItem() instanceof ItemBlock)) {
if (itemRenderer == null)
itemRenderer = new RenderItem();
itemRenderer.zLevel = 1;
GL11.glPushMatrix();
GL11.glTranslated(0, 0, -50);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, FMLClientHandler.instance().getClient().renderEngine, iStack, renderBaseX - (leftSided ? 16 : 0), renderAffectedY);
GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
}
use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.
the class ModelAssemblyIOUnit method renderModel.
public void renderModel(float size, float[] angles, float clawProgress, EntityItem carriedItem) {
float clawTrans;
float scaleFactor = 0.7F;
IAssemblyRenderOverriding renderOverride = null;
if (carriedItem != null) {
renderOverride = AssemblyRenderOverriding.renderOverrides.get(carriedItem.getEntityItem());
if (renderOverride != null) {
clawTrans = renderOverride.getIOUnitClawShift(carriedItem.getEntityItem());
} else {
if (carriedItem.getEntityItem().getItem() instanceof ItemBlock) {
clawTrans = 1.5F / 16F - clawProgress * 0.1F / 16F;
} else {
clawTrans = 1.5F / 16F - clawProgress * 1.4F / 16F;
scaleFactor = 0.4F;
}
}
} else {
clawTrans = 1.5F / 16F - clawProgress * 1.5F / 16F;
}
Base.render(size);
GL11.glPushMatrix();
GL11.glRotatef(angles[0], 0, 1, 0);
BaseTurn.render(size);
BaseTurn2.render(size);
GL11.glTranslated(0, 18 / 16F, 0);
GL11.glRotatef(angles[1], 1, 0, 0);
GL11.glTranslated(0, -18 / 16F, 0);
ArmBase1.render(size);
ArmBase2.render(size);
SupportMiddle.render(size);
GL11.glTranslated(0, 18 / 16F, 6 / 16F);
GL11.glRotatef(angles[2], 1, 0, 0);
GL11.glTranslated(0, -18 / 16F, -6 / 16F);
ArmMiddle1.render(size);
ArmMiddle2.render(size);
GL11.glTranslated(0, 3 / 16F, 6 / 16F);
GL11.glRotatef(angles[3], 1, 0, 0);
GL11.glTranslated(0, -3 / 16F, -6 / 16F);
ClawBase.render(size);
GL11.glTranslated(0, 3 / 16F, 0);
GL11.glRotatef(angles[4], 0, 0, 1);
GL11.glTranslated(0, -3 / 16F, 0);
ClawAxil.render(size);
ClawTurn.render(size);
GL11.glPushMatrix();
GL11.glTranslated(clawTrans, 0, 0);
Claw1.render(size);
GL11.glTranslated(-2 * clawTrans, 0, 0);
Claw2.render(size);
GL11.glPopMatrix();
if (carriedItem != null) {
if (renderOverride == null || renderOverride.applyRenderChangeIOUnit(carriedItem.getEntityItem())) {
GL11.glRotated(90, 1, 0, 0);
GL11.glTranslated(0, carriedItem.getEntityItem().getItem() instanceof ItemBlock ? 1.5 / 16D : 0.5 / 16D, -3 / 16D);
GL11.glRotated(-90, 0, 1, 0);
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
customRenderItem.doRender(carriedItem, 0, 0, 0, 0, 0);
}
}
GL11.glPopMatrix();
}
Aggregations