本文整理匯總了Java中net.minecraftforge.client.event.DrawBlockHighlightEvent類的典型用法代碼示例。如果您正苦於以下問題:Java DrawBlockHighlightEvent類的具體用法?Java DrawBlockHighlightEvent怎麽用?Java DrawBlockHighlightEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DrawBlockHighlightEvent類屬於net.minecraftforge.client.event包,在下文中一共展示了DrawBlockHighlightEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockHilight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBlockHilight(DrawBlockHighlightEvent event)
{
if (!TombManyGravesConfigs.DISPLAY_GRAVE_NAME)
{
return;
}
RayTraceResult trace = event.getTarget();
if (trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK)
{
World world = mc.theWorld;
IBlockState state = world.getBlockState(trace.getBlockPos());
if (state.getBlock() == ModBlocks.blockDeath)
{
TileEntity tileEntity = world.getTileEntity(trace.getBlockPos());
if (tileEntity != null && tileEntity instanceof TileDeathBlock)
{
String name = ((TileDeathBlock) tileEntity).getPlayerName();
boolean giveGravePriority = ((TileDeathBlock) tileEntity).areGraveItemsForced();
this.renderPlayerName(trace.getBlockPos(), event.getPartialTicks(), name, giveGravePriority);
}
}
}
}
示例2: highlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void highlight( DrawBlockHighlightEvent event )
{
ItemStack held = event.player.getHeldItem();
if ( held == null || held.getItem() != BiomeWandMod.items.wand )
{
return;
}
NBTTagCompound tag = held.getTagCompound();
if ( tag == null ) tag = new NBTTagCompound();
if ( !tag.hasKey( WandItem.SAMPLED_BIOME_TAG ) )
{
return;
}
int size = tag.hasKey( WandItem.ACTION_SIZE_TAG ) ? tag.getInteger( WandItem.ACTION_SIZE_TAG ) : 7;
drawSelectionBox( size, event.context, event.player, event.target, 0, event.partialTicks );
//event.setCanceled( true );
}
示例3: onBlockHighlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBlockHighlight(DrawBlockHighlightEvent e) {
GL11.glPushMatrix();
if (e.player.getCurrentEquippedItem() != null) {
Item i = e.player.getCurrentEquippedItem().getItem();
if (Block.getBlockFromItem(i) instanceof RLMBlockContainer && e.target.getBlockPos() != null) {
if (e.player.worldObj.getBlockState(e.target.getBlockPos()).getBlock() != Blocks.air) {
if (TileEntityRendererDispatcher.instance != null) {
RLMBlockContainer b = (RLMBlockContainer) Block.getBlockFromItem(i);
if (b != null) {
BlockPos p = e.target.getBlockPos();
GL11.glTranslated(p.getX(), p.getY(), p.getZ());
// if
// (b.createNewTileEntity(Minecraft.getMinecraft().theWorld,
// 0) != null);
// TileEntityRendererDispatcher.instance.renderTileEntity(b.createNewTileEntity(Minecraft.getMinecraft().theWorld,
// 0),0.0f,1);
}
}
}
}
}
GL11.glPopMatrix();
}
示例4: handleDrawBlockHighlightEvent
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
/**
* Check for blocks that need a custom block highlight and draw if checked.
* Adapted from the vanilla highlight code.
*/
public static void handleDrawBlockHighlightEvent(DrawBlockHighlightEvent event)
{
BlockPos pos = event.getTarget().getBlockPos();
if(pos != null && event.getPlayer() != null)
{
World world = event.getPlayer().world;
IBlockState bs = world.getBlockState(pos);
if (bs != null && bs.getBlock() instanceof SuperBlock)
{
SuperBlock block = (SuperBlock) bs.getBlock();
ModelState modelState = block.getModelStateAssumeStateIsCurrent(bs, world, pos, true);
drawBlockHighlight(modelState, pos, event.getPlayer(), event.getPartialTicks(), false);
event.setCanceled(true);
}
}
}
示例5: onBlockHighlightEvent
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBlockHighlightEvent(DrawBlockHighlightEvent highlightEvent) {
MovingObjectPosition target = highlightEvent.target;
//We're only interested in blocks...
if (target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
World world = highlightEvent.player.worldObj;
TileEntity tileEntity = world.getTileEntity(target.blockX, target.blockY, target.blockZ);
//...From my mod
if (tileEntity instanceof BaseRobotPlatesTileEntity) {
//TODO: Recalculate the vector used to intersect the block so I can be more accurate with SubBlock detection.
BaseRobotPlatesTileEntity rpTileEntity = (BaseRobotPlatesTileEntity)tileEntity;
Vec3 targetBlockVec = Vec3.createVectorHelper(target.blockX, target.blockY, target.blockZ);
Vec3 vec = targetBlockVec.subtract(target.hitVec);
SubObject subObject = rpTileEntity.getSubObject(vec);
//... and we're hovering over one of my Sub-Objects.
if (subObject != null) {
subObject.RenderBoundingBox(highlightEvent.player, rpTileEntity, highlightEvent.partialTicks);
//Don't draw the block's highlight.
highlightEvent.setCanceled(true);
}
}
}
}
示例6: onDrawBlockhightlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDrawBlockhightlight(DrawBlockHighlightEvent event){
ItemStack is = event.player.getCurrentEquippedItem();
if(is == null || !(is.getItem() instanceof ChiselItem))return;
int x = event.target.blockX, y = event.target.blockY,z = event.target.blockZ;
Block sculpture = event.player.worldObj.getBlock(x,y,z);
int[] pos = Operations.raytrace(x,y,z, event.player);
if(pos[0] == -1)return;
ChiselItem ci = Utils.getItem(is);
int flags = ci.getChiselFlags(event.player);
if(!Operations.validOperation(event.player.worldObj, x,y,z, pos, flags))return;
Operations.setBlockBoundsFromRaytrace(pos, sculpture, flags);
event.context.drawSelectionBox(event.player, event.target, 0, event.partialTicks);
sculpture.setBlockBounds(0, 0, 0, 1, 1, 1);
// event.setCanceled(true);
}
示例7: onBlockHilight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBlockHilight(DrawBlockHighlightEvent event)
{
RayTraceResult trace = event.getTarget();
if (trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK)
{
World world = this.mc.world;
BlockPos pos = trace.getBlockPos();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == EnderUtilitiesBlocks.PORTAL_PANEL || block == EnderUtilitiesBlocks.INSERTER)
{
state = state.getActualState(world, pos);
this.updatePointedBlockHilight(world, trace.getBlockPos(), state, (BlockEnderUtilities) block, event.getPartialTicks());
}
if (block == EnderUtilitiesBlocks.PORTAL_PANEL)
{
this.renderPortalPanelText(this.mc.world, trace.getBlockPos(), (BlockEnderUtilities) block, this.mc.player, event.getPartialTicks());
}
}
}
示例8: onDrawHighlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
@SideOnly(Side.CLIENT)
public void onDrawHighlight(DrawBlockHighlightEvent event) {
try {
if (!(event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ) instanceof BlockMultipart))
return;
QMovingObjectPosition mop = retrace(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ,
RayTracer.instance().getStartVector(event.player), RayTracer.instance().getEndVector(event.player));
if (mop == null)
return;
if (mop.getPart() == null || !(mop.getPart() instanceof IPartSelectableCustom))
return;
if (((IPartSelectableCustom) mop.getPart()).drawHighlight(mop, event.player, event.partialTicks))
event.setCanceled(true);
} catch (Exception ex) {
}
}
示例9: onDrawBlockHighlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onDrawBlockHighlight(DrawBlockHighlightEvent event) {
int x = event.target.blockX;
int y = event.target.blockY;
int z = event.target.blockZ;
World world = event.player.worldObj;
if (world != null) {
Block block = world.getBlock(x, y, z);
if (block == Blocks.jukebox) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof BlockJukebox.TileEntityJukebox) {
//BlockJukebox.TileEntityJukebox jb = (BlockJukebox.TileEntityJukebox) te;
Physis.logger.info("test");
}
}
}
}
示例10: onHighlightDraw
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onHighlightDraw(DrawBlockHighlightEvent evt) {
final RayTraceResult mop = evt.getTarget();
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
final World world = evt.getPlayer().world;
final BlockPos blockPos = mop.getBlockPos();
final Block block = world.getBlockState(blockPos).getBlock();
if (block instanceof ISelectionAware) {
final boolean result = ((ISelectionAware)block).onSelected(world, blockPos, evt);
evt.setCanceled(result);
}
}
}
示例11: BuildersWandRender
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void BuildersWandRender(final DrawBlockHighlightEvent event) {
if (event.currentItem != null && event.currentItem.getItem() instanceof ItemBuildersWand) {
final List<ChunkPos> blocks = ((ItemBuildersWand)event.currentItem.getItem()).getPotentialBlocks(event.player, event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit);
final Block blockId = event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
if (blockId != Blocks.air & blocks.size() > 0) {
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.35f);
GL11.glLineWidth(3.0f);
GL11.glDisable(3553);
GL11.glDisable(2929);
GL11.glDepthMask(false);
final double px = event.player.lastTickPosX + (event.player.posX - event.player.lastTickPosX) * event.partialTicks;
final double py = event.player.lastTickPosY + (event.player.posY - event.player.lastTickPosY) * event.partialTicks;
final double pz = event.player.lastTickPosZ + (event.player.posZ - event.player.lastTickPosZ) * event.partialTicks;
GL11.glTranslated(-px, -py, -pz);
for (final ChunkPos temp : blocks) {
this.drawOutlinedBoundingBox(AxisAlignedBB.getBoundingBox((double)temp.x, (double)temp.y, (double)temp.z, (double)(temp.x + 1), (double)(temp.y + 1), (double)(temp.z + 1)));
}
GL11.glDepthMask(true);
GL11.glEnable(3553);
GL11.glDisable(3042);
GL11.glEnable(2929);
GL11.glTranslated(px, py, pz);
event.setCanceled(true);
}
}
}
示例12: onBlockHighlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SideOnly (Side.CLIENT)
@SubscribeEvent (priority = EventPriority.LOW)
public void onBlockHighlight(DrawBlockHighlightEvent event) {
BlockPos pos = event.getTarget().getBlockPos();
//We have found a CuboidRayTraceResult, Lets render it properly..
RayTraceResult hit = event.getTarget();
if (hit.typeOfHit == Type.BLOCK && hit instanceof CuboidRayTraceResult) {
event.setCanceled(true);
RenderUtils.renderHitBox(event.getPlayer(), ((CuboidRayTraceResult) event.getTarget()).cuboid6.copy().add(pos), event.getPartialTicks());
}
}
示例13: highlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void highlight(DrawBlockHighlightEvent event) {
if (event.getTarget() != null && event.getTarget().typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos hit = event.getTarget().getBlockPos();
IBlockState target = event.getPlayer().getEntityWorld().getBlockState(hit);
if (target.getBlock() instanceof IPrecision) {
highlighting = hit;
} else highlighting = null;
}
}
示例14: onBlockHighlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onBlockHighlight(DrawBlockHighlightEvent event) {
if (event.target.typeOfHit == MovingObjectType.BLOCK) {
Block b = event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
if (b == BlockStation.instance || b == BlockStationHorizontal.instance || b == BlockTube.instance)
RayTracer.retraceBlock(event.player.worldObj, event.player, event.target.blockX, event.target.blockY, event.target.blockZ);
ItemStack stack = event.player.inventory.mainInventory[event.player.inventory.currentItem];
if (stack != null && stack.getItem() == ItemTube.instance)
proxy.lastSideHit = event.target.sideHit;
}
}
示例15: onDrawBlockhightlight
import net.minecraftforge.client.event.DrawBlockHighlightEvent; //導入依賴的package包/類
@SubscribeEvent
public void onDrawBlockhightlight(DrawBlockHighlightEvent event) {
final ItemStack is = event.player.getCurrentEquippedItem();
if (is == null) {
return;
}
final Item item = is.getItem();
if ((item == null) || !(item instanceof ChiselItem)) {
return;
}
final ChiselItem ci = (ChiselItem) item;
final int x = event.target.blockX;
final int y = event.target.blockY;
final int z = event.target.blockZ;
final Block sculpture = event.player.worldObj.getBlock(x, y, z);
final int[] pos = Operations.raytrace(x, y, z, event.player);
if (pos[0] == -1) {
return;
}
int flags = ci.getChiselFlags(event.player);
if (!Operations.validOperation(event.player.worldObj, x, y, z, pos, flags)) {
return;
}
Operations.setBlockBoundsFromRaytrace(pos, sculpture, flags);
event.context.drawSelectionBox(event.player, event.target, 0, event.partialTicks);
sculpture.setBlockBounds(0, 0, 0, 1, 1, 1);
// event.setCanceled(true);
}