use of net.minecraft.item.ItemBlock in project BluePower by Qmunity.
the class TubeStack method render.
@SideOnly(Side.CLIENT)
public void render(float partialTick) {
if (renderMode == RenderMode.AUTO) {
renderMode = Minecraft.getMinecraft().gameSettings.fancyGraphics ? RenderMode.NORMAL : RenderMode.REDUCED;
}
final RenderMode finalRenderMode = renderMode;
if (customRenderItem == null) {
customRenderItem = new RenderItem() {
@Override
public boolean shouldBob() {
return false;
}
;
@Override
public byte getMiniBlockCount(ItemStack stack, byte original) {
return finalRenderMode == RenderMode.REDUCED ? (byte) 1 : original;
}
};
customRenderItem.setRenderManager(RenderManager.instance);
renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient());
renderedItem.hoverStart = 0.0F;
}
renderedItem.setEntityItemStack(stack);
double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1;
GL11.glPushMatrix();
GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5, heading.offsetZ * renderProgress * 0.5);
if (finalRenderMode != RenderMode.NONE) {
GL11.glPushMatrix();
if (stack.stackSize > 5) {
GL11.glScaled(0.8, 0.8, 0.8);
}
if (!(stack.getItem() instanceof ItemBlock)) {
GL11.glScaled(0.8, 0.8, 0.8);
GL11.glTranslated(0, -0.15, 0);
}
customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0);
GL11.glPopMatrix();
} else {
float size = 0.02F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBegin(GL11.GL_QUADS);
RenderHelper.drawColoredCube(new Vec3dCube(-size, -size, -size, size, size, size), 1, 1, 1, 1);
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
if (color != TubeColor.NONE) {
float size = 0.2F;
int colorInt = ItemDye.field_150922_c[color.ordinal()];
float red = (colorInt >> 16) / 256F;
float green = (colorInt >> 8 & 255) / 256F;
float blue = (colorInt & 255) / 256F;
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor3f(red, green, blue);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png"));
RenderHelper.drawTesselatedTexturedCube(new Vec3dCube(-size, -size, -size, size, size, size));
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
}
GL11.glPopMatrix();
}
use of net.minecraft.item.ItemBlock in project LogisticsPipes by RS485.
the class ModuleCrafter method openAttachedGui.
public void openAttachedGui(EntityPlayer player) {
if (MainProxy.isClient(player.worldObj)) {
if (player instanceof EntityPlayerMP) {
player.closeScreen();
} else if (player instanceof EntityPlayerSP) {
player.closeScreen();
}
MainProxy.sendPacketToServer(PacketHandler.getPacket(CraftingPipeOpenConnectedGuiPacket.class).setModulePos(this));
return;
}
// 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(getWorld(), getX(), getY(), getZ());
worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).anyMatch(adjacent -> {
boolean found = SimpleServiceLocator.craftingRecipeProviders.stream().anyMatch(provider -> provider.canOpenGui(adjacent.tileEntity));
if (!found) {
found = (adjacent.tileEntity instanceof IInventory);
}
if (found) {
Block block = getWorld().getBlock(adjacent.tileEntity.xCoord, adjacent.tileEntity.yCoord, adjacent.tileEntity.zCoord);
if (block != null && block.onBlockActivated(getWorld(), adjacent.tileEntity.xCoord, adjacent.tileEntity.yCoord, adjacent.tileEntity.zCoord, player, 0, 0, 0, 0)) {
return true;
}
}
return false;
});
player.inventory.currentItem = savedEquipped;
}
use of net.minecraft.item.ItemBlock in project malmo by Microsoft.
the class MinecraftTypeHelper method attemptToGetAsVariant.
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
* (eg blue_orchid vs orchidBlue etc.)
* @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
* @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
* @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
*/
public static Variation attemptToGetAsVariant(String part, ItemStack is) {
if (is.getItem() instanceof ItemBlock) {
// Unlocalised name doesn't always match the names we use in types.xsd
// (which are the names displayed by Minecraft when using the F3 debug etc.)
ItemBlock ib = (ItemBlock) (is.getItem());
IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
for (IProperty prop : (java.util.Set<IProperty>) bs.getProperties().keySet()) {
Comparable<?> comp = bs.getValue(prop);
Variation var = attemptToGetAsVariant(comp.toString());
if (var != null)
return var;
}
return null;
} else
return attemptToGetAsVariant(part);
}
use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.
the class ReplacementBlock method getMeta.
/**
* Called to get the metadata of the replacement block in the world.
* @param world The world object
* @param x The X coord
* @param y The Y coord
* @param z The Z coord
* @param stack The ItemStack being used to replace the block (may be null)
* @return The metadata of the block
*/
protected int getMeta(World world, int x, int y, int z, ItemStack stack) {
int m = 0;
if (_hasMeta > 0) {
if (_hasMeta > 1)
return _meta;
m = stack.getItemDamage();
Item item = stack.getItem();
if (item instanceof ItemBlock)
m = ((ItemBlock) item).getMetadata(m);
}
return m;
}
use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.
the class RenderChargingStationPad method renderWorldBlock.
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityChargingStation) {
TileEntityChargingStation station = (TileEntityChargingStation) te;
if (station.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) {
ItemStack camo = station.getCamoStack();
Block camoBlock = ((ItemBlock) camo.getItem()).field_150939_a;
renderer.renderAllFaces = true;
renderer.setOverrideBlockTexture(camoBlock.getIcon(0, camo.getItemDamage()));
renderer.setRenderBounds(0, 15 / 16D, 0, 1, 1, 1);
renderer.renderStandardBlock(block, x, y, z);
renderer.setOverrideBlockTexture(null);
renderer.renderAllFaces = false;
return true;
}
}
return false;
}
Aggregations