int cleanPosters() { int ret = 0; for (EntityPoster poster : getPosters()) { if (!poster.isLocked()) continue; if (!ItemUtil.is(poster.getItem(), Core.registry.brokenTool)) continue; poster.setItem(null); poster.setLocked(false); poster.syncData(); ret++; ICoordFunction clearSign = new ICoordFunction() { @Override public void handle(Coord here) { if (!(here.getBlock() instanceof BlockSign)) return; TileEntitySign sign = here.getTE(TileEntitySign.class); if (sign == null) return; for (int i = 0; i < sign.signText.length; i++) { sign.signText[i] = new ChatComponentText(""); } here.markBlockForUpdate(); } }; iterateSign(poster, clearSign); } return ret; }
public static void checkBlockInteraction(Resident res, BlockPos bp, PlayerInteractEvent.Action action, Event ev) { if(!ev.isCancelable()) { return; } World world = MinecraftServer.getServer().worldServerForDimension(bp.getDim()); Block block = world.getBlock(bp.getX(), bp.getY(), bp.getZ()); // Bypass for SellSign if (block instanceof BlockSign) { TileEntity te = world.getTileEntity(bp.getX(), bp.getY(), bp.getZ()); if(te instanceof TileEntitySign && SellSign.SellSignType.instance.isTileValid((TileEntitySign) te)) { return; } } for(SegmentBlock segment : segmentsBlock.get(block.getClass())) { if(!segment.shouldInteract(res, bp, action)) { ev.setCanceled(true); } } }
public static @Nullable TileEntitySign getTileSignLooking() { if (MovePos.getBlock() instanceof BlockSign) { final TileEntity tile = MovePos.getTile(); if (tile instanceof TileEntitySign) return (TileEntitySign) tile; } return null; }
public static void addBush() { ShiftedSnowApi.addSimpleClassMapping(BlockBush.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockSign.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockAnvil.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockBush.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockPressurePlate.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockLever.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockRailBase.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockTripWire.class, EnumSnowType.MINUS_FULL); ShiftedSnowApi.addSimpleClassMapping(BlockTripWireHook.class, EnumSnowType.MINUS_FULL); }
/** * Returns true if the whip can grapple the block at the position */ protected boolean canGrabBlock(Block block, BlockPos pos, EnumFacing face) { if (block instanceof IWhipBlock) { return ((IWhipBlock) block).canGrabBlock(getType(), getThrower(), worldObj, pos, face); } switch (getType()) { case WHIP_MAGIC: // this excludes things like dirt, most plants, etc. if (block instanceof BlockSandStone || block instanceof BlockHugeMushroom || (block.getMaterial().blocksMovement() && block.getBlockHardness(worldObj, pos) > 1.0F)) { return true; } // otherwise, fall through to standard case: case WHIP_SHORT: case WHIP_LONG: int clear = 0; if (isSideClear(pos.east()) && isSideClear(pos.west())) { ++clear; } if (isSideClear(pos.up()) && isSideClear(pos.down())) { ++clear; } if (isSideClear(pos.south()) && isSideClear(pos.north())) { ++clear; } return (clear > 1 && (block instanceof BlockFence || block instanceof BlockLog || block instanceof BlockLever || block instanceof BlockSign || block instanceof BlockLadder)); } return false; }
public void drawBlockDamageTexture(Tessellator tessellatorIn, WorldRenderer worldRendererIn, Entity entityIn, float partialTicks) { double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; if (!this.damagedBlocks.isEmpty()) { this.renderEngine.bindTexture(TextureMap.locationBlocksTexture); this.preRenderDamagedBlocks(); worldRendererIn.begin(7, DefaultVertexFormats.BLOCK); worldRendererIn.setTranslation(-d0, -d1, -d2); worldRendererIn.markDirty(); Iterator<DestroyBlockProgress> iterator = this.damagedBlocks.values().iterator(); while (iterator.hasNext()) { DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next(); BlockPos blockpos = destroyblockprogress.getPosition(); double d3 = (double)blockpos.getX() - d0; double d4 = (double)blockpos.getY() - d1; double d5 = (double)blockpos.getZ() - d2; Block block = this.theWorld.getBlockState(blockpos).getBlock(); if (!(block instanceof BlockChest) && !(block instanceof BlockEnderChest) && !(block instanceof BlockSign) && !(block instanceof BlockSkull)) { if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) { iterator.remove(); } else { IBlockState iblockstate = this.theWorld.getBlockState(blockpos); if (iblockstate.getBlock().getMaterial() != Material.air) { int i = destroyblockprogress.getPartialBlockDamage(); TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i]; BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher(); blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.theWorld); } } } } tessellatorIn.draw(); worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D); this.postRenderDamagedBlocks(); } }
public void drawBlockDamageTexture(Tessellator tessellatorIn, WorldRenderer worldRendererIn, Entity entityIn, float partialTicks) { double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; if (!this.damagedBlocks.isEmpty()) { this.renderEngine.bindTexture(TextureMap.locationBlocksTexture); this.preRenderDamagedBlocks(); worldRendererIn.begin(7, DefaultVertexFormats.BLOCK); worldRendererIn.setTranslation(-d0, -d1, -d2); worldRendererIn.markDirty(); Iterator iterator = this.damagedBlocks.values().iterator(); while (iterator.hasNext()) { DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next(); BlockPos blockpos = destroyblockprogress.getPosition(); double d3 = (double)blockpos.getX() - d0; double d4 = (double)blockpos.getY() - d1; double d5 = (double)blockpos.getZ() - d2; Block block = this.theWorld.getBlockState(blockpos).getBlock(); boolean flag; if (Reflector.ForgeTileEntity_canRenderBreaking.exists()) { boolean flag1 = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull; if (!flag1) { TileEntity tileentity = this.theWorld.getTileEntity(blockpos); if (tileentity != null) { flag1 = Reflector.callBoolean(tileentity, Reflector.ForgeTileEntity_canRenderBreaking, new Object[0]); } } flag = !flag1; } else { flag = !(block instanceof BlockChest) && !(block instanceof BlockEnderChest) && !(block instanceof BlockSign) && !(block instanceof BlockSkull); } if (flag) { if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) { iterator.remove(); } else { IBlockState iblockstate = this.theWorld.getBlockState(blockpos); if (iblockstate.getBlock().getMaterial() != Material.air) { int i = destroyblockprogress.getPartialBlockDamage(); TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i]; BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher(); blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.theWorld); } } } } tessellatorIn.draw(); worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D); this.postRenderDamagedBlocks(); } }
public void drawBlockDamageTexture(Tessellator tessellatorIn, VertexBuffer worldRendererIn, Entity entityIn, float partialTicks) { double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; if (!this.damagedBlocks.isEmpty()) { this.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); this.preRenderDamagedBlocks(); worldRendererIn.begin(7, DefaultVertexFormats.BLOCK); worldRendererIn.setTranslation(-d0, -d1, -d2); worldRendererIn.noColor(); Iterator<DestroyBlockProgress> iterator = this.damagedBlocks.values().iterator(); while (iterator.hasNext()) { DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next(); BlockPos blockpos = destroyblockprogress.getPosition(); double d3 = (double)blockpos.getX() - d0; double d4 = (double)blockpos.getY() - d1; double d5 = (double)blockpos.getZ() - d2; Block block = this.theWorld.getBlockState(blockpos).getBlock(); boolean flag; if (Reflector.ForgeTileEntity_canRenderBreaking.exists()) { boolean flag1 = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull; if (!flag1) { TileEntity tileentity = this.theWorld.getTileEntity(blockpos); if (tileentity != null) { flag1 = Reflector.callBoolean(tileentity, Reflector.ForgeTileEntity_canRenderBreaking, new Object[0]); } } flag = !flag1; } else { flag = !(block instanceof BlockChest) && !(block instanceof BlockEnderChest) && !(block instanceof BlockSign) && !(block instanceof BlockSkull); } if (flag) { if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) { iterator.remove(); } else { IBlockState iblockstate = this.theWorld.getBlockState(blockpos); if (iblockstate.getMaterial() != Material.AIR) { int i = destroyblockprogress.getPartialBlockDamage(); TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i]; BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher(); blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.theWorld); } } } } tessellatorIn.draw(); worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D); this.postRenderDamagedBlocks(); } }
public void drawBlockDamageTexture(Tessellator tessellatorIn, VertexBuffer worldRendererIn, Entity entityIn, float partialTicks) { double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; if (!this.damagedBlocks.isEmpty()) { this.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); this.preRenderDamagedBlocks(); worldRendererIn.begin(7, DefaultVertexFormats.BLOCK); worldRendererIn.setTranslation(-d0, -d1, -d2); worldRendererIn.noColor(); Iterator<DestroyBlockProgress> iterator = this.damagedBlocks.values().iterator(); while (iterator.hasNext()) { DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next(); BlockPos blockpos = destroyblockprogress.getPosition(); double d3 = (double)blockpos.getX() - d0; double d4 = (double)blockpos.getY() - d1; double d5 = (double)blockpos.getZ() - d2; Block block = this.theWorld.getBlockState(blockpos).getBlock(); TileEntity te = this.theWorld.getTileEntity(blockpos); boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull; if (!hasBreak) hasBreak = te != null && te.canRenderBreaking(); if (!hasBreak) { if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) { iterator.remove(); } else { IBlockState iblockstate = this.theWorld.getBlockState(blockpos); if (iblockstate.getMaterial() != Material.AIR) { int i = destroyblockprogress.getPartialBlockDamage(); TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i]; BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher(); blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.theWorld); } } } } tessellatorIn.draw(); worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D); this.postRenderDamagedBlocks(); } }
@SuppressWarnings("deprecation") public void drawBlockDamageTexture(Tessellator tessellatorIn, VertexBuffer vertexBuffer, Entity entityIn, float partialTicks, World world, List<BlockPos> blocks) { double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * partialTicks; double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * partialTicks; double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * partialTicks; TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; float curBlockDamageMP = ObfuscationReflectionHelper.getPrivateValue(PlayerControllerMP.class, Minecraft.getMinecraft().playerController, 4); int progress = (int) (curBlockDamageMP * 10f) - 1; // 0-10 if(progress < 0) { return; } renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); //preRenderDamagedBlocks BEGIN GlStateManager.tryBlendFuncSeparate(774, 768, 1, 0); GlStateManager.enableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F); GlStateManager.doPolygonOffset(-3.0F, -3.0F); GlStateManager.enablePolygonOffset(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableAlpha(); GlStateManager.pushMatrix(); //preRenderDamagedBlocks END vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); vertexBuffer.setTranslation(-d0, -d1, -d2); vertexBuffer.noColor(); for(BlockPos blockpos : blocks) { blockpos.getX(); blockpos.getY(); blockpos.getZ(); Block block = world.getBlockState(blockpos).getBlock(); TileEntity te = world.getTileEntity(blockpos); boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull; if(!hasBreak) { hasBreak = te != null && te.canRenderBreaking(); } if(!hasBreak) { IBlockState iblockstate = world.getBlockState(blockpos); if(iblockstate.getBlock().getMaterial(iblockstate) != Material.AIR) { TextureAtlasSprite textureatlassprite = RenderUtil.getSprite("minecraft:blocks/destroy_stage_"+progress)/*ClientProxy.destroyBlockIcons[progress]*/; BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, world); } } } tessellatorIn.draw(); vertexBuffer.setTranslation(0.0D, 0.0D, 0.0D); // postRenderDamagedBlocks BEGIN GlStateManager.disableAlpha(); GlStateManager.doPolygonOffset(0.0F, 0.0F); GlStateManager.disablePolygonOffset(); GlStateManager.enableAlpha(); GlStateManager.depthMask(true); GlStateManager.popMatrix(); // postRenderDamagedBlocks END }