public static ForgeDirection[] getValidVanillaBlockRotations(Block block) { return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireHook || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockRailDetector || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.field_150444_as || block == Blocks.field_150472_an || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator || block instanceof BlockTrapDoor || block instanceof BlockHugeMushroom || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; }
@SubscribeEvent public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event){ if (event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockEnderChest){ event.setCanceled(true); event.getEntityPlayer().openGui(AdventureBags.instance, EnumIDs.GUI_ENDER_BACKPACK.ordinal(),event.getWorld(),(int)event.getEntityPlayer().posX,(int)event.getEntityPlayer().posY,(int)event.getEntityPlayer().posZ); } }
public static ForgeDirection[] getValidVanillaBlockRotations(Block block) { return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireHook || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockRailDetector || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.wall_sign || block == Blocks.standing_sign || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator || block instanceof BlockTrapDoor || block instanceof BlockHugeMushroom || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; }
public static void set(IWorldEditor editor, Cardinal dir, Coord pos){ EnumFacing facing = Arrays.asList(Cardinal.directions).contains(dir) ? Cardinal.facing(Cardinal.reverse(dir)) : Cardinal.facing(Cardinal.SOUTH); MetaBlock chest = new MetaBlock(Blocks.ENDER_CHEST); chest.withProperty(BlockEnderChest.FACING, facing); chest.set(editor, pos); }
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 }
@Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) return EnumActionResult.SUCCESS; IBlockState state = worldIn.getBlockState(pos); ItemStack stack = playerIn.getHeldItem(hand); int id = Enderthing.getIdFromItem(stack); Block b = state.getBlock(); TileEntity te = worldIn.getTileEntity(pos); if (b == Blocks.ENDER_CHEST) { worldIn.setBlockState(pos, Enderthing.enderKeyChest.getDefaultState() .withProperty(BlockEnderKeyChest.FACING, state.getValue(BlockEnderChest.FACING)) .withProperty(BlockEnderKeyChest.PRIVATE, (stack.getMetadata() & 1) != 0)); te = worldIn.getTileEntity(pos); if (te instanceof TileEnderKeyChest) { ((TileEnderKeyChest) te).setInventoryId(id); } if (!playerIn.capabilities.isCreativeMode) stack.grow(-1); return EnumActionResult.SUCCESS; } if (b == Enderthing.enderKeyChest) { boolean oldPrivate = state.getValue(BlockEnderKeyChest.PRIVATE); if (te instanceof TileEnderKeyChest) { int oldId = ((TileEnderKeyChest) te).getInventoryId(); ItemStack oldStack = Enderthing.getLock(oldId, oldPrivate); InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), oldStack); } boolean newPrivate = stack.getMetadata() != 0; if (oldPrivate != newPrivate) { worldIn.setBlockState(pos, state.withProperty(BlockEnderKeyChest.PRIVATE, newPrivate)); te = worldIn.getTileEntity(pos); } if (te instanceof TileEnderKeyChest) { ((TileEnderKeyChest) te).setInventoryId(id >> 4); } if (!playerIn.capabilities.isCreativeMode) stack.grow(-1); return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
private static BlockType getBlockType(Block block) { if(block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockCocoa) { return BlockType.BED; } if(block instanceof BlockRail) { return BlockType.RAIL; } if(block instanceof BlockRailPowered || block instanceof BlockRailDetector) { return BlockType.RAIL_POWERED; } if(block instanceof BlockStairs) { return BlockType.STAIR; } if(block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.wall_sign) { return BlockType.CHEST; } if(block == Blocks.standing_sign) { return BlockType.SIGNPOST; } if(block instanceof BlockDoor) { return BlockType.DOOR; } if(block instanceof BlockButton) { return BlockType.BUTTON; } if(block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator) { return BlockType.REDSTONE_REPEATER; } if(block instanceof BlockTrapDoor) { return BlockType.TRAPDOOR; } if(block instanceof BlockHugeMushroom) { return BlockType.MUSHROOM_CAP; } if(block instanceof BlockVine) { return BlockType.VINE; } if(block instanceof BlockSkull) { return BlockType.SKULL; } if(block instanceof BlockAnvil) { return BlockType.ANVIL; } if(block instanceof BlockLog) { return BlockType.LOG; } if(block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockPistonExtension || block instanceof BlockHopper) { return BlockType.DISPENSER; } if(block instanceof BlockTorch) { return BlockType.TORCH; } if(block instanceof BlockLever) { return BlockType.LEVER; } if(block instanceof BlockTripWireHook) { return BlockType.TRIP_WIRE_HOOK; } return null; }
public static ForgeDirection[] getValidVanillaBlockRotations(Block block) { return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireSource || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockDetectorRail || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block.blockID == Block.signWall.blockID || block.blockID == Block.signPost.blockID || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockComparator || block instanceof BlockTrapDoor || block instanceof BlockMushroomCap || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; }
/**public String getTextureFile() { return CommonProxy.ITEMS_PNG; }**/ public ItemStack onItemRightClick(ItemStack myStack, World myWorld, EntityPlayer myPlayer) { if (!myWorld.isRemote) { if(!myPlayer.isSneaking()) { openGui(0, myPlayer, (int)myPlayer.posX, (int)myPlayer.posY, (int)myPlayer.posZ); //myPlayer.openGui(AdvancedBackpackMod.instance, 0, myPlayer.worldObj, (int)myPlayer.posX, (int)myPlayer.posY, (int)myPlayer.posZ); } else { //System.out.println("player is sneaking, use shared inventory mode for backpackbase"); MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(myWorld, myPlayer, true); if (movingobjectposition != null) { if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (myWorld.getBlockTileEntity(i, j, k) != null) { if (BlockContainer.class.isAssignableFrom(((Object)myWorld.getBlockTileEntity(i, j, k).getBlockType()).getClass())) { //System.out.println("this is a subclass of BlockContainer"); try { IInventory testInv = (IInventory) myWorld.getBlockTileEntity(i, j, k); //System.out.println(Block.blocksList[myWorld.getBlockId(i, j, k)].getUnlocalizedName()); //System.out.println(Block.blocksList[myWorld.getBlockId(i, j, k)].getLocalizedName()); //System.out.println("inventory size = " + testInv.getSizeInventory()); if (checkContainer(Block.blocksList[myWorld.getBlockId(i, j, k)].getUnlocalizedName())) { openGui(1, myPlayer, i, j, k); } } catch(ClassCastException e) { //System.out.println("has no IInventory"); //System.out.println(myWorld.getBlockTileEntity(i, j, k)); //System.out.println(myWorld.getBlockTileEntity(i, j, k).getBlockType()); //System.out.println(myWorld.getBlockTileEntity(i, j, k).getBlockType().getClass()); } if (BlockEnderChest.class.isAssignableFrom(((Object)myWorld.getBlockTileEntity(i, j, k).getBlockType()).getClass())) { //System.out.println("this is a vanilla enderchest"); openGui(2, myPlayer, i, j, k); } } } else { //System.out.println("has no tileentity"); } } } } } return myStack; }