Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.LyesDoesMods.items;
- import net.minecraft.block.Block;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.world.World;
- public class FlintAndRoseQuartzCrystal extends Item {
- boolean firstTimeRightClicking = true;
- public FlintAndRoseQuartzCrystal() {
- this.bFull3D = true;
- this.setMaxStackSize(1);
- this.setMaxDamage(32);
- }
- @Override
- public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x,
- int y, int z, int blockSide, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
- int newX = x, newY = y, newZ = z;
- switch(blockSide)
- {
- case 0:
- //Bottom Face
- newY--;
- break;
- case 1:
- //Top Face
- newY++;
- break;
- case 2:
- //North Face
- newZ--;
- break;
- case 3:
- //South Face
- newZ++;
- break;
- case 4:
- //West Face
- newX--;
- break;
- case 5:
- //East Face
- newX++;
- break;
- default:
- break;
- }
- if(world.isAirBlock(newX, newY, newZ))
- {
- if(world.getBlock(x, y, z) != Blocks.obsidian)
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- else
- {
- if(world.isAirBlock(newX + 1, newY, newZ) && world.getBlock(newX + 2, newY, newZ) == Blocks.obsidian ||
- world.isAirBlock(newX - 1, newY, newZ) && world.getBlock(newX - 2, newY, newZ) == Blocks.obsidian)
- {
- startPortalCheckX(newX, newY, newZ, world, player);
- }
- if(world.isAirBlock(newX, newY, newZ - 1) && world.getBlock(newX, newY, newZ - 2) == Blocks.obsidian ||
- world.isAirBlock(newX, newY, newZ + 1) && world.getBlock(newX, newY, newZ + 2) == Blocks.obsidian)
- {
- startPortalCheckZ(newX, newY, newZ, world, player);
- }
- }
- }
- itemStack.damageItem(1, player);
- return super.onItemUse(itemStack, player, world, x, y, z, blockSide, p_77648_8_,
- p_77648_9_, p_77648_10_);
- }
- public void startPortalCheckX(int newX, int newY, int newZ, World world, EntityPlayer player)
- {
- if(world.isAirBlock(newX + 1, newY, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX + 1, newY + 1, newZ) &&
- world.isAirBlock(newX, newY + 2, newZ) &&
- world.isAirBlock(newX + 1, newY + 2, newZ)) {
- if(!checkPortalFrame(1, 'x', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX - 1, newY, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX - 1, newY + 1, newZ) &&
- world.isAirBlock(newX, newY + 2, newZ) &&
- world.isAirBlock(newX - 1, newY + 2, newZ)) {
- if(!checkPortalFrame(2, 'x', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX + 1, newY, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX + 1, newY + 1, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX + 1, newY - 1, newZ)) {
- if(!checkPortalFrame(3, 'x', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX - 1, newY, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX - 1, newY + 1, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX - 1, newY - 1, newZ)) {
- if(!checkPortalFrame(4, 'x', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX + 1, newY, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX + 1, newY - 1, newZ) &&
- world.isAirBlock(newX, newY - 2, newZ) &&
- world.isAirBlock(newX + 1, newY - 2, newZ)) {
- if(!checkPortalFrame(5, 'x', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX - 1, newY, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX - 1, newY - 1, newZ) &&
- world.isAirBlock(newX, newY - 2, newZ) &&
- world.isAirBlock(newX - 1, newY - 2, newZ)) {
- if(!checkPortalFrame(6, 'x', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- }
- public void startPortalCheckZ(int newX, int newY, int newZ, World world, EntityPlayer player)
- {
- if(world.isAirBlock(newX, newY, newZ - 1) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ - 1) &&
- world.isAirBlock(newX, newY + 2, newZ) &&
- world.isAirBlock(newX, newY + 2, newZ - 1)) {
- System.out.println(String.valueOf(newX) + " " + String.valueOf(newY) + " " + String.valueOf(newZ));
- if(!checkPortalFrame(1, 'z', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX, newY, newZ + 1) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ + 1) &&
- world.isAirBlock(newX, newY + 2, newZ) &&
- world.isAirBlock(newX, newY + 2, newZ + 1)) {
- if(!checkPortalFrame(2, 'z', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX, newY, newZ - 1) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ - 1) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ - 1)) {
- if(!checkPortalFrame(3, 'z', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX, newY, newZ + 1) &&
- world.isAirBlock(newX, newY + 1, newZ) &&
- world.isAirBlock(newX, newY + 1, newZ + 1) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ + 1)) {
- if(!checkPortalFrame(4, 'z', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX, newY, newZ - 1) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ - 1) &&
- world.isAirBlock(newX, newY - 2, newZ) &&
- world.isAirBlock(newX, newY - 2, newZ - 1)) {
- if(!checkPortalFrame(5, 'z', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- else if(world.isAirBlock(newX, newY, newZ + 1) &&
- world.isAirBlock(newX, newY - 1, newZ) &&
- world.isAirBlock(newX, newY - 1, newZ + 1) &&
- world.isAirBlock(newX, newY - 2, newZ) &&
- world.isAirBlock(newX, newY - 2, newZ + 1)) {
- if(!checkPortalFrame(6, 'z', newX, newY, newZ, world, player))
- {
- world.setBlock(newX, newY, newZ, Blocks.fire);
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- }
- }
- public static boolean checkPortalFrame(int portalAirBlockID, char rotation, int airX, int airY, int airZ, World world, EntityPlayer player)
- {
- Block portalBorder = Blocks.obsidian;
- Block portalBlock = Blocks.portal;
- boolean checkedSuccessfully = false;
- switch(portalAirBlockID)
- {
- case 1:
- break;
- case 2:
- if(rotation == 'x')
- {
- airX -= 1;
- }
- else
- {
- airZ += 1;
- }
- break;
- case 3:
- airY -= 1;
- break;
- case 4:
- airY -= 1;
- if(rotation == 'x')
- {
- airX -= 1;
- }
- else
- {
- airZ += 1;
- }
- break;
- case 5:
- airY -= 2;
- break;
- case 6:
- airY -= 2;
- if(rotation == 'x')
- {
- airX -= 1;
- }
- else
- {
- airZ += 1;
- }
- break;
- }
- if(rotation == 'x')
- {
- if(world.getBlock(airX - 1, airY, airZ) == portalBorder &&
- world.getBlock(airX - 1, airY + 1, airZ) == portalBorder &&
- world.getBlock(airX - 1, airY + 2, airZ) == portalBorder &&
- world.getBlock(airX, airY + 3, airZ) == portalBorder &&
- world.getBlock(airX + 1, airY + 3, airZ) == portalBorder &&
- world.getBlock(airX + 2, airY + 2, airZ) == portalBorder &&
- world.getBlock(airX + 2, airY + 1, airZ) == portalBorder &&
- world.getBlock(airX + 2, airY, airZ) == portalBorder &&
- world.getBlock(airX + 1, airY - 1, airZ) == portalBorder &&
- world.getBlock(airX, airY - 1, airZ) == portalBorder)
- {
- world.setBlock(airX, airY, airZ, portalBlock);
- world.setBlock(airX + 1, airY, airZ, portalBlock);
- world.setBlock(airX, airY + 1, airZ, portalBlock);
- world.setBlock(airX + 1, airY + 1, airZ, portalBlock);
- world.setBlock(airX, airY + 2, airZ, portalBlock);
- world.setBlock(airX + 1, airY + 2, airZ, portalBlock);
- checkedSuccessfully = true;
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- else
- {
- checkedSuccessfully = false;
- }
- }
- else if(rotation == 'z')
- {
- if(world.getBlock(airX, airY, airZ + 1) == portalBorder &&
- world.getBlock(airX, airY + 1, airZ + 1) == portalBorder &&
- world.getBlock(airX, airY + 2, airZ + 1) == portalBorder &&
- world.getBlock(airX, airY + 3, airZ) == portalBorder &&
- world.getBlock(airX, airY + 3, airZ - 1) == portalBorder &&
- world.getBlock(airX, airY + 2, airZ - 2) == portalBorder &&
- world.getBlock(airX, airY + 1, airZ - 2) == portalBorder &&
- world.getBlock(airX, airY, airZ - 2) == portalBorder &&
- world.getBlock(airX, airY - 1, airZ - 1) == portalBorder &&
- world.getBlock(airX, airY - 1, airZ) == portalBorder)
- {
- world.setBlock(airX, airY, airZ, portalBlock);
- world.setBlock(airX, airY, airZ - 1, portalBlock);
- world.setBlock(airX, airY + 1, airZ, portalBlock);
- world.setBlock(airX, airY + 1, airZ - 1, portalBlock);
- world.setBlock(airX, airY + 2, airZ, portalBlock);
- world.setBlock(airX, airY + 2, airZ - 1, portalBlock);
- checkedSuccessfully = true;
- world.playSoundAtEntity(player, "fire.ignite", 1.0F, 1.0F);
- player.swingItem();
- }
- else
- {
- checkedSuccessfully = false;
- }
- }
- return checkedSuccessfully;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement