Advertisement
Guest User

Untitled

a guest
Dec 11th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.16 KB | None | 0 0
  1. package com.LyesDoesMods.items;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.client.Minecraft;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.init.Blocks;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.ChatComponentText;
  10. import net.minecraft.world.World;
  11.  
  12. public class FlintAndRoseQuartzCrystal extends Item {
  13.  
  14.     boolean firstTimeRightClicking = true;
  15.    
  16.     public FlintAndRoseQuartzCrystal() {
  17.         this.bFull3D = true;
  18.         this.setMaxStackSize(1);
  19.         this.setMaxDamage(32);
  20.     }
  21.  
  22.     @Override
  23.     public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x,
  24.             int y, int z, int blockSide, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
  25.        
  26.         int newX = x, newY = y, newZ = z;
  27.        
  28.         switch(blockSide)
  29.         {
  30.             case 0:
  31.                 //Bottom Face
  32.                 newY--;
  33.                 break;
  34.             case 1:
  35.                 //Top Face
  36.                 newY++;
  37.                 break;
  38.             case 2:
  39.                 //North Face
  40.                 newZ--;
  41.                 break;
  42.             case 3:
  43.                 //South Face
  44.                 newZ++;
  45.                 break;
  46.             case 4:
  47.                 //West Face
  48.                 newX--;
  49.                 break;
  50.             case 5:
  51.                 //East Face
  52.                 newX++;
  53.                 break;
  54.             default:
  55.                 break;
  56.         }
  57.        
  58.         if(world.isAirBlock(newX, newY, newZ))
  59.         {
  60.             if(world.getBlock(x, y, z) != Blocks.obsidian)
  61.             {
  62.                 world.setBlock(newX, newY, newZ, Blocks.fire);
  63.                 world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  64.                 player.swingItem();
  65.             }
  66.             else
  67.             {
  68.                 if(world.isAirBlock(newX + 1, newY, newZ) && world.getBlock(newX + 2, newY, newZ) == Blocks.obsidian ||
  69.                         world.isAirBlock(newX - 1, newY, newZ) && world.getBlock(newX - 2, newY, newZ) == Blocks.obsidian)
  70.                 {
  71.                     startPortalCheckX(newX, newY, newZ, world, player);
  72.                 }
  73.                 if(world.isAirBlock(newX, newY, newZ - 1) && world.getBlock(newX, newY, newZ - 2) == Blocks.obsidian ||
  74.                         world.isAirBlock(newX, newY, newZ + 1) && world.getBlock(newX, newY, newZ + 2) == Blocks.obsidian)
  75.                 {
  76.                     startPortalCheckZ(newX, newY, newZ, world, player);
  77.                 }
  78.             }
  79.         }
  80.         itemStack.damageItem(1, player);
  81.        
  82.         return super.onItemUse(itemStack, player, world, x, y, z, blockSide, p_77648_8_,
  83.                 p_77648_9_, p_77648_10_);
  84.     }
  85.    
  86.     public void startPortalCheckX(int newX, int newY, int newZ, World world, EntityPlayer player)
  87.     {
  88.         if(world.isAirBlock(newX + 1, newY, newZ) &&
  89.                 world.isAirBlock(newX, newY + 1, newZ) &&
  90.                 world.isAirBlock(newX + 1, newY + 1, newZ) &&
  91.                 world.isAirBlock(newX, newY + 2, newZ) &&
  92.                 world.isAirBlock(newX + 1, newY + 2, newZ)) {
  93.                
  94.                 if(!checkPortalFrame(1, 'x', newX, newY, newZ, world, player))
  95.                 {
  96.                     world.setBlock(newX, newY, newZ, Blocks.fire);
  97.                     world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  98.                     player.swingItem();
  99.                 }
  100.             }
  101.             else if(world.isAirBlock(newX - 1, newY, newZ) &&
  102.                     world.isAirBlock(newX, newY + 1, newZ) &&
  103.                     world.isAirBlock(newX - 1, newY + 1, newZ) &&
  104.                     world.isAirBlock(newX, newY + 2, newZ) &&
  105.                     world.isAirBlock(newX - 1, newY + 2, newZ)) {
  106.                
  107.                     if(!checkPortalFrame(2, 'x', newX, newY, newZ, world, player))
  108.                     {
  109.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  110.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  111.                         player.swingItem();
  112.                     }
  113.                 }
  114.             else if(world.isAirBlock(newX + 1, newY, newZ) &&
  115.                     world.isAirBlock(newX, newY + 1, newZ) &&
  116.                     world.isAirBlock(newX + 1, newY + 1, newZ) &&
  117.                     world.isAirBlock(newX, newY - 1, newZ) &&
  118.                     world.isAirBlock(newX + 1, newY - 1, newZ)) {
  119.                
  120.                     if(!checkPortalFrame(3, 'x', newX, newY, newZ, world, player))
  121.                     {
  122.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  123.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  124.                         player.swingItem();
  125.                     }
  126.                 }
  127.             else if(world.isAirBlock(newX - 1, newY, newZ) &&
  128.                     world.isAirBlock(newX, newY + 1, newZ) &&
  129.                     world.isAirBlock(newX - 1, newY + 1, newZ) &&
  130.                     world.isAirBlock(newX, newY - 1, newZ) &&
  131.                     world.isAirBlock(newX - 1, newY - 1, newZ)) {
  132.                
  133.                     if(!checkPortalFrame(4, 'x', newX, newY, newZ, world, player))
  134.                     {
  135.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  136.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  137.                         player.swingItem();
  138.                     }
  139.                 }
  140.             else if(world.isAirBlock(newX + 1, newY, newZ) &&
  141.                     world.isAirBlock(newX, newY - 1, newZ) &&
  142.                     world.isAirBlock(newX + 1, newY - 1, newZ) &&
  143.                     world.isAirBlock(newX, newY - 2, newZ) &&
  144.                     world.isAirBlock(newX + 1, newY - 2, newZ)) {
  145.                
  146.                     if(!checkPortalFrame(5, 'x', newX, newY, newZ, world, player))
  147.                     {
  148.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  149.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  150.                         player.swingItem();
  151.                     }
  152.                 }
  153.             else if(world.isAirBlock(newX - 1, newY, newZ) &&
  154.                     world.isAirBlock(newX, newY - 1, newZ) &&
  155.                     world.isAirBlock(newX - 1, newY - 1, newZ) &&
  156.                     world.isAirBlock(newX, newY - 2, newZ) &&
  157.                     world.isAirBlock(newX - 1, newY - 2, newZ)) {
  158.                
  159.                     if(!checkPortalFrame(6, 'x', newX, newY, newZ, world, player))
  160.                     {
  161.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  162.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  163.                         player.swingItem();
  164.                     }
  165.                 }
  166.     }
  167.    
  168.     public void startPortalCheckZ(int newX, int newY, int newZ, World world, EntityPlayer player)
  169.     {
  170.         if(world.isAirBlock(newX, newY, newZ - 1) &&
  171.                 world.isAirBlock(newX, newY + 1, newZ) &&
  172.                 world.isAirBlock(newX, newY + 1, newZ - 1) &&
  173.                 world.isAirBlock(newX, newY + 2, newZ) &&
  174.                 world.isAirBlock(newX, newY + 2, newZ - 1)) {
  175.                
  176.            
  177.             System.out.println(String.valueOf(newX) + " " + String.valueOf(newY) + " " + String.valueOf(newZ));
  178.                 if(!checkPortalFrame(1, 'z', newX, newY, newZ, world, player))
  179.                 {
  180.                     world.setBlock(newX, newY, newZ, Blocks.fire);
  181.                     world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  182.                     player.swingItem();
  183.                 }
  184.             }
  185.             else if(world.isAirBlock(newX, newY, newZ + 1) &&
  186.                     world.isAirBlock(newX, newY + 1, newZ) &&
  187.                     world.isAirBlock(newX, newY + 1, newZ + 1) &&
  188.                     world.isAirBlock(newX, newY + 2, newZ) &&
  189.                     world.isAirBlock(newX, newY + 2, newZ + 1)) {
  190.                
  191.                     if(!checkPortalFrame(2, 'z', newX, newY, newZ, world, player))
  192.                     {
  193.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  194.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  195.                         player.swingItem();
  196.                     }
  197.                 }
  198.             else if(world.isAirBlock(newX, newY, newZ - 1) &&
  199.                     world.isAirBlock(newX, newY + 1, newZ) &&
  200.                     world.isAirBlock(newX, newY + 1, newZ - 1) &&
  201.                     world.isAirBlock(newX, newY - 1, newZ) &&
  202.                     world.isAirBlock(newX, newY - 1, newZ - 1)) {
  203.                
  204.                     if(!checkPortalFrame(3, 'z', newX, newY, newZ, world, player))
  205.                     {
  206.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  207.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  208.                         player.swingItem();
  209.                     }
  210.                 }
  211.             else if(world.isAirBlock(newX, newY, newZ + 1) &&
  212.                     world.isAirBlock(newX, newY + 1, newZ) &&
  213.                     world.isAirBlock(newX, newY + 1, newZ + 1) &&
  214.                     world.isAirBlock(newX, newY - 1, newZ) &&
  215.                     world.isAirBlock(newX, newY - 1, newZ + 1)) {
  216.                
  217.                     if(!checkPortalFrame(4, 'z', newX, newY, newZ, world, player))
  218.                     {
  219.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  220.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  221.                         player.swingItem();
  222.                     }
  223.                 }
  224.             else if(world.isAirBlock(newX, newY, newZ - 1) &&
  225.                     world.isAirBlock(newX, newY - 1, newZ) &&
  226.                     world.isAirBlock(newX, newY - 1, newZ - 1) &&
  227.                     world.isAirBlock(newX, newY - 2, newZ) &&
  228.                     world.isAirBlock(newX, newY - 2, newZ - 1)) {
  229.                
  230.                     if(!checkPortalFrame(5, 'z', newX, newY, newZ, world, player))
  231.                     {
  232.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  233.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  234.                         player.swingItem();
  235.                     }
  236.                 }
  237.             else if(world.isAirBlock(newX, newY, newZ + 1) &&
  238.                     world.isAirBlock(newX, newY - 1, newZ) &&
  239.                     world.isAirBlock(newX, newY - 1, newZ + 1) &&
  240.                     world.isAirBlock(newX, newY - 2, newZ) &&
  241.                     world.isAirBlock(newX, newY - 2, newZ + 1)) {
  242.                
  243.                     if(!checkPortalFrame(6, 'z', newX, newY, newZ, world, player))
  244.                     {
  245.                         world.setBlock(newX, newY, newZ, Blocks.fire);
  246.                         world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  247.                         player.swingItem();
  248.                     }
  249.                 }
  250.     }
  251.    
  252.     public static boolean checkPortalFrame(int portalAirBlockID, char rotation, int airX, int airY, int airZ, World world, EntityPlayer player)
  253.     {
  254.         Block portalBorder = Blocks.obsidian;
  255.         Block portalBlock = Blocks.portal;
  256.         boolean checkedSuccessfully = false;
  257.         switch(portalAirBlockID)
  258.         {
  259.             case 1:
  260.                 break;
  261.             case 2:
  262.                 if(rotation == 'x')
  263.                 {
  264.                     airX -= 1;
  265.                 }
  266.                 else
  267.                 {
  268.                     airZ += 1;
  269.                 }
  270.                 break;
  271.                
  272.             case 3:
  273.                 airY -= 1;
  274.                 break;
  275.                
  276.             case 4:
  277.                 airY -= 1;
  278.                 if(rotation == 'x')
  279.                 {
  280.                     airX -= 1;
  281.                 }
  282.                 else
  283.                 {
  284.                     airZ += 1;
  285.                 }
  286.                 break;
  287.                
  288.             case 5:
  289.                 airY -= 2;
  290.                 break;
  291.                
  292.             case 6:
  293.                 airY -= 2;
  294.                 if(rotation == 'x')
  295.                 {
  296.                     airX -= 1;
  297.                 }
  298.                 else
  299.                 {
  300.                     airZ += 1;
  301.                 }
  302.                 break;
  303.         }
  304.  
  305.         if(rotation == 'x')
  306.         {
  307.             if(world.getBlock(airX - 1, airY, airZ) == portalBorder &&
  308.                     world.getBlock(airX - 1, airY + 1, airZ) == portalBorder &&
  309.                     world.getBlock(airX - 1, airY + 2, airZ) == portalBorder &&
  310.                     world.getBlock(airX, airY + 3, airZ) == portalBorder &&
  311.                     world.getBlock(airX + 1, airY + 3, airZ) == portalBorder &&
  312.                     world.getBlock(airX + 2, airY + 2, airZ) == portalBorder &&
  313.                     world.getBlock(airX + 2, airY + 1, airZ) == portalBorder &&
  314.                     world.getBlock(airX + 2, airY, airZ) == portalBorder &&
  315.                     world.getBlock(airX + 1, airY - 1, airZ) == portalBorder &&
  316.                     world.getBlock(airX, airY - 1, airZ) == portalBorder)
  317.             {
  318.                 world.setBlock(airX, airY, airZ, portalBlock);
  319.                 world.setBlock(airX + 1, airY, airZ, portalBlock);
  320.                 world.setBlock(airX, airY + 1, airZ, portalBlock);
  321.                 world.setBlock(airX + 1, airY + 1, airZ, portalBlock);
  322.                 world.setBlock(airX, airY + 2, airZ, portalBlock);
  323.                 world.setBlock(airX + 1, airY + 2, airZ, portalBlock);
  324.                 checkedSuccessfully = true;
  325.                 world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  326.                 player.swingItem();
  327.             }
  328.             else
  329.             {
  330.                 checkedSuccessfully = false;
  331.             }
  332.         }
  333.         else if(rotation == 'z')
  334.         {
  335.             if(world.getBlock(airX, airY, airZ + 1) == portalBorder &&
  336.                     world.getBlock(airX, airY + 1, airZ + 1) == portalBorder &&
  337.                     world.getBlock(airX, airY + 2, airZ + 1) == portalBorder &&
  338.                     world.getBlock(airX, airY + 3, airZ) == portalBorder &&
  339.                     world.getBlock(airX, airY + 3, airZ - 1) == portalBorder &&
  340.                     world.getBlock(airX, airY + 2, airZ - 2) == portalBorder &&
  341.                     world.getBlock(airX, airY + 1, airZ - 2) == portalBorder &&
  342.                     world.getBlock(airX, airY, airZ - 2) == portalBorder &&
  343.                     world.getBlock(airX, airY - 1, airZ - 1) == portalBorder &&
  344.                     world.getBlock(airX, airY - 1, airZ) == portalBorder)
  345.             {
  346.                 world.setBlock(airX, airY, airZ, portalBlock);
  347.                 world.setBlock(airX, airY, airZ - 1, portalBlock);
  348.                 world.setBlock(airX, airY + 1, airZ, portalBlock);
  349.                 world.setBlock(airX, airY + 1, airZ - 1, portalBlock);
  350.                 world.setBlock(airX, airY + 2, airZ, portalBlock);
  351.                 world.setBlock(airX, airY + 2, airZ - 1, portalBlock);
  352.                 checkedSuccessfully = true;
  353.                 world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
  354.                 player.swingItem();
  355.             }
  356.             else
  357.             {
  358.                 checkedSuccessfully = false;
  359.             }
  360.         }
  361.        
  362.         return checkedSuccessfully;
  363.     }
  364.    
  365.    
  366.    
  367. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement