use of codechicken.lib.raytracer.CuboidRayTraceResult in project GregTech by GregTechCE.
the class BlockPipe method onBlockClicked.
@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(worldIn, pos);
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
if (pipeTile == null || rayTraceResult == null) {
return;
}
EnumFacing coverSide = ICoverable.traceCoverSide(rayTraceResult);
CoverBehavior coverBehavior = coverSide == null ? null : pipeTile.getCoverableImplementation().getCoverAtSide(coverSide);
if (coverBehavior != null) {
coverBehavior.onLeftClick(playerIn, rayTraceResult);
}
}
use of codechicken.lib.raytracer.CuboidRayTraceResult in project GregTech by GregTechCE.
the class MultiblockInfoRecipeWrapper method drawInfo.
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
WorldSceneRenderer renderer = getCurrentRenderer();
int sceneHeight = recipeHeight - PARTS_HEIGHT;
renderer.render(recipeLayout.getPosX(), recipeLayout.getPosY(), recipeWidth, sceneHeight, 0xC6C6C6);
drawMultiblockName(recipeWidth);
// reset colors (so any elements render after this point are not dark)
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.infoIcon.draw(minecraft, recipeWidth - (ICON_SIZE + RIGHT_PADDING), 49);
for (int i = 0; i < MAX_PARTS; ++i) {
this.slot.draw(minecraft, SLOT_SIZE * i - (SLOTS_PER_ROW * SLOT_SIZE) * (i / SLOTS_PER_ROW), sceneHeight + SLOT_SIZE * (i / SLOTS_PER_ROW));
}
// the button by mousing over it, leaks into other gui elements?
for (GuiButton button : buttons.keySet()) {
button.drawButton(minecraft, mouseX, mouseY, 0.0f);
}
drawHoveringInformationText(minecraft, infoPage.informationText(), mouseX, mouseY);
this.tooltipBlockStack = null;
BlockPos pos = renderer.getLastHitBlock();
boolean insideView = mouseX >= 0 && mouseY >= 0 && mouseX < recipeWidth && mouseY < sceneHeight;
boolean leftClickHeld = Mouse.isButtonDown(0);
boolean rightClickHeld = Mouse.isButtonDown(1);
boolean isHoldingShift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
if (insideView) {
if (leftClickHeld) {
if (isHoldingShift) {
int mouseDeltaY = mouseY - lastMouseY;
this.rotationPitch += mouseDeltaY * 2.0f;
} else {
int mouseDeltaX = mouseX - lastMouseX;
this.rotationYaw += mouseDeltaX * 2.0f;
}
} else if (rightClickHeld) {
int mouseDeltaY = mouseY - lastMouseY;
if (isHoldingShift) {
this.zoom *= Math.pow(1.05d, -mouseDeltaY);
} else {
int mouseDeltaX = mouseX - lastMouseX;
this.panX -= mouseDeltaX / 2.0f;
this.panY -= mouseDeltaY / 2.0f;
}
}
}
if (!(leftClickHeld || rightClickHeld) && pos != null && !renderer.world.isAirBlock(pos)) {
IBlockState blockState = renderer.world.getBlockState(pos);
RayTraceResult result = new CuboidRayTraceResult(new Vector3(0.5, 0.5, 0.5).add(pos), pos, EnumFacing.UP, new IndexedCuboid6(null, Cuboid6.full), 1.0);
ItemStack itemStack = blockState.getBlock().getPickBlock(blockState, result, renderer.world, pos, minecraft.player);
if (itemStack != null && !itemStack.isEmpty()) {
this.tooltipBlockStack = itemStack;
}
}
this.lastMouseX = mouseX;
this.lastMouseY = mouseY;
}
use of codechicken.lib.raytracer.CuboidRayTraceResult in project GregTech by GregTechCE.
the class BlockMachine method onBlockClicked.
@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
if (metaTileEntity == null)
return;
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
if (rayTraceResult != null) {
metaTileEntity.onCoverLeftClick(playerIn, rayTraceResult);
}
}
use of codechicken.lib.raytracer.CuboidRayTraceResult in project GregTech by GregTechCE.
the class BlockMachine method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
ItemStack itemStack = playerIn.getHeldItem(hand);
if (metaTileEntity == null || rayTraceResult == null) {
return false;
}
if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null)) {
IScrewdriverItem screwdriver = itemStack.getCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null);
if (screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, true) && metaTileEntity.onCoverScrewdriverClick(playerIn, hand, rayTraceResult)) {
screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, false);
return true;
}
return false;
}
if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_WRENCH, null)) {
IWrenchItem wrenchItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_WRENCH, null);
EnumFacing wrenchDirection = ICoverable.determineGridSideHit(rayTraceResult);
if (wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, true) && metaTileEntity.onWrenchClick(playerIn, hand, wrenchDirection, rayTraceResult)) {
wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, false);
return true;
}
return false;
}
return metaTileEntity.onCoverRightClick(playerIn, hand, rayTraceResult);
}
use of codechicken.lib.raytracer.CuboidRayTraceResult in project GregTech by GregTechCE.
the class BlockPipe method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(worldIn, pos);
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
if (rayTraceResult == null || pipeTile == null) {
return false;
}
return onPipeActivated(playerIn, hand, rayTraceResult, pipeTile);
}
Aggregations