use of net.minecraft.util.EnumFacing in project MinecraftForge by MinecraftForge.
the class VanillaInventoryCodeHooks method dropperInsertHook.
/**
* Copied from BlockDropper#dispense and added capability support
*/
public static boolean dropperInsertHook(World world, BlockPos pos, TileEntityDispenser dropper, int slot, @Nonnull ItemStack stack) {
EnumFacing enumfacing = world.getBlockState(pos).getValue(BlockDropper.FACING);
BlockPos blockpos = pos.offset(enumfacing);
Pair<IItemHandler, Object> destinationResult = getItemHandler(world, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), enumfacing.getOpposite());
if (destinationResult == null) {
return true;
} else {
IItemHandler itemHandler = destinationResult.getKey();
Object destination = destinationResult.getValue();
ItemStack dispensedStack = stack.copy().splitStack(1);
ItemStack remainder = putStackInInventoryAllSlots(dropper, destination, itemHandler, dispensedStack);
if (remainder.isEmpty()) {
remainder = stack.copy();
remainder.shrink(1);
} else {
remainder = stack.copy();
}
dropper.setInventorySlotContents(slot, remainder);
return false;
}
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileRenderAutoWorkbench method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityAutoWorkbench te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
//Grab model + correct eextended state
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
//Initialize Tesselator and VertexBuffer
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
//Outer GL Wrapping, initial translation
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
if (te.mirrored)
GlStateManager.scale(te.facing.getFrontOffsetX() == 0 ? -1 : 1, 1, te.facing.getFrontOffsetZ() == 0 ? -1 : 1);
//Item Displacement
float[][] itemDisplays = new float[te.processQueue.size()][];
//Animations
float drill = 0;
float lift = 0;
float press = 0;
float liftPress = 0;
for (int i = 0; i < itemDisplays.length; i++) {
MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
if (process == null || process.processTick <= 0 || process.processTick == process.maxTicks)
continue;
//+partialTicks
float processTimer = ((float) process.processTick) / process.maxTicks * 180;
if (processTimer <= 9)
continue;
float itemX = -1;
float itemY = -.34375f;
float itemZ = -.9375f;
float itemAngle = 90f;
if (//slide
processTimer <= 24) {
itemAngle = 67.5f;
if (processTimer <= 19) {
itemZ += .25 + (19 - processTimer) / 10f * .5f;
itemY += .25 + (19 - processTimer) / 10f * .21875f;
} else {
itemZ += (24 - processTimer) / 5f * .25f;
itemY += (24 - processTimer) / 5f * .25f;
}
} else if (processTimer <= 40) {
itemX += (processTimer - 24) / 16f;
} else if (processTimer <= 100) {
itemX += 1;
float drillStep = 0;
if (processTimer <= 60) {
lift = (processTimer - 40) / 20f * .3125f;
drillStep = 4 + (60 - processTimer) * 4;
} else if (processTimer <= 80) {
lift = .3125f;
drillStep = 4;
} else {
lift = (100 - processTimer) / 20f * .3125f;
drillStep = 4 + (processTimer - 80) * 4;
}
if (drillStep > 0)
drill = processTimer % drillStep / drillStep * 360;
itemY += Math.max(0, lift - .0625);
} else if (processTimer <= 116) {
itemX += 1;
itemZ += (processTimer - 100) / 16f;
} else if (processTimer <= 132) {
itemX += 1 + (processTimer - 116) / 16f;
itemZ += 1;
} else if (processTimer <= 172) {
itemX += 2;
itemZ += 1;
if (processTimer <= 142)
press = (processTimer - 132) / 10f;
else if (processTimer <= 162)
press = 1;
else
press = (172 - processTimer) / 10f;
liftPress = press * .0625f;
itemY += liftPress;
} else if (processTimer <= 180) {
itemX += 2 + (processTimer - 172) / 16f;
itemZ += 1;
}
itemDisplays[i] = new float[] { processTimer, itemX, itemY, itemZ, itemAngle };
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
ItemStack blueprintStack = te.inventory[0];
if (blueprintStack != null)
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "blueprint");
GlStateManager.translate(0, lift, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "lift");
GlStateManager.translate(0, -lift, 0);
EnumFacing f = te.getFacing();
float tx = f == EnumFacing.WEST ? -.9375f : f == EnumFacing.EAST ? .9375f : 0;
float tz = f == EnumFacing.NORTH ? -.9375f : f == EnumFacing.SOUTH ? .9375f : 0;
GlStateManager.translate(tx, 0, tz);
GlStateManager.rotate(drill, 0, 1, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "drill");
GlStateManager.rotate(-drill, 0, 1, 0);
GlStateManager.translate(-tx, 0, -tz);
tx = f == EnumFacing.WEST ? -.59375f : f == EnumFacing.EAST ? .59375f : 0;
tz = f == EnumFacing.NORTH ? -.59375f : f == EnumFacing.SOUTH ? .59375f : 0;
GlStateManager.translate(tx, -.21875, tz);
GlStateManager.rotate(press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX());
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "press");
GlStateManager.rotate(-press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX());
GlStateManager.translate(-tx, .21875, -tz);
GlStateManager.translate(0, liftPress, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "pressLift");
GlStateManager.translate(0, -liftPress, 0);
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
switch(f) {
case NORTH:
break;
case SOUTH:
GlStateManager.rotate(180, 0, 1, 0);
break;
case WEST:
GlStateManager.rotate(90, 0, 1, 0);
break;
case EAST:
GlStateManager.rotate(-90, 0, 1, 0);
break;
}
//DRAW ITEMS HERE
for (int i = 0; i < itemDisplays.length; i++) if (itemDisplays[i] != null) {
MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
if (process == null || !(process instanceof MultiblockProcessInWorld))
continue;
float scale = .3125f;
List<ItemStack> dList = ((MultiblockProcessInWorld) process).getDisplayItem();
if (!dList.isEmpty())
if (dList.size() < 2) {
GlStateManager.translate(itemDisplays[i][1], itemDisplays[i][2], itemDisplays[i][3]);
GlStateManager.rotate(itemDisplays[i][4], 1, 0, 0);
GlStateManager.scale(scale, scale, .5f);
ClientUtils.mc().getRenderItem().renderItem(dList.get(0), ItemCameraTransforms.TransformType.FIXED);
GlStateManager.scale(1 / scale, 1 / scale, 2);
GlStateManager.rotate(-itemDisplays[i][4], 1, 0, 0);
GlStateManager.translate(-itemDisplays[i][1], -itemDisplays[i][2], -itemDisplays[i][3]);
} else {
int size = dList.size();
int lines = (int) Math.ceil(size / 2f);
float spacer = (lines - 1) * .234375f;
for (int d = 0; d < size; d++) {
float oX = (size > 2 ? -.3125f : 0) + (lines - d / 2) * .0625f + d % 2 * .3125f;
float oZ = -spacer / 2f + d / 2 * .234375f;
float oY = 0;
float localItemX = itemDisplays[i][1] + oX;
float localItemY = itemDisplays[i][2] + oY;
float localItemZ = itemDisplays[i][3] + oZ;
float subProcess = itemDisplays[i][0] - d / 2 * 4;
float localAngle = itemDisplays[i][4];
if (//slide
subProcess <= 24) {
localAngle = 67.5f;
if (subProcess <= 19) {
localItemZ = -1 + .25f + (19 - subProcess) / 10f * .5f;
localItemY = -.34375f + .25f + (19 - subProcess) / 10f * .21875f;
} else {
localItemZ = -1 + (oZ - (24 - subProcess) / 5f * oZ);
localItemY = -.34375f + (24 - subProcess) / 5f * .25f;
}
}
GlStateManager.translate(localItemX, localItemY, localItemZ);
GlStateManager.rotate(localAngle, 1, 0, 0);
GlStateManager.scale(scale, scale, .5f);
ClientUtils.mc().getRenderItem().renderItem(dList.get(d), ItemCameraTransforms.TransformType.FIXED);
GlStateManager.scale(1 / scale, 1 / scale, 2);
GlStateManager.rotate(-localAngle, 1, 0, 0);
GlStateManager.translate(-localItemX, -localItemY, -localItemZ);
}
}
}
//Blueprint
double playerDistanceSq = ClientUtils.mc().thePlayer.getDistanceSq(blockPos);
if (blueprintStack != null && playerDistanceSq < 1000) {
BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(blueprintStack, "blueprint"));
BlueprintCraftingRecipe recipe = (te.selectedRecipe < 0 || te.selectedRecipe >= recipes.length) ? null : recipes[te.selectedRecipe];
BlueprintLines blueprint = recipe == null ? null : getBlueprintDrawable(recipe, te.getWorld());
if (blueprint != null) {
//Width depends on distance
float lineWidth = playerDistanceSq < 6 ? 3 : playerDistanceSq < 25 ? 2 : playerDistanceSq < 40 ? 1 : .5f;
GlStateManager.translate(-.195, .125, .97);
GlStateManager.rotate(-45, 1, 0, 0);
GlStateManager.disableCull();
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
float scale = .0375f / (blueprint.textureScale / 16f);
GlStateManager.scale(scale, -scale, scale);
GlStateManager.color(1, 1, 1, 1);
blueprint.draw(lineWidth);
GlStateManager.scale(1 / scale, -1 / scale, 1 / scale);
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableCull();
}
}
GlStateManager.popMatrix();
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileRenderBelljar method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBelljar tile, double x, double y, double z, float partialTicks, int destroyStage) {
if (tile.dummy != 0 || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = tile.getPos();
if (!quads.containsKey(tile.getFacing())) {
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalDevice1)
return;
state = state.getActualState(getWorld(), blockPos);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList("glass"), true));
quads.put(tile.getFacing(), model.getQuads(state, null, 0));
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
VertexBuffer worldRenderer = Tessellator.getInstance().getBuffer();
GlStateManager.enableCull();
IPlantHandler plantHandler = tile.getCurrentPlantHandler();
if (plantHandler != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, 1.0625, 0);
GlStateManager.color(1, 1, 1, 1);
float scale = plantHandler.getRenderSize(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile);
GlStateManager.translate((1 - scale) / 2, 0, (1 - scale) / 2);
GlStateManager.scale(scale, scale, scale);
if (!plantHandler.overrideRender(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile, blockRenderer)) {
IBlockState[] states = plantHandler.getRenderedPlant(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile);
if (states == null || states.length < 1)
return;
for (IBlockState s : states) {
List<BakedQuad> plantQuadList = plantQuads.get(s);
if (plantQuadList == null) {
IBakedModel plantModel = blockRenderer.getModelForState(s);
plantQuadList = plantModel.getQuads(s, null, 0);
for (EnumFacing f : EnumFacing.values()) plantQuadList.addAll(plantModel.getQuads(s, f, 0));
plantQuads.put(s, plantQuadList);
}
if (plantQuadList != null) {
GlStateManager.pushMatrix();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESR(plantQuadList, worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
GlStateManager.translate(0, 1, 0);
}
}
}
GlStateManager.popMatrix();
}
GlStateManager.depthMask(false);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESR(quads.get(tile.getFacing()), worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
Tessellator.getInstance().draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileRenderBucketWheel method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBucketWheel tile, double x, double y, double z, float f, int destroyStage) {
if (!tile.formed || !tile.getWorld().isBlockLoaded(tile.getPos(), false) || tile.isDummy())
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
if (model == null) {
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
model = blockRenderer.getModelForState(state);
}
OBJState objState = null;
HashMap<String, String> texMap = new HashMap<>();
if (state instanceof IExtendedBlockState) {
ArrayList<String> list = Lists.newArrayList("bucketWheel");
synchronized (tile.digStacks) {
for (int i = 0; i < tile.digStacks.length; i++) if (tile.digStacks[i] != null) {
list.add("dig" + i);
Block b = Block.getBlockFromItem(tile.digStacks[i].getItem());
IBlockState digState = b != null ? b.getStateFromMeta(tile.digStacks[i].getMetadata()) : Blocks.STONE.getDefaultState();
IBakedModel digModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(digState);
if (digModel != null && digModel.getParticleTexture() != null)
texMap.put("dig" + i, digModel.getParticleTexture().getIconName());
}
}
objState = new OBJState(list, true);
}
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
EnumFacing facing = tile.facing;
if (tile.mirrored) {
GlStateManager.scale(facing.getAxis() == Axis.X ? -1 : 1, 1, facing.getAxis() == Axis.Z ? -1 : 1);
GlStateManager.disableCull();
}
float dir = tile.facing == EnumFacing.SOUTH ? 90 : tile.facing == EnumFacing.NORTH ? -90 : tile.facing == EnumFacing.EAST ? 180 : 0;
GlStateManager.rotate(dir, 0, 1, 0);
float rot = tile.rotation + (float) (tile.active ? IEConfig.Machines.excavator_speed * f : 0);
GlStateManager.rotate(rot, 1, 0, 0);
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
VertexBuffer worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5, -.5, -.5);
List<BakedQuad> quads;
if (model instanceof IESmartObjModel)
quads = ((IESmartObjModel) model).getQuads(state, null, 0, objState, texMap, true);
else
quads = model.getQuads(state, null, 0);
ClientUtils.renderModelTESR(quads, worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.enableCull();
if (tile.mirrored) {
GlStateManager.enableCull();
}
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method renderAdditionalBlockBounds.
@SubscribeEvent()
public void renderAdditionalBlockBounds(DrawBlockHighlightEvent event) {
if (event.getSubID() == 0 && event.getTarget().typeOfHit == RayTraceResult.Type.BLOCK) {
float f1 = 0.002F;
double px = -TileEntityRendererDispatcher.staticPlayerX;
double py = -TileEntityRendererDispatcher.staticPlayerY;
double pz = -TileEntityRendererDispatcher.staticPlayerZ;
TileEntity tile = event.getPlayer().worldObj.getTileEntity(event.getTarget().getBlockPos());
ItemStack stack = event.getPlayer().getHeldItem(EnumHand.MAIN_HAND);
// if(event.getPlayer().worldObj.getBlockState(event.getTarget().getBlockPos()).getBlock() instanceof IEBlockInterfaces.ICustomBoundingboxes)
if (tile instanceof IAdvancedSelectionBounds) {
// IEBlockInterfaces.ICustomBoundingboxes block = (IEBlockInterfaces.ICustomBoundingboxes) event.getPlayer().worldObj.getBlockState(event.getTarget().getBlockPos()).getBlock();
IAdvancedSelectionBounds iasb = (IAdvancedSelectionBounds) tile;
List<AxisAlignedBB> boxes = iasb.getAdvancedSelectionBounds();
if (boxes != null && !boxes.isEmpty()) {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
ArrayList<AxisAlignedBB> additionalBoxes = new ArrayList<AxisAlignedBB>();
AxisAlignedBB overrideBox = null;
for (AxisAlignedBB aabb : boxes) if (aabb != null) {
if (iasb.isOverrideBox(aabb, event.getPlayer(), event.getTarget(), additionalBoxes))
overrideBox = aabb;
}
if (overrideBox != null)
RenderGlobal.func_189697_a(overrideBox.expand(f1, f1, f1).offset(px, py, pz), 0, 0, 0, 0.4f);
else
for (AxisAlignedBB aabb : additionalBoxes.isEmpty() ? boxes : additionalBoxes) RenderGlobal.func_189697_a(aabb.expand(f1, f1, f1).offset(px, py, pz), 0, 0, 0, 0.4f);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
event.setCanceled(true);
}
}
if (Utils.isHammer(stack) && tile instanceof TileEntityTurntable) {
BlockPos pos = event.getTarget().getBlockPos();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
EnumFacing f = ((TileEntityTurntable) tile).getFacing();
double tx = pos.getX() + .5;
double ty = pos.getY() + .5;
double tz = pos.getZ() + .5;
if (!event.getPlayer().worldObj.isAirBlock(pos.offset(f))) {
tx += f.getFrontOffsetX();
ty += f.getFrontOffsetY();
tz += f.getFrontOffsetZ();
}
vertexbuffer.setTranslation(tx + px, ty + py, tz + pz);
double angle = -event.getPlayer().ticksExisted % 80 / 40d * Math.PI;
drawRotationArrows(tessellator, vertexbuffer, f, angle, ((TileEntityTurntable) tile).invert);
vertexbuffer.setTranslation(0, 0, 0);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
World world = event.getPlayer().worldObj;
if (stack != null && IEContent.blockConveyor.equals(Block.getBlockFromItem(stack.getItem())) && event.getTarget().sideHit.getAxis() == Axis.Y) {
EnumFacing side = event.getTarget().sideHit;
BlockPos pos = event.getTarget().getBlockPos();
AxisAlignedBB targetedBB = world.getBlockState(pos).getSelectedBoundingBox(world, pos);
if (targetedBB != null)
targetedBB = targetedBB.offset(-pos.getX(), -pos.getY(), -pos.getZ());
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
vertexbuffer.setTranslation(pos.getX() + px, pos.getY() + py, pos.getZ() + pz);
double[][] points = new double[4][];
if (side.getAxis() == Axis.Y) {
points[0] = new double[] { 0 - f1, side == EnumFacing.DOWN ? ((targetedBB != null ? targetedBB.minY : 0) - f1) : ((targetedBB != null ? targetedBB.maxY : 1) + f1), 0 - f1 };
points[1] = new double[] { 1 + f1, side == EnumFacing.DOWN ? ((targetedBB != null ? targetedBB.minY : 0) - f1) : ((targetedBB != null ? targetedBB.maxY : 1) + f1), 1 + f1 };
points[2] = new double[] { 0 - f1, side == EnumFacing.DOWN ? ((targetedBB != null ? targetedBB.minY : 0) - f1) : ((targetedBB != null ? targetedBB.maxY : 1) + f1), 1 + f1 };
points[3] = new double[] { 1 + f1, side == EnumFacing.DOWN ? ((targetedBB != null ? targetedBB.minY : 0) - f1) : ((targetedBB != null ? targetedBB.maxY : 1) + f1), 0 - f1 };
} else if (side.getAxis() == Axis.Z) {
points[0] = new double[] { 1 + f1, 1 + f1, side == EnumFacing.NORTH ? ((targetedBB != null ? targetedBB.minZ : 0) - f1) : ((targetedBB != null ? targetedBB.maxZ : 1) + f1) };
points[1] = new double[] { 0 - f1, 0 - f1, side == EnumFacing.NORTH ? ((targetedBB != null ? targetedBB.minZ : 0) - f1) : ((targetedBB != null ? targetedBB.maxZ : 1) + f1) };
points[2] = new double[] { 0 - f1, 1 + f1, side == EnumFacing.NORTH ? ((targetedBB != null ? targetedBB.minZ : 0) - f1) : ((targetedBB != null ? targetedBB.maxZ : 1) + f1) };
points[3] = new double[] { 1 + f1, 0 - f1, side == EnumFacing.NORTH ? ((targetedBB != null ? targetedBB.minZ : 0) - f1) : ((targetedBB != null ? targetedBB.maxZ : 1) + f1) };
} else {
points[0] = new double[] { side == EnumFacing.WEST ? ((targetedBB != null ? targetedBB.minX : 0) - f1) : ((targetedBB != null ? targetedBB.maxX : 1) + f1), 1 + f1, 1 + f1 };
points[1] = new double[] { side == EnumFacing.WEST ? ((targetedBB != null ? targetedBB.minX : 0) - f1) : ((targetedBB != null ? targetedBB.maxX : 1) + f1), 0 - f1, 0 - f1 };
points[2] = new double[] { side == EnumFacing.WEST ? ((targetedBB != null ? targetedBB.minX : 0) - f1) : ((targetedBB != null ? targetedBB.maxX : 1) + f1), 1 + f1, 0 - f1 };
points[3] = new double[] { side == EnumFacing.WEST ? ((targetedBB != null ? targetedBB.minX : 0) - f1) : ((targetedBB != null ? targetedBB.maxX : 1) + f1), 0 - f1, 1 + f1 };
}
vertexbuffer.begin(1, DefaultVertexFormats.POSITION_COLOR);
for (double[] point : points) vertexbuffer.pos(point[0], point[1], point[2]).color(0, 0, 0, 0.4F).endVertex();
tessellator.draw();
vertexbuffer.begin(2, DefaultVertexFormats.POSITION_COLOR);
vertexbuffer.pos(points[0][0], points[0][1], points[0][2]).color(0, 0, 0, 0.4F).endVertex();
vertexbuffer.pos(points[2][0], points[2][1], points[2][2]).color(0, 0, 0, 0.4F).endVertex();
vertexbuffer.pos(points[1][0], points[1][1], points[1][2]).color(0, 0, 0, 0.4F).endVertex();
vertexbuffer.pos(points[3][0], points[3][1], points[3][2]).color(0, 0, 0, 0.4F).endVertex();
tessellator.draw();
float xFromMid = side.getAxis() == Axis.X ? 0 : (float) event.getTarget().hitVec.xCoord - pos.getX() - .5f;
float yFromMid = side.getAxis() == Axis.Y ? 0 : (float) event.getTarget().hitVec.yCoord - pos.getY() - .5f;
float zFromMid = side.getAxis() == Axis.Z ? 0 : (float) event.getTarget().hitVec.zCoord - pos.getZ() - .5f;
float max = Math.max(Math.abs(yFromMid), Math.max(Math.abs(xFromMid), Math.abs(zFromMid)));
Vec3d dir = new Vec3d(max == Math.abs(xFromMid) ? Math.signum(xFromMid) : 0, max == Math.abs(yFromMid) ? Math.signum(yFromMid) : 0, max == Math.abs(zFromMid) ? Math.signum(zFromMid) : 0);
if (dir != null)
drawBlockOverlayArrow(tessellator, vertexbuffer, dir, side, targetedBB);
vertexbuffer.setTranslation(0, 0, 0);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
if (stack != null && stack.getItem() instanceof ItemDrill && ((ItemDrill) stack.getItem()).isEffective(world.getBlockState(event.getTarget().getBlockPos()).getMaterial())) {
ItemStack head = ((ItemDrill) stack.getItem()).getHead(stack);
if (head != null) {
ImmutableList<BlockPos> blocks = ((IDrillHead) head.getItem()).getExtraBlocksDug(head, world, event.getPlayer(), event.getTarget());
drawAdditionalBlockbreak(event.getContext(), event.getPlayer(), event.getPartialTicks(), blocks);
}
}
}
}
Aggregations